Okay, I've extracted a reproducible test case from Warren's info:
Setup:
CREATE TABLE sis_user (
sis_user_id INTEGER PRIMARY KEY,
last_visit DATETIME NOT NULL DEFAULT TEXT 'now');
CREATE TABLE session (
session_key CHAR(40) PRIMARY KEY,
sis_user_id INTEGER NOT NULL REFERENCES sis_user(sis_user_id),
last_access_time DATETIME NOT NULL DEFAULT TEXT 'now');
CREATE RULE session_del AS ON DELETE TO session DO
UPDATE sis_user SET last_visit = OLD.last_access_time
WHERE OLD.sis_user_id = sis_user.sis_user_id;
insert into sis_user values(1);
In session 1, do:
insert into session values('zzz', 1);
begin;
delete from session where session_key = 'zzz';
In session 2, do:
delete from session where session_key = 'zzz';
Back to session 1:
end;
Session 2 crashes. Crash happens in current sources as well as 7.1.
The crash does NOT happen if the foreign key reference is removed from
session.sis_user_id. I'm not sure at this point whether the rule is
a crucial element or not. The problem appears to be generation of
an invalid plan tree: the Var being decoded has varno = OUTER, which
offhand I believe it should not have in an indexscan's qual tree.
I'm tired and am going to bed soon, but perhaps someone else would
like to poke at this before I get back to it...
regards, tom lane