summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2016-03-29 15:04:05 -0400
committerRobert Haas <rhaas@postgresql.org>2016-03-29 15:04:05 -0400
commit5fe5a2cee91117673e04617aeb1a38e305dcd783 (patch)
tree191e937efe0f15daf02c921935d740f429decada /doc/src
parent7f0a2c85fb221bae6908fb2fddad21a4c6d14438 (diff)
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.
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/catalogs.sgml18
-rw-r--r--doc/src/sgml/ref/create_aggregate.sgml50
2 files changed, 68 insertions, 0 deletions
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
@@ -413,6 +413,18 @@
<entry>Combine function (zero if none)</entry>
</row>
<row>
+ <entry><structfield>aggserialfn</structfield></entry>
+ <entry><type>regproc</type></entry>
+ <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
+ <entry>Serialization function (zero if none)</entry>
+ </row>
+ <row>
+ <entry><structfield>aggdeserialfn</structfield></entry>
+ <entry><type>regproc</type></entry>
+ <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
+ <entry>Deserialization function (zero if none)</entry>
+ </row>
+ <row>
<entry><structfield>aggmtransfn</structfield></entry>
<entry><type>regproc</type></entry>
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
@@ -455,6 +467,12 @@
<entry>Data type of the aggregate function's internal transition (state) data</entry>
</row>
<row>
+ <entry><structfield>aggserialtype</structfield></entry>
+ <entry><type>oid</type></entry>
+ <entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
+ <entry>Return data type of the aggregate function's serialization function (zero if none)</entry>
+ </row>
+ <row>
<entry><structfield>aggtransspace</structfield></entry>
<entry><type>int4</type></entry>
<entry></entry>
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 <replaceable class="parameter">name</replaceable> ( [ <replacea
[ , FINALFUNC = <replaceable class="PARAMETER">ffunc</replaceable> ]
[ , FINALFUNC_EXTRA ]
[ , COMBINEFUNC = <replaceable class="PARAMETER">combinefunc</replaceable> ]
+ [ , SERIALFUNC = <replaceable class="PARAMETER">serialfunc</replaceable> ]
+ [ , DESERIALFUNC = <replaceable class="PARAMETER">deserialfunc</replaceable> ]
+ [ , SERIALTYPE = <replaceable class="PARAMETER">serialtype</replaceable> ]
[ , INITCOND = <replaceable class="PARAMETER">initial_condition</replaceable> ]
[ , MSFUNC = <replaceable class="PARAMETER">msfunc</replaceable> ]
[ , MINVFUNC = <replaceable class="PARAMETER">minvfunc</replaceable> ]
@@ -47,6 +50,9 @@ CREATE AGGREGATE <replaceable class="parameter">name</replaceable> ( [ [ <replac
[ , FINALFUNC = <replaceable class="PARAMETER">ffunc</replaceable> ]
[ , FINALFUNC_EXTRA ]
[ , COMBINEFUNC = <replaceable class="PARAMETER">combinefunc</replaceable> ]
+ [ , SERIALFUNC = <replaceable class="PARAMETER">serialfunc</replaceable> ]
+ [ , DESERIALFUNC = <replaceable class="PARAMETER">deserialfunc</replaceable> ]
+ [ , SERIALTYPE = <replaceable class="PARAMETER">serialtype</replaceable> ]
[ , INITCOND = <replaceable class="PARAMETER">initial_condition</replaceable> ]
[ , HYPOTHETICAL ]
)
@@ -61,6 +67,9 @@ CREATE AGGREGATE <replaceable class="PARAMETER">name</replaceable> (
[ , FINALFUNC = <replaceable class="PARAMETER">ffunc</replaceable> ]
[ , FINALFUNC_EXTRA ]
[ , COMBINEFUNC = <replaceable class="PARAMETER">combinefunc</replaceable> ]
+ [ , SERIALFUNC = <replaceable class="PARAMETER">serialfunc</replaceable> ]
+ [ , DESERIALFUNC = <replaceable class="PARAMETER">deserialfunc</replaceable> ]
+ [ , SERIALTYPE = <replaceable class="PARAMETER">serialtype</replaceable> ]
[ , INITCOND = <replaceable class="PARAMETER">initial_condition</replaceable> ]
[ , MSFUNC = <replaceable class="PARAMETER">msfunc</replaceable> ]
[ , MINVFUNC = <replaceable class="PARAMETER">minvfunc</replaceable> ]
@@ -437,6 +446,47 @@ SELECT col FROM tab ORDER BY col USING sortop LIMIT 1;
</varlistentry>
<varlistentry>
+ <term><replaceable class="PARAMETER">serialfunc</replaceable></term>
+ <listitem>
+ <para>
+ In order to allow aggregate functions with an <literal>INTERNAL</>
+ <replaceable class="PARAMETER">state_data_type</replaceable> to
+ participate in parallel aggregation, the aggregate must have a valid
+ <replaceable class="PARAMETER">serialfunc</replaceable>, which must
+ serialize the aggregate state into <replaceable class="PARAMETER">
+ serialtype</replaceable>. This function must take a single argument of
+ <replaceable class="PARAMETER">state_data_type</replaceable> and return
+ <replaceable class="PARAMETER">serialtype</replaceable>. A
+ corresponding <replaceable class="PARAMETER">deserialfunc</replaceable>
+ is also required.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="PARAMETER">deserialfunc</replaceable></term>
+ <listitem>
+ <para>
+ Deserializes a previously serialized aggregate state back into
+ <replaceable class="PARAMETER">state_data_type</replaceable>. This
+ function must take a single argument of <replaceable class="PARAMETER">
+ serialtype</replaceable> and return <replaceable class="PARAMETER">
+ state_data_type</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable class="PARAMETER">serialtype</replaceable></term>
+ <listitem>
+ <para>
+ The data type to into which an <literal>INTERNAL</literal> aggregate
+ state should be serialized.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><replaceable class="PARAMETER">initial_condition</replaceable></term>
<listitem>
<para>