pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix detach of a partition that has a toplevel FK to a partitione 4+ messages / 1 participants [nested] [flat]
* pgsql: Fix detach of a partition that has a toplevel FK to a partitione @ 2025-01-21 13:54 Álvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 4+ messages in thread From: Álvaro Herrera @ 2025-01-21 13:54 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix detach of a partition that has a toplevel FK to a partitioned table In common cases, foreign keys are defined on the toplevel partitioned table; but if instead one is defined on a partition and references a partitioned table, and the referencing partition is detached, we would examine the pg_constraint row on the partition being detached, and fail to realize that the sub-constraints must be left alone. This causes the ALTER TABLE DETACH process to fail with ERROR: could not find ON INSERT check triggers of foreign key constraint NNN This is similar but not quite the same as what was fixed by 53af9491a043. This bug doesn't affect branches earlier than 15, because the detach procedure was different there, so we only backpatch down to 15. Fix by skipping such modifying constraints that are children of other constraints being detached. Author: Amul Sul <sulamul@gmail.com> Diagnosys-by: Sami Imseih <samimseih@gmail.com> Discussion: https://postgr.es/m/CAAJ_b97GuPh6wQPbxQS-Zpy16Oh+0aMv-w64QcGrLhCOZZ6p+g@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/9b21f203dd879a6a7eb3b8629f3d8cae0c1381a5 Modified Files -------------- src/backend/commands/tablecmds.c | 26 ++++++++++++++++++++++++-- src/test/regress/expected/foreign_key.out | 7 +++++++ src/test/regress/sql/foreign_key.sql | 8 ++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix detach of a partition that has a toplevel FK to a partitione @ 2025-01-21 13:54 Álvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 4+ messages in thread From: Álvaro Herrera @ 2025-01-21 13:54 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix detach of a partition that has a toplevel FK to a partitioned table In common cases, foreign keys are defined on the toplevel partitioned table; but if instead one is defined on a partition and references a partitioned table, and the referencing partition is detached, we would examine the pg_constraint row on the partition being detached, and fail to realize that the sub-constraints must be left alone. This causes the ALTER TABLE DETACH process to fail with ERROR: could not find ON INSERT check triggers of foreign key constraint NNN This is similar but not quite the same as what was fixed by 53af9491a043. This bug doesn't affect branches earlier than 15, because the detach procedure was different there, so we only backpatch down to 15. Fix by skipping such modifying constraints that are children of other constraints being detached. Author: Amul Sul <sulamul@gmail.com> Diagnosys-by: Sami Imseih <samimseih@gmail.com> Discussion: https://postgr.es/m/CAAJ_b97GuPh6wQPbxQS-Zpy16Oh+0aMv-w64QcGrLhCOZZ6p+g@mail.gmail.com Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/2f30847d1d04bafa51a17886e132892e38df093f Modified Files -------------- src/backend/commands/tablecmds.c | 26 ++++++++++++++++++++++++-- src/test/regress/expected/foreign_key.out | 7 +++++++ src/test/regress/sql/foreign_key.sql | 8 ++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix detach of a partition that has a toplevel FK to a partitione @ 2025-01-21 13:54 Álvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 4+ messages in thread From: Álvaro Herrera @ 2025-01-21 13:54 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix detach of a partition that has a toplevel FK to a partitioned table In common cases, foreign keys are defined on the toplevel partitioned table; but if instead one is defined on a partition and references a partitioned table, and the referencing partition is detached, we would examine the pg_constraint row on the partition being detached, and fail to realize that the sub-constraints must be left alone. This causes the ALTER TABLE DETACH process to fail with ERROR: could not find ON INSERT check triggers of foreign key constraint NNN This is similar but not quite the same as what was fixed by 53af9491a043. This bug doesn't affect branches earlier than 15, because the detach procedure was different there, so we only backpatch down to 15. Fix by skipping such modifying constraints that are children of other constraints being detached. Author: Amul Sul <sulamul@gmail.com> Diagnosys-by: Sami Imseih <samimseih@gmail.com> Discussion: https://postgr.es/m/CAAJ_b97GuPh6wQPbxQS-Zpy16Oh+0aMv-w64QcGrLhCOZZ6p+g@mail.gmail.com Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ddab512ebb97c03d3c0dcfe0ea20d053a31e24d8 Modified Files -------------- src/backend/commands/tablecmds.c | 30 ++++++++++++++++++++++++++++-- src/test/regress/expected/foreign_key.out | 7 +++++++ src/test/regress/sql/foreign_key.sql | 8 ++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix detach of a partition that has a toplevel FK to a partitione @ 2025-01-21 13:54 Álvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 4+ messages in thread From: Álvaro Herrera @ 2025-01-21 13:54 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix detach of a partition that has a toplevel FK to a partitioned table In common cases, foreign keys are defined on the toplevel partitioned table; but if instead one is defined on a partition and references a partitioned table, and the referencing partition is detached, we would examine the pg_constraint row on the partition being detached, and fail to realize that the sub-constraints must be left alone. This causes the ALTER TABLE DETACH process to fail with ERROR: could not find ON INSERT check triggers of foreign key constraint NNN This is similar but not quite the same as what was fixed by 53af9491a043. This bug doesn't affect branches earlier than 15, because the detach procedure was different there, so we only backpatch down to 15. Fix by skipping such modifying constraints that are children of other constraints being detached. Author: Amul Sul <sulamul@gmail.com> Diagnosys-by: Sami Imseih <samimseih@gmail.com> Discussion: https://postgr.es/m/CAAJ_b97GuPh6wQPbxQS-Zpy16Oh+0aMv-w64QcGrLhCOZZ6p+g@mail.gmail.com Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/1bc092519b77a6386bb84918c7652c70b5d1fd48 Modified Files -------------- src/backend/commands/tablecmds.c | 30 ++++++++++++++++++++++++++++-- src/test/regress/expected/foreign_key.out | 7 +++++++ src/test/regress/sql/foreign_key.sql | 8 ++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2025-01-21 13:54 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2025-01-21 13:54 pgsql: Fix detach of a partition that has a toplevel FK to a partitione Álvaro Herrera <alvherre@alvh.no-ip.org> 2025-01-21 13:54 pgsql: Fix detach of a partition that has a toplevel FK to a partitione Álvaro Herrera <alvherre@alvh.no-ip.org> 2025-01-21 13:54 pgsql: Fix detach of a partition that has a toplevel FK to a partitione Álvaro Herrera <alvherre@alvh.no-ip.org> 2025-01-21 13:54 pgsql: Fix detach of a partition that has a toplevel FK to a partitione Álvaro 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