forked from okbob/pltoolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpltoolbox--1.0.3.sql
218 lines (165 loc) · 7.14 KB
/
pltoolbox--1.0.3.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
CREATE SCHEMA pst;
CREATE OR REPLACE FUNCTION pst.sprintf(fmt text, VARIADIC args "any")
RETURNS text
AS 'MODULE_PATHNAME','pst_sprintf'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION pst.sprintf(fmt text)
RETURNS text
AS 'MODULE_PATHNAME','pst_sprintf_nv'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION pst.format(fmt text, VARIADIC args "any")
RETURNS text
AS 'MODULE_PATHNAME','pst_format'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION pst.format(fmt text)
RETURNS text
AS 'MODULE_PATHNAME','pst_format_nv'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION pst.concat(VARIADIC args "any")
RETURNS text
AS 'MODULE_PATHNAME','pst_concat'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION pst.concat_ws(separator text, VARIADIC args "any")
RETURNS text
AS 'MODULE_PATHNAME','pst_concat_ws'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION pst.concat_js(VARIADIC args "any")
RETURNS text
AS 'MODULE_PATHNAME','pst_concat_js'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION pst.concat_sql(VARIADIC args "any")
RETURNS text
AS 'MODULE_PATHNAME','pst_concat_sql'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION pst.rvrs(str text)
RETURNS text
AS 'MODULE_PATHNAME','pst_rvrs'
LANGUAGE C IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION pst.reverse(str text)
RETURNS text
AS 'MODULE_PATHNAME','pst_rvrs'
LANGUAGE C IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION pst.left(str text, n int)
RETURNS text
AS 'MODULE_PATHNAME','pst_left'
LANGUAGE C IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION pst.right(str text, n int)
RETURNS text
AS 'MODULE_PATHNAME','pst_right'
LANGUAGE C IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION pst.chars_to_array(str text)
RETURNS text[]
AS 'MODULE_PATHNAME','pst_chars_to_array'
LANGUAGE C IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION pst.next_day(day date, dow text)
RETURNS date
AS 'MODULE_PATHNAME','pst_next_day'
LANGUAGE C IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION pst.last_day(day date)
RETURNS date
AS 'MODULE_PATHNAME','pst_last_day'
LANGUAGE C IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION pst.counter(anyelement, int, bool)
RETURNS anyelement
AS 'MODULE_PATHNAME','pst_counter' LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION pst.diff_string(S text, T text)
RETURNS text
AS 'MODULE_PATHNAME','pst_diff_string' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.lc_substring(S text, T text)
RETURNS text
AS 'MODULE_PATHNAME','pst_lc_substring' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.record_expand(record, OUT name text, OUT value text, OUT typ text)
RETURNS SETOF record
AS 'MODULE_PATHNAME','pst_record_expand' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.record_get_field(record, name text)
RETURNS text
AS 'MODULE_PATHNAME','pst_record_get_field' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.record_get_fields(record, VARIADIC names text[])
RETURNS text[]
AS 'MODULE_PATHNAME','pst_record_get_fields' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.record_set_fields(anyelement, VARIADIC params "any")
RETURNS anyelement
AS 'MODULE_PATHNAME','pst_record_set_fields_any' LANGUAGE C;
CREATE OR REPLACE FUNCTION pst.record_set_fields(anyelement, VARIADIC params text[])
RETURNS anyelement
AS 'MODULE_PATHNAME','pst_record_set_fields_textarray' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.format_op(text, "any")
RETURNS text AS 'MODULE_PATHNAME', 'pst_format_op' LANGUAGE C;
CREATE OPERATOR public.%% (
procedure = pst.format_op,
LEFTARG = text,
RIGHTARG = "any"
);
CREATE OPERATOR pst.%% (
procedure = pst.format_op,
LEFTARG = text,
RIGHTARG = "any"
);
CREATE OR REPLACE FUNCTION pst.bitmapset_in(cstring)
RETURNS pst.bitmapset AS 'MODULE_PATHNAME','pst_bms_in' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.bitmapset_out(pst.bitmapset)
RETURNS cstring AS 'MODULE_PATHNAME','pst_bms_out' LANGUAGE C STRICT;
CREATE TYPE pst.bitmapset (
internallength = variable,
input = pst.bitmapset_in,
output = pst.bitmapset_out,
like = bytea
);
CREATE OR REPLACE FUNCTION pst.add_member(pst.bitmapset, int)
RETURNS pst.bitmapset AS 'MODULE_PATHNAME','pst_bms_add_member' LANGUAGE C;
CREATE OR REPLACE FUNCTION pst.add_members(pst.bitmapset, VARIADIC int[])
RETURNS pst.bitmapset AS 'MODULE_PATHNAME','pst_bms_add_members' LANGUAGE C;
CREATE OR REPLACE FUNCTION pst.del_member(pst.bitmapset, int)
RETURNS pst.bitmapset AS 'MODULE_PATHNAME','pst_bms_del_member' LANGUAGE C;
CREATE OR REPLACE FUNCTION pst.del_members(pst.bitmapset, VARIADIC int[])
RETURNS pst.bitmapset AS 'MODULE_PATHNAME','pst_bms_del_members' LANGUAGE C;
CREATE OR REPLACE FUNCTION pst.is_member(pst.bitmapset, int)
RETURNS bool AS 'MODULE_PATHNAME','pst_bms_is_member' LANGUAGE C;
CREATE OR REPLACE FUNCTION pst.bms_to_intarray(pst.bitmapset)
RETURNS int[] AS 'MODULE_PATHNAME','pst_bms_to_intarray' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.intarray_to_bms(int[])
RETURNS pst.bitmapset AS 'MODULE_PATHNAME','pst_intarray_to_bms' LANGUAGE C STRICT;
CREATE CAST (pst.bitmapset AS int[]) WITH FUNCTION pst.bms_to_intarray(pst.bitmapset);
CREATE CAST (int[] AS pst.bitmapset) WITH FUNCTION pst.intarray_to_bms(int[]);
CREATE OR REPLACE FUNCTION pst.bitmapset_equal(pst.bitmapset, pst.bitmapset)
RETURNS bool AS 'MODULE_PATHNAME','pst_bms_equal' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.bitmapset_union(pst.bitmapset, pst.bitmapset)
RETURNS pst.bitmapset AS 'MODULE_PATHNAME','pst_bms_union' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.bitmapset_intersect(pst.bitmapset, pst.bitmapset)
RETURNS pst.bitmapset AS 'MODULE_PATHNAME','pst_bms_intersect' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.bitmapset_is_subset(pst.bitmapset, pst.bitmapset)
RETURNS bool AS 'MODULE_PATHNAME','pst_bms_is_subset' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.bitmapset_overlap(pst.bitmapset, pst.bitmapset)
RETURNS bool AS 'MODULE_PATHNAME','pst_bms_is_overlap' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.bitmapset_num_members(pst.bitmapset)
RETURNS int AS 'MODULE_PATHNAME','pst_bms_num_members' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.bitmapset_is_empty(pst.bitmapset)
RETURNS bool AS 'MODULE_PATHNAME','pst_bms_is_empty' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.bitmapset_difference(pst.bitmapset, pst.bitmapset)
RETURNS pst.bitmapset AS 'MODULE_PATHNAME','pst_bms_difference' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION pst.bitmapset_nonempty_difference(pst.bitmapset, pst.bitmapset)
RETURNS bool AS 'MODULE_PATHNAME','pst_bms_nonempty_difference' LANGUAGE C STRICT;
CREATE OPERATOR || (
PROCEDURE = pst.bitmapset_union,
LEFTARG = pst.bitmapset,
RIGHTARG = pst.bitmapset
);
CREATE OPERATOR || (
PROCEDURE = pst.add_member,
LEFTARG = pst.bitmapset,
RIGHTARG = int
);
CREATE OPERATOR = (
PROCEDURE = pst.bitmapset_equal,
LEFTARG = pst.bitmapset,
RIGHTARG = pst.bitmapset
);
CREATE OR REPLACE FUNCTION pst.bitmapset_collect_transfn(internal, int)
RETURNS internal AS 'MODULE_PATHNAME','pst_bms_collect_transfn' LANGUAGE C;
CREATE OR REPLACE FUNCTION pst.bitmapset_collect_final(internal)
RETURNS pst.bitmapset AS 'MODULE_PATHNAME','pst_bms_collect_final' LANGUAGE C;
CREATE AGGREGATE pst.bitmapset_collect (int) (
sfunc = pst.bitmapset_collect_transfn,
stype = internal,
finalfunc = pst.bitmapset_collect_final
);