aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-06-13 02:04:46 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-06-13 02:04:46 +0000
commit59c325bb7363aed9115e9f3ccb77feca05b00ec4 (patch)
tree7527429caf2074367b85c0a91b8a90ad03020df5 /src
parent2ed878d31dcab9dec215992c7c05e9ae40344d44 (diff)
downloadpostgresql-59c325bb7363aed9115e9f3ccb77feca05b00ec4.tar.gz
postgresql-59c325bb7363aed9115e9f3ccb77feca05b00ec4.zip
Repair for bug #691 --- CREATE TABLE AS column aliases fail to be
applied when the select is a UNION (or other set-operation). An alternative route to a fix would be to leave analyze.c alone and change plan_set_operations in prepunion.c to take column names from the topmost targetlist. But I am not sure that would work in all cases. This patch seems the minimum-risk fix.
Diffstat (limited to 'src')
-rw-r--r--src/backend/parser/analyze.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 916067a1d04..1eb5627a8fb 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.235 2002/05/28 22:15:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.236 2002/06/13 02:04:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2212,8 +2212,16 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
qry->isBinary = FALSE;
}
+ /*
+ * Any column names from CREATE TABLE AS need to be attached to both the
+ * top level and the leftmost subquery. We do not do this earlier
+ * because we do *not* want the targetnames list to be affected.
+ */
if (intoColNames)
+ {
applyColumnNames(qry->targetList, intoColNames);
+ applyColumnNames(leftmostQuery->targetList, intoColNames);
+ }
/*
* As a first step towards supporting sort clauses that are