]> granicus.if.org Git - postgresql/commitdiff
Fix for queries with 3 or more relations participating in
authorVadim B. Mikheev <vadim4o@yahoo.com>
Thu, 20 Feb 1997 02:54:09 +0000 (02:54 +0000)
committerVadim B. Mikheev <vadim4o@yahoo.com>
Thu, 20 Feb 1997 02:54:09 +0000 (02:54 +0000)
one clause.

src/backend/optimizer/path/joinrels.c
src/backend/optimizer/plan/initsplan.c

index b26e3364f9379875c0dbfaaefe32369bc2069264..2632fc39514691dd196795b0d30ad792ba8d418d 100644 (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) {
index fcafc872718b5640737c1f2069d4f4bc62b32e78..f7ec544eee2d4260c381dd11edc412273bd8e200 100644 (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);