diff options
author | Neil Conway <neilc@samurai.com> | 2006-01-15 22:34:49 +0000 |
---|---|---|
committer | Neil Conway <neilc@samurai.com> | 2006-01-15 22:34:49 +0000 |
commit | 4dcc82ac7e255c403d5744204534f9338133bcc1 (patch) | |
tree | 4bbfedb0fc8cdf216034c26d687ecd1183fb1a17 /src | |
parent | 106a3695f588a1efd4d68e40fd175a6ee6a3ae84 (diff) | |
download | postgresql-4dcc82ac7e255c403d5744204534f9338133bcc1.tar.gz postgresql-4dcc82ac7e255c403d5744204534f9338133bcc1.zip |
Add regression tests to verify that domain constraints on parameters
to prepared statements with unknown type are correctly enforced, per
recent bug report.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/regress/expected/domain.out | 14 | ||||
-rw-r--r-- | src/test/regress/sql/domain.sql | 9 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/test/regress/expected/domain.out b/src/test/regress/expected/domain.out index 5309234ce23..c89be9535f1 100644 --- a/src/test/regress/expected/domain.out +++ b/src/test/regress/expected/domain.out @@ -314,3 +314,17 @@ create domain str_domain2 as text check (value <> 'foo') default 'foo'; -- should fail alter table domain_test add column d str_domain2; 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 diff --git a/src/test/regress/sql/domain.sql b/src/test/regress/sql/domain.sql index c80b8126267..f6010e636cb 100644 --- a/src/test/regress/sql/domain.sql +++ b/src/test/regress/sql/domain.sql @@ -262,3 +262,12 @@ create domain str_domain2 as text check (value <> 'foo') default 'foo'; -- should fail 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 |