-
Notifications
You must be signed in to change notification settings - Fork 35
/
pg_wait_sampling--1.1.sql
60 lines (48 loc) · 1.46 KB
/
pg_wait_sampling--1.1.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
/* contrib/pg_wait_sampling/setup.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION pg_wait_sampling" to load this file. \quit
CREATE FUNCTION pg_wait_sampling_get_current (
pid int4,
OUT pid int4,
OUT event_type text,
OUT event text,
OUT queryid int8
)
RETURNS SETOF record
AS 'MODULE_PATHNAME'
LANGUAGE C VOLATILE CALLED ON NULL INPUT;
CREATE VIEW pg_wait_sampling_current AS
SELECT * FROM pg_wait_sampling_get_current(NULL::integer);
GRANT SELECT ON pg_wait_sampling_current TO PUBLIC;
CREATE FUNCTION pg_wait_sampling_get_history (
OUT pid int4,
OUT ts timestamptz,
OUT event_type text,
OUT event text,
OUT queryid int8
)
RETURNS SETOF record
AS 'MODULE_PATHNAME'
LANGUAGE C VOLATILE STRICT;
CREATE VIEW pg_wait_sampling_history AS
SELECT * FROM pg_wait_sampling_get_history();
GRANT SELECT ON pg_wait_sampling_history TO PUBLIC;
CREATE FUNCTION pg_wait_sampling_get_profile (
OUT pid int4,
OUT event_type text,
OUT event text,
OUT queryid int8,
OUT count int8
)
RETURNS SETOF record
AS 'MODULE_PATHNAME'
LANGUAGE C VOLATILE STRICT;
CREATE VIEW pg_wait_sampling_profile AS
SELECT * FROM pg_wait_sampling_get_profile();
GRANT SELECT ON pg_wait_sampling_profile TO PUBLIC;
CREATE FUNCTION pg_wait_sampling_reset_profile()
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C VOLATILE STRICT;
-- Don't want this to be available to non-superusers.
REVOKE ALL ON FUNCTION pg_wait_sampling_reset_profile() FROM PUBLIC;