From: | Gregory Stark <stark(at)enterprisedb(dot)com> |
---|---|
To: | PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Bug? CREATE TABLE AS (... UNION ...) |
Date: | 2007-01-30 11:00:16 |
Message-ID: | 87fy9saif3.fsf@stark.xeocode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I think I found a bug, or at least a discrepancy. Afaict the
transformSetOperationsStmt function should have identical code to
transformSelectStmt outside of the operations affected by set operations. If
that's the case then the SELECT INTO/CREATE TABLE AS code was not updated when
last it was touched for regular queries.
I think this means WITH[OUT] OIDS and WITH <definition> won't currently work
correctly if the select query involves a UNION or other set operation. Also
temporary tables created with an ON COMMIT option will ignore it and any
tablespace directive will be ignored.
Should I just copy the same code over or is anyone interested in refactoring
this? Or do I have it wrong somehow?
TransformSelectStmt:
/* handle any SELECT INTO/CREATE TABLE AS spec */
if (stmt->into)
{
qry->into = stmt->into;
if (stmt->intoColNames)
applyColumnNames(qry->targetList, stmt->intoColNames);
qry->intoOptions = copyObject(stmt->intoOptions);
qry->intoOnCommit = stmt->intoOnCommit;
qry->intoTableSpaceName = stmt->intoTableSpaceName;
}
transformSetOperationStmt:
/*
* Handle SELECT INTO/CREATE TABLE AS.
*
* 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 sortClause processing to be affected.
*/
if (intoColNames)
{
applyColumnNames(qry->targetList, intoColNames);
applyColumnNames(leftmostQuery->targetList, intoColNames);
}
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2007-01-30 11:19:12 | Phantom Command IDs, updated patch |
Previous Message | Guido Goldstein | 2007-01-30 10:43:52 | Re: pgsql: Fix for plpython functions; return true/false for boolean, |