aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorAndrew Gierth <rhodiumtoad@postgresql.org>2019-03-19 01:16:50 +0000
committerAndrew Gierth <rhodiumtoad@postgresql.org>2019-03-19 01:16:50 +0000
commit01bde4fa4c24f4eea0a634d8fcad0b376efda6b1 (patch)
tree3891ad9efa650892c78e8d13f41c5eb151ff7a9e /doc/src
parentf2004f19ed9c9228d3ea2b12379ccb4b9212641f (diff)
downloadpostgresql-01bde4fa4c24f4eea0a634d8fcad0b376efda6b1.tar.gz
postgresql-01bde4fa4c24f4eea0a634d8fcad0b376efda6b1.zip
Implement OR REPLACE option for CREATE AGGREGATE.
Aggregates have acquired a dozen or so optional attributes in recent years for things like parallel query and moving-aggregate mode; the lack of an OR REPLACE option to add or change these for an existing agg makes extension upgrades gratuitously hard. Rectify.
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/ref/create_aggregate.sgml27
1 files changed, 18 insertions, 9 deletions
diff --git a/doc/src/sgml/ref/create_aggregate.sgml b/doc/src/sgml/ref/create_aggregate.sgml
index b8cd2e7af90..ca0e9db8b13 100644
--- a/doc/src/sgml/ref/create_aggregate.sgml
+++ b/doc/src/sgml/ref/create_aggregate.sgml
@@ -21,7 +21,7 @@ PostgreSQL documentation
<refsynopsisdiv>
<synopsis>
-CREATE AGGREGATE <replaceable class="parameter">name</replaceable> ( [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">arg_data_type</replaceable> [ , ... ] ) (
+CREATE [ OR REPLACE ] AGGREGATE <replaceable class="parameter">name</replaceable> ( [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">arg_data_type</replaceable> [ , ... ] ) (
SFUNC = <replaceable class="parameter">sfunc</replaceable>,
STYPE = <replaceable class="parameter">state_data_type</replaceable>
[ , SSPACE = <replaceable class="parameter">state_data_size</replaceable> ]
@@ -44,7 +44,7 @@ CREATE AGGREGATE <replaceable class="parameter">name</replaceable> ( [ <replacea
[ , PARALLEL = { SAFE | RESTRICTED | UNSAFE } ]
)
-CREATE AGGREGATE <replaceable class="parameter">name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">arg_data_type</replaceable> [ , ... ] ]
+CREATE [ OR REPLACE ] AGGREGATE <replaceable class="parameter">name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">arg_data_type</replaceable> [ , ... ] ]
ORDER BY [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">arg_data_type</replaceable> [ , ... ] ) (
SFUNC = <replaceable class="parameter">sfunc</replaceable>,
STYPE = <replaceable class="parameter">state_data_type</replaceable>
@@ -59,7 +59,7 @@ CREATE AGGREGATE <replaceable class="parameter">name</replaceable> ( [ [ <replac
<phrase>or the old syntax</phrase>
-CREATE AGGREGATE <replaceable class="parameter">name</replaceable> (
+CREATE [ OR REPLACE ] AGGREGATE <replaceable class="parameter">name</replaceable> (
BASETYPE = <replaceable class="parameter">base_type</replaceable>,
SFUNC = <replaceable class="parameter">sfunc</replaceable>,
STYPE = <replaceable class="parameter">state_data_type</replaceable>
@@ -88,12 +88,21 @@ CREATE AGGREGATE <replaceable class="parameter">name</replaceable> (
<title>Description</title>
<para>
- <command>CREATE AGGREGATE</command> defines a new aggregate
- function. Some basic and commonly-used aggregate functions are
- included with the distribution; they are documented in <xref
- linkend="functions-aggregate"/>. If one defines new types or needs
- an aggregate function not already provided, then <command>CREATE
- AGGREGATE</command> can be used to provide the desired features.
+ <command>CREATE AGGREGATE</command> defines a new aggregate function.
+ <command>CREATE OR REPLACE AGGREGATE</command> will either define a new
+ aggregate function or replace an existing definition. Some basic and
+ commonly-used aggregate functions are included with the distribution; they
+ are documented in <xref linkend="functions-aggregate"/>. If one defines new
+ types or needs an aggregate function not already provided, then
+ <command>CREATE AGGREGATE</command> can be used to provide the desired
+ features.
+ </para>
+
+ <para>
+ When replacing an existing definition, the argument types, result type,
+ and number of direct arguments may not be changed. Also, the new definition
+ must be of the same kind (ordinary aggregate, ordered-set aggregate, or
+ hypothetical-set aggregate) as the old one.
</para>
<para>