pgsql: Don't add a redundant constraint when detaching a partition

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Don't add a redundant constraint when detaching a partition
Date: 2021-04-21 22:12:42
Message-ID: E1lZL5O-0005g9-DN@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't add a redundant constraint when detaching a partition

On ALTER TABLE .. DETACH CONCURRENTLY, we add a new table constraint
that duplicates the partition constraint. But if the partition already
has another constraint that implies that one, then that's unnecessary.
We were already avoiding the addition of a duplicate constraint if there
was an exact 'equal' match -- this just improves the quality of the check.

Author: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Reviewed-by: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Discussion: https://postgr.es/m/20210410184226.GY6592@telsasoft.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7b357cc6ae553c0ecacdc11b2e5278b7bf477dba

Modified Files
--------------
src/backend/commands/tablecmds.c | 61 ++++++++++++++-----------------
src/test/regress/expected/alter_table.out | 20 ++++++++++
src/test/regress/sql/alter_table.sql | 6 +++
3 files changed, 54 insertions(+), 33 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2021-04-21 22:39:23 pgsql: Add comment about extract_autovac_opts not holding lock
Previous Message Andrew Dunstan 2021-04-21 15:17:45 pgsql: fix silly perl error in commit d064afc720