BUG #17817: DISABLE TRIGGER ALL on a partitioned table with foreign key fails

The Post Office <noreply@postgresql.org>

From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: ahodgson@simkin.ca
Date: 2023-03-01T19:21:44Z
Lists: pgsql-bugs
The following bug has been logged on the website:

Bug reference:      17817
Logged by:          Alan Hodgson
Email address:      ahodgson@simkin.ca
PostgreSQL version: 15.2
Operating system:   linux-amd64
Description:        

This works on 14.7. It fails on 15.2. The Ruby on Rails test suites use
DISABLE TRIGGER ALL extensively.

BEGIN;
CREATE TABLE test_fk (id serial primary key);
CREATE TABLE test_table (test serial, created_at timestamp not null, fk_id
int not null references test_fk(id)) PARTITION BY RANGE (created_at);
CREATE TABLE test_table_2017 PARTITION OF test_table FOR VALUES FROM
('2017-01-01') TO ('2018-01-01');
ALTER TABLE test_table DISABLE TRIGGER ALL;
ROLLBACK;

ERROR:  trigger "RI_ConstraintTrigger_c_46838897" for table
"test_table_2017" does not exist

Commits

  1. Avoid failure when altering state of partitioned foreign-key triggers.

  2. Fix ENABLE/DISABLE TRIGGER to handle recursion correctly