1/* contrib/tablefunc/tablefunc--1.0.sql */
2
3-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4\echo Use "CREATE EXTENSION tablefunc" to load this file. \quit
5
6CREATE FUNCTION normal_rand(int4, float8, float8)
7RETURNS setof float8
8AS 'MODULE_PATHNAME','normal_rand'
9LANGUAGE C VOLATILE STRICT;
10
11-- the generic crosstab function:
12CREATE FUNCTION crosstab(text)
13RETURNS setof record
14AS 'MODULE_PATHNAME','crosstab'
15LANGUAGE C STABLE STRICT;
16
17-- examples of building custom type-specific crosstab functions:
18CREATE TYPE tablefunc_crosstab_2 AS
19(
20	row_name TEXT,
21	category_1 TEXT,
22	category_2 TEXT
23);
24
25CREATE TYPE tablefunc_crosstab_3 AS
26(
27	row_name TEXT,
28	category_1 TEXT,
29	category_2 TEXT,
30	category_3 TEXT
31);
32
33CREATE TYPE tablefunc_crosstab_4 AS
34(
35	row_name TEXT,
36	category_1 TEXT,
37	category_2 TEXT,
38	category_3 TEXT,
39	category_4 TEXT
40);
41
42CREATE FUNCTION crosstab2(text)
43RETURNS setof tablefunc_crosstab_2
44AS 'MODULE_PATHNAME','crosstab'
45LANGUAGE C STABLE STRICT;
46
47CREATE FUNCTION crosstab3(text)
48RETURNS setof tablefunc_crosstab_3
49AS 'MODULE_PATHNAME','crosstab'
50LANGUAGE C STABLE STRICT;
51
52CREATE FUNCTION crosstab4(text)
53RETURNS setof tablefunc_crosstab_4
54AS 'MODULE_PATHNAME','crosstab'
55LANGUAGE C STABLE STRICT;
56
57-- obsolete:
58CREATE FUNCTION crosstab(text,int)
59RETURNS setof record
60AS 'MODULE_PATHNAME','crosstab'
61LANGUAGE C STABLE STRICT;
62
63CREATE FUNCTION crosstab(text,text)
64RETURNS setof record
65AS 'MODULE_PATHNAME','crosstab_hash'
66LANGUAGE C STABLE STRICT;
67
68CREATE FUNCTION connectby(text,text,text,text,int,text)
69RETURNS setof record
70AS 'MODULE_PATHNAME','connectby_text'
71LANGUAGE C STABLE STRICT;
72
73CREATE FUNCTION connectby(text,text,text,text,int)
74RETURNS setof record
75AS 'MODULE_PATHNAME','connectby_text'
76LANGUAGE C STABLE STRICT;
77
78-- These 2 take the name of a field to ORDER BY as 4th arg (for sorting siblings)
79
80CREATE FUNCTION connectby(text,text,text,text,text,int,text)
81RETURNS setof record
82AS 'MODULE_PATHNAME','connectby_text_serial'
83LANGUAGE C STABLE STRICT;
84
85CREATE FUNCTION connectby(text,text,text,text,text,int)
86RETURNS setof record
87AS 'MODULE_PATHNAME','connectby_text_serial'
88LANGUAGE C STABLE STRICT;
89