pgsql: Choose FK name correctly during partition attachment - Mailing list pgsql-committers

From Alvaro Herrera
Subject pgsql: Choose FK name correctly during partition attachment
Date
Msg-id E1oWFZd-001zTn-Mi@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/562e100aeeaf5db2243adbe6ff6a68bee313038e

Modified Files
--------------
src/backend/commands/tablecmds.c           | 20 ++++++++++----------
src/test/regress/input/constraints.source  | 19 +++++++++++++++++++
src/test/regress/output/constraints.source | 23 +++++++++++++++++++++++
3 files changed, 52 insertions(+), 10 deletions(-)


pgsql-committers by date:

Previous
From: Thomas Munro
Date:
Subject: pgsql: Fix recovery_prefetch with low maintenance_io_concurrency.
Next
From: Peter Eisentraut
Date:
Subject: Re: pgsql: doc: clarify recursion internal behavior