@oliphaunt/extension-pgtap-linux-arm64-gnu 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +6 -0
- package/THIRD_PARTY_NOTICES.md +20 -0
- package/extension-contract.json +31 -0
- package/package.json +49 -0
- package/runtime/share/licenses/pgtap/README.md +153 -0
- package/runtime/share/postgresql/extension/pgtap--0.90.0--0.91.0.sql +29 -0
- package/runtime/share/postgresql/extension/pgtap--0.91.0--0.92.0.sql +1650 -0
- package/runtime/share/postgresql/extension/pgtap--0.92.0--0.93.0.sql +679 -0
- package/runtime/share/postgresql/extension/pgtap--0.93.0--0.94.0.sql +193 -0
- package/runtime/share/postgresql/extension/pgtap--0.94.0--0.95.0.sql +639 -0
- package/runtime/share/postgresql/extension/pgtap--0.95.0--0.96.0.sql +415 -0
- package/runtime/share/postgresql/extension/pgtap--0.96.0--0.97.0.sql +375 -0
- package/runtime/share/postgresql/extension/pgtap--0.97.0--0.98.0.sql +441 -0
- package/runtime/share/postgresql/extension/pgtap--0.98.0--0.99.0.sql +209 -0
- package/runtime/share/postgresql/extension/pgtap--0.99.0--1.0.0.sql +737 -0
- package/runtime/share/postgresql/extension/pgtap--1.0.0--1.1.0.sql +186 -0
- package/runtime/share/postgresql/extension/pgtap--1.1.0--1.2.0.sql +889 -0
- package/runtime/share/postgresql/extension/pgtap--1.2.0--1.3.0.sql +495 -0
- package/runtime/share/postgresql/extension/pgtap--1.3.0--1.3.1.sql +229 -0
- package/runtime/share/postgresql/extension/pgtap--1.3.1--1.3.2.sql +34 -0
- package/runtime/share/postgresql/extension/pgtap--1.3.2--1.3.3.sql +42 -0
- package/runtime/share/postgresql/extension/pgtap--1.3.3--1.3.4.sql +89 -0
- package/runtime/share/postgresql/extension/pgtap--1.3.4--1.3.5.sql +1 -0
- package/runtime/share/postgresql/extension/pgtap--1.3.5.sql +11520 -0
- package/runtime/share/postgresql/extension/pgtap--unpackaged--0.91.0.sql +714 -0
- package/runtime/share/postgresql/extension/pgtap-core--1.3.5.sql +4390 -0
- package/runtime/share/postgresql/extension/pgtap-core.sql +4390 -0
- package/runtime/share/postgresql/extension/pgtap-schema--1.3.5.sql +6764 -0
- package/runtime/share/postgresql/extension/pgtap-schema.sql +6764 -0
- package/runtime/share/postgresql/extension/pgtap.control +6 -0
- package/runtime/share/postgresql/extension/pgtap.sql +11520 -0
- package/runtime/share/postgresql/extension/uninstall_pgtap.sql +1088 -0
- package/share/licenses/pgtap/README.md +153 -0
|
@@ -0,0 +1,889 @@
|
|
|
1
|
+
CREATE OR REPLACE FUNCTION pgtap_version()
|
|
2
|
+
RETURNS NUMERIC AS 'SELECT 1.2;'
|
|
3
|
+
LANGUAGE SQL IMMUTABLE;
|
|
4
|
+
|
|
5
|
+
-- isnt_member_of( role, members[], description )
|
|
6
|
+
CREATE OR REPLACE FUNCTION isnt_member_of( NAME, NAME[], TEXT )
|
|
7
|
+
RETURNS TEXT AS $$
|
|
8
|
+
DECLARE
|
|
9
|
+
extra text[];
|
|
10
|
+
BEGIN
|
|
11
|
+
IF NOT _has_role($1) THEN
|
|
12
|
+
RETURN fail( $3 ) || E'\n' || diag (
|
|
13
|
+
' Role ' || quote_ident($1) || ' does not exist'
|
|
14
|
+
);
|
|
15
|
+
END IF;
|
|
16
|
+
|
|
17
|
+
SELECT ARRAY(
|
|
18
|
+
SELECT quote_ident($2[i])
|
|
19
|
+
FROM generate_series(1, array_upper($2, 1)) s(i)
|
|
20
|
+
LEFT JOIN pg_catalog.pg_roles r ON rolname = $2[i]
|
|
21
|
+
WHERE r.oid = ANY ( _grolist($1) )
|
|
22
|
+
ORDER BY s.i
|
|
23
|
+
) INTO extra;
|
|
24
|
+
IF extra[1] IS NULL THEN
|
|
25
|
+
RETURN ok( true, $3 );
|
|
26
|
+
END IF;
|
|
27
|
+
RETURN ok( false, $3 ) || E'\n' || diag(
|
|
28
|
+
' Members, who should not be in ' || quote_ident($1) || E' role:\n ' ||
|
|
29
|
+
array_to_string( extra, E'\n ')
|
|
30
|
+
);
|
|
31
|
+
END;
|
|
32
|
+
$$ LANGUAGE plpgsql;
|
|
33
|
+
|
|
34
|
+
-- isnt_member_of( role, member, description )
|
|
35
|
+
CREATE OR REPLACE FUNCTION isnt_member_of( NAME, NAME, TEXT )
|
|
36
|
+
RETURNS TEXT AS $$
|
|
37
|
+
SELECT isnt_member_of( $1, ARRAY[$2], $3 );
|
|
38
|
+
$$ LANGUAGE SQL;
|
|
39
|
+
|
|
40
|
+
-- isnt_member_of( role, members[] )
|
|
41
|
+
CREATE OR REPLACE FUNCTION isnt_member_of( NAME, NAME[] )
|
|
42
|
+
RETURNS TEXT AS $$
|
|
43
|
+
SELECT isnt_member_of( $1, $2, 'Should not have members of role ' || quote_ident($1) );
|
|
44
|
+
$$ LANGUAGE SQL;
|
|
45
|
+
|
|
46
|
+
-- isnt_member_of( role, member )
|
|
47
|
+
CREATE OR REPLACE FUNCTION isnt_member_of( NAME, NAME )
|
|
48
|
+
RETURNS TEXT AS $$
|
|
49
|
+
SELECT isnt_member_of( $1, ARRAY[$2] );
|
|
50
|
+
$$ LANGUAGE SQL;
|
|
51
|
+
|
|
52
|
+
-- has_view( schema, view )
|
|
53
|
+
CREATE OR REPLACE FUNCTION has_view ( NAME, NAME )
|
|
54
|
+
RETURNS TEXT AS $$
|
|
55
|
+
SELECT has_view ($1, $2,
|
|
56
|
+
'View ' || quote_ident($1) || '.' || quote_ident($2) || ' should exist'
|
|
57
|
+
);
|
|
58
|
+
$$ LANGUAGE SQL;
|
|
59
|
+
|
|
60
|
+
-- hasnt_view( schema, table )
|
|
61
|
+
CREATE OR REPLACE FUNCTION hasnt_view ( NAME, NAME )
|
|
62
|
+
RETURNS TEXT AS $$
|
|
63
|
+
SELECT hasnt_view( $1, $2,
|
|
64
|
+
'View ' || quote_ident($1) || '.' || quote_ident($2) || ' should not exist'
|
|
65
|
+
);
|
|
66
|
+
$$ LANGUAGE SQL;
|
|
67
|
+
|
|
68
|
+
CREATE OR REPLACE FUNCTION _def_is( TEXT, TEXT, anyelement, TEXT )
|
|
69
|
+
RETURNS TEXT AS $$
|
|
70
|
+
DECLARE
|
|
71
|
+
thing text;
|
|
72
|
+
BEGIN
|
|
73
|
+
-- Function, cast, or special SQL syntax.
|
|
74
|
+
IF $1 ~ '^[^'']+[(]' OR $1 ~ '[)]::[^'']+$' OR $1 = ANY('{CURRENT_CATALOG,CURRENT_ROLE,CURRENT_SCHEMA,CURRENT_USER,SESSION_USER,USER,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,LOCALTIME,LOCALTIMESTAMP}') THEN
|
|
75
|
+
RETURN is( $1, $3, $4 );
|
|
76
|
+
END IF;
|
|
77
|
+
|
|
78
|
+
EXECUTE 'SELECT is('
|
|
79
|
+
|| COALESCE($1, 'NULL' || '::' || $2) || '::' || $2 || ', '
|
|
80
|
+
|| COALESCE(quote_literal($3), 'NULL') || '::' || $2 || ', '
|
|
81
|
+
|| COALESCE(quote_literal($4), 'NULL')
|
|
82
|
+
|| ')' INTO thing;
|
|
83
|
+
RETURN thing;
|
|
84
|
+
END;
|
|
85
|
+
$$ LANGUAGE plpgsql;
|
|
86
|
+
|
|
87
|
+
-- results_eq( cursor, cursor, description )
|
|
88
|
+
CREATE OR REPLACE FUNCTION results_eq( refcursor, refcursor, text )
|
|
89
|
+
RETURNS TEXT AS $$
|
|
90
|
+
DECLARE
|
|
91
|
+
have ALIAS FOR $1;
|
|
92
|
+
want ALIAS FOR $2;
|
|
93
|
+
have_rec RECORD;
|
|
94
|
+
want_rec RECORD;
|
|
95
|
+
have_found BOOLEAN;
|
|
96
|
+
want_found BOOLEAN;
|
|
97
|
+
rownum INTEGER := 1;
|
|
98
|
+
err_msg text := 'details not available in pg <= 9.1';
|
|
99
|
+
BEGIN
|
|
100
|
+
FETCH have INTO have_rec;
|
|
101
|
+
have_found := FOUND;
|
|
102
|
+
FETCH want INTO want_rec;
|
|
103
|
+
want_found := FOUND;
|
|
104
|
+
WHILE have_found OR want_found LOOP
|
|
105
|
+
IF have_rec IS DISTINCT FROM want_rec OR have_found <> want_found THEN
|
|
106
|
+
RETURN ok( false, $3 ) || E'\n' || diag(
|
|
107
|
+
' Results differ beginning at row ' || rownum || E':\n' ||
|
|
108
|
+
' have: ' || CASE WHEN have_found THEN have_rec::text ELSE 'NULL' END || E'\n' ||
|
|
109
|
+
' want: ' || CASE WHEN want_found THEN want_rec::text ELSE 'NULL' END
|
|
110
|
+
);
|
|
111
|
+
END IF;
|
|
112
|
+
rownum = rownum + 1;
|
|
113
|
+
FETCH have INTO have_rec;
|
|
114
|
+
have_found := FOUND;
|
|
115
|
+
FETCH want INTO want_rec;
|
|
116
|
+
want_found := FOUND;
|
|
117
|
+
END LOOP;
|
|
118
|
+
|
|
119
|
+
RETURN ok( true, $3 );
|
|
120
|
+
EXCEPTION
|
|
121
|
+
WHEN datatype_mismatch THEN
|
|
122
|
+
GET STACKED DIAGNOSTICS err_msg = MESSAGE_TEXT;
|
|
123
|
+
RETURN ok( false, $3 ) || E'\n' || diag(
|
|
124
|
+
E' Number of columns or their types differ between the queries' ||
|
|
125
|
+
CASE WHEN have_rec::TEXT = want_rec::text THEN '' ELSE E':\n' ||
|
|
126
|
+
' have: ' || CASE WHEN have_found THEN have_rec::text ELSE 'NULL' END || E'\n' ||
|
|
127
|
+
' want: ' || CASE WHEN want_found THEN want_rec::text ELSE 'NULL' END
|
|
128
|
+
END || E'\n ERROR: ' || err_msg
|
|
129
|
+
);
|
|
130
|
+
END;
|
|
131
|
+
$$ LANGUAGE plpgsql;
|
|
132
|
+
|
|
133
|
+
CREATE OR REPLACE FUNCTION results_ne( refcursor, refcursor, text )
|
|
134
|
+
RETURNS TEXT AS $$
|
|
135
|
+
DECLARE
|
|
136
|
+
have ALIAS FOR $1;
|
|
137
|
+
want ALIAS FOR $2;
|
|
138
|
+
have_rec RECORD;
|
|
139
|
+
want_rec RECORD;
|
|
140
|
+
have_found BOOLEAN;
|
|
141
|
+
want_found BOOLEAN;
|
|
142
|
+
err_msg text := 'details not available in pg <= 9.1';
|
|
143
|
+
BEGIN
|
|
144
|
+
FETCH have INTO have_rec;
|
|
145
|
+
have_found := FOUND;
|
|
146
|
+
FETCH want INTO want_rec;
|
|
147
|
+
want_found := FOUND;
|
|
148
|
+
WHILE have_found OR want_found LOOP
|
|
149
|
+
IF have_rec IS DISTINCT FROM want_rec OR have_found <> want_found THEN
|
|
150
|
+
RETURN ok( true, $3 );
|
|
151
|
+
ELSE
|
|
152
|
+
FETCH have INTO have_rec;
|
|
153
|
+
have_found := FOUND;
|
|
154
|
+
FETCH want INTO want_rec;
|
|
155
|
+
want_found := FOUND;
|
|
156
|
+
END IF;
|
|
157
|
+
END LOOP;
|
|
158
|
+
RETURN ok( false, $3 );
|
|
159
|
+
EXCEPTION
|
|
160
|
+
WHEN datatype_mismatch THEN
|
|
161
|
+
GET STACKED DIAGNOSTICS err_msg = MESSAGE_TEXT;
|
|
162
|
+
RETURN ok( false, $3 ) || E'\n' || diag(
|
|
163
|
+
E' Number of columns or their types differ between the queries' ||
|
|
164
|
+
CASE WHEN have_rec::TEXT = want_rec::text THEN '' ELSE E':\n' ||
|
|
165
|
+
' have: ' || CASE WHEN have_found THEN have_rec::text ELSE 'NULL' END || E'\n' ||
|
|
166
|
+
' want: ' || CASE WHEN want_found THEN want_rec::text ELSE 'NULL' END
|
|
167
|
+
END || E'\n ERROR: ' || err_msg
|
|
168
|
+
);
|
|
169
|
+
END;
|
|
170
|
+
$$ LANGUAGE plpgsql;
|
|
171
|
+
|
|
172
|
+
-- hasnt_operator( left_type, schema, name, right_type, return_type, description )
|
|
173
|
+
CREATE OR REPLACE FUNCTION hasnt_operator ( NAME, NAME, NAME, NAME, NAME, TEXT )
|
|
174
|
+
RETURNS TEXT AS $$
|
|
175
|
+
SELECT ok( NOT _op_exists($1, $2, $3, $4, $5 ), $6 );
|
|
176
|
+
$$ LANGUAGE SQL;
|
|
177
|
+
|
|
178
|
+
-- hasnt_operator( left_type, schema, name, right_type, return_type )
|
|
179
|
+
CREATE OR REPLACE FUNCTION hasnt_operator ( NAME, NAME, NAME, NAME, NAME )
|
|
180
|
+
RETURNS TEXT AS $$
|
|
181
|
+
SELECT ok(
|
|
182
|
+
NOT _op_exists($1, $2, $3, $4, $5 ),
|
|
183
|
+
'Operator ' || quote_ident($2) || '.' || $3 || '(' || $1 || ',' || $4
|
|
184
|
+
|| ') RETURNS ' || $5 || ' should not exist'
|
|
185
|
+
);
|
|
186
|
+
$$ LANGUAGE SQL;
|
|
187
|
+
|
|
188
|
+
-- hasnt_operator( left_type, name, right_type, return_type, description )
|
|
189
|
+
CREATE OR REPLACE FUNCTION hasnt_operator ( NAME, NAME, NAME, NAME, TEXT )
|
|
190
|
+
RETURNS TEXT AS $$
|
|
191
|
+
SELECT ok( NOT _op_exists($1, $2, $3, $4 ), $5 );
|
|
192
|
+
$$ LANGUAGE SQL;
|
|
193
|
+
|
|
194
|
+
-- hasnt_operator( left_type, name, right_type, return_type )
|
|
195
|
+
CREATE OR REPLACE FUNCTION hasnt_operator ( NAME, NAME, NAME, NAME )
|
|
196
|
+
RETURNS TEXT AS $$
|
|
197
|
+
SELECT ok(
|
|
198
|
+
NOT _op_exists($1, $2, $3, $4 ),
|
|
199
|
+
'Operator ' || $2 || '(' || $1 || ',' || $3
|
|
200
|
+
|| ') RETURNS ' || $4 || ' should not exist'
|
|
201
|
+
);
|
|
202
|
+
$$ LANGUAGE SQL;
|
|
203
|
+
|
|
204
|
+
-- hasnt_operator( left_type, name, right_type, description )
|
|
205
|
+
CREATE OR REPLACE FUNCTION hasnt_operator ( NAME, NAME, NAME, TEXT )
|
|
206
|
+
RETURNS TEXT AS $$
|
|
207
|
+
SELECT ok( NOT _op_exists($1, $2, $3 ), $4 );
|
|
208
|
+
$$ LANGUAGE SQL;
|
|
209
|
+
|
|
210
|
+
-- hasnt_operator( left_type, name, right_type )
|
|
211
|
+
CREATE OR REPLACE FUNCTION hasnt_operator ( NAME, NAME, NAME )
|
|
212
|
+
RETURNS TEXT AS $$
|
|
213
|
+
SELECT ok(
|
|
214
|
+
NOT _op_exists($1, $2, $3 ),
|
|
215
|
+
'Operator ' || $2 || '(' || $1 || ',' || $3
|
|
216
|
+
|| ') should not exist'
|
|
217
|
+
);
|
|
218
|
+
$$ LANGUAGE SQL;
|
|
219
|
+
|
|
220
|
+
-- hasnt_leftop( schema, name, right_type, return_type, description )
|
|
221
|
+
CREATE OR REPLACE FUNCTION hasnt_leftop ( NAME, NAME, NAME, NAME, TEXT )
|
|
222
|
+
RETURNS TEXT AS $$
|
|
223
|
+
SELECT ok( NOT _op_exists(NULL, $1, $2, $3, $4), $5 );
|
|
224
|
+
$$ LANGUAGE SQL;
|
|
225
|
+
|
|
226
|
+
-- hasnt_leftop( schema, name, right_type, return_type )
|
|
227
|
+
CREATE OR REPLACE FUNCTION hasnt_leftop ( NAME, NAME, NAME, NAME )
|
|
228
|
+
RETURNS TEXT AS $$
|
|
229
|
+
SELECT ok(
|
|
230
|
+
NOT _op_exists(NULL, $1, $2, $3, $4 ),
|
|
231
|
+
'Left operator ' || quote_ident($1) || '.' || $2 || '(NONE,'
|
|
232
|
+
|| $3 || ') RETURNS ' || $4 || ' should not exist'
|
|
233
|
+
);
|
|
234
|
+
$$ LANGUAGE SQL;
|
|
235
|
+
|
|
236
|
+
-- hasnt_leftop( name, right_type, return_type, description )
|
|
237
|
+
CREATE OR REPLACE FUNCTION hasnt_leftop ( NAME, NAME, NAME, TEXT )
|
|
238
|
+
RETURNS TEXT AS $$
|
|
239
|
+
SELECT ok( NOT _op_exists(NULL, $1, $2, $3), $4 );
|
|
240
|
+
$$ LANGUAGE SQL;
|
|
241
|
+
|
|
242
|
+
-- hasnt_leftop( name, right_type, return_type )
|
|
243
|
+
CREATE OR REPLACE FUNCTION hasnt_leftop ( NAME, NAME, NAME )
|
|
244
|
+
RETURNS TEXT AS $$
|
|
245
|
+
SELECT ok(
|
|
246
|
+
NOT _op_exists(NULL, $1, $2, $3 ),
|
|
247
|
+
'Left operator ' || $1 || '(NONE,' || $2 || ') RETURNS ' || $3 || ' should not exist'
|
|
248
|
+
);
|
|
249
|
+
$$ LANGUAGE SQL;
|
|
250
|
+
|
|
251
|
+
-- hasnt_leftop( name, right_type, description )
|
|
252
|
+
CREATE OR REPLACE FUNCTION hasnt_leftop ( NAME, NAME, TEXT )
|
|
253
|
+
RETURNS TEXT AS $$
|
|
254
|
+
SELECT ok( NOT _op_exists(NULL, $1, $2), $3 );
|
|
255
|
+
$$ LANGUAGE SQL;
|
|
256
|
+
|
|
257
|
+
-- hasnt_leftop( name, right_type )
|
|
258
|
+
CREATE OR REPLACE FUNCTION hasnt_leftop ( NAME, NAME )
|
|
259
|
+
RETURNS TEXT AS $$
|
|
260
|
+
SELECT ok(
|
|
261
|
+
NOT _op_exists(NULL, $1, $2 ),
|
|
262
|
+
'Left operator ' || $1 || '(NONE,' || $2 || ') should not exist'
|
|
263
|
+
);
|
|
264
|
+
$$ LANGUAGE SQL;
|
|
265
|
+
|
|
266
|
+
-- hasnt_rightop( left_type, schema, name, return_type, description )
|
|
267
|
+
CREATE OR REPLACE FUNCTION hasnt_rightop ( NAME, NAME, NAME, NAME, TEXT )
|
|
268
|
+
RETURNS TEXT AS $$
|
|
269
|
+
SELECT ok( NOT _op_exists( $1, $2, $3, NULL, $4), $5 );
|
|
270
|
+
$$ LANGUAGE SQL;
|
|
271
|
+
|
|
272
|
+
-- hasnt_rightop( left_type, schema, name, return_type )
|
|
273
|
+
CREATE OR REPLACE FUNCTION hasnt_rightop ( NAME, NAME, NAME, NAME )
|
|
274
|
+
RETURNS TEXT AS $$
|
|
275
|
+
SELECT ok(
|
|
276
|
+
NOT _op_exists($1, $2, $3, NULL, $4 ),
|
|
277
|
+
'Right operator ' || quote_ident($2) || '.' || $3 || '('
|
|
278
|
+
|| $1 || ',NONE) RETURNS ' || $4 || ' should not exist'
|
|
279
|
+
);
|
|
280
|
+
$$ LANGUAGE SQL;
|
|
281
|
+
|
|
282
|
+
-- hasnt_rightop( left_type, name, return_type, description )
|
|
283
|
+
CREATE OR REPLACE FUNCTION hasnt_rightop ( NAME, NAME, NAME, TEXT )
|
|
284
|
+
RETURNS TEXT AS $$
|
|
285
|
+
SELECT ok( NOT _op_exists( $1, $2, NULL, $3), $4 );
|
|
286
|
+
$$ LANGUAGE SQL;
|
|
287
|
+
|
|
288
|
+
-- hasnt_rightop( left_type, name, return_type )
|
|
289
|
+
CREATE OR REPLACE FUNCTION hasnt_rightop ( NAME, NAME, NAME )
|
|
290
|
+
RETURNS TEXT AS $$
|
|
291
|
+
SELECT ok(
|
|
292
|
+
NOT _op_exists($1, $2, NULL, $3 ),
|
|
293
|
+
'Right operator ' || $2 || '('
|
|
294
|
+
|| $1 || ',NONE) RETURNS ' || $3 || ' should not exist'
|
|
295
|
+
);
|
|
296
|
+
$$ LANGUAGE SQL;
|
|
297
|
+
|
|
298
|
+
-- hasnt_rightop( left_type, name, description )
|
|
299
|
+
CREATE OR REPLACE FUNCTION hasnt_rightop ( NAME, NAME, TEXT )
|
|
300
|
+
RETURNS TEXT AS $$
|
|
301
|
+
SELECT ok( NOT _op_exists( $1, $2, NULL), $3 );
|
|
302
|
+
$$ LANGUAGE SQL;
|
|
303
|
+
|
|
304
|
+
-- hasnt_rightop( left_type, name )
|
|
305
|
+
CREATE OR REPLACE FUNCTION hasnt_rightop ( NAME, NAME )
|
|
306
|
+
RETURNS TEXT AS $$
|
|
307
|
+
SELECT ok(
|
|
308
|
+
NOT _op_exists($1, $2, NULL ),
|
|
309
|
+
'Right operator ' || $2 || '(' || $1 || ',NONE) should not exist'
|
|
310
|
+
);
|
|
311
|
+
$$ LANGUAGE SQL;
|
|
312
|
+
|
|
313
|
+
/*
|
|
314
|
+
* tap_funky used to just be a simple view, but the problem with that is the
|
|
315
|
+
* definition of pg_proc changed in version 11. Thanks to how pg_dump (and
|
|
316
|
+
* hence pg_upgrade) works, this made it impossible to upgrade Postgres if
|
|
317
|
+
* pgTap was installed. In order to fix that, we need code that will actually
|
|
318
|
+
* work on both < PG11 and >= PG11.
|
|
319
|
+
*/
|
|
320
|
+
CREATE OR REPLACE FUNCTION _prokind( p_oid oid )
|
|
321
|
+
RETURNS "char" AS $$
|
|
322
|
+
BEGIN
|
|
323
|
+
IF pg_version_num() >= 110000 THEN
|
|
324
|
+
RETURN prokind FROM pg_catalog.pg_proc WHERE oid = p_oid;
|
|
325
|
+
ELSE
|
|
326
|
+
RETURN CASE WHEN proisagg THEN 'a' WHEN proiswindow THEN 'w' ELSE 'f' END
|
|
327
|
+
FROM pg_catalog.pg_proc WHERE oid = p_oid;
|
|
328
|
+
END IF;
|
|
329
|
+
END;
|
|
330
|
+
$$ LANGUAGE plpgsql STABLE;
|
|
331
|
+
|
|
332
|
+
DROP VIEW IF EXISTS tap_funky;
|
|
333
|
+
CREATE VIEW tap_funky
|
|
334
|
+
AS SELECT p.oid AS oid,
|
|
335
|
+
n.nspname AS schema,
|
|
336
|
+
p.proname AS name,
|
|
337
|
+
pg_catalog.pg_get_userbyid(p.proowner) AS owner,
|
|
338
|
+
array_to_string(p.proargtypes::regtype[], ',') AS args,
|
|
339
|
+
CASE p.proretset WHEN TRUE THEN 'setof ' ELSE '' END
|
|
340
|
+
|| p.prorettype::regtype AS returns,
|
|
341
|
+
p.prolang AS langoid,
|
|
342
|
+
p.proisstrict AS is_strict,
|
|
343
|
+
_prokind(p.oid) AS kind,
|
|
344
|
+
p.prosecdef AS is_definer,
|
|
345
|
+
p.proretset AS returns_set,
|
|
346
|
+
p.provolatile::char AS volatility,
|
|
347
|
+
pg_catalog.pg_function_is_visible(p.oid) AS is_visible
|
|
348
|
+
FROM pg_catalog.pg_proc p
|
|
349
|
+
JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid
|
|
350
|
+
;
|
|
351
|
+
|
|
352
|
+
-- Returns true if the specified function exists and is the specified type,
|
|
353
|
+
-- false if it exists and is not the specified type, and NULL if it does not
|
|
354
|
+
-- exist. Types are f for a normal function, p for a procedure, a for an
|
|
355
|
+
-- aggregate function, or w for a window function
|
|
356
|
+
-- _type_func(type, schema, function, args[])
|
|
357
|
+
CREATE OR REPLACE FUNCTION _type_func ( "char", NAME, NAME, NAME[] )
|
|
358
|
+
RETURNS BOOLEAN AS $$
|
|
359
|
+
SELECT kind = $1
|
|
360
|
+
FROM tap_funky
|
|
361
|
+
WHERE schema = $2
|
|
362
|
+
AND name = $3
|
|
363
|
+
AND args = array_to_string($4, ',')
|
|
364
|
+
$$ LANGUAGE SQL;
|
|
365
|
+
|
|
366
|
+
-- _type_func(type, schema, function)
|
|
367
|
+
CREATE OR REPLACE FUNCTION _type_func ( "char", NAME, NAME )
|
|
368
|
+
RETURNS BOOLEAN AS $$
|
|
369
|
+
SELECT kind = $1 FROM tap_funky WHERE schema = $2 AND name = $3
|
|
370
|
+
$$ LANGUAGE SQL;
|
|
371
|
+
|
|
372
|
+
-- _type_func(type, function, args[])
|
|
373
|
+
CREATE OR REPLACE FUNCTION _type_func ( "char", NAME, NAME[] )
|
|
374
|
+
RETURNS BOOLEAN AS $$
|
|
375
|
+
SELECT kind = $1
|
|
376
|
+
FROM tap_funky
|
|
377
|
+
WHERE name = $2
|
|
378
|
+
AND args = array_to_string($3, ',')
|
|
379
|
+
AND is_visible;
|
|
380
|
+
$$ LANGUAGE SQL;
|
|
381
|
+
|
|
382
|
+
-- _type_func(type, function)
|
|
383
|
+
CREATE OR REPLACE FUNCTION _type_func ( "char", NAME )
|
|
384
|
+
RETURNS BOOLEAN AS $$
|
|
385
|
+
SELECT kind = $1 FROM tap_funky WHERE name = $2 AND is_visible;
|
|
386
|
+
$$ LANGUAGE SQL;
|
|
387
|
+
|
|
388
|
+
-- is_aggregate( schema, function, args[], description )
|
|
389
|
+
CREATE OR REPLACE FUNCTION is_aggregate ( NAME, NAME, NAME[], TEXT )
|
|
390
|
+
RETURNS TEXT AS $$
|
|
391
|
+
SELECT _func_compare($1, $2, $3, _type_func( 'a', $1, $2, $3), $4 );
|
|
392
|
+
$$ LANGUAGE SQL;
|
|
393
|
+
|
|
394
|
+
-- is_aggregate( schema, function, args[] )
|
|
395
|
+
CREATE OR REPLACE FUNCTION is_aggregate( NAME, NAME, NAME[] )
|
|
396
|
+
RETURNS TEXT AS $$
|
|
397
|
+
SELECT _func_compare(
|
|
398
|
+
$1, $2, $3, _type_func('a', $1, $2, $3),
|
|
399
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '(' ||
|
|
400
|
+
array_to_string($3, ', ') || ') should be an aggregate function'
|
|
401
|
+
);
|
|
402
|
+
$$ LANGUAGE sql;
|
|
403
|
+
|
|
404
|
+
-- is_aggregate( schema, function, description )
|
|
405
|
+
CREATE OR REPLACE FUNCTION is_aggregate ( NAME, NAME, TEXT )
|
|
406
|
+
RETURNS TEXT AS $$
|
|
407
|
+
SELECT _func_compare($1, $2, _type_func('a', $1, $2), $3 );
|
|
408
|
+
$$ LANGUAGE SQL;
|
|
409
|
+
|
|
410
|
+
-- is_aggregate( schema, function )
|
|
411
|
+
CREATE OR REPLACE FUNCTION is_aggregate( NAME, NAME )
|
|
412
|
+
RETURNS TEXT AS $$
|
|
413
|
+
SELECT _func_compare(
|
|
414
|
+
$1, $2, _type_func('a', $1, $2),
|
|
415
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '() should be an aggregate function'
|
|
416
|
+
);
|
|
417
|
+
$$ LANGUAGE sql;
|
|
418
|
+
|
|
419
|
+
-- is_aggregate( function, args[], description )
|
|
420
|
+
CREATE OR REPLACE FUNCTION is_aggregate ( NAME, NAME[], TEXT )
|
|
421
|
+
RETURNS TEXT AS $$
|
|
422
|
+
SELECT _func_compare( NULL, $1, $2, _type_func('a', $1, $2), $3 );
|
|
423
|
+
$$ LANGUAGE SQL;
|
|
424
|
+
|
|
425
|
+
-- is_aggregate( function, args[] )
|
|
426
|
+
CREATE OR REPLACE FUNCTION is_aggregate( NAME, NAME[] )
|
|
427
|
+
RETURNS TEXT AS $$
|
|
428
|
+
SELECT _func_compare(
|
|
429
|
+
NULL, $1, $2, _type_func('a', $1, $2),
|
|
430
|
+
'Function ' || quote_ident($1) || '(' ||
|
|
431
|
+
array_to_string($2, ', ') || ') should be an aggregate function'
|
|
432
|
+
);
|
|
433
|
+
$$ LANGUAGE sql;
|
|
434
|
+
|
|
435
|
+
-- is_aggregate( function, description )
|
|
436
|
+
CREATE OR REPLACE FUNCTION is_aggregate( NAME, TEXT )
|
|
437
|
+
RETURNS TEXT AS $$
|
|
438
|
+
SELECT _func_compare(NULL, $1, _type_func('a', $1), $2 );
|
|
439
|
+
$$ LANGUAGE sql;
|
|
440
|
+
|
|
441
|
+
-- is_aggregate( function )
|
|
442
|
+
CREATE OR REPLACE FUNCTION is_aggregate( NAME )
|
|
443
|
+
RETURNS TEXT AS $$
|
|
444
|
+
SELECT _func_compare(
|
|
445
|
+
NULL, $1, _type_func('a', $1),
|
|
446
|
+
'Function ' || quote_ident($1) || '() should be an aggregate function'
|
|
447
|
+
);
|
|
448
|
+
$$ LANGUAGE sql;
|
|
449
|
+
|
|
450
|
+
-- isnt_aggregate( schema, function, args[], description )
|
|
451
|
+
CREATE OR REPLACE FUNCTION isnt_aggregate ( NAME, NAME, NAME[], TEXT )
|
|
452
|
+
RETURNS TEXT AS $$
|
|
453
|
+
SELECT _func_compare($1, $2, $3, NOT _type_func('a', $1, $2, $3), $4 );
|
|
454
|
+
$$ LANGUAGE SQL;
|
|
455
|
+
|
|
456
|
+
-- isnt_aggregate( schema, function, args[] )
|
|
457
|
+
CREATE OR REPLACE FUNCTION isnt_aggregate( NAME, NAME, NAME[] )
|
|
458
|
+
RETURNS TEXT AS $$
|
|
459
|
+
SELECT _func_compare(
|
|
460
|
+
$1, $2, $3, NOT _type_func('a', $1, $2, $3),
|
|
461
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '(' ||
|
|
462
|
+
array_to_string($3, ', ') || ') should not be an aggregate function'
|
|
463
|
+
);
|
|
464
|
+
$$ LANGUAGE sql;
|
|
465
|
+
|
|
466
|
+
-- isnt_aggregate( schema, function, description )
|
|
467
|
+
CREATE OR REPLACE FUNCTION isnt_aggregate ( NAME, NAME, TEXT )
|
|
468
|
+
RETURNS TEXT AS $$
|
|
469
|
+
SELECT _func_compare($1, $2, NOT _type_func('a', $1, $2), $3 );
|
|
470
|
+
$$ LANGUAGE SQL;
|
|
471
|
+
|
|
472
|
+
-- isnt_aggregate( schema, function )
|
|
473
|
+
CREATE OR REPLACE FUNCTION isnt_aggregate( NAME, NAME )
|
|
474
|
+
RETURNS TEXT AS $$
|
|
475
|
+
SELECT _func_compare(
|
|
476
|
+
$1, $2, NOT _type_func('a', $1, $2),
|
|
477
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '() should not be an aggregate function'
|
|
478
|
+
);
|
|
479
|
+
$$ LANGUAGE sql;
|
|
480
|
+
|
|
481
|
+
-- isnt_aggregate( function, args[], description )
|
|
482
|
+
CREATE OR REPLACE FUNCTION isnt_aggregate ( NAME, NAME[], TEXT )
|
|
483
|
+
RETURNS TEXT AS $$
|
|
484
|
+
SELECT _func_compare(NULL, $1, $2, NOT _type_func('a', $1, $2), $3 );
|
|
485
|
+
$$ LANGUAGE SQL;
|
|
486
|
+
|
|
487
|
+
-- isnt_aggregate( function, args[] )
|
|
488
|
+
CREATE OR REPLACE FUNCTION isnt_aggregate( NAME, NAME[] )
|
|
489
|
+
RETURNS TEXT AS $$
|
|
490
|
+
SELECT _func_compare(
|
|
491
|
+
NULL, $1, $2, NOT _type_func('a', $1, $2),
|
|
492
|
+
'Function ' || quote_ident($1) || '(' ||
|
|
493
|
+
array_to_string($2, ', ') || ') should not be an aggregate function'
|
|
494
|
+
);
|
|
495
|
+
$$ LANGUAGE sql;
|
|
496
|
+
|
|
497
|
+
-- isnt_aggregate( function, description )
|
|
498
|
+
CREATE OR REPLACE FUNCTION isnt_aggregate( NAME, TEXT )
|
|
499
|
+
RETURNS TEXT AS $$
|
|
500
|
+
SELECT _func_compare(NULL, $1, NOT _type_func('a', $1), $2 );
|
|
501
|
+
$$ LANGUAGE sql;
|
|
502
|
+
|
|
503
|
+
-- isnt_aggregate( function )
|
|
504
|
+
CREATE OR REPLACE FUNCTION isnt_aggregate( NAME )
|
|
505
|
+
RETURNS TEXT AS $$
|
|
506
|
+
SELECT _func_compare(
|
|
507
|
+
NULL, $1, NOT _type_func('a', $1),
|
|
508
|
+
'Function ' || quote_ident($1) || '() should not be an aggregate function'
|
|
509
|
+
);
|
|
510
|
+
$$ LANGUAGE sql;
|
|
511
|
+
|
|
512
|
+
DROP FUNCTION _agg ( NAME );
|
|
513
|
+
DROP FUNCTION _agg ( NAME, NAME[] );
|
|
514
|
+
DROP FUNCTION _agg ( NAME, NAME );
|
|
515
|
+
DROP FUNCTION _agg ( NAME, NAME, NAME[] );
|
|
516
|
+
|
|
517
|
+
-- is_normal_function( schema, function, args[], description )
|
|
518
|
+
CREATE OR REPLACE FUNCTION is_normal_function ( NAME, NAME, NAME[], TEXT )
|
|
519
|
+
RETURNS TEXT AS $$
|
|
520
|
+
SELECT _func_compare($1, $2, $3, _type_func('f', $1, $2, $3), $4 );
|
|
521
|
+
$$ LANGUAGE SQL;
|
|
522
|
+
|
|
523
|
+
-- is_normal_function( schema, function, args[] )
|
|
524
|
+
CREATE OR REPLACE FUNCTION is_normal_function( NAME, NAME, NAME[] )
|
|
525
|
+
RETURNS TEXT AS $$
|
|
526
|
+
SELECT _func_compare(
|
|
527
|
+
$1, $2, $3,
|
|
528
|
+
_type_func('f', $1, $2, $3),
|
|
529
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '(' ||
|
|
530
|
+
array_to_string($3, ', ') || ') should be a normal function'
|
|
531
|
+
);
|
|
532
|
+
$$ LANGUAGE sql;
|
|
533
|
+
|
|
534
|
+
-- is_normal_function( schema, function, description )
|
|
535
|
+
CREATE OR REPLACE FUNCTION is_normal_function ( NAME, NAME, TEXT )
|
|
536
|
+
RETURNS TEXT AS $$
|
|
537
|
+
SELECT _func_compare($1, $2, _type_func('f', $1, $2), $3 );
|
|
538
|
+
$$ LANGUAGE SQL;
|
|
539
|
+
|
|
540
|
+
-- is_normal_function( schema, function )
|
|
541
|
+
CREATE OR REPLACE FUNCTION is_normal_function( NAME, NAME )
|
|
542
|
+
RETURNS TEXT AS $$
|
|
543
|
+
SELECT _func_compare(
|
|
544
|
+
$1, $2, _type_func('f', $1, $2),
|
|
545
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '() should be a normal function'
|
|
546
|
+
);
|
|
547
|
+
$$ LANGUAGE sql;
|
|
548
|
+
|
|
549
|
+
-- is_normal_function( function, args[], description )
|
|
550
|
+
CREATE OR REPLACE FUNCTION is_normal_function ( NAME, NAME[], TEXT )
|
|
551
|
+
RETURNS TEXT AS $$
|
|
552
|
+
SELECT _func_compare(NULL, $1, $2, _type_func('f', $1, $2), $3 );
|
|
553
|
+
$$ LANGUAGE SQL;
|
|
554
|
+
|
|
555
|
+
-- is_normal_function( function, args[] )
|
|
556
|
+
CREATE OR REPLACE FUNCTION is_normal_function( NAME, NAME[] )
|
|
557
|
+
RETURNS TEXT AS $$
|
|
558
|
+
SELECT _func_compare(
|
|
559
|
+
NULL, $1, $2, _type_func('f', $1, $2),
|
|
560
|
+
'Function ' || quote_ident($1) || '(' ||
|
|
561
|
+
array_to_string($2, ', ') || ') should be a normal function'
|
|
562
|
+
);
|
|
563
|
+
$$ LANGUAGE sql;
|
|
564
|
+
|
|
565
|
+
-- is_normal_function( function, description )
|
|
566
|
+
CREATE OR REPLACE FUNCTION is_normal_function( NAME, TEXT )
|
|
567
|
+
RETURNS TEXT AS $$
|
|
568
|
+
SELECT _func_compare(NULL, $1, _type_func('f', $1), $2 );
|
|
569
|
+
$$ LANGUAGE sql;
|
|
570
|
+
|
|
571
|
+
-- is_normal_function( function )
|
|
572
|
+
CREATE OR REPLACE FUNCTION is_normal_function( NAME )
|
|
573
|
+
RETURNS TEXT AS $$
|
|
574
|
+
SELECT _func_compare(
|
|
575
|
+
NULL, $1, _type_func('f', $1),
|
|
576
|
+
'Function ' || quote_ident($1) || '() should be a normal function'
|
|
577
|
+
);
|
|
578
|
+
$$ LANGUAGE sql;
|
|
579
|
+
|
|
580
|
+
-- isnt_normal_function( schema, function, args[], description )
|
|
581
|
+
CREATE OR REPLACE FUNCTION isnt_normal_function ( NAME, NAME, NAME[], TEXT )
|
|
582
|
+
RETURNS TEXT AS $$
|
|
583
|
+
SELECT _func_compare($1, $2, $3, NOT _type_func('f', $1, $2, $3), $4 );
|
|
584
|
+
$$ LANGUAGE SQL;
|
|
585
|
+
|
|
586
|
+
-- isnt_normal_function( schema, function, args[] )
|
|
587
|
+
CREATE OR REPLACE FUNCTION isnt_normal_function( NAME, NAME, NAME[] )
|
|
588
|
+
RETURNS TEXT AS $$
|
|
589
|
+
SELECT _func_compare(
|
|
590
|
+
$1, $2, $3, NOT _type_func('f', $1, $2, $3),
|
|
591
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '(' ||
|
|
592
|
+
array_to_string($3, ', ') || ') should not be a normal function'
|
|
593
|
+
);
|
|
594
|
+
$$ LANGUAGE sql;
|
|
595
|
+
|
|
596
|
+
-- isnt_normal_function( schema, function, description )
|
|
597
|
+
CREATE OR REPLACE FUNCTION isnt_normal_function ( NAME, NAME, TEXT )
|
|
598
|
+
RETURNS TEXT AS $$
|
|
599
|
+
SELECT _func_compare($1, $2, NOT _type_func('f', $1, $2), $3 );
|
|
600
|
+
$$ LANGUAGE SQL;
|
|
601
|
+
|
|
602
|
+
-- isnt_normal_function( schema, function )
|
|
603
|
+
CREATE OR REPLACE FUNCTION isnt_normal_function( NAME, NAME )
|
|
604
|
+
RETURNS TEXT AS $$
|
|
605
|
+
SELECT _func_compare(
|
|
606
|
+
$1, $2, NOT _type_func('f', $1, $2),
|
|
607
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '() should not be a normal function'
|
|
608
|
+
);
|
|
609
|
+
$$ LANGUAGE sql;
|
|
610
|
+
|
|
611
|
+
-- isnt_normal_function( function, args[], description )
|
|
612
|
+
CREATE OR REPLACE FUNCTION isnt_normal_function ( NAME, NAME[], TEXT )
|
|
613
|
+
RETURNS TEXT AS $$
|
|
614
|
+
SELECT _func_compare(NULL, $1, $2, NOT _type_func('f', $1, $2), $3 );
|
|
615
|
+
$$ LANGUAGE SQL;
|
|
616
|
+
|
|
617
|
+
-- isnt_normal_function( function, args[] )
|
|
618
|
+
CREATE OR REPLACE FUNCTION isnt_normal_function( NAME, NAME[] )
|
|
619
|
+
RETURNS TEXT AS $$
|
|
620
|
+
SELECT _func_compare(
|
|
621
|
+
NULL, $1, $2,
|
|
622
|
+
NOT _type_func('f', $1, $2),
|
|
623
|
+
'Function ' || quote_ident($1) || '(' ||
|
|
624
|
+
array_to_string($2, ', ') || ') should not be a normal function'
|
|
625
|
+
);
|
|
626
|
+
$$ LANGUAGE sql;
|
|
627
|
+
|
|
628
|
+
-- isnt_normal_function( function, description )
|
|
629
|
+
CREATE OR REPLACE FUNCTION isnt_normal_function( NAME, TEXT )
|
|
630
|
+
RETURNS TEXT AS $$
|
|
631
|
+
SELECT _func_compare(NULL, $1, NOT _type_func('f', $1), $2 );
|
|
632
|
+
$$ LANGUAGE sql;
|
|
633
|
+
|
|
634
|
+
-- isnt_normal_function( function )
|
|
635
|
+
CREATE OR REPLACE FUNCTION isnt_normal_function( NAME )
|
|
636
|
+
RETURNS TEXT AS $$
|
|
637
|
+
SELECT _func_compare(
|
|
638
|
+
NULL, $1, NOT _type_func('f', $1),
|
|
639
|
+
'Function ' || quote_ident($1) || '() should not be a normal function'
|
|
640
|
+
);
|
|
641
|
+
$$ LANGUAGE sql;
|
|
642
|
+
|
|
643
|
+
-- is_window( schema, function, args[], description )
|
|
644
|
+
CREATE OR REPLACE FUNCTION is_window ( NAME, NAME, NAME[], TEXT )
|
|
645
|
+
RETURNS TEXT AS $$
|
|
646
|
+
SELECT _func_compare($1, $2, $3, _type_func( 'w', $1, $2, $3), $4 );
|
|
647
|
+
$$ LANGUAGE SQL;
|
|
648
|
+
|
|
649
|
+
-- is_window( schema, function, args[] )
|
|
650
|
+
CREATE OR REPLACE FUNCTION is_window( NAME, NAME, NAME[] )
|
|
651
|
+
RETURNS TEXT AS $$
|
|
652
|
+
SELECT _func_compare(
|
|
653
|
+
$1, $2, $3, _type_func('w', $1, $2, $3),
|
|
654
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '(' ||
|
|
655
|
+
array_to_string($3, ', ') || ') should be a window function'
|
|
656
|
+
);
|
|
657
|
+
$$ LANGUAGE sql;
|
|
658
|
+
|
|
659
|
+
-- is_window( schema, function, description )
|
|
660
|
+
CREATE OR REPLACE FUNCTION is_window ( NAME, NAME, TEXT )
|
|
661
|
+
RETURNS TEXT AS $$
|
|
662
|
+
SELECT _func_compare($1, $2, _type_func('w', $1, $2), $3 );
|
|
663
|
+
$$ LANGUAGE SQL;
|
|
664
|
+
|
|
665
|
+
-- is_window( schema, function )
|
|
666
|
+
CREATE OR REPLACE FUNCTION is_window( NAME, NAME )
|
|
667
|
+
RETURNS TEXT AS $$
|
|
668
|
+
SELECT _func_compare(
|
|
669
|
+
$1, $2, _type_func('w', $1, $2),
|
|
670
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '() should be a window function'
|
|
671
|
+
);
|
|
672
|
+
$$ LANGUAGE sql;
|
|
673
|
+
|
|
674
|
+
-- is_window( function, args[], description )
|
|
675
|
+
CREATE OR REPLACE FUNCTION is_window ( NAME, NAME[], TEXT )
|
|
676
|
+
RETURNS TEXT AS $$
|
|
677
|
+
SELECT _func_compare(NULL, $1, $2, _type_func('w', $1, $2), $3 );
|
|
678
|
+
$$ LANGUAGE SQL;
|
|
679
|
+
|
|
680
|
+
-- is_window( function, args[] )
|
|
681
|
+
CREATE OR REPLACE FUNCTION is_window( NAME, NAME[] )
|
|
682
|
+
RETURNS TEXT AS $$
|
|
683
|
+
SELECT _func_compare(
|
|
684
|
+
NULL, $1, $2, _type_func('w', $1, $2),
|
|
685
|
+
'Function ' || quote_ident($1) || '(' ||
|
|
686
|
+
array_to_string($2, ', ') || ') should be a window function'
|
|
687
|
+
);
|
|
688
|
+
$$ LANGUAGE sql;
|
|
689
|
+
|
|
690
|
+
-- is_window( function, description )
|
|
691
|
+
CREATE OR REPLACE FUNCTION is_window( NAME, TEXT )
|
|
692
|
+
RETURNS TEXT AS $$
|
|
693
|
+
SELECT _func_compare(NULL, $1, _type_func('w', $1), $2 );
|
|
694
|
+
$$ LANGUAGE sql;
|
|
695
|
+
|
|
696
|
+
-- is_window( function )
|
|
697
|
+
CREATE OR REPLACE FUNCTION is_window( NAME )
|
|
698
|
+
RETURNS TEXT AS $$
|
|
699
|
+
SELECT _func_compare(
|
|
700
|
+
NULL, $1, _type_func('w', $1),
|
|
701
|
+
'Function ' || quote_ident($1) || '() should be a window function'
|
|
702
|
+
);
|
|
703
|
+
$$ LANGUAGE sql;
|
|
704
|
+
|
|
705
|
+
-- isnt_window( schema, function, args[], description )
|
|
706
|
+
CREATE OR REPLACE FUNCTION isnt_window ( NAME, NAME, NAME[], TEXT )
|
|
707
|
+
RETURNS TEXT AS $$
|
|
708
|
+
SELECT _func_compare($1, $2, $3, NOT _type_func('w', $1, $2, $3), $4 );
|
|
709
|
+
$$ LANGUAGE SQL;
|
|
710
|
+
|
|
711
|
+
-- isnt_window( schema, function, args[] )
|
|
712
|
+
CREATE OR REPLACE FUNCTION isnt_window( NAME, NAME, NAME[] )
|
|
713
|
+
RETURNS TEXT AS $$
|
|
714
|
+
SELECT _func_compare(
|
|
715
|
+
$1, $2, $3, NOT _type_func('w', $1, $2, $3),
|
|
716
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '(' ||
|
|
717
|
+
array_to_string($3, ', ') || ') should not be a window function'
|
|
718
|
+
);
|
|
719
|
+
$$ LANGUAGE sql;
|
|
720
|
+
|
|
721
|
+
-- isnt_window( schema, function, description )
|
|
722
|
+
CREATE OR REPLACE FUNCTION isnt_window ( NAME, NAME, TEXT )
|
|
723
|
+
RETURNS TEXT AS $$
|
|
724
|
+
SELECT _func_compare($1, $2, NOT _type_func('w', $1, $2), $3 );
|
|
725
|
+
$$ LANGUAGE SQL;
|
|
726
|
+
|
|
727
|
+
-- isnt_window( schema, function )
|
|
728
|
+
CREATE OR REPLACE FUNCTION isnt_window( NAME, NAME )
|
|
729
|
+
RETURNS TEXT AS $$
|
|
730
|
+
SELECT _func_compare(
|
|
731
|
+
$1, $2, NOT _type_func('w', $1, $2),
|
|
732
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '() should not be a window function'
|
|
733
|
+
);
|
|
734
|
+
$$ LANGUAGE sql;
|
|
735
|
+
|
|
736
|
+
-- isnt_window( function, args[], description )
|
|
737
|
+
CREATE OR REPLACE FUNCTION isnt_window ( NAME, NAME[], TEXT )
|
|
738
|
+
RETURNS TEXT AS $$
|
|
739
|
+
SELECT _func_compare(NULL, $1, $2, NOT _type_func('w', $1, $2), $3 );
|
|
740
|
+
$$ LANGUAGE SQL;
|
|
741
|
+
|
|
742
|
+
-- isnt_window( function, args[] )
|
|
743
|
+
CREATE OR REPLACE FUNCTION isnt_window( NAME, NAME[] )
|
|
744
|
+
RETURNS TEXT AS $$
|
|
745
|
+
SELECT _func_compare(
|
|
746
|
+
NULL, $1, $2, NOT _type_func('w', $1, $2),
|
|
747
|
+
'Function ' || quote_ident($1) || '(' ||
|
|
748
|
+
array_to_string($2, ', ') || ') should not be a window function'
|
|
749
|
+
);
|
|
750
|
+
$$ LANGUAGE sql;
|
|
751
|
+
|
|
752
|
+
-- isnt_window( function, description )
|
|
753
|
+
CREATE OR REPLACE FUNCTION isnt_window( NAME, TEXT )
|
|
754
|
+
RETURNS TEXT AS $$
|
|
755
|
+
SELECT _func_compare(NULL, $1, NOT _type_func('w', $1), $2 );
|
|
756
|
+
$$ LANGUAGE sql;
|
|
757
|
+
|
|
758
|
+
-- isnt_window( function )
|
|
759
|
+
CREATE OR REPLACE FUNCTION isnt_window( NAME )
|
|
760
|
+
RETURNS TEXT AS $$
|
|
761
|
+
SELECT _func_compare(
|
|
762
|
+
NULL, $1, NOT _type_func('w', $1),
|
|
763
|
+
'Function ' || quote_ident($1) || '() should not be a window function'
|
|
764
|
+
);
|
|
765
|
+
$$ LANGUAGE sql;
|
|
766
|
+
|
|
767
|
+
-- is_procedure( schema, function, args[], description )
|
|
768
|
+
CREATE OR REPLACE FUNCTION is_procedure ( NAME, NAME, NAME[], TEXT )
|
|
769
|
+
RETURNS TEXT AS $$
|
|
770
|
+
SELECT _func_compare($1, $2, $3, _type_func( 'p', $1, $2, $3), $4 );
|
|
771
|
+
$$ LANGUAGE SQL;
|
|
772
|
+
|
|
773
|
+
-- is_procedure( schema, function, args[] )
|
|
774
|
+
CREATE OR REPLACE FUNCTION is_procedure( NAME, NAME, NAME[] )
|
|
775
|
+
RETURNS TEXT AS $$
|
|
776
|
+
SELECT _func_compare(
|
|
777
|
+
$1, $2, $3, _type_func('p', $1, $2, $3),
|
|
778
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '(' ||
|
|
779
|
+
array_to_string($3, ', ') || ') should be a procedure'
|
|
780
|
+
);
|
|
781
|
+
$$ LANGUAGE sql;
|
|
782
|
+
|
|
783
|
+
-- is_procedure( schema, function, description )
|
|
784
|
+
CREATE OR REPLACE FUNCTION is_procedure ( NAME, NAME, TEXT )
|
|
785
|
+
RETURNS TEXT AS $$
|
|
786
|
+
SELECT _func_compare($1, $2, _type_func('p', $1, $2), $3 );
|
|
787
|
+
$$ LANGUAGE SQL;
|
|
788
|
+
|
|
789
|
+
-- is_procedure( schema, function )
|
|
790
|
+
CREATE OR REPLACE FUNCTION is_procedure( NAME, NAME )
|
|
791
|
+
RETURNS TEXT AS $$
|
|
792
|
+
SELECT _func_compare(
|
|
793
|
+
$1, $2, _type_func('p', $1, $2),
|
|
794
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '() should be a procedure'
|
|
795
|
+
);
|
|
796
|
+
$$ LANGUAGE sql;
|
|
797
|
+
|
|
798
|
+
-- is_procedure( function, args[], description )
|
|
799
|
+
CREATE OR REPLACE FUNCTION is_procedure ( NAME, NAME[], TEXT )
|
|
800
|
+
RETURNS TEXT AS $$
|
|
801
|
+
SELECT _func_compare(NULL, $1, $2, _type_func('p', $1, $2), $3 );
|
|
802
|
+
$$ LANGUAGE SQL;
|
|
803
|
+
|
|
804
|
+
-- is_procedure( function, args[] )
|
|
805
|
+
CREATE OR REPLACE FUNCTION is_procedure( NAME, NAME[] )
|
|
806
|
+
RETURNS TEXT AS $$
|
|
807
|
+
SELECT _func_compare(
|
|
808
|
+
NULL, $1, $2, _type_func('p', $1, $2),
|
|
809
|
+
'Function ' || quote_ident($1) || '(' ||
|
|
810
|
+
array_to_string($2, ', ') || ') should be a procedure'
|
|
811
|
+
);
|
|
812
|
+
$$ LANGUAGE sql;
|
|
813
|
+
|
|
814
|
+
-- is_procedure( function, description )
|
|
815
|
+
CREATE OR REPLACE FUNCTION is_procedure( NAME, TEXT )
|
|
816
|
+
RETURNS TEXT AS $$
|
|
817
|
+
SELECT _func_compare(NULL, $1, _type_func('p', $1), $2 );
|
|
818
|
+
$$ LANGUAGE sql;
|
|
819
|
+
|
|
820
|
+
-- is_procedure( function )
|
|
821
|
+
CREATE OR REPLACE FUNCTION is_procedure( NAME )
|
|
822
|
+
RETURNS TEXT AS $$
|
|
823
|
+
SELECT _func_compare(
|
|
824
|
+
NULL, $1, _type_func('p', $1),
|
|
825
|
+
'Function ' || quote_ident($1) || '() should be a procedure'
|
|
826
|
+
);
|
|
827
|
+
$$ LANGUAGE sql;
|
|
828
|
+
|
|
829
|
+
-- isnt_procedure( schema, function, args[], description )
|
|
830
|
+
CREATE OR REPLACE FUNCTION isnt_procedure ( NAME, NAME, NAME[], TEXT )
|
|
831
|
+
RETURNS TEXT AS $$
|
|
832
|
+
SELECT _func_compare($1, $2, $3, NOT _type_func('p', $1, $2, $3), $4 );
|
|
833
|
+
$$ LANGUAGE SQL;
|
|
834
|
+
|
|
835
|
+
-- isnt_procedure( schema, function, args[] )
|
|
836
|
+
CREATE OR REPLACE FUNCTION isnt_procedure( NAME, NAME, NAME[] )
|
|
837
|
+
RETURNS TEXT AS $$
|
|
838
|
+
SELECT _func_compare(
|
|
839
|
+
$1, $2, $3, NOT _type_func('p', $1, $2, $3),
|
|
840
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '(' ||
|
|
841
|
+
array_to_string($3, ', ') || ') should not be a procedure'
|
|
842
|
+
);
|
|
843
|
+
$$ LANGUAGE sql;
|
|
844
|
+
|
|
845
|
+
-- isnt_procedure( schema, function, description )
|
|
846
|
+
CREATE OR REPLACE FUNCTION isnt_procedure ( NAME, NAME, TEXT )
|
|
847
|
+
RETURNS TEXT AS $$
|
|
848
|
+
SELECT _func_compare($1, $2, NOT _type_func('p', $1, $2), $3 );
|
|
849
|
+
$$ LANGUAGE SQL;
|
|
850
|
+
|
|
851
|
+
-- isnt_procedure( schema, function )
|
|
852
|
+
CREATE OR REPLACE FUNCTION isnt_procedure( NAME, NAME )
|
|
853
|
+
RETURNS TEXT AS $$
|
|
854
|
+
SELECT _func_compare(
|
|
855
|
+
$1, $2, NOT _type_func('p', $1, $2),
|
|
856
|
+
'Function ' || quote_ident($1) || '.' || quote_ident($2) || '() should not be a procedure'
|
|
857
|
+
);
|
|
858
|
+
$$ LANGUAGE sql;
|
|
859
|
+
|
|
860
|
+
-- isnt_procedure( function, args[], description )
|
|
861
|
+
CREATE OR REPLACE FUNCTION isnt_procedure ( NAME, NAME[], TEXT )
|
|
862
|
+
RETURNS TEXT AS $$
|
|
863
|
+
SELECT _func_compare(NULL, $1, $2, NOT _type_func('p', $1, $2), $3 );
|
|
864
|
+
$$ LANGUAGE SQL;
|
|
865
|
+
|
|
866
|
+
-- isnt_procedure( function, args[] )
|
|
867
|
+
CREATE OR REPLACE FUNCTION isnt_procedure( NAME, NAME[] )
|
|
868
|
+
RETURNS TEXT AS $$
|
|
869
|
+
SELECT _func_compare(
|
|
870
|
+
NULL, $1, $2, NOT _type_func('p', $1, $2),
|
|
871
|
+
'Function ' || quote_ident($1) || '(' ||
|
|
872
|
+
array_to_string($2, ', ') || ') should not be a procedure'
|
|
873
|
+
);
|
|
874
|
+
$$ LANGUAGE sql;
|
|
875
|
+
|
|
876
|
+
-- isnt_procedure( function, description )
|
|
877
|
+
CREATE OR REPLACE FUNCTION isnt_procedure( NAME, TEXT )
|
|
878
|
+
RETURNS TEXT AS $$
|
|
879
|
+
SELECT _func_compare(NULL, $1, NOT _type_func('p', $1), $2 );
|
|
880
|
+
$$ LANGUAGE sql;
|
|
881
|
+
|
|
882
|
+
-- isnt_procedure( function )
|
|
883
|
+
CREATE OR REPLACE FUNCTION isnt_procedure( NAME )
|
|
884
|
+
RETURNS TEXT AS $$
|
|
885
|
+
SELECT _func_compare(
|
|
886
|
+
NULL, $1, NOT _type_func('p', $1),
|
|
887
|
+
'Function ' || quote_ident($1) || '() should not be a procedure'
|
|
888
|
+
);
|
|
889
|
+
$$ LANGUAGE sql;
|