Commit 08fc73c4 authored by Tom Lane's avatar Tom Lane

Code review for btreefuncs additions: restrict to superusers to avoid

exposing user data to others, and clean up usage of deprecated APIs.
parent 67bf7b91
The functions in this module allow you to inspect the contents of data pages The functions in this module allow you to inspect the contents of data pages
at a low level, for debugging purposes. at a low level, for debugging purposes. All of these functions may be used
only by superusers.
1. Installation 1. Installation
...@@ -13,12 +14,12 @@ at a low level, for debugging purposes. ...@@ -13,12 +14,12 @@ at a low level, for debugging purposes.
------------ ------------
get_raw_page reads one block of the named table and returns a copy as a get_raw_page reads one block of the named table and returns a copy as a
bytea field. This allows a single time-consistent copy of the block to be bytea field. This allows a single time-consistent copy of the block to be
made. Use of this functions is restricted to superusers. made.
page_header page_header
----------- -----------
page_header shows fields which are common to all PostgreSQL heap and index page_header shows fields which are common to all PostgreSQL heap and index
pages. Use of this function is restricted to superusers. pages.
A page image obtained with get_raw_page should be passed as argument: A page image obtained with get_raw_page should be passed as argument:
...@@ -36,8 +37,7 @@ at a low level, for debugging purposes. ...@@ -36,8 +37,7 @@ at a low level, for debugging purposes.
heap_page_items shows all line pointers on a heap page. For those line heap_page_items shows all line pointers on a heap page. For those line
pointers that are in use, tuple headers are also shown. All tuples are pointers that are in use, tuple headers are also shown. All tuples are
shown, whether or not the tuples were visible to an MVCC snapshot at the shown, whether or not the tuples were visible to an MVCC snapshot at the
time the raw page was copied. Use of this function is restricted to time the raw page was copied.
superusers.
A heap page image obtained with get_raw_page should be passed as argument: A heap page image obtained with get_raw_page should be passed as argument:
...@@ -48,7 +48,7 @@ at a low level, for debugging purposes. ...@@ -48,7 +48,7 @@ at a low level, for debugging purposes.
bt_metap bt_metap
-------- --------
bt_metap() returns information about the btree index metapage: bt_metap() returns information about a btree index's metapage:
test=> SELECT * FROM bt_metap('pg_cast_oid_index'); test=> SELECT * FROM bt_metap('pg_cast_oid_index');
-[ RECORD 1 ]----- -[ RECORD 1 ]-----
......
This diff is collapsed.
...@@ -12,98 +12,80 @@ LANGUAGE C STRICT; ...@@ -12,98 +12,80 @@ LANGUAGE C STRICT;
-- --
-- page_header() -- page_header()
-- --
CREATE TYPE page_header_type AS ( CREATE OR REPLACE FUNCTION page_header(IN page bytea,
lsn text, OUT lsn text,
tli smallint, OUT tli smallint,
flags smallint, OUT flags smallint,
lower smallint, OUT lower smallint,
upper smallint, OUT upper smallint,
special smallint, OUT special smallint,
pagesize smallint, OUT pagesize smallint,
version smallint OUT version smallint)
);
CREATE OR REPLACE FUNCTION page_header(bytea)
RETURNS page_header_type
AS 'MODULE_PATHNAME', 'page_header' AS 'MODULE_PATHNAME', 'page_header'
LANGUAGE C STRICT; LANGUAGE C STRICT;
-- --
-- heap_page_items() -- heap_page_items()
-- --
CREATE TYPE heap_page_items_type AS ( CREATE OR REPLACE FUNCTION heap_page_items(IN page bytea,
lp smallint, OUT lp smallint,
lp_off smallint, OUT lp_off smallint,
lp_flags smallint, OUT lp_flags smallint,
lp_len smallint, OUT lp_len smallint,
t_xmin xid, OUT t_xmin xid,
t_xmax xid, OUT t_xmax xid,
t_field3 int4, OUT t_field3 int4,
t_ctid tid, OUT t_ctid tid,
t_infomask2 smallint, OUT t_infomask2 smallint,
t_infomask smallint, OUT t_infomask smallint,
t_hoff smallint, OUT t_hoff smallint,
t_bits text, OUT t_bits text,
t_oid oid OUT t_oid oid)
); RETURNS SETOF record
CREATE OR REPLACE FUNCTION heap_page_items(bytea)
RETURNS SETOF heap_page_items_type
AS 'MODULE_PATHNAME', 'heap_page_items' AS 'MODULE_PATHNAME', 'heap_page_items'
LANGUAGE C STRICT; LANGUAGE C STRICT;
-- --
-- bt_metap() -- bt_metap()
-- --
CREATE TYPE bt_metap_type AS ( CREATE OR REPLACE FUNCTION bt_metap(IN relname text,
magic int4, OUT magic int4,
version int4, OUT version int4,
root int4, OUT root int4,
level int4, OUT level int4,
fastroot int4, OUT fastroot int4,
fastlevel int4 OUT fastlevel int4)
);
CREATE OR REPLACE FUNCTION bt_metap(text)
RETURNS bt_metap_type
AS 'MODULE_PATHNAME', 'bt_metap' AS 'MODULE_PATHNAME', 'bt_metap'
LANGUAGE 'C' STRICT; LANGUAGE C STRICT;
-- --
-- bt_page_stats() -- bt_page_stats()
-- --
CREATE TYPE bt_page_stats_type AS ( CREATE OR REPLACE FUNCTION bt_page_stats(IN relname text, IN blkno int4,
blkno int4, OUT blkno int4,
type char, OUT type "char",
live_items int4, OUT live_items int4,
dead_items int4, OUT dead_items int4,
avg_item_size float, OUT avg_item_size int4,
page_size int4, OUT page_size int4,
free_size int4, OUT free_size int4,
btpo_prev int4, OUT btpo_prev int4,
btpo_next int4, OUT btpo_next int4,
btpo int4, OUT btpo int4,
btpo_flags int4 OUT btpo_flags int4)
);
CREATE OR REPLACE FUNCTION bt_page_stats(text, int4)
RETURNS bt_page_stats_type
AS 'MODULE_PATHNAME', 'bt_page_stats' AS 'MODULE_PATHNAME', 'bt_page_stats'
LANGUAGE 'C' STRICT; LANGUAGE C STRICT;
-- --
-- bt_page_items() -- bt_page_items()
-- --
CREATE TYPE bt_page_items_type AS ( CREATE OR REPLACE FUNCTION bt_page_items(IN relname text, IN blkno int4,
itemoffset smallint, OUT itemoffset smallint,
ctid tid, OUT ctid tid,
itemlen smallint, OUT itemlen smallint,
nulls bool, OUT nulls bool,
vars bool, OUT vars bool,
data text OUT data text)
); RETURNS SETOF record
CREATE OR REPLACE FUNCTION bt_page_items(text, int4)
RETURNS SETOF bt_page_items_type
AS 'MODULE_PATHNAME', 'bt_page_items' AS 'MODULE_PATHNAME', 'bt_page_items'
LANGUAGE 'C' STRICT; LANGUAGE C STRICT;
...@@ -2,19 +2,8 @@ ...@@ -2,19 +2,8 @@
SET search_path = public; SET search_path = public;
DROP FUNCTION get_raw_page(text, int4); DROP FUNCTION get_raw_page(text, int4);
DROP FUNCTION page_header(bytea); DROP FUNCTION page_header(bytea);
DROP TYPE page_header_type;
DROP FUNCTION heap_page_items(bytea); DROP FUNCTION heap_page_items(bytea);
DROP TYPE heap_page_items_type;
DROP FUNCTION bt_metap(text); DROP FUNCTION bt_metap(text);
DROP TYPE bt_metap_type;
DROP FUNCTION bt_page_stats(text, int4); DROP FUNCTION bt_page_stats(text, int4);
DROP TYPE bt_page_stats_type;
DROP FUNCTION bt_page_items(text, int4); DROP FUNCTION bt_page_items(text, int4);
DROP TYPE bt_page_items_type;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment