mirror of
https://github.com/postgres/postgres.git
synced 2025-08-17 01:02:17 +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:
@@ -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");
|
||||
|
||||
|
Reference in New Issue
Block a user