This patch adds a regression test for the bug with domains and ALTER
TABLE that Tom fixed a few hours ago.

Barring any objections I'll apply this to HEAD by the end of the day.

-Neil

Index: src/test/regress/expected/domain.out
===================================================================
RCS file: /var/lib/cvs/pgsql/src/test/regress/expected/domain.out,v
retrieving revision 1.32
diff -c -r1.32 domain.out
*** src/test/regress/expected/domain.out	5 Aug 2004 03:30:03 -0000	1.32
--- src/test/regress/expected/domain.out	25 Jan 2005 00:55:11 -0000
***************
*** 300,302 ****
--- 300,316 ----
  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: src/test/regress/sql/domain.sql
===================================================================
RCS file: /var/lib/cvs/pgsql/src/test/regress/sql/domain.sql,v
retrieving revision 1.17
diff -c -r1.17 domain.sql
*** src/test/regress/sql/domain.sql	5 Aug 2004 03:30:44 -0000	1.17
--- src/test/regress/sql/domain.sql	25 Jan 2005 00:51:43 -0000
***************
*** 244,246 ****
--- 244,264 ----
  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;
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to