Regression tests for recent bugfix to ALTER TABLE ADD COLUMN: ensure that
authorNeil Conway <neilc@samurai.com>
Tue, 25 Jan 2005 03:22:19 +0000 (03:22 +0000)
committerNeil Conway <neilc@samurai.com>
Tue, 25 Jan 2005 03:22:19 +0000 (03:22 +0000)
constraints on domain types are properly enforced, even if the newly
added column has no default value. Per bug #1433.

src/test/regress/expected/domain.out
src/test/regress/sql/domain.sql

index 750ebf7ccd895389ff8d1f10c14d3662ae7c1afa..e959b4a9b753882695e461e5e9084c28ea220aa7 100644 (file)
@@ -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"
index acbb9f80ea6af59d059e797912c4ec8566c39dfb..386adede1659943acd90f5edfebcc5070ab04329 100644 (file)
@@ -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;