| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Reject ADD CONSTRAINT NOT NULL if name mismatches existing domain not-null constraint |
| Date: | 2026-03-01 01:53:04 |
| Message-ID: | CACJufxEcTx2U8tQTcJ2g490wzd=jQgJNDpNb2L+f3gr9J=cpNA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi.
Similar to https://git.postgresql.org/cgit/postgresql.git/commit/?id=96e2af605043974137d84edf5c0a24561956919e
We apply this logic to the domain not-null constraint too.
It would error out if ALTER DOMAIN ADD CONSTRAINT NOT NULL, the new
constraint name does not
matches the existing domain's not-null constraint
create domain d1 as int constraint nn not null;
src4=# alter domain d1 add constraint nn1 not null;
ERROR: cannot create not-null constraint "nn1" for domain "d1"
DETAIL: A not-null constraint named "nn" already exists for domain "d1".
However, repeated ALTER DOMAIN SET NOT NULL or ALTER DOMAIN ADD NOT
NULL statements are allowed,
This aligns with the NOT NULL constraints on tables.
No need to worry about CREATE DOMAIN.
We already disallow multiple NOT NULL constraints in CREATE DOMAIN.
Like this would fail:
create domain d2 as text collate "C" constraint nn not null constraint
nn2 not null;
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Reject-ADD-CONSTRAINT-NOT-NULL-if-name-mismatches-existing-domain.patch | text/x-patch | 4.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | vignesh C | 2026-03-01 03:11:30 | Re: Skipping schema changes in publication |
| Previous Message | Andres Freund | 2026-03-01 00:16:04 | Re: Unlogged rel fake lsn vs GetVictimBuffer() |