pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Don't add a redundant constraint when detaching a partition
Date: Wed, 21 Apr 2021 22:12:42 +0000
Message-ID: <E1lZL5O-0005g9-DN@gemulon.postgresql.org> (raw)

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@telsasoft.com>
Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.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(-)



Message-ID: <E1lZL5O-0005g9-DN@gemulon.postgresql.org>
Permalink:  ../E1lZL5O-0005g9-DN@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lZL5O-0005g9-DN@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Don't add a redundant constraint when detaching a partition
  In-Reply-To: <E1lZL5O-0005g9-DN@gemulon.postgresql.org>
  References: <E1lZL5O-0005g9-DN@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox