2011-02-14 09:06:41 +08:00
|
|
|
/* contrib/pg_freespacemap/pg_freespacemap--1.0.sql */
|
2006-04-27 06:46:09 +08:00
|
|
|
|
2008-09-30 18:52:14 +08:00
|
|
|
-- Register the C function.
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION pg_freespace(regclass, bigint)
|
2008-09-30 18:52:14 +08:00
|
|
|
RETURNS int2
|
|
|
|
AS 'MODULE_PATHNAME', 'pg_freespace'
|
2009-06-11 06:12:28 +08:00
|
|
|
LANGUAGE C STRICT;
|
2006-02-12 11:55:53 +08:00
|
|
|
|
2008-09-30 18:52:14 +08:00
|
|
|
-- pg_freespace shows the recorded space avail at each block in a relation
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION
|
2008-10-02 20:20:50 +08:00
|
|
|
pg_freespace(rel regclass, blkno OUT bigint, avail OUT int2)
|
2006-04-27 06:46:09 +08:00
|
|
|
RETURNS SETOF RECORD
|
2008-09-30 18:52:14 +08:00
|
|
|
AS $$
|
2008-10-02 20:20:50 +08:00
|
|
|
SELECT blkno, pg_freespace($1, blkno) AS avail
|
2008-09-30 18:52:14 +08:00
|
|
|
FROM generate_series(0, pg_relation_size($1) / current_setting('block_size')::bigint - 1) AS blkno;
|
|
|
|
$$
|
|
|
|
LANGUAGE SQL;
|
2006-04-27 06:46:09 +08:00
|
|
|
|
|
|
|
|
2006-05-05 04:39:34 +08:00
|
|
|
-- Don't want these to be available to public.
|
2008-10-02 20:20:50 +08:00
|
|
|
REVOKE ALL ON FUNCTION pg_freespace(regclass, bigint) FROM PUBLIC;
|
2008-09-30 18:52:14 +08:00
|
|
|
REVOKE ALL ON FUNCTION pg_freespace(regclass) FROM PUBLIC;
|