mirror of https://github.com/postgres/postgres
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
904 B
33 lines
904 B
|
15 years ago
|
/* contrib/intagg/intagg--1.0.sql */
|
||
|
24 years ago
|
|
||
|
|
-- Internal function for the aggregate
|
||
|
|
-- Is called for each item in an aggregation
|
||
|
15 years ago
|
CREATE FUNCTION int_agg_state (internal, int4)
|
||
|
17 years ago
|
RETURNS internal
|
||
|
|
AS 'array_agg_transfn'
|
||
|
|
LANGUAGE INTERNAL;
|
||
|
24 years ago
|
|
||
|
|
-- Internal function for the aggregate
|
||
|
|
-- Is called at the end of the aggregation, and returns an array.
|
||
|
15 years ago
|
CREATE FUNCTION int_agg_final_array (internal)
|
||
|
24 years ago
|
RETURNS int4[]
|
||
|
17 years ago
|
AS 'array_agg_finalfn'
|
||
|
|
LANGUAGE INTERNAL;
|
||
|
24 years ago
|
|
||
|
22 years ago
|
-- The aggregate function itself
|
||
|
24 years ago
|
-- uses the above functions to create an array of integers from an aggregation.
|
||
|
23 years ago
|
CREATE AGGREGATE int_array_aggregate (
|
||
|
24 years ago
|
BASETYPE = int4,
|
||
|
|
SFUNC = int_agg_state,
|
||
|
17 years ago
|
STYPE = internal,
|
||
|
21 years ago
|
FINALFUNC = int_agg_final_array
|
||
|
24 years ago
|
);
|
||
|
|
|
||
|
|
-- The enumeration function
|
||
|
21 years ago
|
-- returns each element in a one dimensional integer array
|
||
|
24 years ago
|
-- as a row.
|
||
|
15 years ago
|
CREATE FUNCTION int_array_enum(int4[])
|
||
|
24 years ago
|
RETURNS setof integer
|
||
|
17 years ago
|
AS 'array_unnest'
|
||
|
|
LANGUAGE INTERNAL IMMUTABLE STRICT;
|