Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 51227f8

Browse files
committed
Use a cleaner substitute for the inability to apply length() to the tail
of a list. Per private discussion with Neil.
1 parent 0d5364f commit 51227f8

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/backend/optimizer/prep/prepjointree.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.18 2004/05/26 04:41:26 neilc Exp $
19+
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.19 2004/05/26 18:35:41 tgl Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -897,12 +897,15 @@ simplify_jointree(Query *parse, Node *jtnode)
897897
{
898898
FromExpr *f = (FromExpr *) jtnode;
899899
List *newlist = NIL;
900+
int children_remaining;
900901
ListCell *l;
901902

903+
children_remaining = list_length(f->fromlist);
902904
foreach(l, f->fromlist)
903905
{
904906
Node *child = (Node *) lfirst(l);
905907

908+
children_remaining--;
906909
/* Recursively simplify this child... */
907910
child = simplify_jointree(parse, child);
908911
/* Now, is it a FromExpr? */
@@ -917,16 +920,7 @@ simplify_jointree(Query *parse, Node *jtnode)
917920
*/
918921
FromExpr *subf = (FromExpr *) child;
919922
int childlen = length(subf->fromlist);
920-
int myothers;
921-
ListCell *l2;
922-
923-
/*
924-
* XXX: This is a quick hack, not sure of the proper
925-
* fix.
926-
*/
927-
myothers = length(newlist);
928-
for_each_cell(l2, lnext(l))
929-
myothers++;
923+
int myothers = length(newlist) + children_remaining;
930924

931925
if (childlen <= 1 ||
932926
(childlen + myothers) <= from_collapse_limit)

0 commit comments

Comments
 (0)