summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNeil Conway2005-01-25 03:22:19 +0000
committerNeil Conway2005-01-25 03:22:19 +0000
commit4405e74355733075759b9a3f1c5696897c3c55c5 (patch)
treefcaa0f42339026d8a5762ed0af2a7936e7d414e3 /src/test
parentbeaf5ae623f9dd323da095fb65c74768ebc8afc5 (diff)
Regression tests for recent bugfix to ALTER TABLE ADD COLUMN: ensure that
constraints on domain types are properly enforced, even if the newly added column has no default value. Per bug #1433.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/domain.out14
-rw-r--r--src/test/regress/sql/domain.sql18
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/regress/expected/domain.out b/src/test/regress/expected/domain.out
index 750ebf7ccd8..e959b4a9b75 100644
--- a/src/test/regress/expected/domain.out
+++ b/src/test/regress/expected/domain.out
@@ -300,3 +300,17 @@ drop domain ddef2 restrict;
drop domain ddef3 restrict;
drop domain ddef4 restrict;
drop domain ddef5 restrict;
+-- Make sure that constraints of newly-added domain columns are
+-- enforced correctly, even if there's no default value for the new
+-- column. Per bug #1433
+create domain str_domain as text not null;
+create table domain_test (a int, b int);
+insert into domain_test values (1, 2);
+insert into domain_test values (1, 2);
+-- should fail
+alter table domain_test add column c str_domain;
+ERROR: domain str_domain does not allow null values
+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"
diff --git a/src/test/regress/sql/domain.sql b/src/test/regress/sql/domain.sql
index acbb9f80ea6..386adede165 100644
--- a/src/test/regress/sql/domain.sql
+++ b/src/test/regress/sql/domain.sql
@@ -244,3 +244,21 @@ drop domain ddef2 restrict;
drop domain ddef3 restrict;
drop domain ddef4 restrict;
drop domain ddef5 restrict;
+
+-- Make sure that constraints of newly-added domain columns are
+-- enforced correctly, even if there's no default value for the new
+-- column. Per bug #1433
+create domain str_domain as text not null;
+
+create table domain_test (a int, b int);
+
+insert into domain_test values (1, 2);
+insert into domain_test values (1, 2);
+
+-- should fail
+alter table domain_test add column c str_domain;
+
+create domain str_domain2 as text check (value <> 'foo') default 'foo';
+
+-- should fail
+alter table domain_test add column d str_domain2;