mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
Revert "Optimize various aggregate deserialization functions"
This reverts commit 608fd198de.
On 2nd thoughts, the StringInfo API requires that strings are NUL
terminated and pointing directly to the data in a bytea Datum isn't NUL
terminated.
Discussion: https://postgr.es/m/CAApHDvorfO3iBZ=xpiZvp3uHtJVLyFaPBSvcAhAq2HPLnaNSwQ@mail.gmail.com
This commit is contained in:
@@ -5289,13 +5289,12 @@ string_agg_deserialize(PG_FUNCTION_ARGS)
|
||||
sstate = PG_GETARG_BYTEA_PP(0);
|
||||
|
||||
/*
|
||||
* Fake up a StringInfo pointing to the bytea's value so we can "receive"
|
||||
* the serialized aggregate state value.
|
||||
* Copy the bytea into a StringInfo so that we can "receive" it using the
|
||||
* standard recv-function infrastructure.
|
||||
*/
|
||||
buf.data = VARDATA_ANY(sstate);
|
||||
buf.len = VARSIZE_ANY_EXHDR(sstate);
|
||||
buf.maxlen = 0;
|
||||
buf.cursor = 0;
|
||||
initStringInfo(&buf);
|
||||
appendBinaryStringInfo(&buf,
|
||||
VARDATA_ANY(sstate), VARSIZE_ANY_EXHDR(sstate));
|
||||
|
||||
result = makeStringAggState(fcinfo);
|
||||
|
||||
@@ -5308,6 +5307,7 @@ string_agg_deserialize(PG_FUNCTION_ARGS)
|
||||
appendBinaryStringInfo(result, data, datalen);
|
||||
|
||||
pq_getmsgend(&buf);
|
||||
pfree(buf.data);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user