1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +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:
Andres Freund
2017-08-20 11:19:07 -07:00
parent b1c2d76a2f
commit 2cd7084524
100 changed files with 805 additions and 626 deletions

View File

@ -3698,10 +3698,12 @@ set_relation_column_names(deparse_namespace *dpns, RangeTblEntry *rte,
for (i = 0; i < ncolumns; i++)
{
if (tupdesc->attrs[i]->attisdropped)
Form_pg_attribute attr = TupleDescAttr(tupdesc, i);
if (attr->attisdropped)
real_colnames[i] = NULL;
else
real_colnames[i] = pstrdup(NameStr(tupdesc->attrs[i]->attname));
real_colnames[i] = pstrdup(NameStr(attr->attname));
}
relation_close(rel, AccessShareLock);
}
@ -5391,7 +5393,7 @@ get_target_list(List *targetList, deparse_context *context,
* Otherwise, just use what we can find in the TLE.
*/
if (resultDesc && colno <= resultDesc->natts)
colname = NameStr(resultDesc->attrs[colno - 1]->attname);
colname = NameStr(TupleDescAttr(resultDesc, colno - 1)->attname);
else
colname = tle->resname;
@ -6741,7 +6743,7 @@ get_name_for_var_field(Var *var, int fieldno,
Assert(tupleDesc);
/* Got the tupdesc, so we can extract the field name */
Assert(fieldno >= 1 && fieldno <= tupleDesc->natts);
return NameStr(tupleDesc->attrs[fieldno - 1]->attname);
return NameStr(TupleDescAttr(tupleDesc, fieldno - 1)->attname);
}
/* Find appropriate nesting depth */
@ -7051,7 +7053,7 @@ get_name_for_var_field(Var *var, int fieldno,
Assert(tupleDesc);
/* Got the tupdesc, so we can extract the field name */
Assert(fieldno >= 1 && fieldno <= tupleDesc->natts);
return NameStr(tupleDesc->attrs[fieldno - 1]->attname);
return NameStr(TupleDescAttr(tupleDesc, fieldno - 1)->attname);
}
/*
@ -8180,7 +8182,7 @@ get_rule_expr(Node *node, deparse_context *context,
Node *e = (Node *) lfirst(arg);
if (tupdesc == NULL ||
!tupdesc->attrs[i]->attisdropped)
!TupleDescAttr(tupdesc, i)->attisdropped)
{
appendStringInfoString(buf, sep);
/* Whole-row Vars need special treatment here */
@ -8193,7 +8195,7 @@ get_rule_expr(Node *node, deparse_context *context,
{
while (i < tupdesc->natts)
{
if (!tupdesc->attrs[i]->attisdropped)
if (!TupleDescAttr(tupdesc, i)->attisdropped)
{
appendStringInfoString(buf, sep);
appendStringInfoString(buf, "NULL");