summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorBruce Momjian2002-12-06 05:00:34 +0000
committerBruce Momjian2002-12-06 05:00:34 +0000
commit05a6b3791268cfb3739f7e48b8bc034a3b7e92b5 (patch)
treef7de6c95b745c534b2f1716e7253b8468ef98e30 /src/test
parent78705d0a190343598e85f3041200b96cf1003568 (diff)
Re-addd Rod's ALTER DOMAIN patch.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/domain.out80
-rw-r--r--src/test/regress/resultmap4
-rw-r--r--src/test/regress/sql/domain.sql67
3 files changed, 145 insertions, 6 deletions
diff --git a/src/test/regress/expected/domain.out b/src/test/regress/expected/domain.out
index 92c9cc2cc00..f91191bddb6 100644
--- a/src/test/regress/expected/domain.out
+++ b/src/test/regress/expected/domain.out
@@ -115,7 +115,7 @@ INSERT INTO nulltest DEFAULT VALUES;
ERROR: Domain dnotnull does not allow NULL values
INSERT INTO nulltest values ('a', 'b', 'c', 'd', 'c'); -- Good
insert into nulltest values ('a', 'b', 'c', 'd', NULL);
-ERROR: Domain $1 constraint dcheck failed
+ERROR: ExecEvalConstraintTest: Domain dcheck constraint $1 failed
insert into nulltest values ('a', 'b', 'c', 'd', 'a');
ERROR: ExecInsert: rejected due to CHECK constraint "nulltest_col5" on "nulltest"
INSERT INTO nulltest values (NULL, 'b', 'c', 'd', 'd');
@@ -127,7 +127,7 @@ ERROR: ExecInsert: Fail to add null value in not null attribute col3
INSERT INTO nulltest values ('a', 'b', 'c', NULL, 'd'); -- Good
-- Test copy
COPY nulltest FROM stdin; --fail
-ERROR: copy: line 1, Domain $1 constraint dcheck failed
+ERROR: copy: line 1, ExecEvalConstraintTest: Domain dcheck constraint $1 failed
lost synchronization with server, resetting connection
SET autocommit TO 'on';
-- Last row is bad
@@ -158,6 +158,7 @@ ERROR: Domain dnotnull does not allow NULL values
drop table nulltest;
drop domain dnotnull restrict;
drop domain dnull restrict;
+drop domain dcheck restrict;
create domain ddef1 int4 DEFAULT 3;
create domain ddef2 oid DEFAULT '12';
-- Type mixing, function returns int8
@@ -191,7 +192,80 @@ select * from defaulttest;
(4 rows)
drop sequence ddef4_seq;
-drop table defaulttest;
+drop table defaulttest cascade;
+-- Test ALTER DOMAIN .. NOT NULL
+create domain dnotnulltest integer;
+create table domnotnull
+( col1 dnotnulltest
+, col2 dnotnulltest
+);
+insert into domnotnull default values;
+alter domain dnotnulltest set not null; -- fails
+ERROR: ALTER DOMAIN: Relation "domnotnull" Attribute "col1" contains NULL values
+update domnotnull set col1 = 5;
+alter domain dnotnulltest set not null; -- fails
+ERROR: ALTER DOMAIN: Relation "domnotnull" Attribute "col2" contains NULL values
+update domnotnull set col2 = 6;
+alter domain dnotnulltest set not null;
+alter domain dnotnulltest set not null; -- fails
+ERROR: AlterDomain: dnotnulltest is already set to NOT NULL
+update domnotnull set col1 = null; -- fails
+ERROR: Domain dnotnulltest does not allow NULL values
+alter domain dnotnulltest drop not null;
+alter domain dnotnulltest drop not null; -- fails
+ERROR: AlterDomain: dnotnulltest is already set to NULL
+update domnotnull set col1 = null;
+drop domain dnotnulltest cascade;
+NOTICE: Drop cascades to table domnotnull column col2
+NOTICE: Drop cascades to table domnotnull column col1
+-- Test ALTER DOMAIN .. DEFAULT ..
+create table domdeftest (col1 ddef1);
+insert into domdeftest default values;
+select * from domdeftest;
+ col1
+------
+ 3
+(1 row)
+
+alter domain ddef1 set default '42';
+insert into domdeftest default values;
+select * from domdeftest;
+ col1
+------
+ 3
+ 42
+(2 rows)
+
+alter domain ddef1 drop default;
+insert into domdeftest default values;
+select * from domdeftest;
+ col1
+------
+ 3
+ 42
+
+(3 rows)
+
+drop table domdeftest;
+-- Test ALTER DOMAIN .. CONSTRAINT ..
+create domain con as integer;
+create table domcontest (col1 con);
+insert into domcontest values (1);
+insert into domcontest values (2);
+alter domain con add constraint t check (VALUE < 1); -- fails
+ERROR: AlterDomainAddConstraint: Domain con constraint t failed
+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
+insert into domcontest values (42); -- fails
+ERROR: ExecEvalConstraintTest: 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
+insert into domcontest values (42);
+-- cleanup
drop domain ddef1 restrict;
drop domain ddef2 restrict;
drop domain ddef3 restrict;
diff --git a/src/test/regress/resultmap b/src/test/regress/resultmap
index 0ab2f0e2f71..d4fe5af9930 100644
--- a/src/test/regress/resultmap
+++ b/src/test/regress/resultmap
@@ -14,8 +14,8 @@ float8/.*-qnx=float8-exp-three-digits
float8/alpha.*-dec-osf.*:cc=float8-fp-exception
float8/i.86-pc-cygwin=float8-small-is-zero
geometry/.*-darwin=geometry-positive-zeros
-geometry/i.86-.*-freebsd4.[0-5]=geometry-positive-zeros
-geometry/alpha.*-freebsd4.[0-5]=geometry-positive-zeros
+geometry/i.86-.*-freebsd4.[0-7]=geometry-positive-zeros
+geometry/alpha.*-freebsd4.[0-7]=geometry-positive-zeros
geometry/i.86-.*-openbsd=geometry-positive-zeros
geometry/sparc-.*-openbsd=geometry-positive-zeros
geometry/.*-netbsd1.[0-5]=geometry-positive-zeros
diff --git a/src/test/regress/sql/domain.sql b/src/test/regress/sql/domain.sql
index 65fba7466fd..76060e99c8b 100644
--- a/src/test/regress/sql/domain.sql
+++ b/src/test/regress/sql/domain.sql
@@ -127,6 +127,7 @@ SELECT cast(col4 as dnotnull) from nulltest; -- fail
drop table nulltest;
drop domain dnotnull restrict;
drop domain dnull restrict;
+drop domain dcheck restrict;
create domain ddef1 int4 DEFAULT 3;
@@ -159,7 +160,71 @@ COPY defaulttest(col5) FROM stdin;
select * from defaulttest;
drop sequence ddef4_seq;
-drop table defaulttest;
+drop table defaulttest cascade;
+
+-- Test ALTER DOMAIN .. NOT NULL
+create domain dnotnulltest integer;
+create table domnotnull
+( col1 dnotnulltest
+, col2 dnotnulltest
+);
+
+insert into domnotnull default values;
+alter domain dnotnulltest set not null; -- fails
+
+update domnotnull set col1 = 5;
+alter domain dnotnulltest set not null; -- fails
+
+update domnotnull set col2 = 6;
+
+alter domain dnotnulltest set not null;
+alter domain dnotnulltest set not null; -- fails
+
+update domnotnull set col1 = null; -- fails
+
+alter domain dnotnulltest drop not null;
+alter domain dnotnulltest drop not null; -- fails
+
+update domnotnull set col1 = null;
+
+drop domain dnotnulltest cascade;
+
+-- Test ALTER DOMAIN .. DEFAULT ..
+create table domdeftest (col1 ddef1);
+
+insert into domdeftest default values;
+select * from domdeftest;
+
+alter domain ddef1 set default '42';
+insert into domdeftest default values;
+select * from domdeftest;
+
+alter domain ddef1 drop default;
+insert into domdeftest default values;
+select * from domdeftest;
+
+drop table domdeftest;
+
+-- Test ALTER DOMAIN .. CONSTRAINT ..
+create domain con as integer;
+create table domcontest (col1 con);
+
+insert into domcontest values (1);
+insert into domcontest values (2);
+alter domain con add constraint t check (VALUE < 1); -- fails
+
+alter domain con add constraint t check (VALUE < 34);
+alter domain con add check (VALUE > 0);
+
+insert into domcontest values (-5); -- fails
+insert into domcontest values (42); -- fails
+insert into domcontest values (5);
+
+alter domain con drop constraint t;
+insert into domcontest values (-5); --fails
+insert into domcontest values (42);
+
+-- cleanup
drop domain ddef1 restrict;
drop domain ddef2 restrict;
drop domain ddef3 restrict;