For reasons that I'm not quite sure about, the following test case
crashes in v11, but not earlier versions:
create table abc(n int);
create table xyz(n int);
create function fun() returns int as $$begin insert into abc values
(1); return 1; end$$ language plpgsql;
create or replace rule rule1 as on insert to abc do delete from xyz;
select fun();
create or replace rule rule1 as on insert to abc do instead delete from xyz;
select fun();
I get:
TRAP: FailedAssertion("!(!stmt->mod_stmt)", File: "pl_exec.c", Line: 4106)
The xyz table doesn't seem to be important; I can reproduce the crash
if I change 'delete from xyz' to 'do nothing' in both places. But
it's critical to 'SELET fun()' after the first CREATE OR REPLACE RULE
statement and before the second one. The INSERT inside the function
is also critical -- omitting that prevents the crash. I suspect the
problem is likely related to some of the changes made to spi.c rather
than to changes made on the plpgsql side of things, but that might be
wrong.
My colleague Tushar Ahuja deserves credit for finding this problem; I
can take credit only for modifying his test case to work against
unmodified PostgreSQL.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company