aboutsummaryrefslogtreecommitdiff
path: root/contrib/pg_freespacemap/pg_freespacemap.sql.in
blob: a91a991502aacc775e785cdf4b2f603204b1772b (plain)
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
-- Adjust this setting to control where the objects get created.
BEGIN;
SET search_path = public;


-- Register the functions.
CREATE OR REPLACE FUNCTION pg_freespacemap_pages()
RETURNS SETOF RECORD
AS 'MODULE_PATHNAME', 'pg_freespacemap_pages'
LANGUAGE C;

CREATE OR REPLACE FUNCTION pg_freespacemap_relations()
RETURNS SETOF RECORD
AS 'MODULE_PATHNAME', 'pg_freespacemap_relations'
LANGUAGE C;


-- Create views for convenient access.
CREATE VIEW pg_freespacemap_pages AS
	SELECT P.* FROM pg_freespacemap_pages() AS P
	(reltablespace oid,
	 reldatabase oid,
	 relfilenode oid,
	 relblocknumber bigint,
	 bytes integer);
 
CREATE VIEW pg_freespacemap_relations AS
	SELECT P.* FROM pg_freespacemap_relations() AS P
	(reltablespace oid,
	 reldatabase oid,
	 relfilenode oid,
	 avgrequest integer,
	 interestingpages integer,
	 storedpages integer,
	 nextpage integer);

 
-- Don't want these to be available to public.
REVOKE ALL ON FUNCTION pg_freespacemap_pages() FROM PUBLIC;
REVOKE ALL ON pg_freespacemap_pages FROM PUBLIC;

REVOKE ALL ON FUNCTION pg_freespacemap_relations() FROM PUBLIC;
REVOKE ALL ON pg_freespacemap_relations FROM PUBLIC;

COMMIT;