postgresql/contrib/pageinspect/pageinspect.sql.in
Heikki Linnakangas 15c121b3ed Rewrite the FSM. Instead of relying on a fixed-size shared memory segment, the
free space information is stored in a dedicated FSM relation fork, with each
relation (except for hash indexes; they don't use FSM).

This eliminates the max_fsm_relations and max_fsm_pages GUC options; remove any
trace of them from the backend, initdb, and documentation.

Rewrite contrib/pg_freespacemap to match the new FSM implementation. Also
introduce a new variant of the get_raw_page(regclass, int4, int4) function in
contrib/pageinspect that let's you to return pages from any relation fork, and
a new fsm_page_contents() function to inspect the new FSM pages.
2008-09-30 10:52:14 +00:00

108 lines
2.4 KiB
MySQL

/* $PostgreSQL: pgsql/contrib/pageinspect/pageinspect.sql.in,v 1.5 2008/09/30 10:52:09 heikki Exp $ */
-- Adjust this setting to control where the objects get created.
SET search_path = public;
--
-- get_raw_page()
--
CREATE OR REPLACE FUNCTION get_raw_page(text, int4, int4)
RETURNS bytea
AS 'MODULE_PATHNAME', 'get_raw_page'
LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION get_raw_page(text, int4)
RETURNS bytea
AS $$ SELECT get_raw_page($1, 0, $2); $$
LANGUAGE SQL STRICT;
--
-- page_header()
--
CREATE OR REPLACE FUNCTION page_header(IN page bytea,
OUT lsn text,
OUT tli smallint,
OUT flags smallint,
OUT lower smallint,
OUT upper smallint,
OUT special smallint,
OUT pagesize smallint,
OUT version smallint,
OUT prune_xid xid)
AS 'MODULE_PATHNAME', 'page_header'
LANGUAGE C STRICT;
--
-- heap_page_items()
--
CREATE OR REPLACE FUNCTION heap_page_items(IN page bytea,
OUT lp smallint,
OUT lp_off smallint,
OUT lp_flags smallint,
OUT lp_len smallint,
OUT t_xmin xid,
OUT t_xmax xid,
OUT t_field3 int4,
OUT t_ctid tid,
OUT t_infomask2 smallint,
OUT t_infomask smallint,
OUT t_hoff smallint,
OUT t_bits text,
OUT t_oid oid)
RETURNS SETOF record
AS 'MODULE_PATHNAME', 'heap_page_items'
LANGUAGE C STRICT;
--
-- bt_metap()
--
CREATE OR REPLACE FUNCTION bt_metap(IN relname text,
OUT magic int4,
OUT version int4,
OUT root int4,
OUT level int4,
OUT fastroot int4,
OUT fastlevel int4)
AS 'MODULE_PATHNAME', 'bt_metap'
LANGUAGE C STRICT;
--
-- bt_page_stats()
--
CREATE OR REPLACE FUNCTION bt_page_stats(IN relname text, IN blkno int4,
OUT blkno int4,
OUT type "char",
OUT live_items int4,
OUT dead_items int4,
OUT avg_item_size int4,
OUT page_size int4,
OUT free_size int4,
OUT btpo_prev int4,
OUT btpo_next int4,
OUT btpo int4,
OUT btpo_flags int4)
AS 'MODULE_PATHNAME', 'bt_page_stats'
LANGUAGE C STRICT;
--
-- bt_page_items()
--
CREATE OR REPLACE FUNCTION bt_page_items(IN relname text, IN blkno int4,
OUT itemoffset smallint,
OUT ctid tid,
OUT itemlen smallint,
OUT nulls bool,
OUT vars bool,
OUT data text)
RETURNS SETOF record
AS 'MODULE_PATHNAME', 'bt_page_items'
LANGUAGE C STRICT;
--
-- fsm_page_contents()
--
CREATE OR REPLACE FUNCTION fsm_page_contents(IN page bytea)
RETURNS text
AS 'MODULE_PATHNAME', 'fsm_page_contents'
LANGUAGE C STRICT;