Skip to content

Commit 4405e74

Browse files
author
Neil Conway
committed
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.
1 parent beaf5ae commit 4405e74

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/test/regress/expected/domain.out

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,17 @@ drop domain ddef2 restrict;
300300
drop domain ddef3 restrict;
301301
drop domain ddef4 restrict;
302302
drop domain ddef5 restrict;
303+
-- Make sure that constraints of newly-added domain columns are
304+
-- enforced correctly, even if there's no default value for the new
305+
-- column. Per bug #1433
306+
create domain str_domain as text not null;
307+
create table domain_test (a int, b int);
308+
insert into domain_test values (1, 2);
309+
insert into domain_test values (1, 2);
310+
-- should fail
311+
alter table domain_test add column c str_domain;
312+
ERROR: domain str_domain does not allow null values
313+
create domain str_domain2 as text check (value <> 'foo') default 'foo';
314+
-- should fail
315+
alter table domain_test add column d str_domain2;
316+
ERROR: value for domain str_domain2 violates check constraint "str_domain2_check"

src/test/regress/sql/domain.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,21 @@ drop domain ddef2 restrict;
244244
drop domain ddef3 restrict;
245245
drop domain ddef4 restrict;
246246
drop domain ddef5 restrict;
247+
248+
-- Make sure that constraints of newly-added domain columns are
249+
-- enforced correctly, even if there's no default value for the new
250+
-- column. Per bug #1433
251+
create domain str_domain as text not null;
252+
253+
create table domain_test (a int, b int);
254+
255+
insert into domain_test values (1, 2);
256+
insert into domain_test values (1, 2);
257+
258+
-- should fail
259+
alter table domain_test add column c str_domain;
260+
261+
create domain str_domain2 as text check (value <> 'foo') default 'foo';
262+
263+
-- should fail
264+
alter table domain_test add column d str_domain2;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy