SQLpro <sqlpro@sqlspot.com> writes:
> The Following script demonstrate the bug:
> CREATE SCHEMA s;
> CREATE TABLE s.foo (C INT);
> ALTER TABLE s.foo ADD CONSTRAINT k CHECK(C>0);
> CREATE TABLE s.foo2 (C INT);
> ALTER TABLE s.foo2 ADD CONSTRAINT k CHECK(C>=1);
> This last SQL command should fail because the database name, the schema name
> and the constraint name is the same for those two constraints, but did'nt !
Indeed, but Postgres does not require check constraints to be named
uniquely across the whole schema, only per-table. Tightening that would
be a cure worse than the disease, because it would break applications
that work today.
So, sorry, we do not consider this a bug, and it's highly unlikely that
we'd ever "fix" it. You're surely free to use only spec-compliant choices
of constraint names in your own databases if you wish, but PG won't
enforce that.
regards, tom lane