Bug? CREATE TABLE AS (... UNION ...)

Поиск
Список
Период
Сортировка
Искать

Bug? CREATE TABLE AS (... UNION ...)

От:
Gregory Stark <stark@enterprisedb.com>
Дата:


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  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

Re: Bug? CREATE TABLE AS (... UNION ...)

От:
Gregory Stark <stark@enterprisedb.com>
Дата:
"Gregory Stark"  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

Re: Bug? CREATE TABLE AS (... UNION ...)

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Gregory Stark  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

FAQ