From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: boekewurm+postgres@gmail.com
Subject: BUG #16767: Silent dropping of CONSTRAINT... UNIQUE
Date: Tue, 08 Dec 2020 14:17:36 +0000
Message-ID: <16767-1714a2056ca516d0@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16767
Logged by: Matthias vd Meent
Email address: boekewurm+postgres@gmail.com
PostgreSQL version: 12.5
Operating system: Debian Stretch (9.13)
Description:
Hi,
I've just noticed that equivalent unique constraints that are specified in
the same statement only generate one constraint; but if they are specified
in different statements they generate the correct constraints. E.g.:
CREATE TABLE test (
id bigint,
val test,
CONSTRAINT u_id UNIQUE (id),
CONSTRAINT u_id2 UNIQUE (id),
CONSTRAINT pk_id PRIMARY KEY (id),
CONSTRAINT u_val UNIQUE (val)
);
vs
CREATE TABLE test (
id bigint,
val test
);
ALTER TABLE test ADD CONSTRAINT u_id UNIQUE (id);
ALTER TABLE test ADD CONSTRAINT u_id2 UNIQUE (id);
ALTER TABLE test ADD CONSTRAINT pk_id PRIMARY KEY (id);
ALTER TABLE test ADD CONSTRAINT u_val UNIQUE (val);
The first only results in a primary key on (id), and unique(val), the second
(correctly?) generates 4 constraints on the test table.
This unexpected and undocumented behaviour also exists at least in pg10.15
and pg11.10
-Matthias
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: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, boekewurm+postgres@gmail.com
Subject: Re: BUG #16767: Silent dropping of CONSTRAINT... UNIQUE
In-Reply-To: <16767-1714a2056ca516d0@postgresql.org>
* 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