aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_utilcmd.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2017-08-20 11:19:07 -0700
committerAndres Freund <andres@anarazel.de>2017-08-20 11:19:07 -0700
commit2cd70845240087da205695baedab6412342d1dbe (patch)
tree20a3b6a2231dae248218ac54983c7a854328265f /src/backend/parser/parse_utilcmd.c
parentb1c2d76a2fcef812af0be3343082414d401909c8 (diff)
downloadpostgresql-2cd70845240087da205695baedab6412342d1dbe.tar.gz
postgresql-2cd70845240087da205695baedab6412342d1dbe.zip
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
Diffstat (limited to 'src/backend/parser/parse_utilcmd.c')
-rw-r--r--src/backend/parser/parse_utilcmd.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 495ba3dffcb..20586797cc5 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -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)