Skip to content

Commit ab1aaf3

Browse files
committed
Expose the "*VALUES*" alias that we generate for a stand-alone VALUES list.
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.
1 parent bc0550f commit ab1aaf3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/parser/analyze.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
909909
* transforms a VALUES clause that's being used as a standalone SELECT
910910
*
911911
* We build a Query containing a VALUES RTE, rather as if one had written
912-
* SELECT * FROM (VALUES ...)
912+
* SELECT * FROM (VALUES ...) AS "*VALUES*"
913913
*/
914914
static Query *
915915
transformValuesClause(ParseState *pstate, SelectStmt *stmt)
@@ -1034,6 +1034,7 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
10341034
rtr->rtindex = list_length(pstate->p_rtable);
10351035
Assert(rte == rt_fetch(rtr->rtindex, pstate->p_rtable));
10361036
pstate->p_joinlist = lappend(pstate->p_joinlist, rtr);
1037+
pstate->p_relnamespace = lappend(pstate->p_relnamespace, rte);
10371038
pstate->p_varnamespace = lappend(pstate->p_varnamespace, rte);
10381039

10391040
/*

0 commit comments

Comments
 (0)