pgsql: Choose FK name correctly during partition attachment

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Choose FK name correctly during partition attachment
Date: 2022-09-08 11:19:58
Message-ID: E1oWFZd-001zTd-Kt@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)dalibo(dot)com>
Discussion: https://postgr.es/m/20220901184156.738ebee5@karst

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e7936f8b3e57046c0e178ccefa04ac7e6fbae79c

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

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2022-09-08 11:24:14 Re: pgsql: doc: clarify recursion internal behavior
Previous Message Thomas Munro 2022-09-08 09:45:54 pgsql: Fix recovery_prefetch with low maintenance_io_concurrency.