Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n) (#8240)

TupleDescAttr is available since PG11.
https://github.com/postgres/postgres/commit/2cd7084
PG18 simply forces you to use it, but there is no need to
guard it with pg18 version.
pull/8319/head
Naisila Puka 2025-11-03 21:39:11 +03:00 committed by GitHub
parent 94653c1f4e
commit fa7ca79c6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 15 deletions

View File

@ -655,10 +655,12 @@ SaveStripeSkipList(RelFileLocator relfilelocator, uint64 stripe,
{ {
values[Anum_columnar_chunk_minimum_value - 1] = values[Anum_columnar_chunk_minimum_value - 1] =
PointerGetDatum(DatumToBytea(chunk->minimumValue, PointerGetDatum(DatumToBytea(chunk->minimumValue,
Attr(tupleDescriptor, columnIndex))); TupleDescAttr(tupleDescriptor,
columnIndex)));
values[Anum_columnar_chunk_maximum_value - 1] = values[Anum_columnar_chunk_maximum_value - 1] =
PointerGetDatum(DatumToBytea(chunk->maximumValue, PointerGetDatum(DatumToBytea(chunk->maximumValue,
Attr(tupleDescriptor, columnIndex))); TupleDescAttr(tupleDescriptor,
columnIndex)));
} }
else else
{ {
@ -816,9 +818,9 @@ ReadStripeSkipList(RelFileLocator relfilelocator, uint64 stripe,
datumArray[Anum_columnar_chunk_maximum_value - 1]); datumArray[Anum_columnar_chunk_maximum_value - 1]);
chunk->minimumValue = chunk->minimumValue =
ByteaToDatum(minValue, Attr(tupleDescriptor, columnIndex)); ByteaToDatum(minValue, TupleDescAttr(tupleDescriptor, columnIndex));
chunk->maximumValue = chunk->maximumValue =
ByteaToDatum(maxValue, Attr(tupleDescriptor, columnIndex)); ByteaToDatum(maxValue, TupleDescAttr(tupleDescriptor, columnIndex));
chunk->hasMinMax = true; chunk->hasMinMax = true;
} }

View File

@ -1012,7 +1012,7 @@ NeededColumnsList(TupleDesc tupdesc, Bitmapset *attr_needed)
for (int i = 0; i < tupdesc->natts; i++) for (int i = 0; i < tupdesc->natts; i++)
{ {
if (Attr(tupdesc, i)->attisdropped) if (TupleDescAttr(tupdesc, i)->attisdropped)
{ {
continue; continue;
} }
@ -1255,7 +1255,7 @@ LogRelationStats(Relation rel, int elevel)
for (uint32 column = 0; column < skiplist->columnCount; column++) for (uint32 column = 0; column < skiplist->columnCount; column++)
{ {
bool attrDropped = Attr(tupdesc, column)->attisdropped; bool attrDropped = TupleDescAttr(tupdesc, column)->attisdropped;
for (uint32 chunk = 0; chunk < skiplist->chunkCount; chunk++) for (uint32 chunk = 0; chunk < skiplist->chunkCount; chunk++)
{ {
ColumnChunkSkipNode *skipnode = ColumnChunkSkipNode *skipnode =
@ -2638,7 +2638,7 @@ detoast_values(TupleDesc tupleDesc, Datum *orig_values, bool *isnull)
for (int i = 0; i < tupleDesc->natts; i++) for (int i = 0; i < tupleDesc->natts; i++)
{ {
if (!isnull[i] && Attr(tupleDesc, i)->attlen == -1 && if (!isnull[i] && TupleDescAttr(tupleDesc, i)->attlen == -1 &&
VARATT_IS_EXTENDED(values[i])) VARATT_IS_EXTENDED(values[i]))
{ {
/* make a copy */ /* make a copy */

View File

@ -25,12 +25,4 @@
#define ExplainPropertyLong(qlabel, value, es) \ #define ExplainPropertyLong(qlabel, value, es) \
ExplainPropertyInteger(qlabel, NULL, value, es) ExplainPropertyInteger(qlabel, NULL, value, es)
/* tuple-descriptor attributes moved in PostgreSQL 18: */
#if PG_VERSION_NUM >= PG_VERSION_18
#define Attr(tupdesc, colno) TupleDescAttr((tupdesc), (colno))
#else
#define Attr(tupdesc, colno) (&((tupdesc)->attrs[(colno)]))
#endif
#endif /* COLUMNAR_COMPAT_H */ #endif /* COLUMNAR_COMPAT_H */