RefLib

Reference library for AI

Back

postgresql_16:9.6.25.2 Heap Functions

PostgreSQL 16 > Appendixes > Additional Supplied Modules and Extensions > pageinspect — low-level inspection of database pages > Heap Functions

heap_page_items(page bytea) returns setof record

heap_page_items shows all line pointers on a heap page. For those line pointers that are in use, tuple headers as well as tuple raw data are also shown. All tuples are shown, whether or not the tuples were visible to an MVCC snapshot at the time the raw page was copied.

A heap page image obtained with get_raw_page should be passed as argument. For example: test=# SELECT * FROM heap_page_items(get_raw_page('pg_class', 0)); See src/include/storage/itemid.h and src/include/access/htup_details.h for explanations of the fields returned.

The heap_tuple_infomask_flags function can be used to unpack the flag bits of t_infomask and t_infomask2 for heap tuples.

tuple_data_split(rel_oid oid, t_data bytea, t_infomask integer, t_infomask2 integer, t_bits text [, do_detoast bool]) returns bytea[]

tuple_data_split splits tuple data into attributes in the same way as backend internals. test=# SELECT tuple_data_split('pg_class'::regclass, t_data, t_infomask, t_infomask2, t_bits) FROM heap_page_items(get_raw_page('pg_class', 0)); This function should be called with the same arguments as the return attributes of heap_page_items.

If do_detoast is true, attributes will be detoasted as needed. Default value is false.

heap_page_item_attrs(page bytea, rel_oid regclass [, do_detoast bool]) returns setof record

heap_page_item_attrs is equivalent to heap_page_items except that it returns tuple raw data as an array of attributes that can optionally be detoasted by do_detoast which is false by default.

A heap page image obtained with get_raw_page should be passed as argument. For example: test=# SELECT * FROM heap_page_item_attrs(get_raw_page('pg_class', 0), 'pg_class'::regclass);

heap_tuple_infomask_flags(t_infomask integer, t_infomask2 integer) returns record

heap_tuple_infomask_flags decodes the t_infomask and t_infomask2 returned by heap_page_items into a human-readable set of arrays made of flag names, with one column for all the flags and one column for combined flags. For example: test=# SELECT t_ctid, raw_flags, combined_flags FROM heap_page_items(get_raw_page('pg_class', 0)), LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2) WHERE t_infomask IS NOT NULL OR t_infomask2 IS NOT NULL; This function should be called with the same arguments as the return attributes of heap_page_items.

Combined flags are displayed for source-level macros that take into account the value of more than one raw bit, such as HEAP_XMIN_FROZEN.

See src/include/access/htup_details.h for explanations of the flag names returned.

Back