@@ -1028,8 +1028,6 @@ insert into atacc1 (test2, test) values (1, NULL);
1028
1028
ERROR: null value in column "test" violates not-null constraint
1029
1029
DETAIL: Failing row contains (null, 1).
1030
1030
drop table atacc1;
1031
- -- we want check if not null was implied by constraint
1032
- set client_min_messages to 'debug1';
1033
1031
-- alter table / alter column [set/drop] not null tests
1034
1032
-- try altering system catalogs, should fail
1035
1033
alter table pg_class alter column relname drop not null;
@@ -1045,19 +1043,15 @@ ERROR: relation "non_existent" does not exist
1045
1043
-- test checking for null values and primary key
1046
1044
create table atacc1 (test int not null);
1047
1045
alter 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
1050
1046
alter table atacc1 alter column test drop not null;
1051
1047
ERROR: column "test" is in a primary key
1052
1048
alter table atacc1 drop constraint "atacc1_pkey";
1053
1049
alter table atacc1 alter column test drop not null;
1054
1050
insert into atacc1 values (null);
1055
1051
alter table atacc1 alter test set not null;
1056
- DEBUG: verifying table "atacc1"
1057
1052
ERROR: column "test" contains null values
1058
1053
delete from atacc1;
1059
1054
alter table atacc1 alter test set not null;
1060
- DEBUG: verifying table "atacc1"
1061
1055
-- try altering a non-existent column, should fail
1062
1056
alter table atacc1 alter bar set not null;
1063
1057
ERROR: column "bar" of relation "atacc1" does not exist
@@ -1076,49 +1070,36 @@ create table atacc1 (test_a int, test_b int);
1076
1070
insert into atacc1 values (null, 1);
1077
1071
-- constraint not cover all values, should fail
1078
1072
alter table atacc1 add constraint atacc1_constr_or check(test_a is not null or test_b < 10);
1079
- DEBUG: verifying table "atacc1"
1080
1073
alter table atacc1 alter test_a set not null;
1081
- DEBUG: verifying table "atacc1"
1082
1074
ERROR: column "test_a" contains null values
1083
1075
alter table atacc1 drop constraint atacc1_constr_or;
1084
1076
-- not valid constraint, should fail
1085
1077
alter table atacc1 add constraint atacc1_constr_invalid check(test_a is not null) not valid;
1086
1078
alter table atacc1 alter test_a set not null;
1087
- DEBUG: verifying table "atacc1"
1088
1079
ERROR: column "test_a" contains null values
1089
1080
alter table atacc1 drop constraint atacc1_constr_invalid;
1090
1081
-- with valid constraint
1091
1082
update atacc1 set test_a = 1;
1092
1083
alter table atacc1 add constraint atacc1_constr_a_valid check(test_a is not null);
1093
- DEBUG: verifying table "atacc1"
1094
1084
alter 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
1096
1085
delete from atacc1;
1097
1086
insert into atacc1 values (2, null);
1098
1087
alter table atacc1 alter test_a drop not null;
1099
1088
-- test multiple set not null at same time
1100
1089
-- test_a checked by atacc1_constr_a_valid, test_b should fail by table scan
1101
1090
alter 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"
1104
1091
ERROR: column "test_b" contains null values
1105
1092
-- commands order has no importance
1106
1093
alter table atacc1 alter test_b set not null, alter test_a set not null;
1107
- DEBUG: verifying table "atacc1"
1108
1094
ERROR: column "test_b" contains null values
1109
1095
-- valid one by table scan, one by check constraints
1110
1096
update atacc1 set test_b = 1;
1111
1097
alter table atacc1 alter test_b set not null, alter test_a set not null;
1112
- DEBUG: verifying table "atacc1"
1113
1098
alter table atacc1 alter test_a drop not null, alter test_b drop not null;
1114
1099
-- both column has check constraints
1115
1100
alter table atacc1 add constraint atacc1_constr_b_valid check(test_b is not null);
1116
- DEBUG: verifying table "atacc1"
1117
1101
alter 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
1120
1102
drop table atacc1;
1121
- reset client_min_messages;
1122
1103
-- test inheritance
1123
1104
create table parent (a int);
1124
1105
create table child (b varchar(255)) inherits (parent);
0 commit comments