Re: BUG #16767: Silent dropping of CONSTRAINT... UNIQUE
Peter Eisentraut <peter.eisentraut@enterprisedb.com>
From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>, boekewurm+postgres@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2020-12-12T22:18:15Z
Lists: pgsql-bugs
On 2020-12-08 17:48, Tom Lane wrote: > PG Bug reporting form <noreply@postgresql.org> writes: >> I've just noticed that equivalent unique constraints that are specified in >> the same statement only generate one constraint; > > Yeah, that's intentional. Per the source code comments: > > * Scan the index list and remove any redundant index specifications. This > * can happen if, for instance, the user writes UNIQUE PRIMARY KEY. A > * strict reading of SQL would suggest raising an error instead, but that > * strikes me as too anal-retentive. - tgl 2001-02-14 It's nonetheless inconsistent that you can create redundant unique constraints via ALTER TABLE, but doing it in CREATE TABLE results in different behavior. This all seems a bit dubious to me. We should either allow it or prohibit it, not silently do something else in some cases.
Commits
-
Doc: clarify that CREATE TABLE discards redundant unique constraints.
- e824ddc37f3c 12.6 landed
- 567d6d1ff617 10.16 landed
- 5303706b3208 11.11 landed
- 2bf5d1a74a33 9.6.21 landed
- 14db95792221 9.5.25 landed
- f2a69b352de1 14.0 landed
- c6f8d17d04d1 13.2 landed