diff --git a/src/backend/distributed/commands/create_distributed_table.c b/src/backend/distributed/commands/create_distributed_table.c index 1e3d1da9f..6aee796fc 100644 --- a/src/backend/distributed/commands/create_distributed_table.c +++ b/src/backend/distributed/commands/create_distributed_table.c @@ -1284,7 +1284,7 @@ TupleDescColumnNameList(TupleDesc tupleDescriptor) for (columnIndex = 0; columnIndex < tupleDescriptor->natts; columnIndex++) { - Form_pg_attribute currentColumn = tupleDescriptor->attrs[columnIndex]; + Form_pg_attribute currentColumn = TupleDescAttr(tupleDescriptor, columnIndex); char *columnName = NameStr(currentColumn->attname); if (currentColumn->attisdropped) @@ -1311,7 +1311,7 @@ RelationUsesIdentityColumns(TupleDesc relationDesc) for (attributeIndex = 0; attributeIndex < relationDesc->natts; attributeIndex++) { - Form_pg_attribute attributeForm = relationDesc->attrs[attributeIndex]; + Form_pg_attribute attributeForm = TupleDescAttr(relationDesc, attributeIndex); if (attributeForm->attidentity != '\0') { diff --git a/src/backend/distributed/commands/multi_copy.c b/src/backend/distributed/commands/multi_copy.c index 899d9e34a..1853b3875 100644 --- a/src/backend/distributed/commands/multi_copy.c +++ b/src/backend/distributed/commands/multi_copy.c @@ -334,7 +334,7 @@ CopyToExistingShards(CopyStmt *copyStatement, char *completionTag) /* build the list of column names for remote COPY statements */ for (columnIndex = 0; columnIndex < columnCount; columnIndex++) { - Form_pg_attribute currentColumn = tupleDescriptor->attrs[columnIndex]; + Form_pg_attribute currentColumn = TupleDescAttr(tupleDescriptor, columnIndex); char *columnName = NameStr(currentColumn->attname); if (currentColumn->attisdropped) @@ -892,7 +892,7 @@ CanUseBinaryCopyFormat(TupleDesc tupleDescription) for (columnIndex = 0; columnIndex < totalColumnCount; columnIndex++) { - Form_pg_attribute currentColumn = tupleDescription->attrs[columnIndex]; + Form_pg_attribute currentColumn = TupleDescAttr(tupleDescription, columnIndex); Oid typeId = InvalidOid; char typeCategory = '\0'; bool typePreferred = false; @@ -1231,7 +1231,7 @@ ColumnOutputFunctions(TupleDesc rowDescriptor, bool binaryFormat) for (columnIndex = 0; columnIndex < columnCount; columnIndex++) { FmgrInfo *currentOutputFunction = &columnOutputFunctions[columnIndex]; - Form_pg_attribute currentColumn = rowDescriptor->attrs[columnIndex]; + Form_pg_attribute currentColumn = TupleDescAttr(rowDescriptor, columnIndex); Oid columnTypeId = currentColumn->atttypid; Oid outputFunctionId = InvalidOid; bool typeVariableLength = false; @@ -1282,7 +1282,7 @@ AppendCopyRowData(Datum *valueArray, bool *isNullArray, TupleDesc rowDescriptor, } for (columnIndex = 0; columnIndex < totalColumnCount; columnIndex++) { - Form_pg_attribute currentColumn = rowDescriptor->attrs[columnIndex]; + Form_pg_attribute currentColumn = TupleDescAttr(rowDescriptor, columnIndex); Datum value = valueArray[columnIndex]; bool isNull = isNullArray[columnIndex]; bool lastColumn = false; @@ -1357,7 +1357,7 @@ AvailableColumnCount(TupleDesc tupleDescriptor) for (columnIndex = 0; columnIndex < tupleDescriptor->natts; columnIndex++) { - Form_pg_attribute currentColumn = tupleDescriptor->attrs[columnIndex]; + Form_pg_attribute currentColumn = TupleDescAttr(tupleDescriptor, columnIndex); if (!currentColumn->attisdropped) { diff --git a/src/backend/distributed/master/master_citus_tools.c b/src/backend/distributed/master/master_citus_tools.c index b51bed900..faa4d1865 100644 --- a/src/backend/distributed/master/master_citus_tools.c +++ b/src/backend/distributed/master/master_citus_tools.c @@ -108,10 +108,10 @@ master_run_on_worker(PG_FUNCTION_ARGS) * Check to make sure we have correct tuple descriptor */ if (tupleDescriptor->natts != 4 || - tupleDescriptor->attrs[0]->atttypid != TEXTOID || - tupleDescriptor->attrs[1]->atttypid != INT4OID || - tupleDescriptor->attrs[2]->atttypid != BOOLOID || - tupleDescriptor->attrs[3]->atttypid != TEXTOID) + TupleDescAttr(tupleDescriptor, 0)->atttypid != TEXTOID || + TupleDescAttr(tupleDescriptor, 1)->atttypid != INT4OID || + TupleDescAttr(tupleDescriptor, 2)->atttypid != BOOLOID || + TupleDescAttr(tupleDescriptor, 3)->atttypid != TEXTOID) { ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_DEFINITION), diff --git a/src/backend/distributed/metadata/metadata_sync.c b/src/backend/distributed/metadata/metadata_sync.c index 55c96e596..54dc9c0c1 100644 --- a/src/backend/distributed/metadata/metadata_sync.c +++ b/src/backend/distributed/metadata/metadata_sync.c @@ -984,7 +984,7 @@ TypeOfColumn(Oid tableId, int16 columnId) { Relation tableRelation = relation_open(tableId, NoLock); TupleDesc tupleDescriptor = RelationGetDescr(tableRelation); - Form_pg_attribute attrForm = tupleDescriptor->attrs[columnId - 1]; + Form_pg_attribute attrForm = TupleDescAttr(tupleDescriptor, columnId - 1); relation_close(tableRelation, NoLock); return attrForm->atttypid; } diff --git a/src/backend/distributed/planner/deparse_shard_query.c b/src/backend/distributed/planner/deparse_shard_query.c index dc06ff81a..c52913559 100644 --- a/src/backend/distributed/planner/deparse_shard_query.c +++ b/src/backend/distributed/planner/deparse_shard_query.c @@ -262,7 +262,8 @@ ConvertRteToSubqueryWithEmptyResult(RangeTblEntry *rte) for (columnIndex = 0; columnIndex < columnCount; columnIndex++) { - FormData_pg_attribute *attributeForm = tupleDescriptor->attrs[columnIndex]; + FormData_pg_attribute *attributeForm = TupleDescAttr(tupleDescriptor, + columnIndex); TargetEntry *targetEntry = NULL; StringInfo resname = NULL; Const *constValue = NULL; diff --git a/src/backend/distributed/utils/citus_ruleutils.c b/src/backend/distributed/utils/citus_ruleutils.c index 4cd3b7a1a..ee152fd65 100644 --- a/src/backend/distributed/utils/citus_ruleutils.c +++ b/src/backend/distributed/utils/citus_ruleutils.c @@ -333,7 +333,7 @@ pg_get_tableschemadef_string(Oid tableRelationId, bool includeSequenceDefaults) for (attributeIndex = 0; attributeIndex < tupleDescriptor->natts; attributeIndex++) { - Form_pg_attribute attributeForm = tupleDescriptor->attrs[attributeIndex]; + Form_pg_attribute attributeForm = TupleDescAttr(tupleDescriptor, attributeIndex); /* * We disregard the inherited attributes (i.e., attinhcount > 0) here. The @@ -545,7 +545,7 @@ pg_get_tablecolumnoptionsdef_string(Oid tableRelationId) for (attributeIndex = 0; attributeIndex < tupleDescriptor->natts; attributeIndex++) { - Form_pg_attribute attributeForm = tupleDescriptor->attrs[attributeIndex]; + Form_pg_attribute attributeForm = TupleDescAttr(tupleDescriptor, attributeIndex); char *attributeName = NameStr(attributeForm->attname); char defaultStorageType = get_typstorage(attributeForm->atttypid);