diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-03-22 17:11:25 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-03-22 17:11:25 +0000 |
commit | 9323cb0aaba14ddd0d44f946c8218af5dd75611f (patch) | |
tree | b3e90cb5e4c915ecb43cbafb87984218696cd02b /src/backend/optimizer/path/allpaths.c | |
parent | ed11ccf4d4243e0c7bd45eaab8eaaeb25e9882f0 (diff) | |
download | postgresql-9323cb0aaba14ddd0d44f946c8218af5dd75611f.tar.gz postgresql-9323cb0aaba14ddd0d44f946c8218af5dd75611f.zip |
Department of second thoughts: probably shouldn't use nth() to get the
appropriate targetlist entry out of the subquery. Use an explicit search
like we do everywhere else.
Diffstat (limited to 'src/backend/optimizer/path/allpaths.c')
-rw-r--r-- | src/backend/optimizer/path/allpaths.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index 0ee36240ab0..24f0ebf54dc 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.100 2003/03/22 01:49:38 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.101 2003/03/22 17:11:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -638,7 +638,7 @@ qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual) { bool safe = true; List *vars; - List *l; + List *vl; Bitmapset *tested = NULL; /* Refuse subselects (point 1) */ @@ -650,10 +650,11 @@ qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual) * all such Vars must refer to subselect output columns. */ vars = pull_var_clause(qual, false); - foreach(l, vars) + foreach(vl, vars) { - Var *var = (Var *) lfirst(l); - TargetEntry *tle; + Var *var = (Var *) lfirst(vl); + List *tl; + TargetEntry *tle = NULL; Assert(var->varno == rti); /* @@ -665,8 +666,13 @@ qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual) continue; tested = bms_add_member(tested, var->varattno); - tle = (TargetEntry *) nth(var->varattno-1, subquery->targetList); - Assert(tle->resdom->resno == var->varattno); + foreach(tl, subquery->targetList) + { + tle = (TargetEntry *) lfirst(tl); + if (tle->resdom->resno == var->varattno) + break; + } + Assert(tl != NIL); Assert(!tle->resdom->resjunk); /* If subquery uses DISTINCT or DISTINCT ON, check point 2 */ |