提交 51227f8d 编写于 作者: T Tom Lane

Use a cleaner substitute for the inability to apply length() to the tail

of a list.  Per private discussion with Neil.
上级 0d5364fd
......@@ -16,7 +16,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.18 2004/05/26 04:41:26 neilc Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.19 2004/05/26 18:35:41 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -897,12 +897,15 @@ simplify_jointree(Query *parse, Node *jtnode)
{
FromExpr *f = (FromExpr *) jtnode;
List *newlist = NIL;
int children_remaining;
ListCell *l;
children_remaining = list_length(f->fromlist);
foreach(l, f->fromlist)
{
Node *child = (Node *) lfirst(l);
children_remaining--;
/* Recursively simplify this child... */
child = simplify_jointree(parse, child);
/* Now, is it a FromExpr? */
......@@ -917,16 +920,7 @@ simplify_jointree(Query *parse, Node *jtnode)
*/
FromExpr *subf = (FromExpr *) child;
int childlen = length(subf->fromlist);
int myothers;
ListCell *l2;
/*
* XXX: This is a quick hack, not sure of the proper
* fix.
*/
myothers = length(newlist);
for_each_cell(l2, lnext(l))
myothers++;
int myothers = length(newlist) + children_remaining;
if (childlen <= 1 ||
(childlen + myothers) <= from_collapse_limit)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册