mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-04 22:16:54 +02:00
74883d3373
Initially it was called int_aggregate after the old SQL file, but since the documentation just says "intagg" and that's also the directory name, let's conform to that instead.
33 lines
904 B
SQL
33 lines
904 B
SQL
/* contrib/intagg/intagg--1.0.sql */
|
|
|
|
-- Internal function for the aggregate
|
|
-- Is called for each item in an aggregation
|
|
CREATE FUNCTION int_agg_state (internal, int4)
|
|
RETURNS internal
|
|
AS 'array_agg_transfn'
|
|
LANGUAGE INTERNAL;
|
|
|
|
-- Internal function for the aggregate
|
|
-- Is called at the end of the aggregation, and returns an array.
|
|
CREATE FUNCTION int_agg_final_array (internal)
|
|
RETURNS int4[]
|
|
AS 'array_agg_finalfn'
|
|
LANGUAGE INTERNAL;
|
|
|
|
-- The aggregate function itself
|
|
-- uses the above functions to create an array of integers from an aggregation.
|
|
CREATE AGGREGATE int_array_aggregate (
|
|
BASETYPE = int4,
|
|
SFUNC = int_agg_state,
|
|
STYPE = internal,
|
|
FINALFUNC = int_agg_final_array
|
|
);
|
|
|
|
-- The enumeration function
|
|
-- returns each element in a one dimensional integer array
|
|
-- as a row.
|
|
CREATE FUNCTION int_array_enum(int4[])
|
|
RETURNS setof integer
|
|
AS 'array_unnest'
|
|
LANGUAGE INTERNAL IMMUTABLE STRICT;
|