Re: UPSERT wiki page, and SQL MERGE syntax

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: UPSERT wiki page, and SQL MERGE syntax
Дата
Msg-id CAM3SWZSMUr_oxFqWJb7eUfLVOH9=vd9-MNc4JogfuT2iGz44ZQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: UPSERT wiki page, and SQL MERGE syntax  (Kevin Grittner <kgrittn@ymail.com>)
Список pgsql-hackers
On Fri, Oct 10, 2014 at 12:04 PM, Kevin Grittner <kgrittn@ymail.com> wrote:
> Peter Geoghegan <pg@heroku.com> wrote:
>
>> There is no danger of UPDATE before row-level triggers firing
>> without then updating (unless the xact aborts, but you know what
>> I mean).
>
> Well, let's make sure I do know what you mean.  If a BEFORE UPDATE
> ... FOR EACH ROW trigger returns NULL, the UPDATE will be skipped
> without error, right?  The BEFORE UPDATE triggers will run before
> the UPDATE if a duplicate is found, and the return value will be
> treated in the usual manner, replacing values and potentially
> skipping the update?

That's exactly right, yes (in particular, you can return NULL from
before row update triggers and have that cancel the update in the
usual manner). And potentially, the final value could be affected by
both the before row insert and before row update triggers (by way of
CONFLICTING()). That's the most surprising aspect of what I've done
(although I would argue it's the least surprising behavior possible
given my constraints).

-- 
Peter Geoghegan



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

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: UPSERT wiki page, and SQL MERGE syntax
Следующее
От: Peter Geoghegan
Дата:
Сообщение: Re: UPSERT wiki page, and SQL MERGE syntax