diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-04 19:19:42 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-04 19:19:42 +0000 |
commit | e18e8f873594fd4ff2f12e734a624102d3ef1e39 (patch) | |
tree | 2be63f655263ca41ca15ea0f4e018bab97bfe3c0 /src/backend/parser | |
parent | fb91a83e0ebf11b99148d15891188333381f82b1 (diff) | |
download | postgresql-e18e8f873594fd4ff2f12e734a624102d3ef1e39.tar.gz postgresql-e18e8f873594fd4ff2f12e734a624102d3ef1e39.zip |
Change expandRTE() and ResolveNew() back to taking just the single
RTE of interest, rather than the whole rangetable list. This makes
the API more understandable and avoids duplicate RTE lookups. This
patch reverts no-longer-needed portions of my patch of 2004-08-19.
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/parse_clause.c | 8 | ||||
-rw-r--r-- | src/backend/parser/parse_coerce.c | 9 | ||||
-rw-r--r-- | src/backend/parser/parse_relation.c | 41 | ||||
-rw-r--r-- | src/backend/parser/parse_target.c | 13 |
4 files changed, 28 insertions, 43 deletions
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index 42960d43760..8d282d13e4f 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.140 2005/04/13 16:50:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.141 2005/06/04 19:19:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -663,7 +663,8 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels) elog(ERROR, "unrecognized node type: %d", (int) nodeTag(j->larg)); leftrti = 0; /* keep compiler quiet */ } - expandRTE(pstate->p_rtable, leftrti, 0, false, + rte = rt_fetch(leftrti, pstate->p_rtable); + expandRTE(rte, leftrti, 0, false, &l_colnames, &l_colvars); if (IsA(j->rarg, RangeTblRef)) @@ -675,7 +676,8 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels) elog(ERROR, "unrecognized node type: %d", (int) nodeTag(j->rarg)); rightrti = 0; /* keep compiler quiet */ } - expandRTE(pstate->p_rtable, rightrti, 0, false, + rte = rt_fetch(rightrti, pstate->p_rtable); + expandRTE(rte, rightrti, 0, false, &r_colnames, &r_colvars); /* diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index e46b63f6d9f..32a20fc3622 100644 --- a/src/backend/parser/parse_coerce.c +++ b/src/backend/parser/parse_coerce.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.130 2005/05/30 01:20:49 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.131 2005/06/04 19:19:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -695,10 +695,11 @@ coerce_record_to_complex(ParseState *pstate, Node *node, { int rtindex = ((Var *) node)->varno; int sublevels_up = ((Var *) node)->varlevelsup; - List *rtable; + RangeTblEntry *rte; - rtable = GetLevelNRangeTable(pstate, sublevels_up); - expandRTE(rtable, rtindex, sublevels_up, false, NULL, &args); + rte = GetRTEByRangeTablePosn(pstate, rtindex, sublevels_up); + expandRTE(rte, rtindex, sublevels_up, false, + NULL, &args); } else ereport(ERROR, diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index 25205d8894e..39d18ffbf8a 100644 --- a/src/backend/parser/parse_relation.c +++ b/src/backend/parser/parse_relation.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.109 2005/06/03 23:05:28 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.110 2005/06/04 19:19:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -446,27 +446,6 @@ GetRTEByRangeTablePosn(ParseState *pstate, } /* - * GetLevelNRangeTable - * Get the rangetable list for the N'th query level up from current. - */ -List * -GetLevelNRangeTable(ParseState *pstate, int sublevels_up) -{ - int index = 0; - - while (pstate != NULL) - { - if (index == sublevels_up) - return pstate->p_rtable; - index++; - pstate = pstate->parentParseState; - } - - elog(ERROR, "rangetable not found (internal error)"); - return NIL; /* keep compiler quiet */ -} - -/* * scanRTEForColumn * Search the column names of a single RTE for the given name. * If found, return an appropriate Var node, else return NULL. @@ -1202,19 +1181,19 @@ addImplicitRTE(ParseState *pstate, RangeVar *relation) * results. If include_dropped is TRUE then empty strings and NULL constants * (not Vars!) are returned for dropped columns. * - * The target RTE is the rtindex'th entry of rtable. - * sublevels_up is the varlevelsup value to use in the created Vars. + * rtindex and sublevels_up are the varno and varlevelsup values to use + * in the created Vars. Ordinarily rtindex should match the actual position + * of the RTE in its rangetable. * * The output lists go into *colnames and *colvars. * If only one of the two kinds of output list is needed, pass NULL for the * output pointer for the unwanted one. */ void -expandRTE(List *rtable, int rtindex, int sublevels_up, +expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, bool include_dropped, List **colnames, List **colvars) { - RangeTblEntry *rte = rt_fetch(rtindex, rtable); int varattno; if (colnames) @@ -1490,9 +1469,14 @@ expandTupleDesc(TupleDesc tupdesc, Alias *eref, * expandRelAttrs - * Workhorse for "*" expansion: produce a list of targetentries * for the attributes of the rte + * + * As with expandRTE, rtindex/sublevels_up determine the varno/varlevelsup + * fields of the Vars produced. pstate->p_next_resno determines the resnos + * assigned to the TLEs. */ List * -expandRelAttrs(ParseState *pstate, List *rtable, int rtindex, int sublevels_up) +expandRelAttrs(ParseState *pstate, RangeTblEntry *rte, + int rtindex, int sublevels_up) { List *names, *vars; @@ -1500,7 +1484,8 @@ expandRelAttrs(ParseState *pstate, List *rtable, int rtindex, int sublevels_up) *var; List *te_list = NIL; - expandRTE(rtable, rtindex, sublevels_up, false, &names, &vars); + expandRTE(rte, rtindex, sublevels_up, false, + &names, &vars); forboth(name, names, var, vars) { diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index 12acfb83029..27e818dcbe2 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.134 2005/05/31 01:03:23 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.135 2005/06/04 19:19:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -697,7 +697,6 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref) RangeTblEntry *rte; int sublevels_up; int rtindex; - List *rtable; switch (numnames) { @@ -742,9 +741,8 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref) relname)); rtindex = RTERangeTablePosn(pstate, rte, &sublevels_up); - rtable = GetLevelNRangeTable(pstate, sublevels_up); - return expandRelAttrs(pstate, rtable, rtindex, sublevels_up); + return expandRelAttrs(pstate, rte, rtindex, sublevels_up); } } @@ -789,8 +787,7 @@ ExpandAllTables(ParseState *pstate) found_table = true; target = list_concat(target, - expandRelAttrs(pstate, pstate->p_rtable, - rtindex, 0)); + expandRelAttrs(pstate, rte, rtindex, 0)); } /* Check for SELECT *; */ @@ -929,8 +926,8 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup) *lvar; int i; - expandRTE(GetLevelNRangeTable(pstate, netlevelsup), - var->varno, 0, false, &names, &vars); + expandRTE(rte, var->varno, 0, false, + &names, &vars); tupleDesc = CreateTemplateTupleDesc(list_length(vars), false); i = 1; |