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" <jd@commandprompt.com>)
Список pgsql-general
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
Дата:
Сообщение: Re: giving a user permission to kill their processes only
Следующее
От: "Reuven M. Lerner"
Дата:
Сообщение: Database slowness -- my design, hardware, or both?