@@ -1028,8 +1028,6 @@ insert into atacc1 (test2, test) values (1, NULL);
10281028ERROR: null value in column "test" violates not-null constraint
10291029DETAIL: Failing row contains (null, 1).
10301030drop table atacc1;
1031- -- we want check if not null was implied by constraint
1032- set client_min_messages to 'debug1';
10331031-- alter table / alter column [set/drop] not null tests
10341032-- try altering system catalogs, should fail
10351033alter table pg_class alter column relname drop not null;
@@ -1045,19 +1043,15 @@ ERROR: relation "non_existent" does not exist
10451043-- test checking for null values and primary key
10461044create table atacc1 (test int not null);
10471045alter table atacc1 add constraint "atacc1_pkey" primary key (test);
1048- DEBUG: ALTER TABLE / ADD PRIMARY KEY will create implicit index "atacc1_pkey" for table "atacc1"
1049- DEBUG: building index "atacc1_pkey" on table "atacc1" serially
10501046alter table atacc1 alter column test drop not null;
10511047ERROR: column "test" is in a primary key
10521048alter table atacc1 drop constraint "atacc1_pkey";
10531049alter table atacc1 alter column test drop not null;
10541050insert into atacc1 values (null);
10551051alter table atacc1 alter test set not null;
1056- DEBUG: verifying table "atacc1"
10571052ERROR: column "test" contains null values
10581053delete from atacc1;
10591054alter table atacc1 alter test set not null;
1060- DEBUG: verifying table "atacc1"
10611055-- try altering a non-existent column, should fail
10621056alter table atacc1 alter bar set not null;
10631057ERROR: column "bar" of relation "atacc1" does not exist
@@ -1076,49 +1070,36 @@ create table atacc1 (test_a int, test_b int);
10761070insert into atacc1 values (null, 1);
10771071-- constraint not cover all values, should fail
10781072alter table atacc1 add constraint atacc1_constr_or check(test_a is not null or test_b < 10);
1079- DEBUG: verifying table "atacc1"
10801073alter table atacc1 alter test_a set not null;
1081- DEBUG: verifying table "atacc1"
10821074ERROR: column "test_a" contains null values
10831075alter table atacc1 drop constraint atacc1_constr_or;
10841076-- not valid constraint, should fail
10851077alter table atacc1 add constraint atacc1_constr_invalid check(test_a is not null) not valid;
10861078alter table atacc1 alter test_a set not null;
1087- DEBUG: verifying table "atacc1"
10881079ERROR: column "test_a" contains null values
10891080alter table atacc1 drop constraint atacc1_constr_invalid;
10901081-- with valid constraint
10911082update atacc1 set test_a = 1;
10921083alter table atacc1 add constraint atacc1_constr_a_valid check(test_a is not null);
1093- DEBUG: verifying table "atacc1"
10941084alter table atacc1 alter test_a set not null;
1095- DEBUG: existing constraints on column "atacc1"."test_a" are sufficient to prove that it does not contain nulls
10961085delete from atacc1;
10971086insert into atacc1 values (2, null);
10981087alter table atacc1 alter test_a drop not null;
10991088-- test multiple set not null at same time
11001089-- test_a checked by atacc1_constr_a_valid, test_b should fail by table scan
11011090alter table atacc1 alter test_a set not null, alter test_b set not null;
1102- DEBUG: existing constraints on column "atacc1"."test_a" are sufficient to prove that it does not contain nulls
1103- DEBUG: verifying table "atacc1"
11041091ERROR: column "test_b" contains null values
11051092-- commands order has no importance
11061093alter table atacc1 alter test_b set not null, alter test_a set not null;
1107- DEBUG: verifying table "atacc1"
11081094ERROR: column "test_b" contains null values
11091095-- valid one by table scan, one by check constraints
11101096update atacc1 set test_b = 1;
11111097alter table atacc1 alter test_b set not null, alter test_a set not null;
1112- DEBUG: verifying table "atacc1"
11131098alter table atacc1 alter test_a drop not null, alter test_b drop not null;
11141099-- both column has check constraints
11151100alter table atacc1 add constraint atacc1_constr_b_valid check(test_b is not null);
1116- DEBUG: verifying table "atacc1"
11171101alter table atacc1 alter test_b set not null, alter test_a set not null;
1118- DEBUG: existing constraints on column "atacc1"."test_b" are sufficient to prove that it does not contain nulls
1119- DEBUG: existing constraints on column "atacc1"."test_a" are sufficient to prove that it does not contain nulls
11201102drop table atacc1;
1121- reset client_min_messages;
11221103-- test inheritance
11231104create table parent (a int);
11241105create table child (b varchar(255)) inherits (parent);
0 commit comments