Block creation of partitions with open references to its parent

Michael Paquier <michael@paquier.xyz>

Commit: 7c222d5e56cca4e2081dc7841ed118a97666cb8e
Author: Michael Paquier <michael@paquier.xyz>
Date: 2018-11-05T02:04:14Z
Releases: 11.1
Block creation of partitions with open references to its parent

When a partition is created as part of a trigger processing, it is
possible that the partition which just gets created changes the
properties of the table the executor of the ongoing command relies on,
causing a subsequent crash.  This has been found possible when for
example using a BEFORE INSERT which creates a new partition for a
partitioned table being inserted to.

Any attempt to do so is blocked when working on a partition, with
regression tests added for both CREATE TABLE PARTITION OF and ALTER
TABLE ATTACH PARTITION.

Reported-by: Dmitry Shalashov
Author: Amit Langote
Reviewed-by: Michael Paquier, Tom Lane
Discussion: https://postgr.es/m/15437-3fe01ee66bd1bae1@postgresql.org
Backpatch-through: 10

Files

Discussion