MCPcopy Create free account
hub / github.com/apache/cloudberry / array_agg_deserialize

Function array_agg_deserialize

src/backend/utils/adt/array_userfuncs.c:745–867  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

743}
744
745Datum
746array_agg_deserialize(PG_FUNCTION_ARGS)
747{
748 bytea *sstate;
749 ArrayBuildState *result;
750 StringInfoData buf;
751 Oid element_type;
752 int64 nelems;
753 const char *temp;
754
755 if (!AggCheckCallContext(fcinfo, NULL))
756 elog(ERROR, "aggregate function called in non-aggregate context");
757
758 sstate = PG_GETARG_BYTEA_PP(0);
759
760 /*
761 * Copy the bytea into a StringInfo so that we can "receive" it using the
762 * standard recv-function infrastructure.
763 */
764 initStringInfo(&buf);
765 appendBinaryStringInfo(&buf,
766 VARDATA_ANY(sstate), VARSIZE_ANY_EXHDR(sstate));
767
768 /* element_type */
769 element_type = pq_getmsgint(&buf, sizeof(Oid));
770
771 /* nelems */
772 nelems = pq_getmsgint64(&buf);
773
774 /* Create output ArrayBuildState with the needed number of elements */
775 result = initArrayResultWithSize(element_type, CurrentMemoryContext,
776 false, nelems);
777 result->nelems = nelems;
778
779 /* typlen */
780 result->typlen = pq_getmsgint(&buf, sizeof(int16));
781
782 /* typbyval */
783 result->typbyval = pq_getmsgbyte(&buf);
784
785 /* typalign */
786 result->typalign = pq_getmsgbyte(&buf);
787
788 /* dnulls */
789 temp = pq_getmsgbytes(&buf, sizeof(bool) * nelems);
790 memcpy(result->dnulls, temp, sizeof(bool) * nelems);
791
792 /* dvalues --- see comment in array_agg_serialize */
793 if (result->typbyval)
794 {
795 temp = pq_getmsgbytes(&buf, sizeof(Datum) * nelems);
796 memcpy(result->dvalues, temp, sizeof(Datum) * nelems);
797 }
798 else
799 {
800 DeserialIOData *iodata;
801 int i;
802

Callers

nothing calls this directly

Calls 15

AggCheckCallContextFunction · 0.85
initStringInfoFunction · 0.85
appendBinaryStringInfoFunction · 0.85
pq_getmsgintFunction · 0.85
pq_getmsgint64Function · 0.85
initArrayResultWithSizeFunction · 0.85
pq_getmsgbyteFunction · 0.85
pq_getmsgbytesFunction · 0.85
MemoryContextAllocFunction · 0.85
getTypeBinaryInputInfoFunction · 0.85
fmgr_info_cxtFunction · 0.85
ReceiveFunctionCallFunction · 0.85

Tested by

no test coverage detected