Skip to content

Commit b747010

Browse files
committed
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.
1 parent f2a8861 commit b747010

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/backend/bootstrap/bootstrap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,11 @@ InsertOneNull(int i)
843843
{
844844
elog(DEBUG4, "inserting column %d NULL", i);
845845
Assert(i >= 0 && i < MAXATTR);
846+
if (boot_reldesc->rd_att->attrs[i]->attnotnull)
847+
elog(ERROR,
848+
"NULL value specified for not-null column \"%s\" of relation \"%s\"",
849+
NameStr(boot_reldesc->rd_att->attrs[i]->attname),
850+
RelationGetRelationName(boot_reldesc));
846851
values[i] = PointerGetDatum(NULL);
847852
Nulls[i] = true;
848853
}

0 commit comments

Comments
 (0)