mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
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.
This commit is contained in:
@ -412,6 +412,18 @@
|
||||
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
|
||||
<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>
|
||||
@ -454,6 +466,12 @@
|
||||
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
|
||||
<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>
|
||||
|
@ -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> ]
|
||||
@ -436,6 +445,47 @@ SELECT col FROM tab ORDER BY col USING sortop LIMIT 1;
|
||||
</listitem>
|
||||
</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>
|
||||
|
Reference in New Issue
Block a user