Re: Support for idempotent schema changes?
От
Florian G. Pflug
Тема
Re: Support for idempotent schema changes?
Дата
Msg-id
45ECEE1A.90208@phlo.org
Ответ на
Re: Support for idempotent schema changes? (Joshua D. Drake)
Список
Дерево обсуждения
Support for idempotent schema changes? "David Lowe" <dlowe@airplay.com>
Re: Support for idempotent schema changes? Peter Eisentraut <peter_e@gmx.net>
Re: Support for idempotent schema changes? Flemming Frandsen <ff@partyticket.net>
Re: Support for idempotent schema changes? "David Lowe" <dlowe@airplay.com>
Re: Support for idempotent schema changes? "Joshua D. Drake" <jd@commandprompt.com>
Re: Support for idempotent schema changes? "Florian G. Pflug" <fgp@phlo.org>
Joshua D. Drake wrote:
> David Lowe wrote:
>> Within the context of a script, executing:
>>
>> Begin
>> Statement1
>> Statement2
>> Statement3
>> Commit
>>
>> Where I only wish to commit if the error is specific to the object
>> already existing, and rollback for all other errors, what's the best way
>> to accomplish that?
>>
> You would have to put each statement into a savepoint, and catch each
> error that occured and commit or rollback to a savepoint
> based on that result.
You could write a plpgsql function that executes a text given to it
as a parameter, and catches only "already exists" errors. Then your
schema script could look like
select execute_ignoreexists('create table ...') ;
select execute_ignoreexists('create index ...') ;
...
greetings, Florian Pflug
В списке pgsql-general по дате отправления
От: Robert Treat
Дата: