pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
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
Date: Mon, 27 Mar 2023 10:49:39 -0400
Message-ID: <3169550.1679928579@sss.pgh.pa.us> (raw)
In-Reply-To: <17872-d0fbb799dc3fd85d@postgresql.org>
References: <17872-d0fbb799dc3fd85d@postgresql.org>

PG Bug reporting form <noreply@postgresql.org> 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





view thread (9+ messages)  latest in thread

Message-ID: <3169550.1679928579@sss.pgh.pa.us>
Permalink:  ../3169550.1679928579@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3169550.1679928579@sss.pgh.pa.us

 · 

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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, exclusion@gmail.com, 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: <3169550.1679928579@sss.pgh.pa.us>

* 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