mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +03:00
Prevent creation of duplicate not-null constraints for domains
This was previously harmless, but now that we create pg_constraint rows for those, duplicates are not welcome anymore. Backpatch to 18. Co-authored-by: jian he <jian.universality@gmail.com> Co-authored-by: Álvaro Herrera <alvherre@kurilemu.de> Discussion: https://postgr.es/m/CACJufxFSC0mcQ82bSk58sO-WJY4P-o4N6RD2M0D=DD_u_6EzdQ@mail.gmail.com
This commit is contained in:
@@ -1019,6 +1019,11 @@ insert into domain_test values (1, 2);
|
||||
-- should fail
|
||||
alter table domain_test add column c str_domain;
|
||||
ERROR: domain str_domain does not allow null values
|
||||
-- disallow duplicated not-null constraints
|
||||
create domain int_domain1 as int constraint nn1 not null constraint nn2 not null;
|
||||
ERROR: redundant NOT NULL constraint definition
|
||||
LINE 1: ...domain int_domain1 as int constraint nn1 not null constraint...
|
||||
^
|
||||
create domain str_domain2 as text check (value <> 'foo') default 'foo';
|
||||
-- should fail
|
||||
alter table domain_test add column d str_domain2;
|
||||
|
||||
@@ -602,6 +602,9 @@ insert into domain_test values (1, 2);
|
||||
-- should fail
|
||||
alter table domain_test add column c str_domain;
|
||||
|
||||
-- disallow duplicated not-null constraints
|
||||
create domain int_domain1 as int constraint nn1 not null constraint nn2 not null;
|
||||
|
||||
create domain str_domain2 as text check (value <> 'foo') default 'foo';
|
||||
|
||||
-- should fail
|
||||
|
||||
Reference in New Issue
Block a user