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).