pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Detach constraints when partitions are detached
Date: Thu, 24 Jan 2019 14:22:07 +0900
Message-ID: <d24d40f3-52d7-296c-8e06-5b153c5ba0dd@lab.ntt.co.jp> (raw)
In-Reply-To: <21693.1548305934@sss.pgh.pa.us>
References: <E1gmVI1-00071l-SO@gemulon.postgresql.org>
	<21693.1548305934@sss.pgh.pa.us>

On 2019/01/24 13:58, Tom Lane wrote:
> Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
>> Detach constraints when partitions are detached
> 
> Hm ... it looks like this fails under -DRELCACHE_FORCE_RELEASE:

Oops, sorry.  This is why:

         index_close(idx, NoLock);
...
+        if (!idx->rd_index->indisprimary && !idx->rd_index->indisunique)
+            continue;

Attached a fix.

Thanks,
Amit

Attachments:

ae366aa577-fixup.patch (text/plain, 1.1K) download diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 738c178107..98366a2d5b 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -15095,6 +15095,7 @@ ATExecDetachPartition(Relation rel, RangeVar *name) { Oid idxid = lfirst_oid(cell); Relation idx; + bool detachConstraint = false; Oid constrOid; if (!has_superclass(idxid)) @@ -15106,14 +15107,18 @@ ATExecDetachPartition(Relation rel, RangeVar *name) idx = index_open(idxid, AccessExclusiveLock); IndexSetParentIndex(idx, InvalidOid); update_relispartition(classRel, idxid, false); - index_close(idx, NoLock); /* * Detach any constraints associated with the index too. Only UNIQUE * and PRIMARY KEY index constraints can be inherited, so no need * to check for others. */ - if (!idx->rd_index->indisprimary && !idx->rd_index->indisunique) + if (idx->rd_index->indisprimary || idx->rd_index->indisunique) + detachConstraint = true; + + index_close(idx, NoLock); + + if (!detachConstraint) continue; constrOid = get_relation_idx_constraint_oid(RelationGetRelid(partRel),

view thread (5+ messages)  latest in thread

Message-ID: <d24d40f3-52d7-296c-8e06-5b153c5ba0dd@lab.ntt.co.jp>
Permalink:  ../d24d40f3-52d7-296c-8e06-5b153c5ba0dd@lab.ntt.co.jp/
Also on:    postgresql.org/message-id/d24d40f3-52d7-296c-8e06-5b153c5ba0dd@lab.ntt.co.jp

 ·  · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: Langote_Amit_f8@lab.ntt.co.jp, tgl@sss.pgh.pa.us, alvherre@alvh.no-ip.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Detach constraints when partitions are detached
  In-Reply-To: <d24d40f3-52d7-296c-8e06-5b153c5ba0dd@lab.ntt.co.jp>

* 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