rule-related crash in v11 - Mailing list pgsql-hackers

From Robert Haas
Subject rule-related crash in v11
Date
Msg-id CA+TgmoZUrRN4xvZe_BbBn_Xp0BDwuMEue-0OyF0fJpfvU2Yc7Q@mail.gmail.com
Whole thread Raw
Responses Re: rule-related crash in v11  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Enhancement Idea - Expose the active value of a parameter in pg_settings
Next
From: Tom Lane
Date:
Subject: Re: In what range of the code can we read debug_query_string?