1/* contrib/pageinspect/pageinspect--1.5.sql */ 2 3-- complain if script is sourced in psql, rather than via CREATE EXTENSION 4\echo Use "CREATE EXTENSION pageinspect" to load this file. \quit 5 6-- 7-- get_raw_page() 8-- 9CREATE FUNCTION get_raw_page(text, int4) 10RETURNS bytea 11AS 'MODULE_PATHNAME', 'get_raw_page' 12LANGUAGE C STRICT PARALLEL SAFE; 13 14CREATE FUNCTION get_raw_page(text, text, int4) 15RETURNS bytea 16AS 'MODULE_PATHNAME', 'get_raw_page_fork' 17LANGUAGE C STRICT PARALLEL SAFE; 18 19-- 20-- page_header() 21-- 22CREATE FUNCTION page_header(IN page bytea, 23 OUT lsn pg_lsn, 24 OUT checksum smallint, 25 OUT flags smallint, 26 OUT lower smallint, 27 OUT upper smallint, 28 OUT special smallint, 29 OUT pagesize smallint, 30 OUT version smallint, 31 OUT prune_xid xid) 32AS 'MODULE_PATHNAME', 'page_header' 33LANGUAGE C STRICT PARALLEL SAFE; 34 35-- 36-- heap_page_items() 37-- 38CREATE FUNCTION heap_page_items(IN page bytea, 39 OUT lp smallint, 40 OUT lp_off smallint, 41 OUT lp_flags smallint, 42 OUT lp_len smallint, 43 OUT t_xmin xid, 44 OUT t_xmax xid, 45 OUT t_field3 int4, 46 OUT t_ctid tid, 47 OUT t_infomask2 integer, 48 OUT t_infomask integer, 49 OUT t_hoff smallint, 50 OUT t_bits text, 51 OUT t_oid oid, 52 OUT t_data bytea) 53RETURNS SETOF record 54AS 'MODULE_PATHNAME', 'heap_page_items' 55LANGUAGE C STRICT PARALLEL SAFE; 56 57-- 58-- tuple_data_split() 59-- 60CREATE FUNCTION tuple_data_split(rel_oid oid, 61 t_data bytea, 62 t_infomask integer, 63 t_infomask2 integer, 64 t_bits text) 65RETURNS bytea[] 66AS 'MODULE_PATHNAME','tuple_data_split' 67LANGUAGE C PARALLEL SAFE; 68 69CREATE FUNCTION tuple_data_split(rel_oid oid, 70 t_data bytea, 71 t_infomask integer, 72 t_infomask2 integer, 73 t_bits text, 74 do_detoast bool) 75RETURNS bytea[] 76AS 'MODULE_PATHNAME','tuple_data_split' 77LANGUAGE C PARALLEL SAFE; 78 79-- 80-- heap_page_item_attrs() 81-- 82CREATE FUNCTION heap_page_item_attrs( 83 IN page bytea, 84 IN rel_oid regclass, 85 IN do_detoast bool, 86 OUT lp smallint, 87 OUT lp_off smallint, 88 OUT lp_flags smallint, 89 OUT lp_len smallint, 90 OUT t_xmin xid, 91 OUT t_xmax xid, 92 OUT t_field3 int4, 93 OUT t_ctid tid, 94 OUT t_infomask2 integer, 95 OUT t_infomask integer, 96 OUT t_hoff smallint, 97 OUT t_bits text, 98 OUT t_oid oid, 99 OUT t_attrs bytea[] 100 ) 101RETURNS SETOF record AS $$ 102SELECT lp, 103 lp_off, 104 lp_flags, 105 lp_len, 106 t_xmin, 107 t_xmax, 108 t_field3, 109 t_ctid, 110 t_infomask2, 111 t_infomask, 112 t_hoff, 113 t_bits, 114 t_oid, 115 tuple_data_split( 116 rel_oid, 117 t_data, 118 t_infomask, 119 t_infomask2, 120 t_bits, 121 do_detoast) 122 AS t_attrs 123 FROM heap_page_items(page); 124$$ LANGUAGE SQL PARALLEL SAFE; 125 126CREATE FUNCTION heap_page_item_attrs(IN page bytea, IN rel_oid regclass, 127 OUT lp smallint, 128 OUT lp_off smallint, 129 OUT lp_flags smallint, 130 OUT lp_len smallint, 131 OUT t_xmin xid, 132 OUT t_xmax xid, 133 OUT t_field3 int4, 134 OUT t_ctid tid, 135 OUT t_infomask2 integer, 136 OUT t_infomask integer, 137 OUT t_hoff smallint, 138 OUT t_bits text, 139 OUT t_oid oid, 140 OUT t_attrs bytea[] 141 ) 142RETURNS SETOF record AS $$ 143SELECT * from heap_page_item_attrs(page, rel_oid, false); 144$$ LANGUAGE SQL PARALLEL SAFE; 145 146-- 147-- bt_metap() 148-- 149CREATE FUNCTION bt_metap(IN relname text, 150 OUT magic int4, 151 OUT version int4, 152 OUT root int4, 153 OUT level int4, 154 OUT fastroot int4, 155 OUT fastlevel int4) 156AS 'MODULE_PATHNAME', 'bt_metap' 157LANGUAGE C STRICT PARALLEL SAFE; 158 159-- 160-- bt_page_stats() 161-- 162CREATE FUNCTION bt_page_stats(IN relname text, IN blkno int4, 163 OUT blkno int4, 164 OUT type "char", 165 OUT live_items int4, 166 OUT dead_items int4, 167 OUT avg_item_size int4, 168 OUT page_size int4, 169 OUT free_size int4, 170 OUT btpo_prev int4, 171 OUT btpo_next int4, 172 OUT btpo int4, 173 OUT btpo_flags int4) 174AS 'MODULE_PATHNAME', 'bt_page_stats' 175LANGUAGE C STRICT PARALLEL SAFE; 176 177-- 178-- bt_page_items() 179-- 180CREATE FUNCTION bt_page_items(IN relname text, IN blkno int4, 181 OUT itemoffset smallint, 182 OUT ctid tid, 183 OUT itemlen smallint, 184 OUT nulls bool, 185 OUT vars bool, 186 OUT data text) 187RETURNS SETOF record 188AS 'MODULE_PATHNAME', 'bt_page_items' 189LANGUAGE C STRICT PARALLEL SAFE; 190 191-- 192-- brin_page_type() 193-- 194CREATE FUNCTION brin_page_type(IN page bytea) 195RETURNS text 196AS 'MODULE_PATHNAME', 'brin_page_type' 197LANGUAGE C STRICT PARALLEL SAFE; 198 199-- 200-- brin_metapage_info() 201-- 202CREATE FUNCTION brin_metapage_info(IN page bytea, OUT magic text, 203 OUT version integer, OUT pagesperrange integer, OUT lastrevmappage bigint) 204AS 'MODULE_PATHNAME', 'brin_metapage_info' 205LANGUAGE C STRICT PARALLEL SAFE; 206 207-- 208-- brin_revmap_data() 209-- 210CREATE FUNCTION brin_revmap_data(IN page bytea, 211 OUT pages tid) 212RETURNS SETOF tid 213AS 'MODULE_PATHNAME', 'brin_revmap_data' 214LANGUAGE C STRICT PARALLEL SAFE; 215 216-- 217-- brin_page_items() 218-- 219CREATE FUNCTION brin_page_items(IN page bytea, IN index_oid regclass, 220 OUT itemoffset int, 221 OUT blknum int, 222 OUT attnum int, 223 OUT allnulls bool, 224 OUT hasnulls bool, 225 OUT placeholder bool, 226 OUT value text) 227RETURNS SETOF record 228AS 'MODULE_PATHNAME', 'brin_page_items' 229LANGUAGE C STRICT PARALLEL SAFE; 230 231-- 232-- fsm_page_contents() 233-- 234CREATE FUNCTION fsm_page_contents(IN page bytea) 235RETURNS text 236AS 'MODULE_PATHNAME', 'fsm_page_contents' 237LANGUAGE C STRICT PARALLEL SAFE; 238 239-- 240-- GIN functions 241-- 242 243-- 244-- gin_metapage_info() 245-- 246CREATE FUNCTION gin_metapage_info(IN page bytea, 247 OUT pending_head bigint, 248 OUT pending_tail bigint, 249 OUT tail_free_size int4, 250 OUT n_pending_pages bigint, 251 OUT n_pending_tuples bigint, 252 OUT n_total_pages bigint, 253 OUT n_entry_pages bigint, 254 OUT n_data_pages bigint, 255 OUT n_entries bigint, 256 OUT version int4) 257AS 'MODULE_PATHNAME', 'gin_metapage_info' 258LANGUAGE C STRICT PARALLEL SAFE; 259 260-- 261-- gin_page_opaque_info() 262-- 263CREATE FUNCTION gin_page_opaque_info(IN page bytea, 264 OUT rightlink bigint, 265 OUT maxoff int4, 266 OUT flags text[]) 267AS 'MODULE_PATHNAME', 'gin_page_opaque_info' 268LANGUAGE C STRICT PARALLEL SAFE; 269 270-- 271-- gin_leafpage_items() 272-- 273CREATE FUNCTION gin_leafpage_items(IN page bytea, 274 OUT first_tid tid, 275 OUT nbytes int2, 276 OUT tids tid[]) 277RETURNS SETOF record 278AS 'MODULE_PATHNAME', 'gin_leafpage_items' 279LANGUAGE C STRICT PARALLEL SAFE; 280