]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Choose FK name correctly during partition attachment
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 8 Sep 2022 11:17:02 +0000 (13:17 +0200)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 8 Sep 2022 11:17:02 +0000 (13:17 +0200)
commit562e100aeeaf5db2243adbe6ff6a68bee313038e
tree21c2c90f1f6037fc538251069f3ebf872f9ba4ec
parent4d7c0fe51d6b4416db0fcc688a3f46574863426a
Choose FK name correctly during partition attachment

During ALTER TABLE ATTACH PARTITION, if the name of a parent's foreign
key constraint is already used on the partition, the code tries to
choose another one before the FK attributes list has been populated,
so the resulting constraint name was "<relname>__fkey" instead of
"<relname>_<attrs>_fkey".  Repair, and add a test case.

Backpatch to 12.  In 11, the code to attach a partition was not smart
enough to cope with conflicting constraint names, so the problem doesn't
exist there.

Author: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
Discussion: https://postgr.es/m/20220901184156.738ebee5@karst
src/backend/commands/tablecmds.c
src/test/regress/input/constraints.source
src/test/regress/output/constraints.source