mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +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:
@ -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