]> granicus.if.org Git - postgresql/commitdiff
Expose the "*VALUES*" alias that we generate for a stand-alone VALUES list.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 4 Jun 2011 19:48:36 +0000 (15:48 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 4 Jun 2011 19:48:36 +0000 (15:48 -0400)
We were trying to make that strictly an internal implementation detail,
but it turns out that it's exposed anyway when dumping a view defined
like
CREATE VIEW test_view AS VALUES (1), (2), (3) ORDER BY 1;
This comes out as
CREATE VIEW ... ORDER BY "*VALUES*".column1;
which fails to parse when reloading the dump.

Hacking ruleutils.c to suppress the column qualification looks like it'd
be a risky business, so instead promote the RTE alias to full-fledged
usability.

Per bug #6049 from Dylan Adams.  Back-patch to all supported branches.

src/backend/parser/analyze.c

index da3dd289f49a37f9455901b4af736b16d46bb4ce..09c28dca033ca803519b4004781548d51b178456 100644 (file)
@@ -820,7 +820,7 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
  *       transforms a VALUES clause that's being used as a standalone SELECT
  *
  * We build a Query containing a VALUES RTE, rather as if one had written
- *                     SELECT * FROM (VALUES ...)
+ *                     SELECT * FROM (VALUES ...) AS "*VALUES*"
  */
 static Query *
 transformValuesClause(ParseState *pstate, SelectStmt *stmt)
@@ -933,6 +933,7 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
        rtr->rtindex = list_length(pstate->p_rtable);
        Assert(rte == rt_fetch(rtr->rtindex, pstate->p_rtable));
        pstate->p_joinlist = lappend(pstate->p_joinlist, rtr);
+       pstate->p_relnamespace = lappend(pstate->p_relnamespace, rte);
        pstate->p_varnamespace = lappend(pstate->p_varnamespace, rte);
 
        /*