Skip site navigation (1) Skip section navigation (2)

Re: add additional options to CREATE TABLE ... AS

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: Kris Jurka <books(at)ejurka(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: add additional options to CREATE TABLE ... AS
Date: 2006-02-14 20:38:48
Message-ID: 22300.1139949528@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-patches
Neil Conway <neilc(at)samurai(dot)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

In response to

Responses

pgsql-patches by date

Next:From: Stephen FrostDate: 2006-02-14 20:49:12
Subject: Re: BUG #2246: Bad malloc interactions: ecpg, openssl
Previous:From: Neil ConwayDate: 2006-02-14 20:27:12
Subject: Re: add additional options to CREATE TABLE ... AS

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group