mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
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().
This commit is contained in:
@ -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 */
|
||||
|
Reference in New Issue
Block a user