pgsql: Fix SET CONSTRAINTS .. DEFERRED on partitioned tables

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix SET CONSTRAINTS .. DEFERRED on partitioned tables
Date: 2019-11-07 17:28:28
Message-ID: E1iSla8-0005iQ-0M@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix SET CONSTRAINTS .. DEFERRED on partitioned tables

SET CONSTRAINTS ... DEFERRED failed on partitioned tables, because of a
sanity check that ensures that the affected constraints have triggers.
On partitioned tables, the triggers are in the leaf partitions, not in
the partitioned relations themselves, so the sanity check fails.
Removing the sanity check solves the problem, because the code needed to
support the case is already there.

Backpatch to 11.

Note: deferred unique constraints are not affected by this bug, because
they do have triggers in the parent partitioned table. I did not add a
test for this scenario.

Discussion: https://postgr.es/m/20191105212915.GA11324@alvherre.pgsql

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e4baecf1e1626139a2298395257ec1838c133d79

Modified Files
--------------
src/backend/commands/trigger.c | 10 ----------
src/test/regress/expected/foreign_key.out | 21 +++++++++++++++++++--
src/test/regress/sql/foreign_key.sql | 20 +++++++++++++++++++-
3 files changed, 38 insertions(+), 13 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message David Steele 2019-11-07 17:33:33 Re: pgsql: doc: Further clarify how recovery target parameters are applied
Previous Message Alvaro Herrera 2019-11-07 17:28:27 pgsql: Fix SET CONSTRAINTS .. DEFERRED on partitioned tables