pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix creation of duplicate foreign keys on partitions 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix creation of duplicate foreign keys on partitions @ 2019-01-18 18:07 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 2+ messages in thread From: Alvaro Herrera @ 2019-01-18 18:07 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix creation of duplicate foreign keys on partitions When creating a foreign key in a partitioned table, if some partitions already have equivalent constraints, we wastefully create duplicates of the constraints instead of attaching to the existing ones. That's inconsistent with the de-duplication that is applied when a table is attached as a partition. To fix, reuse the FK-cloning code instead of having a separate code path. Backpatch to Postgres 11. This is a subtle behavior change, but surely a welcome one since there's no use in having duplicate foreign keys. Discovered by Álvaro Herrera while thinking about a different problem reported by Jesper Pedersen (bug #15587). Author: Álvaro Herrera Discussion: https://postgr.es/m/201901151935.zfadrzvyof4k@alvherre.pgsql Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/4dff8935fbab64aef38470424cc57dbda9efa1cf Modified Files -------------- src/backend/commands/tablecmds.c | 39 +++++++++++---- src/test/regress/expected/foreign_key.out | 83 +++++++++++++++++++++++++++++++ src/test/regress/sql/foreign_key.sql | 38 ++++++++++++++ 3 files changed, 150 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix creation of duplicate foreign keys on partitions @ 2019-01-18 18:07 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 2+ messages in thread From: Alvaro Herrera @ 2019-01-18 18:07 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix creation of duplicate foreign keys on partitions When creating a foreign key in a partitioned table, if some partitions already have equivalent constraints, we wastefully create duplicates of the constraints instead of attaching to the existing ones. That's inconsistent with the de-duplication that is applied when a table is attached as a partition. To fix, reuse the FK-cloning code instead of having a separate code path. Backpatch to Postgres 11. This is a subtle behavior change, but surely a welcome one since there's no use in having duplicate foreign keys. Discovered by Álvaro Herrera while thinking about a different problem reported by Jesper Pedersen (bug #15587). Author: Álvaro Herrera Discussion: https://postgr.es/m/201901151935.zfadrzvyof4k@alvherre.pgsql Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/0325d7a5957ba39a0dce90835ab54a08ab8bf762 Modified Files -------------- src/backend/commands/tablecmds.c | 39 +++++++++++---- src/test/regress/expected/foreign_key.out | 83 +++++++++++++++++++++++++++++++ src/test/regress/sql/foreign_key.sql | 38 ++++++++++++++ 3 files changed, 150 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2019-01-18 18:07 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-01-18 18:07 pgsql: Fix creation of duplicate foreign keys on partitions Alvaro Herrera <alvherre@alvh.no-ip.org> 2019-01-18 18:07 pgsql: Fix creation of duplicate foreign keys 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