Re: Assertion failure in plpgsql with INSTEAD OF rule

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Assertion failure in plpgsql with INSTEAD OF rule
Дата
Msg-id 1383.1231777765@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Assertion failure in plpgsql with INSTEAD OF rule  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Ответы Re: Assertion failure in plpgsql with INSTEAD OF rule  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Список pgsql-hackers
Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
> If _SPI_execute_plan reaches the above "if" and sets "my_res = res", 
> SPI_processed is left at 0. So FOUND is always set to false if the 
> rewritten command type doesn't match the original.

Right, and I think that's probably sane behavior.  The original command
got rewritten to nothing, therefore it processed zero rows.  I'd be
happy with code that guaranteed that FOUND got set false in that case.
The point I'm making is that the code doesn't guarantee it now (and
would not do so after removing those Asserts either).  Consider

create rule r1 as on insert to foo do instead notify foo_insert;

As implemented, this would send us through the SPI_OK_UTILITY path
and nothing happens to FOUND.  I say that's a bug.

So what I'm thinking is:

1. We can't redefine the SPI interface in back branches, so there's
probably little alternative but to remove those Asserts there.

2. In HEAD, I think we should have SPI return a new SPI_OK_REWRITTEN
code for this case, and have plpgsql respond to that by always setting
found = false.   With that, the Asserts can stay (in fact the new path
should assert !mod_stmt, since it shouldn't have found any canSetTag
query).
        regards, tom lane


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

Предыдущее
От: David Fetter
Дата:
Сообщение: Re: Recovery Test Framework
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Recovery Test Framework