]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix SET CONSTRAINTS .. DEFERRED on partitioned tables
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 7 Nov 2019 16:59:24 +0000 (13:59 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 7 Nov 2019 17:26:10 +0000 (14:26 -0300)
commite4baecf1e1626139a2298395257ec1838c133d79
treef1d73817592aaa7cd5fdd664ccf8e94f47a192a8
parentb49b7f94489a12d0d7d299b2871c4881fa3c5d49
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
src/backend/commands/trigger.c
src/test/regress/expected/foreign_key.out
src/test/regress/sql/foreign_key.sql