1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

Small code simplification

Apply GETSTRUCT() once instead of doing it repeatedly in the same
function.  This simplifies the notation and makes the function's
structure more similar to the surrounding ones.

Discussion: https://www.postgresql.org/message-id/flat/a368248e-69e4-40be-9c07-6c3b5880b0a6@eisentraut.org
This commit is contained in:
Peter Eisentraut
2024-08-21 09:21:25 +02:00
parent 3f28b2fcac
commit 7ff9afbbd1

View File

@ -7736,6 +7736,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
const char *colName, LOCKMODE lockmode) const char *colName, LOCKMODE lockmode)
{ {
HeapTuple tuple; HeapTuple tuple;
Form_pg_attribute attTup;
AttrNumber attnum; AttrNumber attnum;
Relation attr_rel; Relation attr_rel;
ObjectAddress address; ObjectAddress address;
@ -7753,7 +7754,8 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
errmsg("column \"%s\" of relation \"%s\" does not exist", errmsg("column \"%s\" of relation \"%s\" does not exist",
colName, RelationGetRelationName(rel)))); colName, RelationGetRelationName(rel))));
attnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attnum; attTup = (Form_pg_attribute) GETSTRUCT(tuple);
attnum = attTup->attnum;
/* Prevent them from altering a system attribute */ /* Prevent them from altering a system attribute */
if (attnum <= 0) if (attnum <= 0)
@ -7765,9 +7767,9 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
/* /*
* Okay, actually perform the catalog change ... if needed * Okay, actually perform the catalog change ... if needed
*/ */
if (!((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull) if (!attTup->attnotnull)
{ {
((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull = true; attTup->attnotnull = true;
CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple); CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple);
@ -7777,8 +7779,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
* this then we can skip that. We needn't bother looking if we've * this then we can skip that. We needn't bother looking if we've
* already found that we must verify some other not-null constraint. * already found that we must verify some other not-null constraint.
*/ */
if (!tab->verify_new_notnull && if (!tab->verify_new_notnull && !NotNullImpliedByRelConstraints(rel, attTup))
!NotNullImpliedByRelConstraints(rel, (Form_pg_attribute) GETSTRUCT(tuple)))
{ {
/* Tell Phase 3 it needs to test the constraint */ /* Tell Phase 3 it needs to test the constraint */
tab->verify_new_notnull = true; tab->verify_new_notnull = true;