diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-08-11 20:46:47 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-08-11 20:46:47 +0000 |
commit | 88381ade63de931c84f53dc873c986d40b8c8b61 (patch) | |
tree | 1ec3c77e29b1d320718b64b38db10f8a8f0e0cd3 /src/backend/optimizer/path/allpaths.c | |
parent | cae912d05bfb354d81427c6ae5354eab90869fe9 (diff) | |
download | postgresql-88381ade63de931c84f53dc873c986d40b8c8b61.tar.gz postgresql-88381ade63de931c84f53dc873c986d40b8c8b61.zip |
Code cleanup inspired by recent resname bug report (doesn't fix the bug
yet, though). Avoid using nth() to fetch tlist entries; provide a
common routine get_tle_by_resno() to search a tlist for a particular
resno. This replaces a couple uses of nth() and a dozen hand-coded
search loops. Also, replace a few uses of nth(length-1, list) with
llast().
Diffstat (limited to 'src/backend/optimizer/path/allpaths.c')
-rw-r--r-- | src/backend/optimizer/path/allpaths.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index 118a701e346..1c53c8e9f5c 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.106 2003/08/04 02:40:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.107 2003/08/11 20:46:46 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -726,8 +726,7 @@ qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual, foreach(vl, vars) { Var *var = (Var *) lfirst(vl); - List *tl; - TargetEntry *tle = NULL; + TargetEntry *tle; Assert(var->varno == rti); @@ -748,13 +747,8 @@ qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual, } /* Must find the tlist element referenced by the Var */ - foreach(tl, subquery->targetList) - { - tle = (TargetEntry *) lfirst(tl); - if (tle->resdom->resno == var->varattno) - break; - } - Assert(tl != NIL); + tle = get_tle_by_resno(subquery->targetList, var->varattno); + Assert(tle != NULL); Assert(!tle->resdom->resjunk); /* If subquery uses DISTINCT or DISTINCT ON, check point 3 */ |