aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/common/printtup.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/access/common/printtup.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/access/common/printtup.c')
-rw-r--r--src/backend/access/common/printtup.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c
index a2ca2d74aef..20d20e623e8 100644
--- a/src/backend/access/common/printtup.c
+++ b/src/backend/access/common/printtup.c
@@ -187,7 +187,6 @@ printtup_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
void
SendRowDescriptionMessage(TupleDesc typeinfo, List *targetlist, int16 *formats)
{
- Form_pg_attribute *attrs = typeinfo->attrs;
int natts = typeinfo->natts;
int proto = PG_PROTOCOL_MAJOR(FrontendProtocol);
int i;
@@ -199,10 +198,11 @@ SendRowDescriptionMessage(TupleDesc typeinfo, List *targetlist, int16 *formats)
for (i = 0; i < natts; ++i)
{
- Oid atttypid = attrs[i]->atttypid;
- int32 atttypmod = attrs[i]->atttypmod;
+ Form_pg_attribute att = TupleDescAttr(typeinfo, i);
+ Oid atttypid = att->atttypid;
+ int32 atttypmod = att->atttypmod;
- pq_sendstring(&buf, NameStr(attrs[i]->attname));
+ pq_sendstring(&buf, NameStr(att->attname));
/* column ID info appears in protocol 3.0 and up */
if (proto >= 3)
{
@@ -228,7 +228,7 @@ SendRowDescriptionMessage(TupleDesc typeinfo, List *targetlist, int16 *formats)
/* If column is a domain, send the base type and typmod instead */
atttypid = getBaseTypeAndTypmod(atttypid, &atttypmod);
pq_sendint(&buf, (int) atttypid, sizeof(atttypid));
- pq_sendint(&buf, attrs[i]->attlen, sizeof(attrs[i]->attlen));
+ pq_sendint(&buf, att->attlen, sizeof(att->attlen));
pq_sendint(&buf, atttypmod, sizeof(atttypmod));
/* format info appears in protocol 3.0 and up */
if (proto >= 3)
@@ -268,18 +268,19 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs)
{
PrinttupAttrInfo *thisState = myState->myinfo + i;
int16 format = (formats ? formats[i] : 0);
+ Form_pg_attribute attr = TupleDescAttr(typeinfo, i);
thisState->format = format;
if (format == 0)
{
- getTypeOutputInfo(typeinfo->attrs[i]->atttypid,
+ getTypeOutputInfo(attr->atttypid,
&thisState->typoutput,
&thisState->typisvarlena);
fmgr_info(thisState->typoutput, &thisState->finfo);
}
else if (format == 1)
{
- getTypeBinaryOutputInfo(typeinfo->attrs[i]->atttypid,
+ getTypeBinaryOutputInfo(attr->atttypid,
&thisState->typsend,
&thisState->typisvarlena);
fmgr_info(thisState->typsend, &thisState->finfo);
@@ -513,14 +514,13 @@ void
debugStartup(DestReceiver *self, int operation, TupleDesc typeinfo)
{
int natts = typeinfo->natts;
- Form_pg_attribute *attinfo = typeinfo->attrs;
int i;
/*
* show the return type of the tuples
*/
for (i = 0; i < natts; ++i)
- printatt((unsigned) i + 1, attinfo[i], NULL);
+ printatt((unsigned) i + 1, TupleDescAttr(typeinfo, i), NULL);
printf("\t----\n");
}
@@ -545,12 +545,12 @@ debugtup(TupleTableSlot *slot, DestReceiver *self)
attr = slot_getattr(slot, i + 1, &isnull);
if (isnull)
continue;
- getTypeOutputInfo(typeinfo->attrs[i]->atttypid,
+ getTypeOutputInfo(TupleDescAttr(typeinfo, i)->atttypid,
&typoutput, &typisvarlena);
value = OidOutputFunctionCall(typoutput, attr);
- printatt((unsigned) i + 1, typeinfo->attrs[i], value);
+ printatt((unsigned) i + 1, TupleDescAttr(typeinfo, i), value);
}
printf("\t----\n");