aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2024-07-02 13:41:47 +1200
committerDavid Rowley <drowley@postgresql.org>2024-07-02 13:41:47 +1200
commit65b71dec2d577e9ef7423773a88fdd075f3eb97f (patch)
tree29eb2dbbbb577b2c2ad64b4a21fdc0f660aa5347
parent0c1aca461481216ff5a0e65538c4880bcf346433 (diff)
downloadpostgresql-65b71dec2d577e9ef7423773a88fdd075f3eb97f.tar.gz
postgresql-65b71dec2d577e9ef7423773a88fdd075f3eb97f.zip
Use TupleDescAttr macro consistently
A few places were directly accessing the attrs[] array. This goes against the standards set by 2cd708452. Fix that. Discussion: https://postgr.es/m/CAApHDvrBztXP3yx=NKNmo3xwFAFhEdyPnvrDg3=M0RhDs+4vYw@mail.gmail.com
-rw-r--r--contrib/pageinspect/gistfuncs.c2
-rw-r--r--src/backend/catalog/heap.c11
-rw-r--r--src/backend/commands/prepare.c2
-rw-r--r--src/backend/executor/nodeIndexonlyscan.c4
-rw-r--r--src/backend/executor/nodeMemoize.c8
-rw-r--r--src/backend/optimizer/util/plancat.c2
6 files changed, 15 insertions, 14 deletions
diff --git a/contrib/pageinspect/gistfuncs.c b/contrib/pageinspect/gistfuncs.c
index b38f1d32f76..1cc3b8c9e90 100644
--- a/contrib/pageinspect/gistfuncs.c
+++ b/contrib/pageinspect/gistfuncs.c
@@ -309,7 +309,7 @@ gist_page_items(PG_FUNCTION_ARGS)
bool typisvarlena;
Oid typoid;
- typoid = tupdesc->attrs[i].atttypid;
+ typoid = TupleDescAttr(tupdesc, i)->atttypid;
getTypeOutputInfo(typoid, &foutoid, &typisvarlena);
value = OidOutputFunctionCall(foutoid, itup_values[i]);
}
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index ae2efdc760d..00074c8a948 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -839,18 +839,19 @@ AddNewAttributeTuples(Oid new_rel_oid,
/* add dependencies on their datatypes and collations */
for (int i = 0; i < natts; i++)
{
+ Form_pg_attribute attr = TupleDescAttr(tupdesc, i);
+
/* Add dependency info */
ObjectAddressSubSet(myself, RelationRelationId, new_rel_oid, i + 1);
- ObjectAddressSet(referenced, TypeRelationId,
- tupdesc->attrs[i].atttypid);
+ ObjectAddressSet(referenced, TypeRelationId, attr->atttypid);
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
/* The default collation is pinned, so don't bother recording it */
- if (OidIsValid(tupdesc->attrs[i].attcollation) &&
- tupdesc->attrs[i].attcollation != DEFAULT_COLLATION_OID)
+ if (OidIsValid(attr->attcollation) &&
+ attr->attcollation != DEFAULT_COLLATION_OID)
{
ObjectAddressSet(referenced, CollationRelationId,
- tupdesc->attrs[i].attcollation);
+ attr->attcollation);
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
}
}
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index 5e85585e9dd..07257d4db94 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -717,7 +717,7 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
result_types = palloc_array(Oid, result_desc->natts);
for (int i = 0; i < result_desc->natts; i++)
- result_types[i] = result_desc->attrs[i].atttypid;
+ result_types[i] = TupleDescAttr(result_desc, i)->atttypid;
values[4] = build_regtype_array(result_types, result_desc->natts);
}
else
diff --git a/src/backend/executor/nodeIndexonlyscan.c b/src/backend/executor/nodeIndexonlyscan.c
index b49194c0167..612c6738950 100644
--- a/src/backend/executor/nodeIndexonlyscan.c
+++ b/src/backend/executor/nodeIndexonlyscan.c
@@ -658,7 +658,7 @@ ExecInitIndexOnlyScan(IndexOnlyScan *node, EState *estate, int eflags)
/* First, count the number of such index keys */
for (int attnum = 0; attnum < indnkeyatts; attnum++)
{
- if (indexRelation->rd_att->attrs[attnum].atttypid == CSTRINGOID &&
+ if (TupleDescAttr(indexRelation->rd_att, attnum)->atttypid == CSTRINGOID &&
indexRelation->rd_opcintype[attnum] == NAMEOID)
namecount++;
}
@@ -676,7 +676,7 @@ ExecInitIndexOnlyScan(IndexOnlyScan *node, EState *estate, int eflags)
for (int attnum = 0; attnum < indnkeyatts; attnum++)
{
- if (indexRelation->rd_att->attrs[attnum].atttypid == CSTRINGOID &&
+ if (TupleDescAttr(indexRelation->rd_att, attnum)->atttypid == CSTRINGOID &&
indexRelation->rd_opcintype[attnum] == NAMEOID)
indexstate->ioss_NameCStringAttNums[idx++] = (AttrNumber) attnum;
}
diff --git a/src/backend/executor/nodeMemoize.c b/src/backend/executor/nodeMemoize.c
index 45157ffb9c7..df8e3fff082 100644
--- a/src/backend/executor/nodeMemoize.c
+++ b/src/backend/executor/nodeMemoize.c
@@ -175,10 +175,10 @@ MemoizeHash_hash(struct memoize_hash *tb, const MemoizeKey *key)
if (!pslot->tts_isnull[i]) /* treat nulls as having hash key 0 */
{
- FormData_pg_attribute *attr;
+ Form_pg_attribute attr;
uint32 hkey;
- attr = &pslot->tts_tupleDescriptor->attrs[i];
+ attr = TupleDescAttr(pslot->tts_tupleDescriptor, i);
hkey = datum_image_hash(pslot->tts_values[i], attr->attbyval, attr->attlen);
@@ -242,7 +242,7 @@ MemoizeHash_equal(struct memoize_hash *tb, const MemoizeKey *key1,
for (int i = 0; i < numkeys; i++)
{
- FormData_pg_attribute *attr;
+ Form_pg_attribute attr;
if (tslot->tts_isnull[i] != pslot->tts_isnull[i])
{
@@ -255,7 +255,7 @@ MemoizeHash_equal(struct memoize_hash *tb, const MemoizeKey *key1,
continue;
/* perform binary comparison on the two datums */
- attr = &tslot->tts_tupleDescriptor->attrs[i];
+ attr = TupleDescAttr(tslot->tts_tupleDescriptor, i);
if (!datum_image_eq(tslot->tts_values[i], pslot->tts_values[i],
attr->attbyval, attr->attlen))
{
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 775955363ef..9efdd844aac 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -174,7 +174,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
{
for (int i = 0; i < relation->rd_att->natts; i++)
{
- FormData_pg_attribute *attr = &relation->rd_att->attrs[i];
+ Form_pg_attribute attr = TupleDescAttr(relation->rd_att, i);
if (attr->attnotnull)
{