rule-related crash in v11

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: rule-related crash in v11
Date: 2018-05-25 14:06:00
Message-ID: CA+TgmoZUrRN4xvZe_BbBn_Xp0BDwuMEue-0OyF0fJpfvU2Yc7Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-05-25 14:08:08 Re: In what range of the code can we read debug_query_string?
Previous Message Tom Lane 2018-05-25 13:58:48 Re: Enhancement Idea - Expose the active value of a parameter in pg_settings