typedef struct
{
DestReceiver pub; /* publicly-known function pointers */
+ StringInfoData buf; /* output buffer */
Portal portal; /* the Portal we are printing from */
bool sendDescrip; /* send RowDescription at startup? */
TupleDesc attrinfo; /* The attr info we are set up for */
int16 *formats = myState->portal->formats;
int i;
+ initStringInfo(&myState->buf);
+
/* get rid of any old data */
if (myState->myinfo)
pfree(myState->myinfo);
TupleDesc typeinfo = slot->tts_tupleDescriptor;
DR_printtup *myState = (DR_printtup *) self;
MemoryContext oldcontext;
- StringInfoData buf;
+ StringInfo buf = &myState->buf;
int natts = typeinfo->natts;
int i;
/*
* Prepare a DataRow message (note buffer is in per-row context)
*/
- pq_beginmessage(&buf, 'D');
+ pq_beginmessage_pre(buf, 'D');
- pq_sendint(&buf, natts, 2);
+ pq_sendint(buf, natts, 2);
/*
* send the attributes of this tuple
if (slot->tts_isnull[i])
{
- pq_sendint(&buf, -1, 4);
+ pq_sendint(buf, -1, 4);
continue;
}
char *outputstr;
outputstr = OutputFunctionCall(&thisState->finfo, attr);
- pq_sendcountedtext(&buf, outputstr, strlen(outputstr), false);
+ pq_sendcountedtext(buf, outputstr, strlen(outputstr), false);
}
else
{
bytea *outputbytes;
outputbytes = SendFunctionCall(&thisState->finfo, attr);
- pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
- pq_sendbytes(&buf, VARDATA(outputbytes),
+ pq_sendint(buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
+ pq_sendbytes(buf, VARDATA(outputbytes),
VARSIZE(outputbytes) - VARHDRSZ);
}
}
- pq_endmessage(&buf);
+ pq_endmessage_keep(buf);
/* Return to caller's context, and flush row's temporary memory */
MemoryContextSwitchTo(oldcontext);