~ubuntu-branches/debian/sid/postgresql-9.3/sid

« back to all changes in this revision

Viewing changes to contrib/intagg/intagg--1.0.sql

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-05-08 05:39:52 UTC
  • Revision ID: package-import@ubuntu.com-20130508053952-1j7uilp7mjtrvq8q
Tags: upstream-9.3~beta1
ImportĀ upstreamĀ versionĀ 9.3~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* contrib/intagg/intagg--1.0.sql */
 
2
 
 
3
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
 
4
\echo Use "CREATE EXTENSION intagg" to load this file. \quit
 
5
 
 
6
-- Internal function for the aggregate
 
7
-- Is called for each item in an aggregation
 
8
CREATE FUNCTION int_agg_state (internal, int4)
 
9
RETURNS internal
 
10
AS 'array_agg_transfn'
 
11
LANGUAGE INTERNAL;
 
12
 
 
13
-- Internal function for the aggregate
 
14
-- Is called at the end of the aggregation, and returns an array.
 
15
CREATE FUNCTION int_agg_final_array (internal)
 
16
RETURNS int4[]
 
17
AS 'array_agg_finalfn'
 
18
LANGUAGE INTERNAL;
 
19
 
 
20
-- The aggregate function itself
 
21
-- uses the above functions to create an array of integers from an aggregation.
 
22
CREATE AGGREGATE int_array_aggregate (
 
23
        BASETYPE = int4,
 
24
        SFUNC = int_agg_state,
 
25
        STYPE = internal,
 
26
        FINALFUNC = int_agg_final_array
 
27
);
 
28
 
 
29
-- The enumeration function
 
30
-- returns each element in a one dimensional integer array
 
31
-- as a row.
 
32
CREATE FUNCTION int_array_enum(int4[])
 
33
RETURNS setof integer
 
34
AS 'array_unnest'
 
35
LANGUAGE INTERNAL IMMUTABLE STRICT;