Fix for queries with 3 or more relations participating in

one clause.
This commit is contained in:
Vadim B. Mikheev 1997-02-20 02:54:09 +00:00
parent 6eb0525185
commit 4de2f24895
2 changed files with 23 additions and 6 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.1.1.1 1996/07/09 06:21:36 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.2 1997/02/20 02:54:09 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -297,10 +297,18 @@ new_joininfo_list(List *joininfo_list, List *join_relids)
List *xjoininfo = NIL;
foreach (xjoininfo, joininfo_list) {
List *or;
JInfo *joininfo = (JInfo*)lfirst(xjoininfo);
new_otherrels = joininfo->otherrels;
if (nonoverlap_sets(new_otherrels,join_relids)) {
foreach (or, new_otherrels)
{
if ( intMember (lfirsti(or), join_relids) )
new_otherrels = lremove ((void*)lfirst(or), new_otherrels);
}
joininfo->otherrels = new_otherrels;
if ( new_otherrels != NIL )
{
other_joininfo = joininfo_member(new_otherrels,
current_joininfo_list);
if(other_joininfo) {

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.2 1996/10/31 10:59:13 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.3 1997/02/20 02:53:26 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -250,10 +250,19 @@ add_join_clause_info_to_rels(Query *root, CInfo *clauseinfo, List *join_relids)
List *join_relid;
foreach (join_relid, join_relids) {
JInfo *joininfo =
JInfo *joininfo;
List *other_rels = NIL;
List *rel;
foreach (rel, join_relids)
{
if ( (int)lfirst(rel) != (int)lfirst(join_relid) )
other_rels = lappendi (other_rels, lfirst(rel));
}
joininfo =
find_joininfo_node(get_base_rel(root, lfirsti(join_relid)),
intLispRemove((int)lfirst(join_relid),
join_relids));
other_rels);
joininfo->jinfoclauseinfo =
lcons(clauseinfo, joininfo->jinfoclauseinfo);