Re: BUG #15180: Alter table add column if not exists with uniqueconstraint will add extra duplicate

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: BUG #15180: Alter table add column if not exists with uniqueconstraint will add extra duplicate
Дата
Msg-id CAKFQuwaKr8fH3y6ermzKQdE+32UosuuGWmz5w=y2NXYfcWGMRQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #15180: Alter table add column if not exists with unique constraint will add extra duplicate  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: BUG #15180: Alter table add column if not exists with unique constraint will add extra duplicate  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Tue, May 1, 2018 at 11:47 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
A possible objection to this design is that right now, you can do

        alter table foo
          add column if not exists f2 text,
          add column if not exists f2 int;

and it will skip the second ADD subcommand because by that point the
column exists.  With this design, both test subcommands would find that
f2 doesn't exist so we'd try to do both ADD subcommands, and the second
one would fail.  That doesn't particularly bother me, because this
command is silly.

​I'd argue its probably not that silly when you consider copy-paste errors - in which case actually failing instead of silently ignoring the second instance of the same name would be looked upon favorably by the user.  And since pg_dump isn't going to be affected by this the new error seems more positive than negative on-the-whole.

As with the serial thread I'm definitely +1 for making this behave in a less surprising manner - and Tom's proposed flow seems to me to match the expected behavior (I agree with Stephen here, I think I got bogged down in the sequence aspects of the previous thread when having it be this simple is preferable).

David J.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #15180: Alter table add column if not exists with unique constraint will add extra duplicate
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #15183: pg_upgrade and pg_upgrade.exe both corrupt sequences whenmigrating 9.1 10.3