Re: BUG #5081: ON INSERT rule does not work correctly

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #5081: ON INSERT rule does not work correctly
Дата
Msg-id 23790.1254065805@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #5081: ON INSERT rule does not work correctly  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: BUG #5081: ON INSERT rule does not work correctly  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-bugs
Robert Haas <robertmhaas@gmail.com> writes:
> On Sat, Sep 26, 2009 at 12:35 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Well, yeah.  That's exactly how it's documented to work: an ON INSERT
>> rule is executed after the INSERT proper.

> I'm confused.  DO INSTEAD doesn't mean DO INSTEAD?

It does.  What it doesn't mean is "IF ... THEN ... ELSE ...".
The OP's rule actually works more like

    if (!(EXISTS ...))
        INSERT ...

    if ((EXISTS ...))
        UPDATE ...

>> You could maybe make this work with a BEFORE INSERT trigger.

> I'm not sure you can make it reliable though.

Concurrent inserts make things even more interesting, yes; but the rule
had no hope of handling that anyway.

            regards, tom lane

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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: BUG #5081: ON INSERT rule does not work correctly
Следующее
От: Robert Haas
Дата:
Сообщение: Re: BUG #5081: ON INSERT rule does not work correctly