* bsonaggvalue_recv: Deserialize BsonAggValue from binary network data. * Parses pgbson bytes, extracts the value and optional collation string. */
| 2694 | * Parses pgbson bytes, extracts the value and optional collation string. |
| 2695 | */ |
| 2696 | Datum |
| 2697 | bsonaggvalue_recv(PG_FUNCTION_ARGS) |
| 2698 | { |
| 2699 | StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); |
| 2700 | |
| 2701 | /* Parse the buffer as pgbson */ |
| 2702 | pgbson *bson = PgbsonInitFromBuffer(buf->data, buf->len); |
| 2703 | |
| 2704 | /* Mark buffer as consumed */ |
| 2705 | buf->cursor = buf->len; |
| 2706 | |
| 2707 | pgbsonelement element; |
| 2708 | const char *collationString = |
| 2709 | PgbsonToSinglePgbsonElementWithCollation(bson, &element); |
| 2710 | |
| 2711 | /* Allocate BsonAggValue and collation and deep-copy their values */ |
| 2712 | BsonAggValue *state = (BsonAggValue *) palloc0(sizeof(BsonAggValue)); |
| 2713 | SET_VARSIZE(state, sizeof(BsonAggValue)); |
| 2714 | bson_value_copy(&element.bsonValue, &state->value); |
| 2715 | state->collationString = collationString != NULL ? |
| 2716 | pstrdup(collationString) : NULL; |
| 2717 | |
| 2718 | PG_RETURN_POINTER(state); |
| 2719 | } |
nothing calls this directly
no test coverage detected