pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix dependency handling of partitions and inheritance for ON COM 3+ messages / 1 participants [nested] [flat]
* pgsql: Fix dependency handling of partitions and inheritance for ON COM @ 2018-11-09 01:08 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 3+ messages in thread From: Michael Paquier @ 2018-11-09 01:08 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix dependency handling of partitions and inheritance for ON COMMIT This commit fixes a set of issues with ON COMMIT actions when used on partitioned tables and tables with inheritance children: - Applying ON COMMIT DROP on a partitioned table with partitions or on a table with inheritance children caused a failure at commit time, with complains about the children being already dropped as all relations are dropped one at the same time. - Applying ON COMMIT DELETE on a partition relying on a partitioned table which uses ON COMMIT DROP would cause the partition truncation to fail as the parent is removed first. The solution to the first problem is to handle the removal of all the dependencies in one go instead of dropping relations one-by-one, based on a suggestion from Álvaro Herrera. So instead all the relation OIDs to remove are gathered and then processed in one round of multiple deletions. The solution to the second problem is to reorder the actions, with truncation happening first and relation drop done after. Even if it means that a partition could be first truncated, then immediately dropped if its partitioned table is dropped, this has the merit to keep the code simple as there is no need to do existence checks on the relations to drop. Contrary to a manual TRUNCATE on a partitioned table, ON COMMIT DELETE does not cascade to its partitions. The ON COMMIT action defined on each partition gets the priority. Author: Michael Paquier Reviewed-by: Amit Langote, Álvaro Herrera, Robert Haas Discussion: https://postgr.es/m/68f17907-ec98-1192-f99f-8011400517f5@lab.ntt.co.jp Backpatch-through: 10 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/319a8101804f3b62512fdce1a3af1c839344b593 Modified Files -------------- doc/src/sgml/ref/create_table.sgml | 7 +++- src/backend/commands/tablecmds.c | 77 +++++++++++++++++++++++----------- src/test/regress/expected/temp.out | 85 ++++++++++++++++++++++++++++++++++++++ src/test/regress/sql/temp.sql | 59 ++++++++++++++++++++++++++ 4 files changed, 203 insertions(+), 25 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix dependency handling of partitions and inheritance for ON COM @ 2018-11-09 01:08 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 3+ messages in thread From: Michael Paquier @ 2018-11-09 01:08 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix dependency handling of partitions and inheritance for ON COMMIT This commit fixes a set of issues with ON COMMIT actions when used on partitioned tables and tables with inheritance children: - Applying ON COMMIT DROP on a partitioned table with partitions or on a table with inheritance children caused a failure at commit time, with complains about the children being already dropped as all relations are dropped one at the same time. - Applying ON COMMIT DELETE on a partition relying on a partitioned table which uses ON COMMIT DROP would cause the partition truncation to fail as the parent is removed first. The solution to the first problem is to handle the removal of all the dependencies in one go instead of dropping relations one-by-one, based on a suggestion from Álvaro Herrera. So instead all the relation OIDs to remove are gathered and then processed in one round of multiple deletions. The solution to the second problem is to reorder the actions, with truncation happening first and relation drop done after. Even if it means that a partition could be first truncated, then immediately dropped if its partitioned table is dropped, this has the merit to keep the code simple as there is no need to do existence checks on the relations to drop. Contrary to a manual TRUNCATE on a partitioned table, ON COMMIT DELETE does not cascade to its partitions. The ON COMMIT action defined on each partition gets the priority. Author: Michael Paquier Reviewed-by: Amit Langote, Álvaro Herrera, Robert Haas Discussion: https://postgr.es/m/68f17907-ec98-1192-f99f-8011400517f5@lab.ntt.co.jp Backpatch-through: 10 Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/84b4a0cf6619b88bff1b20e8bf612b1c09f150fd Modified Files -------------- doc/src/sgml/ref/create_table.sgml | 7 +++- src/backend/commands/tablecmds.c | 77 +++++++++++++++++++++++----------- src/test/regress/expected/temp.out | 85 ++++++++++++++++++++++++++++++++++++++ src/test/regress/sql/temp.sql | 59 ++++++++++++++++++++++++++ 4 files changed, 203 insertions(+), 25 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix dependency handling of partitions and inheritance for ON COM @ 2018-11-09 01:08 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 3+ messages in thread From: Michael Paquier @ 2018-11-09 01:08 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix dependency handling of partitions and inheritance for ON COMMIT This commit fixes a set of issues with ON COMMIT actions when used on partitioned tables and tables with inheritance children: - Applying ON COMMIT DROP on a partitioned table with partitions or on a table with inheritance children caused a failure at commit time, with complains about the children being already dropped as all relations are dropped one at the same time. - Applying ON COMMIT DELETE on a partition relying on a partitioned table which uses ON COMMIT DROP would cause the partition truncation to fail as the parent is removed first. The solution to the first problem is to handle the removal of all the dependencies in one go instead of dropping relations one-by-one, based on a suggestion from Álvaro Herrera. So instead all the relation OIDs to remove are gathered and then processed in one round of multiple deletions. The solution to the second problem is to reorder the actions, with truncation happening first and relation drop done after. Even if it means that a partition could be first truncated, then immediately dropped if its partitioned table is dropped, this has the merit to keep the code simple as there is no need to do existence checks on the relations to drop. Contrary to a manual TRUNCATE on a partitioned table, ON COMMIT DELETE does not cascade to its partitions. The ON COMMIT action defined on each partition gets the priority. Author: Michael Paquier Reviewed-by: Amit Langote, Álvaro Herrera, Robert Haas Discussion: https://postgr.es/m/68f17907-ec98-1192-f99f-8011400517f5@lab.ntt.co.jp Backpatch-through: 10 Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/52ea6a8209d6cb778640c87644db86a176a61254 Modified Files -------------- doc/src/sgml/ref/create_table.sgml | 7 +++- src/backend/commands/tablecmds.c | 77 +++++++++++++++++++++++----------- src/test/regress/expected/temp.out | 85 ++++++++++++++++++++++++++++++++++++++ src/test/regress/sql/temp.sql | 59 ++++++++++++++++++++++++++ 4 files changed, 203 insertions(+), 25 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2018-11-09 01:08 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2018-11-09 01:08 pgsql: Fix dependency handling of partitions and inheritance for ON COM Michael Paquier <michael@paquier.xyz> 2018-11-09 01:08 pgsql: Fix dependency handling of partitions and inheritance for ON COM Michael Paquier <michael@paquier.xyz> 2018-11-09 01:08 pgsql: Fix dependency handling of partitions and inheritance for ON COM Michael Paquier <michael@paquier.xyz>
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