Skip to content

Commit 4dcc82a

Browse files
author
Neil Conway
committed
Add regression tests to verify that domain constraints on parameters
to prepared statements with unknown type are correctly enforced, per recent bug report.
1 parent 106a369 commit 4dcc82a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/test/regress/expected/domain.out

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,17 @@ create domain str_domain2 as text check (value <> 'foo') default 'foo';
314314
-- should fail
315315
alter table domain_test add column d str_domain2;
316316
ERROR: value for domain str_domain2 violates check constraint "str_domain2_check"
317+
-- Check that domain constraints on prepared statement parameters of
318+
-- unknown type are enforced correctly.
319+
create domain pos_int as int4 check (value > 0) not null;
320+
prepare s1 as select $1::pos_int = 10 as "is_ten";
321+
execute s1(10);
322+
is_ten
323+
--------
324+
t
325+
(1 row)
326+
327+
execute s1(0); -- should fail
328+
ERROR: value for domain pos_int violates check constraint "pos_int_check"
329+
execute s1(NULL); -- should fail
330+
ERROR: domain pos_int does not allow null values

src/test/regress/sql/domain.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,12 @@ create domain str_domain2 as text check (value <> 'foo') default 'foo';
262262

263263
-- should fail
264264
alter table domain_test add column d str_domain2;
265+
266+
-- Check that domain constraints on prepared statement parameters of
267+
-- unknown type are enforced correctly.
268+
create domain pos_int as int4 check (value > 0) not null;
269+
prepare s1 as select $1::pos_int = 10 as "is_ten";
270+
271+
execute s1(10);
272+
execute s1(0); -- should fail
273+
execute s1(NULL); -- should fail

0 commit comments

Comments
 (0)