Debian Codegraph @

contrib/pg_freespacemap/pg_freespacemap--1.1.sql

raw
1 /* contrib/pg_freespacemap/pg_freespacemap--1.1.sql */
2
3 -- complain if script is sourced in psql, rather than via CREATE EXTENSION
4 \echo Use "CREATE EXTENSION pg_freespacemap" to load this file. \quit
5
6 -- Register the C function.
7 CREATE FUNCTION pg_freespace(regclass, bigint)
8 RETURNS int2
9 AS 'MODULE_PATHNAME', 'pg_freespace'
10 LANGUAGE C STRICT PARALLEL SAFE;
11
12 -- pg_freespace shows the recorded space avail at each block in a relation
13 CREATE FUNCTION
14 pg_freespace(rel regclass, blkno OUT bigint, avail OUT int2)
15 RETURNS SETOF RECORD
16 AS $$
17 SELECT blkno, pg_freespace($1, blkno) AS avail
18 FROM generate_series(0, pg_relation_size($1) / current_setting('block_size')::bigint - 1) AS blkno;
19 $$
20 LANGUAGE SQL PARALLEL SAFE;
21
22
23 -- Don't want these to be available to public.
24 REVOKE ALL ON FUNCTION pg_freespace(regclass, bigint) FROM PUBLIC;
25 REVOKE ALL ON FUNCTION pg_freespace(regclass) FROM PUBLIC;