summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2017-06-13 14:54:39 +0000
committerTom Lane2017-06-13 14:54:43 +0000
commitb74701043e396a93f1f18098044741daaf75f761 (patch)
tree254337243b87cb8adfd08a3c2fa0222d2bda2018
parentf2a886104a6683227bfcb0932dde97d30b123961 (diff)
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.
-rw-r--r--src/backend/bootstrap/bootstrap.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 4c28b2b821..d2708cb33e 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -843,6 +843,11 @@ InsertOneNull(int i)
{
elog(DEBUG4, "inserting column %d NULL", i);
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);
Nulls[i] = true;
}