Re: BUG #17872: Dropping an attribute of a composite type breaks indexes over the type silently - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17872: Dropping an attribute of a composite type breaks indexes over the type silently
Date
Msg-id 3169550.1679928579@sss.pgh.pa.us
Whole thread Raw
In response to BUG #17872: Dropping an attribute of a composite type breaks indexes over the type silently  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #17872: Dropping an attribute of a composite type breaks indexes over the type silently
List pgsql-bugs
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



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #17870: Analyze on remote postgresql_fdw table never finish
Next
From: Tom Lane
Date:
Subject: Re: BUG #17871: JIT during postgresql_fdw remote_estimates EXPLAIN have very negatively effect on planning time