Detaching a partition from a partitioned table that's constrained by foreign keys requires additional action triggers on the referenced side; otherwise, DELETE/UPDATE actions there fail to notice rows in the table that was partition, and so are incorrectly allowed through. With this commit, those triggers are now created. Conversely, when a table that has a foreign key is attached as a partition to a table that also has the same foreign key, those action triggers are no longer needed, so we remove them.
Add a minimal test case verifying (part of) this.
Authors: Amit Langote, Álvaro Herrera Discussion: https://firstname.lastname@example.org
0464fdf07f Create action triggers when partitions are detached
src/backend/commands/tablecmds.c | 71 ++++++++++++++++++++++++++++++-
src/test/regress/expected/foreign_key.out | 28 +++++++++++-
src/test/regress/sql/foreign_key.sql | 19 ++++++++-
3 files changed, 113 insertions(+), 5 deletions(-)