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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #15180: Alter table add column if not exists with unique constraint will add extra duplicate
Дата
Msg-id 13929.1525206573@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #15180: Alter table add column if not exists with uniqueconstraint will add extra duplicate  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-bugs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> 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.

Yeah, good point.

I also noticed while looking at the code that AT_AddOids is a rather
klugy implementation of, effectively, ADD COLUMN IF NOT EXISTS.
Perhaps it'd save code to fold it into this mechanism.  Or maybe not,
since the OID column is pretty special-casey anyway.

            regards, tom lane


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

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #15183: pg_upgrade and pg_upgrade.exe both corrupt sequences whenmigrating 9.1 10.3
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #15183: pg_upgrade and pg_upgrade.exe both corrupt sequences when migrating 9.1 10.3