Commit 4de2f248 authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

Fix for queries with 3 or more relations participating in

one clause.
parent 6eb05251
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -297,10 +297,18 @@ new_joininfo_list(List *joininfo_list, List *join_relids)
List *xjoininfo = NIL; List *xjoininfo = NIL;
foreach (xjoininfo, joininfo_list) { foreach (xjoininfo, joininfo_list) {
List *or;
JInfo *joininfo = (JInfo*)lfirst(xjoininfo); JInfo *joininfo = (JInfo*)lfirst(xjoininfo);
new_otherrels = joininfo->otherrels; 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, other_joininfo = joininfo_member(new_otherrels,
current_joininfo_list); current_joininfo_list);
if(other_joininfo) { if(other_joininfo) {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -250,10 +250,19 @@ add_join_clause_info_to_rels(Query *root, CInfo *clauseinfo, List *join_relids)
List *join_relid; List *join_relid;
foreach (join_relid, join_relids) { 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)), find_joininfo_node(get_base_rel(root, lfirsti(join_relid)),
intLispRemove((int)lfirst(join_relid), other_rels);
join_relids));
joininfo->jinfoclauseinfo = joininfo->jinfoclauseinfo =
lcons(clauseinfo, joininfo->jinfoclauseinfo); lcons(clauseinfo, joininfo->jinfoclauseinfo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment