Commit b7470104 authored by Tom Lane's avatar Tom Lane

In initdb, defend against assignment of NULL values to not-null columns.

Previously, you could write _null_ in a BKI DATA line for a column that's
supposed to be NOT NULL and initdb would let it pass, probably breaking
subsequent accesses to the row.  No doubt the original coding overlooked
this simple sanity check because in the beginning we didn't have any way
to mark catalog columns NOT NULL at initdb time.
parent f2a88610
...@@ -843,6 +843,11 @@ InsertOneNull(int i) ...@@ -843,6 +843,11 @@ InsertOneNull(int i)
{ {
elog(DEBUG4, "inserting column %d NULL", i); elog(DEBUG4, "inserting column %d NULL", i);
Assert(i >= 0 && i < MAXATTR); Assert(i >= 0 && i < MAXATTR);
if (boot_reldesc->rd_att->attrs[i]->attnotnull)
elog(ERROR,
"NULL value specified for not-null column \"%s\" of relation \"%s\"",
NameStr(boot_reldesc->rd_att->attrs[i]->attname),
RelationGetRelationName(boot_reldesc));
values[i] = PointerGetDatum(NULL); values[i] = PointerGetDatum(NULL);
Nulls[i] = true; Nulls[i] = true;
} }
......
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