aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_target.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-06-05 00:38:11 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-06-05 00:38:11 +0000
commita4996a895399a4b0363c7dace71fc6ce8acbc196 (patch)
tree9fe26cb35badc6a7b0c86a9db1eaf2e7ca95b142 /src/backend/parser/parse_target.c
parentefe0d0808b055fb2f651dd3732bd770290eb2659 (diff)
downloadpostgresql-a4996a895399a4b0363c7dace71fc6ce8acbc196.tar.gz
postgresql-a4996a895399a4b0363c7dace71fc6ce8acbc196.zip
Replace the parser's namespace tree (which formerly had the same
representation as the jointree) with two lists of RTEs, one showing the RTEs accessible by qualified names, and the other showing the RTEs accessible by unqualified names. I think this is conceptually simpler than what we did before, and it's sure a whole lot easier to search. This seems to eliminate the parse-time bottleneck for deeply nested JOIN structures that was exhibited by phil@vodafone.
Diffstat (limited to 'src/backend/parser/parse_target.c')
-rw-r--r--src/backend/parser/parse_target.c50
1 files changed, 15 insertions, 35 deletions
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index 27e818dcbe2..dd2c0b4e31c 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.135 2005/06/04 19:19:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.136 2005/06/05 00:38:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -750,52 +750,32 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref)
* ExpandAllTables()
* Turns '*' (in the target list) into a list of targetlist entries.
*
- * tlist entries are generated for each relation appearing at the top level
- * of the query's namespace, except for RTEs marked not inFromCl. (These
- * may include NEW/OLD pseudo-entries, implicit RTEs, etc.)
+ * tlist entries are generated for each relation appearing in the query's
+ * varnamespace. We do not consider relnamespace because that would include
+ * input tables of aliasless JOINs, NEW/OLD pseudo-entries, implicit RTEs,
+ * etc.
*/
static List *
ExpandAllTables(ParseState *pstate)
{
List *target = NIL;
- bool found_table = false;
- ListCell *ns;
-
- foreach(ns, pstate->p_namespace)
- {
- Node *n = (Node *) lfirst(ns);
- int rtindex;
- RangeTblEntry *rte;
+ ListCell *l;
- if (IsA(n, RangeTblRef))
- rtindex = ((RangeTblRef *) n)->rtindex;
- else if (IsA(n, JoinExpr))
- rtindex = ((JoinExpr *) n)->rtindex;
- else
- {
- elog(ERROR, "unrecognized node type: %d", (int) nodeTag(n));
- rtindex = 0; /* keep compiler quiet */
- }
+ /* Check for SELECT *; */
+ if (!pstate->p_varnamespace)
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("SELECT * with no tables specified is not valid")));
- /*
- * Ignore added-on relations that were not listed in the FROM
- * clause.
- */
- rte = rt_fetch(rtindex, pstate->p_rtable);
- if (!rte->inFromCl)
- continue;
+ foreach(l, pstate->p_varnamespace)
+ {
+ RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
+ int rtindex = RTERangeTablePosn(pstate, rte, NULL);
- found_table = true;
target = list_concat(target,
expandRelAttrs(pstate, rte, rtindex, 0));
}
- /* Check for SELECT *; */
- if (!found_table)
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("SELECT * with no tables specified is not valid")));
-
return target;
}