/* *DestReceiverfunctionsforSERIALIZEoption * *ADestReceiverforquerytuples,thatserializespassedrowsintoRowData *messageswhilemeasuringtheresourcesexpendedandtotalserializedsize, *whileneversendingthedatatotheclient.Thisallowsmeasuringthe *overheadofdeTOASTinganddatatypeout/sendfuncs,whicharenototherwise *exercisablewithoutactuallyhittingthenetwork.
*/ typedefstruct SerializeDestReceiver
{
DestReceiver pub;
ExplainState *es; /* this EXPLAIN statement's ExplainState */
int8 format; /* text or binary, like pq wire protocol */
TupleDesc attrinfo; /* the output tuple desc */ int nattrs; /* current number of columns */
FmgrInfo *finfos; /* precomputed call info for output fns */
MemoryContext tmpcontext; /* per-row temporary memory context */
StringInfoData buf; /* buffer to hold the constructed message */
SerializeMetrics metrics; /* collected metrics */
} SerializeDestReceiver;
/* *Getthefunctionlookupinfothatwe'llneedforoutput. * *Thisisasubsetofwhatprinttup_prepare_info()does.Wedon'tneedto *copewithformatchoicesvaryingacrosscolumns,soit'sslightlysimpler.
*/ staticvoid
serialize_prepare_info(SerializeDestReceiver *receiver,
TupleDesc typeinfo, int nattrs)
{ /* get rid of any old data */ if (receiver->finfos)
pfree(receiver->finfos);
receiver->finfos = NULL;
/* only measure time, buffers if requested */ if (myState->es->timing)
INSTR_TIME_SET_CURRENT(start); if (myState->es->buffers)
instr_start = pgBufferUsage;
/* Set or update my derived attribute info, if needed */ if (myState->attrinfo != typeinfo || myState->nattrs != natts)
serialize_prepare_info(myState, typeinfo, natts);
/* Make sure the tuple is fully deconstructed */
slot_getallattrs(slot);
/* Switch into per-row context so we can recover memory below */
oldcontext = MemoryContextSwitchTo(myState->tmpcontext);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.