Commit 4dcc82ac authored by Neil Conway's avatar Neil Conway

Add regression tests to verify that domain constraints on parameters

to prepared statements with unknown type are correctly enforced, per
recent bug report.
parent 106a3695
...@@ -314,3 +314,17 @@ create domain str_domain2 as text check (value <> 'foo') default 'foo'; ...@@ -314,3 +314,17 @@ create domain str_domain2 as text check (value <> 'foo') default 'foo';
-- should fail -- should fail
alter table domain_test add column d str_domain2; alter table domain_test add column d str_domain2;
ERROR: value for domain str_domain2 violates check constraint "str_domain2_check" ERROR: value for domain str_domain2 violates check constraint "str_domain2_check"
-- Check that domain constraints on prepared statement parameters of
-- unknown type are enforced correctly.
create domain pos_int as int4 check (value > 0) not null;
prepare s1 as select $1::pos_int = 10 as "is_ten";
execute s1(10);
is_ten
--------
t
(1 row)
execute s1(0); -- should fail
ERROR: value for domain pos_int violates check constraint "pos_int_check"
execute s1(NULL); -- should fail
ERROR: domain pos_int does not allow null values
...@@ -262,3 +262,12 @@ create domain str_domain2 as text check (value <> 'foo') default 'foo'; ...@@ -262,3 +262,12 @@ create domain str_domain2 as text check (value <> 'foo') default 'foo';
-- should fail -- should fail
alter table domain_test add column d str_domain2; alter table domain_test add column d str_domain2;
-- Check that domain constraints on prepared statement parameters of
-- unknown type are enforced correctly.
create domain pos_int as int4 check (value > 0) not null;
prepare s1 as select $1::pos_int = 10 as "is_ten";
execute s1(10);
execute s1(0); -- should fail
execute s1(NULL); -- should fail
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment