From: Álvaro Herrera Date: Mon, 3 Aug 2026 11:52:41 +0000 (+0200) Subject: Remove unused arg and dead code in set_attnotnull() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d24c588975a3982720cd7874496d1dffb83d292;p=thirdparty%2Fpostgresql.git Remove unused arg and dead code in set_attnotnull() The is_valid parameter was never referenced in the function body, and the 'thisatt' local variable is set but never used. Remove both. Oversight in a379061a22a8. Author: Sami Imseih Backpatch-through: 18 Discussion: https://postgr.es/m/CAA5RZ0tHnvSrfUy4jWJchjvkL_aJe0hCnZpMsFRdLrSxCne5qQ@mail.gmail.com --- diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index ed212f5af5c..c323eb36a10 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -547,7 +547,7 @@ static void add_column_collation_dependency(Oid relid, int32 attnum, Oid collid) static ObjectAddress ATExecDropNotNull(Relation rel, const char *colName, bool recurse, LOCKMODE lockmode); static void set_attnotnull(List **wqueue, Relation rel, AttrNumber attnum, - bool is_valid, bool queue_validation); + bool queue_validation); static ObjectAddress ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName, bool recurse, bool recursing, @@ -1411,7 +1411,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, nncols = AddRelationNotNullConstraints(rel, stmt->nnconstraints, old_notnulls, connames); foreach_int(attrnum, nncols) - set_attnotnull(NULL, rel, attrnum, true, false); + set_attnotnull(NULL, rel, attrnum, false); ObjectAddressSet(address, RelationRelationId, relationId); @@ -7936,10 +7936,9 @@ ATExecDropNotNull(Relation rel, const char *colName, bool recurse, */ static void set_attnotnull(List **wqueue, Relation rel, AttrNumber attnum, - bool is_valid, bool queue_validation) + bool queue_validation) { Form_pg_attribute attr; - CompactAttribute *thisatt; Assert(!queue_validation || wqueue); @@ -7965,9 +7964,6 @@ set_attnotnull(List **wqueue, Relation rel, AttrNumber attnum, elog(ERROR, "cache lookup failed for attribute %d of relation %u", attnum, RelationGetRelid(rel)); - thisatt = TupleDescCompactAttr(RelationGetDescr(rel), attnum - 1); - thisatt->attnullability = ATTNULLABLE_VALID; - attr = (Form_pg_attribute) GETSTRUCT(tuple); attr->attnotnull = true; @@ -8149,7 +8145,7 @@ ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName, ObjectAddressSet(address, ConstraintRelationId, ccon->conoid); /* Mark pg_attribute.attnotnull for the column and queue validation */ - set_attnotnull(wqueue, rel, attnum, true, true); + set_attnotnull(wqueue, rel, attnum, true); InvokeObjectPostAlterHook(RelationRelationId, RelationGetRelid(rel), attnum); @@ -10070,7 +10066,6 @@ ATAddCheckNNConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel, */ if (constr->contype == CONSTR_NOTNULL) set_attnotnull(wqueue, rel, ccon->attnum, - !constr->skip_validation, !constr->skip_validation); ObjectAddressSet(address, ConstraintRelationId, ccon->conoid); @@ -13771,7 +13766,7 @@ QueueNNConstraintValidation(List **wqueue, Relation conrel, Relation rel, } /* Set attnotnull appropriately without queueing another validation */ - set_attnotnull(NULL, rel, attnum, true, false); + set_attnotnull(NULL, rel, attnum, false); tab = ATGetQueueEntry(wqueue, rel); tab->verify_new_notnull = true;