pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Check that partitions are not in use when dropping constraints
3+ messages / 1 participants
[nested] [flat]

* pgsql: Check that partitions are not in use when dropping constraints
@ 2019-07-23 21:25  Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Alvaro Herrera @ 2019-07-23 21:25 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Check that partitions are not in use when dropping constraints

If the user creates a deferred constraint in a partition, and in a
transaction they cause the constraint's trigger execution to be deferred
until commit time *and* drop the constraint, then when commit time comes
the queued trigger will fail to run because the trigger object will have
been dropped.

This is explained because when a constraint gets dropped in a
partitioned table, the recursion to drop the ones in partitions is done
by the dependency mechanism, not by ALTER TABLE traversing the recursion
tree as in all other cases.  In the non-partitioned case, this problem
is avoided by checking that the table is not "in use" by alter-table;
other alter-table subcommands that recurse to partitions do that check
for each partition.  But the dependency mechanism doesn't have a way to
do that.  Fix the problem by applying the same check to all partitions
during ALTER TABLE's "prep" phase, which correctly raises the necessary
error.

Reported-by: Rajkumar Raghuwanshi <rajkumar.raghuwanshi@enterprisedb.com>
Discussion: https://postgr.es/m/CAKcux6nZiO9-eEpr1ZD84bT1mBoVmeZkfont8iSpcmYrjhGWgA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5562272a4229cfa57354aa203cffd36b4e7f70cb

Modified Files
--------------
src/backend/commands/tablecmds.c          | 56 +++++++++++++++++++++++++------
src/test/regress/expected/foreign_key.out | 15 +++++++++
src/test/regress/sql/foreign_key.sql      | 12 +++++++
3 files changed, 72 insertions(+), 11 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Check that partitions are not in use when dropping constraints
@ 2019-07-23 21:25  Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Alvaro Herrera @ 2019-07-23 21:25 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Check that partitions are not in use when dropping constraints

If the user creates a deferred constraint in a partition, and in a
transaction they cause the constraint's trigger execution to be deferred
until commit time *and* drop the constraint, then when commit time comes
the queued trigger will fail to run because the trigger object will have
been dropped.

This is explained because when a constraint gets dropped in a
partitioned table, the recursion to drop the ones in partitions is done
by the dependency mechanism, not by ALTER TABLE traversing the recursion
tree as in all other cases.  In the non-partitioned case, this problem
is avoided by checking that the table is not "in use" by alter-table;
other alter-table subcommands that recurse to partitions do that check
for each partition.  But the dependency mechanism doesn't have a way to
do that.  Fix the problem by applying the same check to all partitions
during ALTER TABLE's "prep" phase, which correctly raises the necessary
error.

Reported-by: Rajkumar Raghuwanshi <rajkumar.raghuwanshi@enterprisedb.com>
Discussion: https://postgr.es/m/CAKcux6nZiO9-eEpr1ZD84bT1mBoVmeZkfont8iSpcmYrjhGWgA@mail.gmail.com

Branch
------
REL_11_STABLE

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

Modified Files
--------------
src/backend/commands/tablecmds.c          | 56 +++++++++++++++++++++++++------
src/test/regress/expected/foreign_key.out | 15 +++++++--
src/test/regress/sql/foreign_key.sql      | 13 ++++++-
3 files changed, 70 insertions(+), 14 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Check that partitions are not in use when dropping constraints
@ 2019-07-23 21:25  Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Alvaro Herrera @ 2019-07-23 21:25 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Check that partitions are not in use when dropping constraints

If the user creates a deferred constraint in a partition, and in a
transaction they cause the constraint's trigger execution to be deferred
until commit time *and* drop the constraint, then when commit time comes
the queued trigger will fail to run because the trigger object will have
been dropped.

This is explained because when a constraint gets dropped in a
partitioned table, the recursion to drop the ones in partitions is done
by the dependency mechanism, not by ALTER TABLE traversing the recursion
tree as in all other cases.  In the non-partitioned case, this problem
is avoided by checking that the table is not "in use" by alter-table;
other alter-table subcommands that recurse to partitions do that check
for each partition.  But the dependency mechanism doesn't have a way to
do that.  Fix the problem by applying the same check to all partitions
during ALTER TABLE's "prep" phase, which correctly raises the necessary
error.

Reported-by: Rajkumar Raghuwanshi <rajkumar.raghuwanshi@enterprisedb.com>
Discussion: https://postgr.es/m/CAKcux6nZiO9-eEpr1ZD84bT1mBoVmeZkfont8iSpcmYrjhGWgA@mail.gmail.com

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3ffe655c0af03cb4d5aab18da2aaa7022d207bf3

Modified Files
--------------
src/backend/commands/tablecmds.c          | 56 +++++++++++++++++++++++++------
src/test/regress/expected/foreign_key.out | 15 +++++++++
src/test/regress/sql/foreign_key.sql      | 12 +++++++
3 files changed, 72 insertions(+), 11 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2019-07-23 21:25 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-07-23 21:25 pgsql: Check that partitions are not in use when dropping constraints Alvaro Herrera <alvherre@alvh.no-ip.org>
2019-07-23 21:25 pgsql: Check that partitions are not in use when dropping constraints Alvaro Herrera <alvherre@alvh.no-ip.org>
2019-07-23 21:25 pgsql: Check that partitions are not in use when dropping constraints Alvaro Herrera <alvherre@alvh.no-ip.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox