Choose FK name correctly during partition attachment
Alvaro Herrera <alvherre@alvh.no-ip.org>
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
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/commands/tablecmds.c | modified | +10 −10 |
| src/test/regress/expected/constraints.out | modified | +23 −0 |
| src/test/regress/sql/constraints.sql | modified | +19 −0 |
Discussion
- Self FK oddity when attaching a partition 27 messages · 2022-06-03 → 2022-11-04