forked from cybertec-postgresql/pg_show_plans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pg_show_plans--1.0.sql
48 lines (39 loc) · 1.14 KB
/
pg_show_plans--1.0.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
/* pg_show_plans/pg_show_plans--1.0.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION pg_show_plans" to load this file. \quit
-- Register functions.
CREATE FUNCTION pg_show_plans_enable()
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C;
CREATE FUNCTION pg_show_plans_disable()
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C;
CREATE FUNCTION pgsp_format_json()
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C;
CREATE FUNCTION pgsp_format_text()
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C;
CREATE FUNCTION pg_show_plans(
OUT pid int8,
OUT level int8,
OUT userid oid,
OUT dbid oid,
OUT plan text
)
RETURNS SETOF record
AS 'MODULE_PATHNAME'
LANGUAGE C;
-- Register a view on the function for ease of use.
CREATE VIEW pg_show_plans AS
SELECT * FROM pg_show_plans();
GRANT SELECT ON pg_show_plans TO PUBLIC;
-- Don't want this to be available to non-superusers.
REVOKE ALL ON FUNCTION pg_show_plans_enable() FROM PUBLIC;
REVOKE ALL ON FUNCTION pg_show_plans_disable() FROM PUBLIC;
REVOKE ALL ON FUNCTION pgsp_format_json() FROM PUBLIC;
REVOKE ALL ON FUNCTION pgsp_format_text() FROM PUBLIC;