Re: Add column if not exists (CINE)

Andrew Dunstan <andrew@dunslane.net>

From: Andrew Dunstan <andrew@dunslane.net>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>, Kjell Rune Skaaraas <kjella79@yahoo.no>, pgsql-hackers@postgresql.org
Date: 2010-04-28T16:14:54Z
Lists: pgsql-hackers

Robert Haas wrote:
> On Wed, Apr 28, 2010 at 11:20 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>   
>> Robert Haas <robertmhaas@gmail.com> writes:
>>     
>>> I don't believe you are fairly stating the consensus from previous
>>> discussion and I believe that you are actually in the minority on this
>>> one.  I agree that we probably don't need to support this for object
>>> types for which CREATE OR REPLACE is available or can be made
>>> available, but that isn't feasible for all object types - tables and
>>> columns being the obvious examples.
>>>       
>> What's obvious about it?  In particular, I should think that ADD OR
>> REPLACE COLUMN would usefully be defined as "ADD if no such column,
>> else ALTER COLUMN as necessary to match this spec".  Dropping the
>> ALTER part of that has no benefit except to lazy implementors; it
>> certainly is not more useful to users if they can't be sure of the
>> column properties after issuing the command.
>>     
>
> Actually, that's a good idea.  But how will you handle tables?
>
>
>   

I think I Iike Heikki's suggestion better, to error out if the object 
exists but the properties differ. At least I'd like an option for that.

cheers

andrew