Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gheL5-0001S1-I0 for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Jan 2019 17:41:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gheL4-0003ca-2Y for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Jan 2019 17:41:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gheL3-0003aJ-Nr for pgsql-bugs@lists.postgresql.org; Thu, 10 Jan 2019 17:41:53 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gheL1-0004cC-8M for pgsql-bugs@lists.postgresql.org; Thu, 10 Jan 2019 17:41:52 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x0AHfniM003056; Thu, 10 Jan 2019 12:41:49 -0500 From: Tom Lane To: Alvaro Herrera cc: jesper.pedersen@redhat.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15587: Partitions with ALTER TABLE ADD CONSTRAINT In-reply-to: <201901101711.ngskkvwyqgr6@alvherre.pgsql> References: <201901101711.ngskkvwyqgr6@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Thu, 10 Jan 2019 14:11:23 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3053.1547142109.1@sss.pgh.pa.us> Date: Thu, 10 Jan 2019 12:41:49 -0500 Message-ID: <3055.1547142109@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > On 2019-Jan-10, PG Bug reporting form wrote: >> ALTER TABLE ONLY t1 ADD CONSTRAINT uniq_t1_i1_i2 UNIQUE (i1, i2); >> [ leads to ] >> Indexes: >> "uniq_t1_i1_i2" UNIQUE CONSTRAINT, btree (i1, i2) INVALID > I'm not clear what problem you're reporting. If you use ONLY, then the > command doesn't cascade to create the index on partitions, and the index > is marked invalid. If you add the constraint to each partition and > ALTER INDEX ATTACH PARTITION, the index on t1 should become valid when > every partition of the table has its index. I concur that the code is operating as designed. I think however that there's a user-experience problem here, which is that INVALID suggests that something's broken. I wonder if we could improve matters by making psql and the docs describe this state of a partitioned index as INCOMPLETE. regards, tom lane