From 799de598b2e0715d6ca539e1e1be9b633d4ad61d Mon Sep 17 00:00:00 2001 From: Chuck Litzell Date: Wed, 3 Apr 2019 20:10:12 -0500 Subject: [PATCH] Docs postgresql 9.4 merge ga (#7208) * REASSIGN OWNED. edits. Remove qualification that it doesn't change the database ownership * ALTER FUNCTION. set from current clause description revision * COMMENT. capitalize proper noun. * COPY. describe PROGRAM option. * CREATE AGGREGATE. Implements new syntax. * CREATE FUNCTION. edits. * DROP ROLE. small edit, link to other commands * DROP USER. trivial edit. * PREPARE. small edits * REASSIGN OWNED. Trivial edits. * REINDEX. trivial edit. * pg_dump. use --quote-all-identifers for cross-version dumps * Additional edits * Updates from review * Updates from review --- .../ref_guide/sql_commands/ALTER_FUNCTION.xml | 3 +- .../ref_guide/sql_commands/ALTER_TABLE.xml | 3 +- .../dita/ref_guide/sql_commands/COMMENT.xml | 2 +- gpdb-doc/dita/ref_guide/sql_commands/COPY.xml | 4 + .../sql_commands/CREATE_AGGREGATE.xml | 409 ++++++++++++++---- .../sql_commands/CREATE_FUNCTION.xml | 11 +- .../dita/ref_guide/sql_commands/DROP_ROLE.xml | 12 +- .../dita/ref_guide/sql_commands/PREPARE.xml | 24 +- .../ref_guide/sql_commands/REASSIGN_OWNED.xml | 11 +- .../dita/ref_guide/sql_commands/REINDEX.xml | 2 +- .../client_utilities/pg_dump.xml | 37 +- 11 files changed, 387 insertions(+), 131 deletions(-) diff --git a/gpdb-doc/dita/ref_guide/sql_commands/ALTER_FUNCTION.xml b/gpdb-doc/dita/ref_guide/sql_commands/ALTER_FUNCTION.xml index 37b59d911c..9bf472665a 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/ALTER_FUNCTION.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/ALTER_FUNCTION.xml @@ -139,7 +139,8 @@ RESET ALL RESET is used, the function-local setting is removed, and the function executes with the value present in its environment. Use RESET ALL to clear all function-local settings. SET FROM CURRENT - applies the session's current value of the parameter when the function is entered. + saves the value of the parameter that is current when ALTER FUNCTION is + executed as the value to be applied when the function is entered. RESTRICT diff --git a/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml b/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml index 36664b7c77..f2fa80a06e 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml @@ -1023,8 +1023,7 @@ where action is one of: ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5);

To add a check constraint only to a table and not to its children:

- ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5) NO INHERIT -; + ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5) NO INHERIT;

(The check constraint will not be inherited by future children, either.)

Remove a check constraint from a table and all of its children:

diff --git a/gpdb-doc/dita/ref_guide/sql_commands/COMMENT.xml b/gpdb-doc/dita/ref_guide/sql_commands/COMMENT.xml index 843c744e81..9ddfd5e210 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/COMMENT.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/COMMENT.xml @@ -177,7 +177,7 @@ COMMENT ON SERVER myserver IS 'my foreign server'; COMMENT ON TABLE my_schema.my_table IS 'Employee Information'; COMMENT ON TABLESPACE my_tablespace IS 'Tablespace for indexes'; COMMENT ON TEXT SEARCH CONFIGURATION my_config IS 'Special word filtering'; -COMMENT ON TEXT SEARCH DICTIONARY swedish IS 'Snowball stemmer for swedish language'; +COMMENT ON TEXT SEARCH DICTIONARY swedish IS 'Snowball stemmer for Swedish language'; COMMENT ON TEXT SEARCH PARSER my_parser IS 'Splits text into words'; COMMENT ON TEXT SEARCH TEMPLATE snowball IS 'Snowball stemmer'; COMMENT ON TRIGGER my_trigger ON my_table IS 'Used for RI'; diff --git a/gpdb-doc/dita/ref_guide/sql_commands/COPY.xml b/gpdb-doc/dita/ref_guide/sql_commands/COPY.xml index 968f03f6d3..1a7a736029 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/COPY.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/COPY.xml @@ -66,6 +66,10 @@ IGNORE EXTERNAL PARTITIONS

as gpfdist, which is useful for high speed data loading.

Use of the ON SEGMENT clause is recommended for expert users only. +

When PROGRAM is specified, the server executes the given command and reads + from the standard output of the program, or writes to the standard input of the program. The + command must be specified from the viewpoint of the server, and be executable by the gpadmin + user.

When STDIN or STDOUT is specified, data is transmitted via the connection between the client and the master. STDIN and STDOUT cannot be used with the ON SEGMENT clause.

diff --git a/gpdb-doc/dita/ref_guide/sql_commands/CREATE_AGGREGATE.xml b/gpdb-doc/dita/ref_guide/sql_commands/CREATE_AGGREGATE.xml index 281c1e9617..80e7986564 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/CREATE_AGGREGATE.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/CREATE_AGGREGATE.xml @@ -1,54 +1,111 @@ -CREATE AGGREGATE

Defines a new aggregate function.

SynopsisCREATE [ORDERED] AGGREGATE name (input_data_type [ , ... ]) -      ( SFUNC = sfunc, -        STYPE = state_data_type -        [, COMBINEFUNC = combinefunc] -        [, FINALFUNC = ffunc] -        [, INITCOND = initial_condition] -        [, SORTOP = sort_operator] )
Description

CREATE AGGREGATE defines a new +CREATE AGGREGATE

Defines a new aggregate function.

SynopsisargnameCREATE AGGREGATE name ( [ argmode ] [ ] arg_data_type [ , ... ] ) ( + SFUNC = sfunc, + STYPE = state_data_type + [ , SSPACE = state_data_size ] + [ , FINALFUNC = ffunc ] + [ , FINALFUNC_EXTRA ] + [ , COMBINEFUNC = combinefunc ] + [ , SERIALFUNC = serialfunc ] + [ , DESERIALFUNC = deserialfunc ] + [ , INITCOND = initial_condition ] + [ , MSFUNC = msfunc ] + [ , MINVFUNC = minvfunc ] + [ , MSTYPE = mstate_data_type ] + [ , MSSPACE = mstate_data_size ] + [ , MFINALFUNC = mffunc ] + [ , MFINALFUNC_EXTRA ] + [ , MINITCOND = minitial_condition ] + [ , SORTOP = sort_operator ] + ) + + CREATE AGGREGATE name ( [ [ argmode ] [ argname ] arg_data_type [ , ... ] ] + ORDER BY [ argmode ] [ argname ] arg_data_type [ , ... ] ) ( + SFUNC = sfunc, + STYPE = state_data_type + [ , SSPACE = state_data_size ] + [ , FINALFUNC = ffunc ] + [ , FINALFUNC_EXTRA ] + [ , COMBINEFUNC = combinefunc ] + [ , SERIALFUNC = serialfunc ] + [ , DESERIALFUNC = deserialfunc ] + [ , INITCOND = initial_condition ] + [ , HYPOTHETICAL ] + ) + + or the old syntax + + CREATE AGGREGATE name ( + BASETYPE = base_type, + SFUNC = sfunc, + STYPE = state_data_type + [ , SSPACE = state_data_size ] + [ , FINALFUNC = ffunc ] + [ , FINALFUNC_EXTRA ] + [ , COMBINEFUNC = combinefunc ] + [ , SERIALFUNC = serialfunc ] + [ , DESERIALFUNC = deserialfunc ] + [ , INITCOND = initial_condition ] + [ , MSFUNC = msfunc ] + [ , MINVFUNC = minvfunc ] + [ , MSTYPE = mstate_data_type ] + [ , MSSPACE = mstate_data_size ] + [ , MFINALFUNC = mffunc ] + [ , MFINALFUNC_EXTRA ] + [ , MINITCOND = minitial_condition ] + [ , SORTOP = sort_operator ] + )
Description

CREATE AGGREGATE defines a new aggregate function. Some basic and commonly-used aggregate functions such as count, min, max, sum, avg and so on are already provided in Greenplum Database. If one defines new types or needs an aggregate function not already provided, then CREATE - AGGREGATE can be used to provide the desired features.

An aggregate - function is identified by its name and input data types. Two aggregate functions in the same - schema can have the same name if they operate on different input types. The name and input - data types of an aggregate function must also be distinct from the name and input data types - of every ordinary function in the same schema.

- -

An aggregate function is made from one, - two or three ordinary functions (all of which must be IMMUTABLE functions):

-
    -
  • A state transition function sfunc
  • -
  • An optional combine function combinefunc
  • -
  • An optional final calculation function ffunc
  • -
+ AGGREGATE can be used to provide the desired features.

+

If a schema name is given (for example, CREATE AGGREGATE myschema.myagg + ...) then the aggregate function is created in the specified schema. Otherwise it + is created in the current schema.

+

An aggregate function is identified by its name and input data types. Two aggregate + functions in the same schema can have the same name if they operate on different input + types. The name and input data types of an aggregate function must also be distinct from the + name and input data types of every ordinary function in the same schema. This behavior is + identical to overloading of ordinary function names. See .

+

A simple aggregate function is made from one, two, or three ordinary functions (which must + be IMMUTABLE functions):

+
    +
  • a state transition function sfunc
  • +
  • an optional final calculation function ffunc
  • +
  • an optional combine function combinefunc
  • +
+

These functions are used as - follows:

sfunc( internal-state, next-data-values ) ---> next-internal-state -combinefunc( internal-state, internal-state ) ---> next-internal-state -ffunc( internal-state ) ---> aggregate-value

You - can specify COMBINEFUNC as method for optimizing aggregate execution. By - specifying COMBINEFUNC, the aggregate can be executed in parallel on segments - first and then on the master. When a two-level execution is performed, - SFUNC is executed on the segments to generate partial aggregate results, - and COMBINEFUNC is executed on the master to aggregate the partial results from - segments. If single-level aggregation is performed, all the rows are sent to the master and - sfunc is applied to the rows.

Single-level aggregation and - two-level aggregation are equivalent execution strategies. Either type of aggregation can be - implemented in a query plan. When you implement the functions combinefunc and - sfunc, you must ensure that the invocation of sfunc on - the segment instances followed by combinefunc on the master produce the same - result as single-level aggregation that sends all the rows to the master and then applies - only the sfunc to the rows.

Greenplum Database creates a temporary - variable of data type stype to hold the current internal state of the aggregate - function. At each input row, the aggregate argument values are calculated and the state - transition function is invoked with the current state value and the new argument values to - calculate a new internal state value. After all the rows have been processed, the final - function is invoked once to calculate the aggregate return value. If there is no final - function then the ending state value is returned as-is.

An aggregate function can + follows:

sfunc( internal-state, next-data-values ) ---> next-internal-state +ffunc( internal-state ) ---> aggregate-value +combinefunc( internal-state, internal-state ) ---> next-internal-state +

Greenplum Database creates a temporary variable of data type stype to + hold the current internal state of the aggregate function. At each input row, the aggregate + argument values are calculated and the state transition function is invoked with the current + state value and the new argument values to calculate a new internal state value. After all + the rows have been processed, the final function is invoked once to calculate the aggregate + return value. If there is no final function then the ending state value is returned + as-is.

You can specify combinefunc as a method for optimizing + aggregate execution. By specifying combinefunc, the + aggregate can be executed in parallel on segments first and then on the master. When a + two-level execution is performed, sfunc is executed on + the segments to generate partial aggregate results, and + combinefunc is executed on the master to aggregate + the partial results from segments. If single-level aggregation is performed, all the rows + are sent to the master and sfunc is applied to the + rows.

Single-level aggregation and two-level aggregation are equivalent execution strategies. Either + type of aggregation can be implemented in a query plan. When you implement the functions + combinefunc and sfunc, you must ensure that the + invocation of sfunc on the segment instances followed by + combinefunc on the master produce the same result as single-level + aggregation that sends all the rows to the master and then applies only the + sfunc to the rows.

An aggregate function can provide an optional initial condition, an initial value for the internal state value. This is specified and stored in the database as a value of type text, but it must be a valid external representation of a constant of the state value data type. If it is not supplied @@ -62,24 +119,60 @@ ffunc( internal-state ) ---> aggregate-value

You values. This is useful for implementing aggregates like max. Note that this behavior is only available when state_data_type is the same as the first input_data_type. When these types are different, you must supply a non-null initial - condition or use a nonstrict transition function.

If the state transition function is - not declared STRICT, then it will be called unconditionally at each input - row, and must deal with NULL inputs and NULL transition - values for itself. This allows the aggregate author to have full control over the aggregate - handling of NULL values.

If the final function is declared + condition or use a nonstrict transition function.

If the state transition function is not declared STRICT, then it will be called + unconditionally at each input row, and must deal with NULL inputs and + NULL transition values for itself. This allows the aggregate author to + have full control over the aggregate's handling of NULL values.

If the final function is declared STRICT, then it will not be called when the ending state value is NULL; instead a NULL result will be returned automatically. (This is the normal behavior of STRICT functions.) In any case the final function has the option of returning a NULL value. For example, the final function for avg returns NULL when it - sees there were zero input rows.

Single argument aggregate functions, such as min or + sees there were zero input rows.

+

+ Sometimes it is useful to declare the final function as taking not just + the state value, but extra parameters corresponding to the aggregate's + input values. The main reason for doing this is if the final function + is polymorphic and the state value's data type would be inadequate to + pin down the result type. These extra parameters are always passed as + NULL (and so the final function must not be strict when + the FINALFUNC_EXTRA option is used), but nonetheless they + are valid parameters. The final function could for example make use + of get_fn_expr_argtype to identify the actual argument type + in the current call. +

+

An aggregate can optionally support moving-aggregate mode, as described in Moving-Aggregate Mode in the PostgreSQL + documentation. This requires specifying the msfunc, + minfunc, and + mstype functions, and optionally the + mspace, + mfinalfunc, + mfinalfunc_extra, and + minitcond functions. Except for + minvfunc, these functions work like the + corresponding simple-aggregate functions without m; they + define a separate implementation of the aggregate that includes an inverse transition + function.

+

The syntax with ORDER BY in the parameter list creates a special type of + aggregate called an ordered-set aggregate; or if HYPOTHETICAL is + specified, then a hypothetical-set aggregate is created. These aggregates operate + over groups of sorted values in order-dependent ways, so that specification of an input sort + order is an essential part of a call. Also, they can have direct arguments, which are + arguments that are evaluated only once per aggregation rather than once per input row. + Hypothetical-set aggregates are a subclass of ordered-set aggregates in which some of the + direct arguments are required to match, in number and data types, the aggregated argument + columns. This allows the values of those direct arguments to be added to the collection of + aggregate-input rows as an additional "hypothetical" row.

+

Single argument aggregate functions, such as min or max, can sometimes be optimized by looking into an index instead of scanning every input row. If this aggregate can be so optimized, indicate it by specifying a sort operator. The basic requirement is that the aggregate must yield the first element in the sort ordering induced by the operator; in other - words:

SELECT agg(col) FROM tab;

must be - equivalent - to:

SELECT col FROM tab ORDER BY col USING sortop LIMIT 1;

Further + words:

SELECT agg(col) FROM tab; +

must be equivalent to:

+ SELECT col FROM tab ORDER BY col USING sortop LIMIT 1;

Further assumptions are that the aggregate function ignores NULL inputs, and that it delivers a NULL result if and only if there were no non-null inputs. Ordinarily, a data type's < operator is the proper sort operator for @@ -90,39 +183,175 @@ ffunc( internal-state ) ---> aggregate-value

You

To be able to create an aggregate function, you must have USAGE privilege on the argument types, the state type, and the return type, as well as EXECUTE privilege on the transition and final functions.

-
ParametersnameThe name (optionally schema-qualified) of the aggregate function -to create.input_data_typeAn input data type on which this aggregate function operates. To -create a zero-argument aggregate function, write * in place of the list -of input data types. An example of such an aggregate is count(*).sfuncThe name of the state transition function to be called for each input -row. For an N-argument aggregate function, the sfunc must take -N+1 arguments, the first being of type state_data_type and the -rest matching the declared input data types of the aggregate. The function -must return a value of type state_data_type. This function takes -the current state value and the current input data values, and returns -the next state value.state_data_typeThe data type for the aggregate state value. -combinefuncThe name of a combine function. This is a function -of two arguments, both of type state_data_type. It must return -a value of state_data_type. A combine function takes two transition -state values and returns a new transition state value representing the -combined aggregation. In Greenplum Database, if the result of the aggregate -function is computed in a segmented fashion, the combine -function is invoked on the individual internal states in order to combine -them into an ending internal state.Note that this function is also called in hash aggregate mode within -a segment. Therefore, if you call this aggregate function without a combine -function, hash aggregate is never chosen. Since hash aggregate is efficient, -consider defining combine function whenever possible. -ffuncThe name of the final function called to compute the aggregate result after all input rows have - been traversed. The function must take a single argument of type +
Parameters + + + name + The name (optionally schema-qualified) of the aggregate function to create. + + + argmode + The mode of an argument: IN or VARIADIC. (Aggregate + functions do not support OUT arguments.) If omitted, the default is + IN. Only the last argument can be marked + VARIADIC. + + + argname + The name of an argument. This is currently only useful for documentation purposes. If + omitted, the argument has no name. + + + arg_data_type + An input data type on which this aggregate function operates. To create a + zero-argument aggregate function, write * in place of the list of + argument specifications. (An example of such an aggregate is count(*).) + + + + base_type + In the old syntax for CREATE AGGREGATE, the input data type is + specified by a basetype parameter rather than being written next to the + aggregate name. Note that this syntax allows only one input parameter. To define a + zero-argument aggregate function with this syntax, specify the basetype + as "ANY" (not *). Ordered-set aggregates cannot be + defined with the old syntax. + + + sfunc + The name of the state transition function to be called for each input row. For a + normal N-argument aggregate function, the sfunc must take N+1 + arguments, the first being of type state_data_type and the rest + matching the declared input data types of the aggregate. The function must return a + value of type state_data_type. This function takes the current state + value and the current input data values, and returns the next state value. + For ordered-set (including hypothetical-set) aggregates, the state transition function + receives only the current state value and the aggregated arguments, not the direct + arguments. Otherwise it is the same. + + + state_data_type + The data type for the aggregate state value. + + + state_data_size + The approximate average size (in bytes) of the aggregate's state value. If this + parameter is omitted or is zero, a default estimate is used based on the + state_data_type. The planner uses this value to estimate the memory + required for a grouped aggregate query. Large values of this parameter discourage use of + hash aggregation. + + + ffunc + The name of the final function called to compute the aggregate result after all input + rows have been traversed. The function must take a single argument of type state_data_type. The return data type of the aggregate is defined as - the return type of this function. If ffunc is not specified, then the + the return type of this function. If ffunc is not specified, then the ending state value is used as the aggregate result, and the return type is - state_data_type. initial_conditionThe initial setting for the state value. This must be a string constant in the form accepted for - the data type state_data_type. If not specified, the state value starts out - NULL. sort_operatorThe associated sort operator for a MIN- or MAX-like aggregate function. -This is just an operator name (possibly schema-qualified). The operator -is assumed to have the same input data types as the aggregate function -(which must be a single-argument aggregate function).
- + state_data_type. + For ordered-set (including hypothetical-set) aggregates, the final function receives + not only the final state value, but also the values of all the direct arguments. + If FINALFUNC_EXTRA is specified, then in addition to the final state + value and any direct arguments, the final function receives extra NULL values + corresponding to the aggregate's regular (aggregated) arguments. This is mainly useful + to allow correct resolution of the aggregate result type when a polymorphic aggregate is + being defined. + + + serialfunc + An aggregate function whose state_data_type is + internal can participate in parallel aggregation only if it has a + serialfunc function, which must serialize the aggregate state into + a bytea value for transmission to another process. This function must + take a single argument of type internal and return type + bytea. A corresponding deserialfunc is also + required. + + + deserialfunc + Deserialize a previously serialized aggregate state back into + state_data_type. This function must take two arguments of types + bytea and internal, and produce a result of type + internal. (Note: the second, internal argument is + unused, but is required for type safety reasons.) + + + initial_condition + The initial setting for the state value. This must be a string constant in the form + accepted for the data type state_data_type. If not specified, the + state value starts out null. + + + msfunc + 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 mstate_data_type, which + might be different from state_data_type. + + + minvfunc + 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 msfunc, + 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. + + + mstate_data_type + The data type for the aggregate's state value, when using moving-aggregate mode. + + + + mstate_data_size + The approximate average size (in bytes) of the aggregate's state value, when using + moving-aggregate mode. This works the same as state_data_size. + + + mffunc + 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 + ffunc, except that its first argument's type is + mstate_data_type and extra dummy arguments are specified by writing + MFINALFUNC_EXTRA. The aggregate result type determined by + mffunc or mstate_data_type must match that + determined by the aggregate's regular implementation. + + + minitial_condition + The initial setting for the state value, when using moving-aggregate mode. This works + the same as initial_condition. + + + sort_operator + The associated sort operator for a MIN- or MAX-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 normal aggregate). + + + HYPOTHETICAL + For ordered-set aggregates only, this flag specifies that the aggregate arguments are + to be processed according to the requirements for hypothetical-set aggregates: that is, + the last few direct arguments must match the data types of the aggregated + (WITHIN GROUP) arguments. The HYPOTHETICAL flag has + no effect on run-time behavior, only on parse-time resolution of the data types and + collations of the aggregate's arguments. + + + combinefunc + The name of a combine function. This is a function of two arguments, both of type + state_data_type. It must return a value of + state_data_type. A combine function takes two transition state + values and returns a new transition state value representing the combined aggregation. + In Greenplum Database, if the result of the aggregate function is computed in a + segmented fashion, the combine function is invoked on the individual internal states in + order to combine them into an ending internal state. + Note that this function is also called in hash aggregate mode within a segment. + Therefore, if you call this aggregate function without a combine function, hash + aggregate is never chosen. Since hash aggregate is efficient, consider defining a combine + function whenever possible. + +
Notes

The ordinary functions used to define a new aggregate function must @@ -153,16 +382,16 @@ ordered aggregate, using the syntax: COMBINEFUNC.

Example

The following simple example creates an aggregate function that computes -the sum of two columns.

Before creating the aggregate function, create two functions that -are used as the SFUNC and COMBINEFUNC functions -of the aggregate function.

This function is specified as the SFUNC function -in the aggregate function.

CREATE FUNCTION mysfunc_accum(numeric, numeric, numeric) +the sum of two columns.

Before creating the aggregate function, create two functions that are used as the + sfunc and + combinefunc functions of the aggregate function.

This function is specified as the sfunc function in the + aggregate function.

CREATE FUNCTION mysfunc_accum(numeric, numeric, numeric)   RETURNS numeric    AS 'select $1 + $2 + $3'    LANGUAGE SQL    IMMUTABLE -   RETURNS NULL ON NULL INPUT;

This function is specified as the COMBINEFUNC function in -the aggregate function.

CREATE FUNCTION mycombine_accum(numeric, numeric ) +   RETURNS NULL ON NULL INPUT;

This function is specified as the combinefunc function in the + aggregate function.

CREATE FUNCTION mycombine_accum(numeric, numeric )   RETURNS numeric    AS 'select $1 + $2'    LANGUAGE SQL @@ -187,8 +416,8 @@ Aggregate (cost=1.10..1.11 rows=1 width=32)        width=32)     -> Aggregate (cost=1.04..1.05 rows=1 width=32)       -> Seq Scan on t1 (cost=0.00..1.03 rows=2 width=8) - (4 rows)
Compatibility

CREATE AGGREGATE is a Greenplum Database language extension. -The SQL standard does not provide for user-defined aggregate functions.

See Also

, + (4 rows)

Compatibility

CREATE AGGREGATE is a Greenplum Database language extension. The SQL standard + does not provide for user-defined aggregate functions.

See Also

, ,

diff --git a/gpdb-doc/dita/ref_guide/sql_commands/CREATE_FUNCTION.xml b/gpdb-doc/dita/ref_guide/sql_commands/CREATE_FUNCTION.xml index eed928fa6a..d507b77567 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/CREATE_FUNCTION.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/CREATE_FUNCTION.xml @@ -290,8 +290,9 @@ SELECT foo();

In The SET clause applies a value to a session configuration parameter when the function is entered. The configuration parameter is restored to its prior value when the function exits. SET FROM - CURRENT applies the session's current value of the parameter - when the function is entered. + CURRENT saves the value of the parameter that is current when + CREATE FUNCTION is executed as the value to be applied + when the function is entered. definition @@ -308,7 +309,11 @@ SELECT foo();

In dynamically loadable object, and link_symbol is the name of the function in the C language source code. If the link symbol is omitted, it is assumed to be the same as the name of the SQL function being - defined. It is recommended to locate shared libraries either relative to + defined. The C names + of all functions must be different, so you must give overloaded SQL + functions different C names (for example, use the argument types as + part of the C names). + It is recommended to locate shared libraries either relative to $libdir (which is located at $GPHOME/lib) or through the dynamic library path (set by the dynamic_library_path server configuration diff --git a/gpdb-doc/dita/ref_guide/sql_commands/DROP_ROLE.xml b/gpdb-doc/dita/ref_guide/sql_commands/DROP_ROLE.xml index 831e656e5a..9a35b89fb7 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/DROP_ROLE.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/DROP_ROLE.xml @@ -3,12 +3,12 @@ PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd"> DROP ROLE

Removes a database role.

SynopsisDROP ROLE [IF EXISTS] name [, ...]
Description

DROP ROLE removes the specified role(s). To drop a superuser role, you must be a superuser yourself. To drop non-superuser -roles, you must have CREATEROLE privilege.

A role cannot be removed if it is still referenced in any database; -an error will be raised if so. Before dropping the role, you must drop -all the objects it owns (or reassign their ownership) and revoke any -privileges the role has been granted. The REASSIGN OWNED -and DROP OWNED commands can be useful for this purpose. -

However, it is not necessary to remove role memberships involving +roles, you must have CREATEROLE privilege.

A role cannot be removed if it is still referenced in any database; an error will be raised if + so. Before dropping the role, you must drop all the objects it owns (or reassign their + ownership) and revoke any privileges the role has been granted on other objects. The + REASSIGN OWNED and + DROP OWNED commands can be + useful for this purpose.

However, it is not necessary to remove role memberships involving the role; DROP ROLE automatically revokes any memberships of the target role in other roles, and of other roles in the target role. The other roles are not dropped nor otherwise affected.

ParametersIF EXISTSDo not throw an error if the role does not exist. A notice is issued diff --git a/gpdb-doc/dita/ref_guide/sql_commands/PREPARE.xml b/gpdb-doc/dita/ref_guide/sql_commands/PREPARE.xml index f1e98546af..1c5a3ec660 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/PREPARE.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/PREPARE.xml @@ -10,14 +10,13 @@ issued, the prepared statement is planned and executed. This division of labor avoids repetitive parse analysis work, while allowing the execution plan to depend on the specific parameter values supplied.

-

Prepared statements can take parameters: values that are substituted -into the statement when it is executed. When creating the prepared statement, -refer to parameters by position, using $1, $2, -etc. A corresponding list of parameter data types can optionally be specified. -When a parameter's data type is not specified or is declared as unknown, -the type is inferred from the context in which the parameter is used -(if possible). When executing the statement, specify the actual values -for these parameters in the EXECUTE statement.

Prepared statements only last for the duration of the current database session. When the session +

Prepared statements can take parameters: values that are substituted into the statement when it + is executed. When creating the prepared statement, refer to parameters by position, using + $1, $2, etc. A corresponding list of parameter data + types can optionally be specified. When a parameter's data type is not specified or is + declared as unknown, the type is inferred from the context in which the parameter is first + used (if possible). When executing the statement, specify the actual values for these + parameters in the EXECUTE statement.

Prepared statements only last for the duration of the current database session. When the session ends, the prepared statement is forgotten, so it must be recreated before being used again. This also means that a single prepared statement cannot be used by multiple simultaneous database clients; however, each client can create their own prepared statement to use. @@ -31,11 +30,10 @@ the statement is relatively simple to plan and rewrite but relatively expensive to execute, the performance advantage of prepared statements will be less noticeable.

ParametersnameAn arbitrary name given to this particular prepared statement. It must be unique within a single session and is subsequently used to execute -or deallocate a previously prepared statement.datatypeThe data type of a parameter to the prepared statement. If the data -type of a particular parameter is unspecified or is specified as unknown, -it will be inferred from the context in which the parameter is used. -To refer to the parameters in the prepared statement itself, use $1, -$2, etc. statementAny SELECT, INSERT, UPDATE, +or deallocate a previously prepared statement.datatypeThe data type of a parameter to the prepared statement. If the data type of a particular + parameter is unspecified or is specified as unknown, it will be inferred from the + context in which the parameter is first used. To refer to the parameters in the prepared + statement itself, use $1, $2, etc. statementAny SELECT, INSERT, UPDATE, DELETE, or VALUES statement.
Notes

If a prepared statement is executed enough times, the server may eventually decide to save and re-use a generic plan rather than re-planning each time. This will occur immediately if diff --git a/gpdb-doc/dita/ref_guide/sql_commands/REASSIGN_OWNED.xml b/gpdb-doc/dita/ref_guide/sql_commands/REASSIGN_OWNED.xml index 17e15c5a81..15a227b333 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/REASSIGN_OWNED.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/REASSIGN_OWNED.xml @@ -12,6 +12,7 @@

Description

REASSIGN OWNED changes the ownership of database objects owned by any of + the old_roles to new_role.

@@ -38,10 +39,10 @@

REASSIGN OWNED requires privileges on both the source role(s) and the target role.

The DROP OWNED command is an - alternative that drops all the database objects owned by one or more roles. DROP - OWNED requires privileges only on the source role(s).

-

The REASSIGN OWNED command does not affect the privileges granted to the - old roles in objects that are not owned by them. Use DROP OWNED to revoke + alternative that simply drops all of the database objects owned by one or more roles. + DROP OWNED requires privileges only on the source role(s).

+

The REASSIGN OWNED command does not affect any privileges granted to the + old roles for objects that are not owned by them. Use DROP OWNED to revoke those privileges.

@@ -52,7 +53,7 @@
Compatibility -

The REASSIGN OWNED statement is a Greenplum Database extension.

+

The REASSIGN OWNED command is a Greenplum Database extension.

See Also diff --git a/gpdb-doc/dita/ref_guide/sql_commands/REINDEX.xml b/gpdb-doc/dita/ref_guide/sql_commands/REINDEX.xml index ad7bc428b4..103523c21b 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/REINDEX.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/REINDEX.xml @@ -55,7 +55,7 @@ REINDEX locks out writes but not reads of the index's parent table. It also takes an exclusive lock on the specific index being processed, which will block reads that attempt to use that index. In contrast, DROP INDEX momentarily takes - exclusive lock on the parent table, blocking both writes and reads. The subsequent + an exclusive lock on the parent table, blocking both writes and reads. The subsequent CREATE INDEX locks out writes but not reads; since the index is not there, no read will attempt to use it, meaning that there will be no blocking but reads may be forced into expensive sequential scans.

diff --git a/gpdb-doc/dita/utility_guide/client_utilities/pg_dump.xml b/gpdb-doc/dita/utility_guide/client_utilities/pg_dump.xml index 7dc69d692a..5437ef0454 100644 --- a/gpdb-doc/dita/utility_guide/client_utilities/pg_dump.xml +++ b/gpdb-doc/dita/utility_guide/client_utilities/pg_dump.xml @@ -83,8 +83,12 @@ -b | --blobs Include large objects in the dump. This is the default behavior except when --schema, --table, or - --schema-only is specified, so the -b switch is - only useful to add large objects to selective dumps.Greenplum Database does not + --schema-only is specified. The -b switch is + only useful add large objects to dumps + where a specific schema or table has been requested. Note that + blobs are considered data and therefore will be included when + --data-only is used, but not when --schema-only is. + Greenplum Database does not support the PostgreSQL large object facility for streaming user data that is @@ -153,7 +157,7 @@ href="./pg_restore.xml#topic1" type="topic" format="dita"/>. The tar format is compatible with the directory format; extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support - compression and has a limit of 8 GB on the size of individual tables. Also, the + compression. Also, when using tar format the relative order of table data items cannot be changed during restore. @@ -375,6 +379,12 @@ To exclude data for all tables in the database, see --schema-only. + + --if-exists + Use conditional commands (i.e. add an IF EXISTS clause) when + cleaning database objects. This option is not valid unless --clean is + also specified. + --inserts Dump data as INSERT commands (rather than COPY). @@ -563,17 +573,26 @@ pg_dump emits commands to disable triggers on user tables before inserting the data and commands to re-enable them after the data has been inserted. If the restore is stopped in the middle, the system catalogs may be left in the wrong state.

-

Members of tar archives are limited to a size less than 8 GB. (This is an - inherent limitation of the tar file format.) Therefore this format cannot - be used if the textual representation of any one table exceeds that size. The total size of - a tar archive and any of the other output formats is not limited, except possibly by the - operating system.

The dump file produced by pg_dump does not contain the statistics used by the optimizer to make query planning decisions. Therefore, it is wise to run - ANALYZE after restoring from a dump file to ensure optimal performance.

+ ANALYZE after restoring from a dump file to ensure optimal + performance.

The database activity of pg_dump is normally collected by the statistics collector. If this is undesirable, you can set parameter track_counts to false via PGOPTIONS or the ALTER USER command.

+

Because pg_dump may be used to transfer data to newer versions of + Greenplum Database, the output of pg_dump can be expected to load into + Greenplum Database versions newer than pg_dump's version. + pg_dump can also dump from Greenplum Database versions older than its own + version. However, pg_dump cannot dump from Greenplum Database versions + newer than its own major version; it will refuse to even try, rather than risk making an + invalid dump. Also, it is not guaranteed that pg_dump's output can be + loaded into a server of an older major version — not even if the dump was taken from a + server of that version. Loading a dump file into an older server may require manual editing + of the dump file to remove syntax not understood by the older server. Use of the + --quote-all-identifiers option is recommended in cross-version cases, as + it can prevent problems arising from varying reserved-word lists in different Greenplum + Database versions.

Examples -- GitLab