Re: BUG #17872: Dropping an attribute of a composite type breaks indexes over the type silently

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: exclusion(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17872: Dropping an attribute of a composite type breaks indexes over the type silently
Date: 2023-03-27 14:49:39
Message-ID: 3169550.1679928579@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2023-03-27 14:53:28 Re: BUG #17871: JIT during postgresql_fdw remote_estimates EXPLAIN have very negatively effect on planning time
Previous Message Tom Lane 2023-03-27 14:43:13 Re: BUG #17870: Analyze on remote postgresql_fdw table never finish