Skip to content

Commit 97cfb9d

Browse files
committed
Make sure make_rels_by_clause_joins doesn't return multiple references
to same joinrel. Although make_rels_by_joins doesn't mind, GEQO has an Assert that doesn't like this.
1 parent cf35a70 commit 97cfb9d

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/backend/optimizer/path/joinrels.c

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.48 2000/09/29 18:21:32 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.49 2000/12/18 06:50:51 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -262,9 +262,18 @@ make_rels_by_clause_joins(Query *root,
262262
RelOptInfo *other_rel = (RelOptInfo *) lfirst(j);
263263

264264
if (is_subseti(unjoined_relids, other_rel->relids))
265-
result = lcons(make_join_rel(root, old_rel, other_rel,
266-
JOIN_INNER),
267-
result);
265+
{
266+
RelOptInfo *jrel;
267+
268+
jrel = make_join_rel(root, old_rel, other_rel, JOIN_INNER);
269+
/*
270+
* Avoid entering same joinrel into our output list more
271+
* than once. (make_rels_by_joins doesn't really care,
272+
* but GEQO does.)
273+
*/
274+
if (!ptrMember(jrel, result))
275+
result = lcons(jrel, result);
276+
}
268277
}
269278
}
270279

@@ -297,9 +306,16 @@ make_rels_by_clauseless_joins(Query *root,
297306
RelOptInfo *other_rel = (RelOptInfo *) lfirst(i);
298307

299308
if (nonoverlap_setsi(other_rel->relids, old_rel->relids))
300-
result = lcons(make_join_rel(root, old_rel, other_rel,
301-
JOIN_INNER),
302-
result);
309+
{
310+
RelOptInfo *jrel;
311+
312+
jrel = make_join_rel(root, old_rel, other_rel, JOIN_INNER);
313+
/*
314+
* As long as given other_rels are distinct, don't need
315+
* to test to see if jrel is already part of output list.
316+
*/
317+
result = lcons(jrel, result);
318+
}
303319
}
304320

305321
return result;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy