2008-09-30 19:17:07 +08:00
|
|
|
/* $PostgreSQL: pgsql/contrib/pg_freespacemap/pg_freespacemap.sql.in,v 1.10 2008/09/30 11:17:07 heikki Exp $ */
|
2007-11-13 12:24:29 +08:00
|
|
|
|
2006-02-12 11:55:53 +08:00
|
|
|
-- Adjust this setting to control where the objects get created.
|
|
|
|
SET search_path = public;
|
|
|
|
|
2006-04-27 06:46:09 +08:00
|
|
|
|
2008-09-30 18:52:14 +08:00
|
|
|
-- Register the C function.
|
|
|
|
CREATE OR REPLACE FUNCTION pg_freespace(regclass, int4)
|
|
|
|
RETURNS int2
|
|
|
|
AS 'MODULE_PATHNAME', 'pg_freespace'
|
2006-02-28 00:09:50 +08:00
|
|
|
LANGUAGE C;
|
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
|
|
|
|
CREATE OR REPLACE FUNCTION
|
|
|
|
pg_freespace(rel regclass, blkno OUT int4, avail OUT int2)
|
2006-04-27 06:46:09 +08:00
|
|
|
RETURNS SETOF RECORD
|
2008-09-30 18:52:14 +08:00
|
|
|
AS $$
|
|
|
|
SELECT blkno::int4, pg_freespace($1, blkno::int4) AS avail
|
|
|
|
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-09-30 18:52:14 +08:00
|
|
|
REVOKE ALL ON FUNCTION pg_freespace(regclass, int4) FROM PUBLIC;
|
|
|
|
REVOKE ALL ON FUNCTION pg_freespace(regclass) FROM PUBLIC;
|