Fix TRUNCATE .. CASCADE on partitions
Alvaro Herrera <alvherre@alvh.no-ip.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
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/ref/truncate.sgml | modified | +3 −0 |
| src/backend/catalog/heap.c | modified | +82 −2 |
| src/test/regress/expected/truncate.out | modified | +50 −0 |
| src/test/regress/sql/truncate.sql | modified | +38 −0 |
Documentation touched
Discussion
- FK violation in partitioned table after truncating a referenced partition 15 messages · 2020-02-04 → 2020-02-07