Home Explore Blog CI



postgresql

9th chunk of `doc/src/sgml/ref/create_aggregate.sgml`
b99ff3b311fd4c9f995a15901b95a15ab5ee4ece53ab5da70000000100000fa5
    <listitem>
     <para>
      The initial setting for the state value.  This must be a string
      constant in the form accepted for the data type <replaceable
      class="parameter">state_data_type</replaceable>.  If not
      specified, the state value starts out null.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">msfunc</replaceable></term>
    <listitem>
     <para>
      The name of the forward state transition function to be called for each
      input row in moving-aggregate mode.  This is exactly like the regular
      transition function, except that its first argument and result are of
      type <replaceable>mstate_data_type</replaceable>, which might be different
      from <replaceable>state_data_type</replaceable>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">minvfunc</replaceable></term>
    <listitem>
     <para>
      The name of the inverse state transition function to be used in
      moving-aggregate mode.  This function has the same argument and
      result types as <replaceable>msfunc</replaceable>, but it is used to remove
      a value from the current aggregate state, rather than add a value to
      it.  The inverse transition function must have the same strictness
      attribute as the forward state transition function.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">mstate_data_type</replaceable></term>
    <listitem>
     <para>
      The data type for the aggregate's state value, when using
      moving-aggregate mode.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">mstate_data_size</replaceable></term>
    <listitem>
     <para>
      The approximate average size (in bytes) of the aggregate's state
      value, when using moving-aggregate mode.  This works the same as
      <replaceable>state_data_size</replaceable>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">mffunc</replaceable></term>
    <listitem>
     <para>
      The name of the final function called to compute the aggregate's
      result after all input rows have been traversed, when using
      moving-aggregate mode.  This works the same as <replaceable>ffunc</replaceable>,
      except that its first argument's type
      is <replaceable>mstate_data_type</replaceable> and extra dummy arguments are
      specified by writing <literal>MFINALFUNC_EXTRA</literal>.
      The aggregate result type determined by <replaceable>mffunc</replaceable>
      or <replaceable>mstate_data_type</replaceable> must match that determined by the
      aggregate's regular implementation.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>MFINALFUNC_MODIFY</literal> = { <literal>READ_ONLY</literal> | <literal>SHAREABLE</literal> | <literal>READ_WRITE</literal> }</term>
    <listitem>
     <para>
      This option is like <literal>FINALFUNC_MODIFY</literal>, but it describes
      the behavior of the moving-aggregate final function.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">minitial_condition</replaceable></term>
    <listitem>
     <para>
      The initial setting for the state value, when using moving-aggregate
      mode.  This works the same as <replaceable>initial_condition</replaceable>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">sort_operator</replaceable></term>
    <listitem>
     <para>
      The associated sort operator for a <function>MIN</function>- or
      <function>MAX</function>-like aggregate.
      This is just an operator name (possibly schema-qualified).
      The operator is assumed to have the same input data types as
      the aggregate (which must be a single-argument

Title: CREATE AGGREGATE Parameters: Moving Aggregate Functions, State Data Type and Size, Final Function, and Sort Operator
Summary
This section details additional parameters for creating aggregate functions, specifically for moving-aggregate mode: 'msfunc' (forward state transition), 'minvfunc' (inverse state transition), 'mstate_data_type' and 'mstate_data_size' (data type and size of the aggregate state), 'mffunc' (final function), 'MFINALFUNC_MODIFY' (behavior of the moving-aggregate final function), 'minitial_condition' (initial state value), and 'sort_operator' (associated sort operator for MIN/MAX-like aggregates).