| 1381 | } |
| 1382 | |
| 1383 | Datum |
| 1384 | array_agg_array_deserialize(PG_FUNCTION_ARGS) |
| 1385 | { |
| 1386 | bytea *sstate; |
| 1387 | ArrayBuildStateArr *result; |
| 1388 | StringInfoData buf; |
| 1389 | Oid element_type; |
| 1390 | Oid array_type; |
| 1391 | int nbytes; |
| 1392 | const char *temp; |
| 1393 | |
| 1394 | /* cannot be called directly because of internal-type argument */ |
| 1395 | Assert(AggCheckCallContext(fcinfo, NULL)); |
| 1396 | |
| 1397 | sstate = PG_GETARG_BYTEA_PP(0); |
| 1398 | |
| 1399 | /* |
| 1400 | * Copy the bytea into a StringInfo so that we can "receive" it using the |
| 1401 | * standard recv-function infrastructure. |
| 1402 | */ |
| 1403 | initStringInfo(&buf); |
| 1404 | appendBinaryStringInfo(&buf, |
| 1405 | VARDATA_ANY(sstate), VARSIZE_ANY_EXHDR(sstate)); |
| 1406 | |
| 1407 | /* element_type */ |
| 1408 | element_type = pq_getmsgint(&buf, sizeof(Oid)); |
| 1409 | |
| 1410 | /* array_type */ |
| 1411 | array_type = pq_getmsgint(&buf, sizeof(Oid)); |
| 1412 | |
| 1413 | /* nbytes */ |
| 1414 | nbytes = pq_getmsgint(&buf, sizeof(int)); |
| 1415 | |
| 1416 | result = initArrayResultArr(array_type, element_type, |
| 1417 | CurrentMemoryContext, false); |
| 1418 | |
| 1419 | result->abytes = 1024; |
| 1420 | while (result->abytes < nbytes) |
| 1421 | result->abytes *= 2; |
| 1422 | |
| 1423 | result->data = (char *) palloc(result->abytes); |
| 1424 | |
| 1425 | /* data */ |
| 1426 | temp = pq_getmsgbytes(&buf, nbytes); |
| 1427 | memcpy(result->data, temp, nbytes); |
| 1428 | result->nbytes = nbytes; |
| 1429 | |
| 1430 | /* abytes */ |
| 1431 | result->abytes = pq_getmsgint(&buf, sizeof(int)); |
| 1432 | |
| 1433 | /* aitems: might be 0 */ |
| 1434 | result->aitems = pq_getmsgint(&buf, sizeof(int)); |
| 1435 | |
| 1436 | /* nullbitmap */ |
| 1437 | if (result->aitems > 0) |
| 1438 | { |
| 1439 | int size = (result->aitems + 7) / 8; |
| 1440 |
nothing calls this directly
no test coverage detected