From 01bde4fa4c24f4eea0a634d8fcad0b376efda6b1 Mon Sep 17 00:00:00 2001 From: Andrew Gierth Date: Tue, 19 Mar 2019 01:16:50 +0000 Subject: 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. --- doc/src/sgml/ref/create_aggregate.sgml | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'doc/src') 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 -CREATE AGGREGATE name ( [ argmode ] [ argname ] arg_data_type [ , ... ] ) ( +CREATE [ OR REPLACE ] AGGREGATE name ( [ argmode ] [ argname ] arg_data_type [ , ... ] ) ( SFUNC = sfunc, STYPE = state_data_type [ , SSPACE = state_data_size ] @@ -44,7 +44,7 @@ CREATE AGGREGATE name ( [ name ( [ [ argmode ] [ argname ] arg_data_type [ , ... ] ] +CREATE [ OR REPLACE ] AGGREGATE name ( [ [ argmode ] [ argname ] arg_data_type [ , ... ] ] ORDER BY [ argmode ] [ argname ] arg_data_type [ , ... ] ) ( SFUNC = sfunc, STYPE = state_data_type @@ -59,7 +59,7 @@ CREATE AGGREGATE name ( [ [ or the old syntax -CREATE AGGREGATE name ( +CREATE [ OR REPLACE ] AGGREGATE name ( BASETYPE = base_type, SFUNC = sfunc, STYPE = state_data_type @@ -88,12 +88,21 @@ CREATE AGGREGATE name ( Description - CREATE AGGREGATE defines a new aggregate - function. Some basic and commonly-used aggregate functions are - included with the distribution; they are documented in . If one defines new types or needs - an aggregate function not already provided, then CREATE - AGGREGATE can be used to provide the desired features. + CREATE AGGREGATE defines a new aggregate function. + CREATE OR REPLACE AGGREGATE 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 . If one defines new + types or needs an aggregate function not already provided, then + CREATE AGGREGATE can be used to provide the desired + features. + + + + 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. -- cgit v1.2.3