diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 1488520a5d..35da49a0bb 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -2184,6 +2184,7 @@ StoreRelNotNull(Relation rel, const char *nnname, AttrNumber attnum, Oid constrOid; Assert(attnum > InvalidAttrNumber); + Assert(is_validated); constrOid = CreateConstraintEntry(nnname, @@ -2799,6 +2800,7 @@ AddRelationNotNullConstraints(Relation rel, List *constraints, List *givennames; List *nnnames; List *nncols = NIL; + int inh_count = 0; /* * We track two lists of names: nnnames keeps all the constraint names, @@ -2924,12 +2926,13 @@ AddRelationNotNullConstraints(Relation rel, List *constraints, { CookedConstraint *cooked; char *conname = NULL; - int add_inhcount = 0; cooked = (CookedConstraint *) list_nth(old_notnulls, outerpos); Assert(cooked->contype == CONSTR_NOTNULL); Assert(cooked->name); + Assert(!cooked->is_no_inherit); + inh_count = cooked->inhcount; /* * Preserve the first non-conflicting constraint name we come across. */ @@ -2947,7 +2950,7 @@ AddRelationNotNullConstraints(Relation rel, List *constraints, if (conname == NULL) conname = other->name; - add_inhcount++; + inh_count = inh_count + other->inhcount; old_notnulls = list_delete_nth_cell(old_notnulls, restpos); } else @@ -2978,8 +2981,8 @@ AddRelationNotNullConstraints(Relation rel, List *constraints, nnnames = lappend(nnnames, conname); StoreRelNotNull(rel, conname, cooked->attnum, true, - cooked->is_local, cooked->inhcount + add_inhcount, - cooked->is_no_inherit); + cooked->is_local, inh_count, + false); nncols = lappend_int(nncols, cooked->attnum); }