mirror of
https://github.com/postgres/postgres.git
synced 2025-07-09 22:41:56 +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 */
|
||||
|
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.153 2003/08/08 21:41:48 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.154 2003/08/11 20:46:46 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -28,6 +28,7 @@
|
||||
#include "optimizer/restrictinfo.h"
|
||||
#include "optimizer/tlist.h"
|
||||
#include "optimizer/var.h"
|
||||
#include "parser/parsetree.h"
|
||||
#include "parser/parse_clause.h"
|
||||
#include "parser/parse_expr.h"
|
||||
#include "utils/lsyscache.h"
|
||||
@ -626,8 +627,8 @@ create_unique_plan(Query *root, UniquePath *best_path)
|
||||
{
|
||||
TargetEntry *tle;
|
||||
|
||||
tle = nth(groupColIdx[groupColPos] - 1, my_tlist);
|
||||
Assert(tle->resdom->resno == groupColIdx[groupColPos]);
|
||||
tle = get_tle_by_resno(my_tlist, groupColIdx[groupColPos]);
|
||||
Assert(tle != NULL);
|
||||
sortList = addTargetToSortList(NULL, tle, sortList,
|
||||
my_tlist, NIL, false);
|
||||
}
|
||||
@ -1975,7 +1976,7 @@ make_sort_from_groupcols(Query *root,
|
||||
foreach(i, groupcls)
|
||||
{
|
||||
GroupClause *grpcl = (GroupClause *) lfirst(i);
|
||||
TargetEntry *tle = nth(grpColIdx[grpno] - 1, sub_tlist);
|
||||
TargetEntry *tle = get_tle_by_resno(sub_tlist, grpColIdx[grpno]);
|
||||
Resdom *resdom = tle->resdom;
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user