mirror of
https://github.com/postgres/postgres.git
synced 2025-06-17 17:02:08 +03:00
Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n).
This is a mechanical change in preparation for a later commit that will change the layout of TupleDesc. Introducing a macro to abstract the details of where attributes are stored will allow us to change that in separate step and revise it in future. Author: Thomas Munro, editorialized by Andres Freund Reviewed-By: Andres Freund Discussion: https://postgr.es/m/CAEepm=0ZtQ-SpsgCyzzYpsXS6e=kZWqk3g5Ygn3MDV7A8dabUA@mail.gmail.com
This commit is contained in:
@ -969,7 +969,8 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
|
||||
for (parent_attno = 1; parent_attno <= tupleDesc->natts;
|
||||
parent_attno++)
|
||||
{
|
||||
Form_pg_attribute attribute = tupleDesc->attrs[parent_attno - 1];
|
||||
Form_pg_attribute attribute = TupleDescAttr(tupleDesc,
|
||||
parent_attno - 1);
|
||||
char *attributeName = NameStr(attribute->attname);
|
||||
ColumnDef *def;
|
||||
|
||||
@ -1219,7 +1220,7 @@ transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
|
||||
tupdesc = lookup_rowtype_tupdesc(ofTypeId, -1);
|
||||
for (i = 0; i < tupdesc->natts; i++)
|
||||
{
|
||||
Form_pg_attribute attr = tupdesc->attrs[i];
|
||||
Form_pg_attribute attr = TupleDescAttr(tupdesc, i);
|
||||
ColumnDef *n;
|
||||
|
||||
if (attr->attisdropped)
|
||||
@ -1256,7 +1257,6 @@ generateClonedIndexStmt(CreateStmtContext *cxt, Relation source_idx,
|
||||
const AttrNumber *attmap, int attmap_length)
|
||||
{
|
||||
Oid source_relid = RelationGetRelid(source_idx);
|
||||
Form_pg_attribute *attrs = RelationGetDescr(source_idx)->attrs;
|
||||
HeapTuple ht_idxrel;
|
||||
HeapTuple ht_idx;
|
||||
HeapTuple ht_am;
|
||||
@ -1434,6 +1434,8 @@ generateClonedIndexStmt(CreateStmtContext *cxt, Relation source_idx,
|
||||
{
|
||||
IndexElem *iparam;
|
||||
AttrNumber attnum = idxrec->indkey.values[keyno];
|
||||
Form_pg_attribute attr = TupleDescAttr(RelationGetDescr(source_idx),
|
||||
keyno);
|
||||
int16 opt = source_idx->rd_indoption[keyno];
|
||||
|
||||
iparam = makeNode(IndexElem);
|
||||
@ -1481,7 +1483,7 @@ generateClonedIndexStmt(CreateStmtContext *cxt, Relation source_idx,
|
||||
}
|
||||
|
||||
/* Copy the original index column name */
|
||||
iparam->indexcolname = pstrdup(NameStr(attrs[keyno]->attname));
|
||||
iparam->indexcolname = pstrdup(NameStr(attr->attname));
|
||||
|
||||
/* Add the collation name, if non-default */
|
||||
iparam->collation = get_collation(indcollation->values[keyno], keycoltype);
|
||||
@ -1921,7 +1923,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
|
||||
if (attnum > 0)
|
||||
{
|
||||
Assert(attnum <= heap_rel->rd_att->natts);
|
||||
attform = heap_rel->rd_att->attrs[attnum - 1];
|
||||
attform = TupleDescAttr(heap_rel->rd_att, attnum - 1);
|
||||
}
|
||||
else
|
||||
attform = SystemAttributeDefinition(attnum,
|
||||
@ -2040,7 +2042,8 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
|
||||
inh->relname)));
|
||||
for (count = 0; count < rel->rd_att->natts; count++)
|
||||
{
|
||||
Form_pg_attribute inhattr = rel->rd_att->attrs[count];
|
||||
Form_pg_attribute inhattr = TupleDescAttr(rel->rd_att,
|
||||
count);
|
||||
char *inhname = NameStr(inhattr->attname);
|
||||
|
||||
if (inhattr->attisdropped)
|
||||
|
Reference in New Issue
Block a user