Re: Add column if not exists (CINE)

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: Add column if not exists (CINE)
Дата
Msg-id t2n603c8f071004271718r6d00814waa5277d59976623e@mail.gmail.com
обсуждение исходный текст
Ответ на Add column if not exists (CINE)  (Kjell Rune Skaaraas <kjella79@yahoo.no>)
Ответы Re: Add column if not exists (CINE)
Список pgsql-hackers
On Tue, Apr 27, 2010 at 6:45 PM, Kjell Rune Skaaraas <kjella79@yahoo.no> wrote:
> Hello,
>
> I've been reading the earlier threads at:
> http://archives.postgresql.org/pgsql-hackers/2009-05/thrd7.php#00252
> http://archives.postgresql.org/pgsql-hackers/2005-10/thrd4.php#00632
> and I'm not sure I have anything that substantially new to add but:
>
> 1. I can't see there's an unambiguity about what the syntax would do. It is IF NOT EXISTS, not IF NOT LIKE. Anyone
whoshoots themselves in the foot by calling a CINE and thinking that a preexisting differently defined column is
magicallyconverted deserves it. Either it should act exactly like the non-CINE command, or do nothing at all as if the
statementwasn't there. 
>
> 2. The use case is pretty clear to me - flexible scripts that'll bring all earlier database versions to the latest
schema.I've been experimenting in 9.0 alpha with calling DROP CONSTRAINT IF EXISTS then ADD CONSTRAINT with named
constantsfor a CINE effect. which as a side effect will correct any updated constraints too - and it works great.
UnfortunatelyDROP COLUMN IF EXISTS then ADD COLUMN has the side effect of deleting all the data, so that's hardly
usable.
>
> I saw some indications that this might be a minority opinion, well I would like to cast a vote FOR this
functionality.The workarounds are ugly, the solution simple and while I agree it's possible to misuse it, my opinion is
thatyou shouldn't become a surgeon if you can't handle a scalpel. In this case I get the feeling I'm reading
instructionson how to do surgery with a butter knife because we don't dare hand out anything sharper. 

I've already said my piece on this, but I couldn't agree more.  Well
said, and your use case is exactly the one I want it for.

...Robert


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Jehan-Guillaume (ioguix) de Rorthais"
Дата:
Сообщение: providing tokenized version of parsed SQL script (was: nodeToString format and exporting the SQL parser)
Следующее
От: Robert Haas
Дата:
Сообщение: Re: providing tokenized version of parsed SQL script (was: nodeToString format and exporting the SQL parser)