postgresql/src/backend
Alvaro Herrera 0325d7a595 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
2019-01-18 15:00:45 -03:00
..
access Fix incorrect relation name in comment of vacuumlazy.c 2019-01-18 13:53:43 +09:00
bootstrap Don't include genam.h from execnodes.h and relscan.h anymore. 2019-01-14 17:02:12 -08:00
catalog Move CloneForeignKeyConstraints to tablecmds.c 2019-01-18 15:00:06 -03:00
commands Fix creation of duplicate foreign keys on partitions 2019-01-18 15:00:45 -03:00
executor Fix parent of WCO qual. 2019-01-15 12:04:32 -08:00
foreign Update copyright for 2019 2019-01-02 12:44:25 -05:00
jit Make naming of tupdesc related structs more consistent with the rest of PG. 2019-01-14 16:25:50 -08:00
lib Update copyright for 2019 2019-01-02 12:44:25 -05:00
libpq Update copyright for 2019 2019-01-02 12:44:25 -05:00
main Update copyright for 2019 2019-01-02 12:44:25 -05:00
nodes Update copyright for 2019 2019-01-02 12:44:25 -05:00
optimizer Reorganize planner code moved in b60c397599 2019-01-16 16:27:44 -03:00
parser Postpone aggregate checks until after collation is assigned. 2019-01-17 06:46:10 +00:00
partitioning Don't include heapam.h from others headers. 2019-01-14 16:24:41 -08:00
po Translation updates 2018-06-25 12:37:18 +02:00
port Update copyright for 2019 2019-01-02 12:44:25 -05:00
postmaster Fix typos in documentation and for one wait event 2019-01-15 08:47:01 +09:00
regex Update copyright for 2019 2019-01-02 12:44:25 -05:00
replication Don't include heapam.h from others headers. 2019-01-14 16:24:41 -08:00
rewrite Don't include heapam.h from others headers. 2019-01-14 16:24:41 -08:00
snowball Update copyright for 2019 2019-01-02 12:44:25 -05:00
statistics Update copyright for 2019 2019-01-02 12:44:25 -05:00
storage Fix grammar mistakes in md.c 2019-01-10 09:36:25 +09:00
tcop Update copyright for 2019 2019-01-02 12:44:25 -05:00
tsearch Update copyright for 2019 2019-01-02 12:44:25 -05:00
utils Refactor duplicate code into DeconstructFkConstraintRow 2019-01-18 14:59:44 -03:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Ensure link commands list *.o files before LDFLAGS. 2019-01-02 13:57:54 -05:00
nls.mk Translation updates 2018-06-25 12:37:18 +02:00