pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix TRUNCATE .. CASCADE on partitions
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix TRUNCATE .. CASCADE on partitions
@ 2020-02-07 20:22  Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Alvaro Herrera @ 2020-02-07 20:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix TRUNCATE .. CASCADE on partitions

When running TRUNCATE CASCADE on a child of a partitioned table
referenced by another partitioned table, the truncate was not applied to
partitions of the referencing table; this could leave rows violating the
constraint in the referencing partitioned table.  Repair by walking the
pg_constraint chain all the way up to the topmost referencing table.

Note: any partitioned tables containing FKs that reference other
partitioned tables should be checked for possible violating rows, if
TRUNCATE has occurred in partitions of the referenced table.

Reported-by: Christophe Courtois
Author: Jehan-Guillaume de Rorthais
Discussion: https://postgr.es/m/20200204183906.115f693e@firost

Branch
------
REL_12_STABLE

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

Modified Files
--------------
doc/src/sgml/ref/truncate.sgml         |  3 ++
src/backend/catalog/heap.c             | 84 +++++++++++++++++++++++++++++++++-
src/test/regress/expected/truncate.out | 50 ++++++++++++++++++++
src/test/regress/sql/truncate.sql      | 38 +++++++++++++++
4 files changed, 173 insertions(+), 2 deletions(-)



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

* pgsql: Fix TRUNCATE .. CASCADE on partitions
@ 2020-02-07 20:22  Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Alvaro Herrera @ 2020-02-07 20:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix TRUNCATE .. CASCADE on partitions

When running TRUNCATE CASCADE on a child of a partitioned table
referenced by another partitioned table, the truncate was not applied to
partitions of the referencing table; this could leave rows violating the
constraint in the referencing partitioned table.  Repair by walking the
pg_constraint chain all the way up to the topmost referencing table.

Note: any partitioned tables containing FKs that reference other
partitioned tables should be checked for possible violating rows, if
TRUNCATE has occurred in partitions of the referenced table.

Reported-by: Christophe Courtois
Author: Jehan-Guillaume de Rorthais
Discussion: https://postgr.es/m/20200204183906.115f693e@firost

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9710d3d4a87f428a10f63015a0d75ccf028dd137

Modified Files
--------------
doc/src/sgml/ref/truncate.sgml         |  3 ++
src/backend/catalog/heap.c             | 84 +++++++++++++++++++++++++++++++++-
src/test/regress/expected/truncate.out | 50 ++++++++++++++++++++
src/test/regress/sql/truncate.sql      | 38 +++++++++++++++
4 files changed, 173 insertions(+), 2 deletions(-)



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


end of thread, other threads:[~2020-02-07 20:22 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-02-07 20:22 pgsql: Fix TRUNCATE .. CASCADE on partitions Alvaro Herrera <alvherre@alvh.no-ip.org>
2020-02-07 20:22 pgsql: Fix TRUNCATE .. CASCADE on partitions 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