From 5fe5a2cee91117673e04617aeb1a38e305dcd783 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 29 Mar 2016 15:04:05 -0400 Subject: Allow aggregate transition states to be serialized and deserialized. This is necessary infrastructure for supporting parallel aggregation for aggregates whose transition type is "internal". Such values can't be passed between cooperating processes, because they are just pointers. David Rowley, reviewed by Tomas Vondra and by me. --- doc/src/sgml/catalogs.sgml | 18 ++++++++++++ doc/src/sgml/ref/create_aggregate.sgml | 50 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 4a0ede6a72c..bb752294c3f 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -412,6 +412,18 @@ pg_proc.oid Combine function (zero if none) + + aggserialfn + regproc + pg_proc.oid + Serialization function (zero if none) + + + aggdeserialfn + regproc + pg_proc.oid + Deserialization function (zero if none) + aggmtransfn regproc @@ -454,6 +466,12 @@ pg_type.oid Data type of the aggregate function's internal transition (state) data + + aggserialtype + oid + pg_type.oid + Return data type of the aggregate function's serialization function (zero if none) + aggtransspace int4 diff --git a/doc/src/sgml/ref/create_aggregate.sgml b/doc/src/sgml/ref/create_aggregate.sgml index 837b83c00b8..7a6f8a97fda 100644 --- a/doc/src/sgml/ref/create_aggregate.sgml +++ b/doc/src/sgml/ref/create_aggregate.sgml @@ -28,6 +28,9 @@ CREATE AGGREGATE name ( [ ffunc ] [ , FINALFUNC_EXTRA ] [ , COMBINEFUNC = combinefunc ] + [ , SERIALFUNC = serialfunc ] + [ , DESERIALFUNC = deserialfunc ] + [ , SERIALTYPE = serialtype ] [ , INITCOND = initial_condition ] [ , MSFUNC = msfunc ] [ , MINVFUNC = minvfunc ] @@ -47,6 +50,9 @@ CREATE AGGREGATE name ( [ [ ffunc ] [ , FINALFUNC_EXTRA ] [ , COMBINEFUNC = combinefunc ] + [ , SERIALFUNC = serialfunc ] + [ , DESERIALFUNC = deserialfunc ] + [ , SERIALTYPE = serialtype ] [ , INITCOND = initial_condition ] [ , HYPOTHETICAL ] ) @@ -61,6 +67,9 @@ CREATE AGGREGATE name ( [ , FINALFUNC = ffunc ] [ , FINALFUNC_EXTRA ] [ , COMBINEFUNC = combinefunc ] + [ , SERIALFUNC = serialfunc ] + [ , DESERIALFUNC = deserialfunc ] + [ , SERIALTYPE = serialtype ] [ , INITCOND = initial_condition ] [ , MSFUNC = msfunc ] [ , MINVFUNC = minvfunc ] @@ -436,6 +445,47 @@ SELECT col FROM tab ORDER BY col USING sortop LIMIT 1; + + serialfunc + + + In order to allow aggregate functions with an INTERNAL + state_data_type to + participate in parallel aggregation, the aggregate must have a valid + serialfunc, which must + serialize the aggregate state into + serialtype. This function must take a single argument of + state_data_type and return + serialtype. A + corresponding deserialfunc + is also required. + + + + + + deserialfunc + + + Deserializes a previously serialized aggregate state back into + state_data_type. This + function must take a single argument of + serialtype and return + state_data_type. + + + + + + serialtype + + + The data type to into which an INTERNAL aggregate + state should be serialized. + + + + initial_condition -- cgit v1.2.3