Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgoAO-0006Wb-Ne for pgsql-bugs@arkaria.postgresql.org; Mon, 27 Mar 2023 14:49:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pgoAN-0006MR-8r for pgsql-bugs@arkaria.postgresql.org; Mon, 27 Mar 2023 14:49:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgoAN-0006MI-0Z for pgsql-bugs@lists.postgresql.org; Mon, 27 Mar 2023 14:49:47 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgoAH-0000oe-KJ for pgsql-bugs@lists.postgresql.org; Mon, 27 Mar 2023 14:49:46 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 32REnd0c3169551; Mon, 27 Mar 2023 10:49:39 -0400 From: Tom Lane To: exclusion@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17872: Dropping an attribute of a composite type breaks indexes over the type silently In-reply-to: <17872-d0fbb799dc3fd85d@postgresql.org> References: <17872-d0fbb799dc3fd85d@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 27 Mar 2023 10:00:01 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3169549.1679928579.1@sss.pgh.pa.us> Date: Mon, 27 Mar 2023 10:49:39 -0400 Message-ID: <3169550.1679928579@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > The following script: > CREATE TYPE ctype AS (i int, j int); > CREATE TABLE ctbl(a int, cf ctype); > CREATE UNIQUE INDEX ctbl_idx ON ctbl(cf); > INSERT INTO ctbl VALUES (1, '(1, 2)'::ctype), (2, '(1, 1)'::ctype); > ALTER TYPE ctype DROP ATTRIBUTE j; > Results in the UNIQUE constraint broken: > SELECT ctid, * FROM ctbl; > ctid | a | cf > -------+---+----- > (0,1) | 1 | (1) > (0,2) | 2 | (1) Meh. I'm happy to classify this as "so don't do that". The cost of having ALTER TYPE detect such situations seems vastly out of proportion to the value (and I think it'd be impossible to prevent race conditions in the detection anyway). regards, tom lane