Lists: | pgsql-hackers |
---|
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 |
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: | Gregory Stark <stark(at)enterprisedb(dot)com> |
---|---|
To: | "PostgreSQL Development" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Bug? CREATE TABLE AS (... UNION ...) |
Date: | 2007-01-30 11:19:13 |
Message-ID: | 87bqkgahji.fsf@stark.xeocode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
"Gregory Stark" <stark(at)enterprisedb(dot)com> writes:
> Should I just copy the same code over or is anyone interested in refactoring
> this? Or do I have it wrong somehow?
Hm, it appears I have this wrong somehow since I can create tables using
CREATE TABLE AS specifying tablespaces just fine. But I do't see how it can
work.
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Gregory Stark <stark(at)enterprisedb(dot)com> |
Cc: | "PostgreSQL Development" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Bug? CREATE TABLE AS (... UNION ...) |
Date: | 2007-01-30 17:02:14 |
Message-ID: | 3312.1170176534@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> Hm, it appears I have this wrong somehow since I can create tables using
> CREATE TABLE AS specifying tablespaces just fine. But I do't see how it can
> work.
Look at the first few lines of transformSetOperationStmt.
regards, tom lane