Re: add additional options to CREATE TABLE ... AS - Mailing list pgsql-patches

From Tom Lane
Subject Re: add additional options to CREATE TABLE ... AS
Date
Msg-id 22300.1139949528@sss.pgh.pa.us
Whole thread Raw
In response to Re: add additional options to CREATE TABLE ... AS  (Neil Conway <neilc@samurai.com>)
Responses Re: add additional options to CREATE TABLE ... AS
Re: add additional options to CREATE TABLE ... AS
List pgsql-patches
Neil Conway <neilc@samurai.com> writes:
> The implementation is pretty ugly -- it clutters ExecuteStmt and Query
> with fields that really do not belong there. Per previous discussion, I
> think it would be better to refactor the CREATE TABLE AS implementation
> to be essentially a CREATE TABLE followed by a INSERT ... SELECT.

I kinda wonder why bother at all.  I don't see any good reason why
people shouldn't issue two statements.


>>     if (stmt->intoTableSpaceName)
>>         qry->intoTableSpaceName = pstrdup(stmt->intoTableSpaceName);
>>     else
>>         qry->intoTableSpaceName = NULL;

> You can omit the "else", as makeNode() zeroes all the fields of the new
> node.

For that matter, why not just

    qry->intoTableSpaceName = stmt->intoTableSpaceName;

There's no need for the string-copy operation here, is there?

            regards, tom lane

pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: Re: add additional options to CREATE TABLE ... AS
Next
From: Kris Jurka
Date:
Subject: Re: add additional options to CREATE TABLE ... AS