| 743 | } |
| 744 | |
| 745 | Datum |
| 746 | array_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 |
nothing calls this directly
no test coverage detected