diff options
| author | Tom Lane | 2003-02-03 21:15:45 +0000 |
|---|---|---|
| committer | Tom Lane | 2003-02-03 21:15:45 +0000 |
| commit | 3752e85bad45e98383ea1c9e7e7dbaf13f41da7e (patch) | |
| tree | ce6735a837cf169d82744b7877630494d35ce65a /src/test | |
| parent | 464598b637cfabde01695a27a32ed8f133d127d7 (diff) | |
Determine the set of constraints applied to a domain at executor
startup, not in the parser; this allows ALTER DOMAIN to work correctly
with domain constraint operations stored in rules. Rod Taylor;
code review by Tom Lane.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/domain.out | 41 | ||||
| -rw-r--r-- | src/test/regress/sql/domain.sql | 20 |
2 files changed, 58 insertions, 3 deletions
diff --git a/src/test/regress/expected/domain.out b/src/test/regress/expected/domain.out index e48120a68d8..1aaa4a85ef4 100644 --- a/src/test/regress/expected/domain.out +++ b/src/test/regress/expected/domain.out @@ -257,14 +257,49 @@ ERROR: ALTER DOMAIN: Relation "domcontest" attribute "col1" contains values tha alter domain con add constraint t check (VALUE < 34); alter domain con add check (VALUE > 0); insert into domcontest values (-5); -- fails -ERROR: ExecEvalConstraintTest: Domain con constraint $1 failed +ERROR: ExecEvalCoerceToDomain: Domain con constraint $1 failed insert into domcontest values (42); -- fails -ERROR: ExecEvalConstraintTest: Domain con constraint t failed +ERROR: ExecEvalCoerceToDomain: Domain con constraint t failed insert into domcontest values (5); alter domain con drop constraint t; insert into domcontest values (-5); --fails -ERROR: ExecEvalConstraintTest: Domain con constraint $1 failed +ERROR: ExecEvalCoerceToDomain: Domain con constraint $1 failed insert into domcontest values (42); +-- Confirm ALTER DOMAIN with RULES. +create table domtab (col1 integer); +create domain dom as integer; +create view domview as select cast(col1 as dom) from domtab; +insert into domtab (col1) values (null); +insert into domtab (col1) values (5); +select * from domview; + col1 +------ + + 5 +(2 rows) + +alter domain dom set not null; +select * from domview; -- fail +ERROR: Domain dom does not allow NULL values +alter domain dom drop not null; +select * from domview; + col1 +------ + + 5 +(2 rows) + +alter domain dom add constraint domchkgt6 check(value > 6); +select * from domview; --fail +ERROR: ExecEvalCoerceToDomain: Domain dom constraint domchkgt6 failed +alter domain dom drop constraint domchkgt6 restrict; +select * from domview; + col1 +------ + + 5 +(2 rows) + -- cleanup drop domain ddef1 restrict; drop domain ddef2 restrict; diff --git a/src/test/regress/sql/domain.sql b/src/test/regress/sql/domain.sql index 76060e99c8b..00a38f449cd 100644 --- a/src/test/regress/sql/domain.sql +++ b/src/test/regress/sql/domain.sql @@ -224,6 +224,26 @@ alter domain con drop constraint t; insert into domcontest values (-5); --fails insert into domcontest values (42); +-- Confirm ALTER DOMAIN with RULES. +create table domtab (col1 integer); +create domain dom as integer; +create view domview as select cast(col1 as dom) from domtab; +insert into domtab (col1) values (null); +insert into domtab (col1) values (5); +select * from domview; + +alter domain dom set not null; +select * from domview; -- fail + +alter domain dom drop not null; +select * from domview; + +alter domain dom add constraint domchkgt6 check(value > 6); +select * from domview; --fail + +alter domain dom drop constraint domchkgt6 restrict; +select * from domview; + -- cleanup drop domain ddef1 restrict; drop domain ddef2 restrict; |
