Commit 05f18c6b authored by Amit Kapila's avatar Amit Kapila

Added relation name in error messages for constraint checks.

This gives more information to the user about the error and it makes such
messages consistent with the other similar messages in the code.

Reported-by: Simon Riggs
Author: Mahendra Singh and Simon Riggs
Reviewed-by: Beena Emerson and Amit Kapila
Discussion: https://postgr.es/m/CANP8+j+7YUvQvGxTrCiw77R23enMJ7DFmyA3buR+fa2pKs4XhA@mail.gmail.com
parent ff8ca5fa
...@@ -5288,8 +5288,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode) ...@@ -5288,8 +5288,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_NOT_NULL_VIOLATION), (errcode(ERRCODE_NOT_NULL_VIOLATION),
errmsg("column \"%s\" contains null values", errmsg("column \"%s\" of relation \"%s\" contains null values",
NameStr(attr->attname)), NameStr(attr->attname),
RelationGetRelationName(oldrel)),
errtablecol(oldrel, attn + 1))); errtablecol(oldrel, attn + 1)));
} }
} }
...@@ -5304,8 +5305,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode) ...@@ -5304,8 +5305,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
if (!ExecCheck(con->qualstate, econtext)) if (!ExecCheck(con->qualstate, econtext))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CHECK_VIOLATION), (errcode(ERRCODE_CHECK_VIOLATION),
errmsg("check constraint \"%s\" is violated by some row", errmsg("check constraint \"%s\" of relation \"%s\" is violated by some row",
con->name), con->name,
RelationGetRelationName(oldrel)),
errtableconstraint(oldrel, con->name))); errtableconstraint(oldrel, con->name)));
break; break;
case CONSTR_FOREIGN: case CONSTR_FOREIGN:
...@@ -5322,11 +5324,13 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode) ...@@ -5322,11 +5324,13 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
if (tab->validate_default) if (tab->validate_default)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CHECK_VIOLATION), (errcode(ERRCODE_CHECK_VIOLATION),
errmsg("updated partition constraint for default partition would be violated by some row"))); errmsg("updated partition constraint for default partition \"%s\" would be violated by some row",
RelationGetRelationName(oldrel))));
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CHECK_VIOLATION), (errcode(ERRCODE_CHECK_VIOLATION),
errmsg("partition constraint is violated by some row"))); errmsg("partition constraint of relation \"%s\" is violated by some row",
RelationGetRelationName(oldrel))));
} }
/* Write the tuple out to the new relation */ /* Write the tuple out to the new relation */
...@@ -10160,8 +10164,9 @@ validateCheckConstraint(Relation rel, HeapTuple constrtup) ...@@ -10160,8 +10164,9 @@ validateCheckConstraint(Relation rel, HeapTuple constrtup)
if (!ExecCheck(exprstate, econtext)) if (!ExecCheck(exprstate, econtext))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CHECK_VIOLATION), (errcode(ERRCODE_CHECK_VIOLATION),
errmsg("check constraint \"%s\" is violated by some row", errmsg("check constraint \"%s\" of relation \"%s\" is violated by some row",
NameStr(constrForm->conname)), NameStr(constrForm->conname),
RelationGetRelationName(rel)),
errtableconstraint(rel, NameStr(constrForm->conname)))); errtableconstraint(rel, NameStr(constrForm->conname))));
ResetExprContext(econtext); ResetExprContext(econtext);
......
...@@ -1957,8 +1957,9 @@ ExecConstraints(ResultRelInfo *resultRelInfo, ...@@ -1957,8 +1957,9 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_NOT_NULL_VIOLATION), (errcode(ERRCODE_NOT_NULL_VIOLATION),
errmsg("null value in column \"%s\" violates not-null constraint", errmsg("null value in column \"%s\" of relation \"%s\" violates not-null constraint",
NameStr(att->attname)), NameStr(att->attname),
RelationGetRelationName(orig_rel)),
val_desc ? errdetail("Failing row contains %s.", val_desc) : 0, val_desc ? errdetail("Failing row contains %s.", val_desc) : 0,
errtablecol(orig_rel, attrChk))); errtablecol(orig_rel, attrChk)));
} }
......
This diff is collapsed.
...@@ -440,7 +440,7 @@ SELECT c, d FROM forcetest WHERE a = 2; ...@@ -440,7 +440,7 @@ SELECT c, d FROM forcetest WHERE a = 2;
-- should fail with not-null constraint violation -- should fail with not-null constraint violation
BEGIN; BEGIN;
COPY forcetest (a, b, c) FROM STDIN WITH (FORMAT csv, FORCE_NULL(b), FORCE_NOT_NULL(c)); COPY forcetest (a, b, c) FROM STDIN WITH (FORMAT csv, FORCE_NULL(b), FORCE_NOT_NULL(c));
ERROR: null value in column "b" violates not-null constraint ERROR: null value in column "b" of relation "forcetest" violates not-null constraint
DETAIL: Failing row contains (3, null, , null, null). DETAIL: Failing row contains (3, null, , null, null).
CONTEXT: COPY forcetest, line 1: "3,,""" CONTEXT: COPY forcetest, line 1: "3,,"""
ROLLBACK; ROLLBACK;
......
...@@ -955,7 +955,7 @@ CREATE TABLE part_c_1_10 PARTITION OF part_c FOR VALUES FROM (1) TO (10); ...@@ -955,7 +955,7 @@ CREATE TABLE part_c_1_10 PARTITION OF part_c FOR VALUES FROM (1) TO (10);
create table parted_notnull_inh_test (a int default 1, b int not null default 0) partition by list (a); create table parted_notnull_inh_test (a int default 1, b int not null default 0) partition by list (a);
create table parted_notnull_inh_test1 partition of parted_notnull_inh_test (a not null, b default 1) for values in (1); create table parted_notnull_inh_test1 partition of parted_notnull_inh_test (a not null, b default 1) for values in (1);
insert into parted_notnull_inh_test (b) values (null); insert into parted_notnull_inh_test (b) values (null);
ERROR: null value in column "b" violates not-null constraint ERROR: null value in column "b" of relation "parted_notnull_inh_test1" violates not-null constraint
DETAIL: Failing row contains (1, null). DETAIL: Failing row contains (1, null).
-- note that while b's default is overriden, a's default is preserved -- note that while b's default is overriden, a's default is preserved
\d parted_notnull_inh_test1 \d parted_notnull_inh_test1
......
...@@ -90,7 +90,7 @@ CREATE TABLE test_like_id_2 (LIKE test_like_id_1); ...@@ -90,7 +90,7 @@ CREATE TABLE test_like_id_2 (LIKE test_like_id_1);
b | text | | | b | text | | |
INSERT INTO test_like_id_2 (b) VALUES ('b2'); INSERT INTO test_like_id_2 (b) VALUES ('b2');
ERROR: null value in column "a" violates not-null constraint ERROR: null value in column "a" of relation "test_like_id_2" violates not-null constraint
DETAIL: Failing row contains (null, b2). DETAIL: Failing row contains (null, b2).
SELECT * FROM test_like_id_2; -- identity was not copied SELECT * FROM test_like_id_2; -- identity was not copied
a | b a | b
......
...@@ -542,12 +542,12 @@ ERROR: domain dnotnull does not allow null values ...@@ -542,12 +542,12 @@ ERROR: domain dnotnull does not allow null values
INSERT INTO nulltest values ('a', NULL, 'c', 'd', 'c'); INSERT INTO nulltest values ('a', NULL, 'c', 'd', 'c');
ERROR: domain dnotnull does not allow null values ERROR: domain dnotnull does not allow null values
INSERT INTO nulltest values ('a', 'b', NULL, 'd', 'c'); INSERT INTO nulltest values ('a', 'b', NULL, 'd', 'c');
ERROR: null value in column "col3" violates not-null constraint ERROR: null value in column "col3" of relation "nulltest" violates not-null constraint
DETAIL: Failing row contains (a, b, null, d, c). DETAIL: Failing row contains (a, b, null, d, c).
INSERT INTO nulltest values ('a', 'b', 'c', NULL, 'd'); -- Good INSERT INTO nulltest values ('a', 'b', 'c', NULL, 'd'); -- Good
-- Test copy -- Test copy
COPY nulltest FROM stdin; --fail COPY nulltest FROM stdin; --fail
ERROR: null value in column "col3" violates not-null constraint ERROR: null value in column "col3" of relation "nulltest" violates not-null constraint
DETAIL: Failing row contains (a, b, null, d, d). DETAIL: Failing row contains (a, b, null, d, d).
CONTEXT: COPY nulltest, line 1: "a b \N d d" CONTEXT: COPY nulltest, line 1: "a b \N d d"
COPY nulltest FROM stdin; --fail COPY nulltest FROM stdin; --fail
...@@ -601,14 +601,14 @@ create table defaulttest ...@@ -601,14 +601,14 @@ create table defaulttest
, col8 ddef5 , col8 ddef5
); );
insert into defaulttest(col4) values(0); -- fails, col5 defaults to null insert into defaulttest(col4) values(0); -- fails, col5 defaults to null
ERROR: null value in column "col5" violates not-null constraint ERROR: null value in column "col5" of relation "defaulttest" violates not-null constraint
DETAIL: Failing row contains (3, 12, 5, 0, null, 88, 8000, 12.12). DETAIL: Failing row contains (3, 12, 5, 0, null, 88, 8000, 12.12).
alter table defaulttest alter column col5 drop default; alter table defaulttest alter column col5 drop default;
insert into defaulttest default values; -- succeeds, inserts domain default insert into defaulttest default values; -- succeeds, inserts domain default
-- We used to treat SET DEFAULT NULL as equivalent to DROP DEFAULT; wrong -- We used to treat SET DEFAULT NULL as equivalent to DROP DEFAULT; wrong
alter table defaulttest alter column col5 set default null; alter table defaulttest alter column col5 set default null;
insert into defaulttest(col4) values(0); -- fails insert into defaulttest(col4) values(0); -- fails
ERROR: null value in column "col5" violates not-null constraint ERROR: null value in column "col5" of relation "defaulttest" violates not-null constraint
DETAIL: Failing row contains (3, 12, 5, 0, null, 88, 8000, 12.12). DETAIL: Failing row contains (3, 12, 5, 0, null, 88, 8000, 12.12).
alter table defaulttest alter column col5 drop default; alter table defaulttest alter column col5 drop default;
insert into defaulttest default values; insert into defaulttest default values;
......
...@@ -406,24 +406,24 @@ CREATE TABLE gtest20a (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STOR ...@@ -406,24 +406,24 @@ CREATE TABLE gtest20a (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STOR
INSERT INTO gtest20a (a) VALUES (10); INSERT INTO gtest20a (a) VALUES (10);
INSERT INTO gtest20a (a) VALUES (30); INSERT INTO gtest20a (a) VALUES (30);
ALTER TABLE gtest20a ADD CHECK (b < 50); -- fails on existing row ALTER TABLE gtest20a ADD CHECK (b < 50); -- fails on existing row
ERROR: check constraint "gtest20a_b_check" is violated by some row ERROR: check constraint "gtest20a_b_check" of relation "gtest20a" is violated by some row
CREATE TABLE gtest20b (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED); CREATE TABLE gtest20b (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED);
INSERT INTO gtest20b (a) VALUES (10); INSERT INTO gtest20b (a) VALUES (10);
INSERT INTO gtest20b (a) VALUES (30); INSERT INTO gtest20b (a) VALUES (30);
ALTER TABLE gtest20b ADD CONSTRAINT chk CHECK (b < 50) NOT VALID; ALTER TABLE gtest20b ADD CONSTRAINT chk CHECK (b < 50) NOT VALID;
ALTER TABLE gtest20b VALIDATE CONSTRAINT chk; -- fails on existing row ALTER TABLE gtest20b VALIDATE CONSTRAINT chk; -- fails on existing row
ERROR: check constraint "chk" is violated by some row ERROR: check constraint "chk" of relation "gtest20b" is violated by some row
-- not-null constraints -- not-null constraints
CREATE TABLE gtest21a (a int PRIMARY KEY, b int GENERATED ALWAYS AS (nullif(a, 0)) STORED NOT NULL); CREATE TABLE gtest21a (a int PRIMARY KEY, b int GENERATED ALWAYS AS (nullif(a, 0)) STORED NOT NULL);
INSERT INTO gtest21a (a) VALUES (1); -- ok INSERT INTO gtest21a (a) VALUES (1); -- ok
INSERT INTO gtest21a (a) VALUES (0); -- violates constraint INSERT INTO gtest21a (a) VALUES (0); -- violates constraint
ERROR: null value in column "b" violates not-null constraint ERROR: null value in column "b" of relation "gtest21a" violates not-null constraint
DETAIL: Failing row contains (0, null). DETAIL: Failing row contains (0, null).
CREATE TABLE gtest21b (a int PRIMARY KEY, b int GENERATED ALWAYS AS (nullif(a, 0)) STORED); CREATE TABLE gtest21b (a int PRIMARY KEY, b int GENERATED ALWAYS AS (nullif(a, 0)) STORED);
ALTER TABLE gtest21b ALTER COLUMN b SET NOT NULL; ALTER TABLE gtest21b ALTER COLUMN b SET NOT NULL;
INSERT INTO gtest21b (a) VALUES (1); -- ok INSERT INTO gtest21b (a) VALUES (1); -- ok
INSERT INTO gtest21b (a) VALUES (0); -- violates constraint INSERT INTO gtest21b (a) VALUES (0); -- violates constraint
ERROR: null value in column "b" violates not-null constraint ERROR: null value in column "b" of relation "gtest21b" violates not-null constraint
DETAIL: Failing row contains (0, null). DETAIL: Failing row contains (0, null).
ALTER TABLE gtest21b ALTER COLUMN b DROP NOT NULL; ALTER TABLE gtest21b ALTER COLUMN b DROP NOT NULL;
INSERT INTO gtest21b (a) VALUES (0); -- ok now INSERT INTO gtest21b (a) VALUES (0); -- ok now
......
...@@ -186,7 +186,7 @@ ERROR: column "a" of relation "itest4" is not an identity column ...@@ -186,7 +186,7 @@ ERROR: column "a" of relation "itest4" is not an identity column
ALTER TABLE itest4 ALTER COLUMN a DROP IDENTITY IF EXISTS; -- noop ALTER TABLE itest4 ALTER COLUMN a DROP IDENTITY IF EXISTS; -- noop
NOTICE: column "a" of relation "itest4" is not an identity column, skipping NOTICE: column "a" of relation "itest4" is not an identity column, skipping
INSERT INTO itest4 DEFAULT VALUES; -- fails because NOT NULL is not dropped INSERT INTO itest4 DEFAULT VALUES; -- fails because NOT NULL is not dropped
ERROR: null value in column "a" violates not-null constraint ERROR: null value in column "a" of relation "itest4" violates not-null constraint
DETAIL: Failing row contains (null, ). DETAIL: Failing row contains (null, ).
ALTER TABLE itest4 ALTER COLUMN a DROP NOT NULL; ALTER TABLE itest4 ALTER COLUMN a DROP NOT NULL;
INSERT INTO itest4 DEFAULT VALUES; INSERT INTO itest4 DEFAULT VALUES;
...@@ -414,7 +414,7 @@ INSERT INTO itest8 VALUES(0), (1); ...@@ -414,7 +414,7 @@ INSERT INTO itest8 VALUES(0), (1);
ALTER TABLE itest8 ALTER TABLE itest8
ADD COLUMN f22 int NOT NULL, ADD COLUMN f22 int NOT NULL,
ALTER COLUMN f22 ADD GENERATED ALWAYS AS IDENTITY; ALTER COLUMN f22 ADD GENERATED ALWAYS AS IDENTITY;
ERROR: column "f22" contains null values ERROR: column "f22" of relation "itest8" contains null values
TABLE itest8; TABLE itest8;
f1 | f2 | f3 | f4 | f5 f1 | f2 | f3 | f4 | f5
----+----+----+----+---- ----+----+----+----+----
......
...@@ -124,7 +124,7 @@ INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x ...@@ -124,7 +124,7 @@ INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x
ERROR: duplicate key value violates unique constraint "covering" ERROR: duplicate key value violates unique constraint "covering"
DETAIL: Key (c1, c2)=(1, 2) already exists. DETAIL: Key (c1, c2)=(1, 2) already exists.
INSERT INTO tbl SELECT 1, NULL, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x; INSERT INTO tbl SELECT 1, NULL, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x;
ERROR: null value in column "c2" violates not-null constraint ERROR: null value in column "c2" of relation "tbl" violates not-null constraint
DETAIL: Failing row contains (1, null, 3, (4,4),(4,4)). DETAIL: Failing row contains (1, null, 3, (4,4),(4,4)).
INSERT INTO tbl SELECT x, 2*x, NULL, NULL FROM generate_series(1,300) AS x; INSERT INTO tbl SELECT x, 2*x, NULL, NULL FROM generate_series(1,300) AS x;
explain (costs off) explain (costs off)
...@@ -202,7 +202,7 @@ INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x ...@@ -202,7 +202,7 @@ INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x
ERROR: duplicate key value violates unique constraint "tbl_pkey" ERROR: duplicate key value violates unique constraint "tbl_pkey"
DETAIL: Key (c1, c2)=(1, 2) already exists. DETAIL: Key (c1, c2)=(1, 2) already exists.
INSERT INTO tbl SELECT 1, NULL, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x; INSERT INTO tbl SELECT 1, NULL, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x;
ERROR: null value in column "c2" violates not-null constraint ERROR: null value in column "c2" of relation "tbl" violates not-null constraint
DETAIL: Failing row contains (1, null, 3, (4,4),(4,4)). DETAIL: Failing row contains (1, null, 3, (4,4),(4,4)).
INSERT INTO tbl SELECT x, 2*x, NULL, NULL FROM generate_series(1,10) AS x; INSERT INTO tbl SELECT x, 2*x, NULL, NULL FROM generate_series(1,10) AS x;
DROP TABLE tbl; DROP TABLE tbl;
......
...@@ -537,7 +537,7 @@ SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid; ...@@ -537,7 +537,7 @@ SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid;
-- Confirm PRIMARY KEY adds NOT NULL constraint to child table -- Confirm PRIMARY KEY adds NOT NULL constraint to child table
CREATE TEMP TABLE z (b TEXT, PRIMARY KEY(aa, b)) inherits (a); CREATE TEMP TABLE z (b TEXT, PRIMARY KEY(aa, b)) inherits (a);
INSERT INTO z VALUES (NULL, 'text'); -- should fail INSERT INTO z VALUES (NULL, 'text'); -- should fail
ERROR: null value in column "aa" violates not-null constraint ERROR: null value in column "aa" of relation "z" violates not-null constraint
DETAIL: Failing row contains (null, text). DETAIL: Failing row contains (null, text).
-- Check inherited UPDATE with all children excluded -- Check inherited UPDATE with all children excluded
create table some_tab (a int, b int); create table some_tab (a int, b int);
...@@ -940,9 +940,9 @@ create table p2(f2 int); ...@@ -940,9 +940,9 @@ create table p2(f2 int);
create table c1(f3 int) inherits(p1,p2); create table c1(f3 int) inherits(p1,p2);
insert into c1 values(1,-1,2); insert into c1 values(1,-1,2);
alter table p2 add constraint cc check (f2>0); -- fail alter table p2 add constraint cc check (f2>0); -- fail
ERROR: check constraint "cc" is violated by some row ERROR: check constraint "cc" of relation "c1" is violated by some row
alter table p2 add check (f2>0); -- check it without a name, too alter table p2 add check (f2>0); -- check it without a name, too
ERROR: check constraint "p2_f2_check" is violated by some row ERROR: check constraint "p2_f2_check" of relation "c1" is violated by some row
delete from c1; delete from c1;
insert into c1 values(1,1,2); insert into c1 values(1,1,2);
alter table p2 add check (f2>0); alter table p2 add check (f2>0);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
-- --
create table inserttest (col1 int4, col2 int4 NOT NULL, col3 text default 'testing'); create table inserttest (col1 int4, col2 int4 NOT NULL, col3 text default 'testing');
insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT); insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT);
ERROR: null value in column "col2" violates not-null constraint ERROR: null value in column "col2" of relation "inserttest" violates not-null constraint
DETAIL: Failing row contains (null, null, testing). DETAIL: Failing row contains (null, null, testing).
insert into inserttest (col2, col3) values (3, DEFAULT); insert into inserttest (col2, col3) values (3, DEFAULT);
insert into inserttest (col1, col2, col3) values (DEFAULT, 5, DEFAULT); insert into inserttest (col1, col2, col3) values (DEFAULT, 5, DEFAULT);
......
...@@ -592,13 +592,13 @@ ERROR: duplicate key value violates unique constraint "t1_pkey" ...@@ -592,13 +592,13 @@ ERROR: duplicate key value violates unique constraint "t1_pkey"
UPDATE t1 SET c2 = 1; -- fail, but row not shown UPDATE t1 SET c2 = 1; -- fail, but row not shown
ERROR: duplicate key value violates unique constraint "t1_pkey" ERROR: duplicate key value violates unique constraint "t1_pkey"
INSERT INTO t1 (c1, c2) VALUES (null, null); -- fail, but see columns being inserted INSERT INTO t1 (c1, c2) VALUES (null, null); -- fail, but see columns being inserted
ERROR: null value in column "c1" violates not-null constraint ERROR: null value in column "c1" of relation "t1" violates not-null constraint
DETAIL: Failing row contains (c1, c2) = (null, null). DETAIL: Failing row contains (c1, c2) = (null, null).
INSERT INTO t1 (c3) VALUES (null); -- fail, but see columns being inserted or have SELECT INSERT INTO t1 (c3) VALUES (null); -- fail, but see columns being inserted or have SELECT
ERROR: null value in column "c1" violates not-null constraint ERROR: null value in column "c1" of relation "t1" violates not-null constraint
DETAIL: Failing row contains (c1, c3) = (null, null). DETAIL: Failing row contains (c1, c3) = (null, null).
INSERT INTO t1 (c1) VALUES (5); -- fail, but see columns being inserted or have SELECT INSERT INTO t1 (c1) VALUES (5); -- fail, but see columns being inserted or have SELECT
ERROR: null value in column "c2" violates not-null constraint ERROR: null value in column "c2" of relation "t1" violates not-null constraint
DETAIL: Failing row contains (c1) = (5). DETAIL: Failing row contains (c1) = (5).
UPDATE t1 SET c3 = 10; -- fail, but see columns with SELECT rights, or being modified UPDATE t1 SET c3 = 10; -- fail, but see columns with SELECT rights, or being modified
ERROR: new row for relation "t1" violates check constraint "t1_c3_check" ERROR: new row for relation "t1" violates check constraint "t1_c3_check"
......
...@@ -100,7 +100,7 @@ SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; ...@@ -100,7 +100,7 @@ SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
(1 row) (1 row)
INSERT INTO reloptions_test VALUES (1, NULL), (NULL, NULL); INSERT INTO reloptions_test VALUES (1, NULL), (NULL, NULL);
ERROR: null value in column "i" violates not-null constraint ERROR: null value in column "i" of relation "reloptions_test" violates not-null constraint
DETAIL: Failing row contains (null, null). DETAIL: Failing row contains (null, null).
VACUUM reloptions_test; VACUUM reloptions_test;
SELECT pg_relation_size('reloptions_test') > 0; SELECT pg_relation_size('reloptions_test') > 0;
...@@ -125,7 +125,7 @@ SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; ...@@ -125,7 +125,7 @@ SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
(1 row) (1 row)
INSERT INTO reloptions_test VALUES (1, NULL), (NULL, NULL); INSERT INTO reloptions_test VALUES (1, NULL), (NULL, NULL);
ERROR: null value in column "i" violates not-null constraint ERROR: null value in column "i" of relation "reloptions_test" violates not-null constraint
DETAIL: Failing row contains (null, null). DETAIL: Failing row contains (null, null).
VACUUM reloptions_test; VACUUM reloptions_test;
SELECT pg_relation_size('reloptions_test') = 0; SELECT pg_relation_size('reloptions_test') = 0;
......
...@@ -69,7 +69,7 @@ INSERT INTO serialTest1 VALUES ('foo'); ...@@ -69,7 +69,7 @@ INSERT INTO serialTest1 VALUES ('foo');
INSERT INTO serialTest1 VALUES ('bar'); INSERT INTO serialTest1 VALUES ('bar');
INSERT INTO serialTest1 VALUES ('force', 100); INSERT INTO serialTest1 VALUES ('force', 100);
INSERT INTO serialTest1 VALUES ('wrong', NULL); INSERT INTO serialTest1 VALUES ('wrong', NULL);
ERROR: null value in column "f2" violates not-null constraint ERROR: null value in column "f2" of relation "serialtest1" violates not-null constraint
DETAIL: Failing row contains (wrong, null). DETAIL: Failing row contains (wrong, null).
SELECT * FROM serialTest1; SELECT * FROM serialTest1;
f1 | f2 f1 | f2
......
...@@ -164,7 +164,7 @@ VACUUM (INDEX_CLEANUP FALSE, FREEZE TRUE) vaccluster; ...@@ -164,7 +164,7 @@ VACUUM (INDEX_CLEANUP FALSE, FREEZE TRUE) vaccluster;
CREATE TABLE vac_truncate_test(i INT NOT NULL, j text) CREATE TABLE vac_truncate_test(i INT NOT NULL, j text)
WITH (vacuum_truncate=true, autovacuum_enabled=false); WITH (vacuum_truncate=true, autovacuum_enabled=false);
INSERT INTO vac_truncate_test VALUES (1, NULL), (NULL, NULL); INSERT INTO vac_truncate_test VALUES (1, NULL), (NULL, NULL);
ERROR: null value in column "i" violates not-null constraint ERROR: null value in column "i" of relation "vac_truncate_test" violates not-null constraint
DETAIL: Failing row contains (null, null). DETAIL: Failing row contains (null, null).
VACUUM (TRUNCATE FALSE) vac_truncate_test; VACUUM (TRUNCATE FALSE) vac_truncate_test;
SELECT pg_relation_size('vac_truncate_test') > 0; SELECT pg_relation_size('vac_truncate_test') > 0;
......
...@@ -377,7 +377,7 @@ DETAIL: Key (i)=(1) already exists. ...@@ -377,7 +377,7 @@ DETAIL: Key (i)=(1) already exists.
INSERT INTO PRIMARY_TBL VALUES (4, 'three'); INSERT INTO PRIMARY_TBL VALUES (4, 'three');
INSERT INTO PRIMARY_TBL VALUES (5, 'one'); INSERT INTO PRIMARY_TBL VALUES (5, 'one');
INSERT INTO PRIMARY_TBL (t) VALUES ('six'); INSERT INTO PRIMARY_TBL (t) VALUES ('six');
ERROR: null value in column "i" violates not-null constraint ERROR: null value in column "i" of relation "primary_tbl" violates not-null constraint
DETAIL: Failing row contains (null, six). DETAIL: Failing row contains (null, six).
SELECT '' AS four, * FROM PRIMARY_TBL; SELECT '' AS four, * FROM PRIMARY_TBL;
four | i | t four | i | t
...@@ -397,7 +397,7 @@ INSERT INTO PRIMARY_TBL VALUES (1, 'three'); ...@@ -397,7 +397,7 @@ INSERT INTO PRIMARY_TBL VALUES (1, 'three');
INSERT INTO PRIMARY_TBL VALUES (4, 'three'); INSERT INTO PRIMARY_TBL VALUES (4, 'three');
INSERT INTO PRIMARY_TBL VALUES (5, 'one'); INSERT INTO PRIMARY_TBL VALUES (5, 'one');
INSERT INTO PRIMARY_TBL (t) VALUES ('six'); INSERT INTO PRIMARY_TBL (t) VALUES ('six');
ERROR: null value in column "i" violates not-null constraint ERROR: null value in column "i" of relation "primary_tbl" violates not-null constraint
DETAIL: Failing row contains (null, six). DETAIL: Failing row contains (null, six).
SELECT '' AS three, * FROM PRIMARY_TBL; SELECT '' AS three, * FROM PRIMARY_TBL;
three | i | t three | i | t
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment