Re: Supported plpgsql BEFORE ... EACH ROW behavior

Поиск
Список
Период
Сортировка
От Karl O. Pinc
Тема Re: Supported plpgsql BEFORE ... EACH ROW behavior
Дата
Msg-id 1172241987l.1041l.0l@mofo
обсуждение исходный текст
Ответ на Re: Supported plpgsql BEFORE ... EACH ROW behavior  (Richard Huxton <dev@archonet.com>)
Список pgsql-general
On 02/23/2007 02:03:25 AM, Richard Huxton wrote:
> Karl O. Pinc wrote:

>> I want to write a plpgsql function for use as a
>> BEFORE ... EACH ROW function.  I want to modify
>> other tables even when the function returns NULL
>> and therefore the table on which the BEFORE
>> trigger is defined is not updated.

> I think it's fairly common, actually. Returning NULL is cancelling
> the update *of that row* rather than aborting the transaction, so all
> side-effects should always survive.

Thats good news.  Thanks for the reply.  But...

> Otherwise you couldn't update 100 rows and just skip one or two by
> returning NULL from a before trigger.

But wanting side effects _when_ those one or two rows are skipped
is probably not so common.  I could imagine a implimentation
of Postgresql that does a SAVEPOINT before executing
a BEFORE ... EACH ROW trigger and then decides whether or
not to ROLLBACK TO SAVEPOINT or RELEASE SAVEPOINT.
That would not break the usage case you give, but would
break what I want to do.  So this is what I'm wanting
assurance about.  I suppose this is kind of silly, seeing
as how it's a BEFORE trigger we're talking about the
db would not have been updated so a SAVEPOINT would
not really be appropriate.  But I did say I was
being paranoid.

Thanks again for the help.

Karl <kop@meme.com>
Free Software:  "You don't pay back, you pay forward."
                  -- Robert A. Heinlein


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: greedy or not? regexps...
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Writing oracle/postgress generic SQL