the page is somehow corrupted. If
data checksums are disabled for this instance, then the value stored
is meaningless.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<function>page_checksum(page bytea, blkno bigint) returns smallint</function>
<indexterm>
<primary>page_checksum</primary>
</indexterm>
</term>
<listitem>
<para>
<function>page_checksum</function> computes the checksum for the page, as if
it was located at the given block.
</para>
<para>
A page image obtained with <function>get_raw_page</function> should be
passed as argument. For example:
<screen>
test=# SELECT page_checksum(get_raw_page('pg_class', 0), 0);
page_checksum
---------------
13443
</screen>
Note that the checksum depends on the block number, so matching block
numbers should be passed (except when doing esoteric debugging).
</para>
<para>
The checksum computed with this function can be compared with
the <structfield>checksum</structfield> result field of the
function <function>page_header</function>. If data checksums are
enabled for this instance, then the two values should be equal.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<function>fsm_page_contents(page bytea) returns text</function>
<indexterm>
<primary>fsm_page_contents</primary>
</indexterm>
</term>
<listitem>
<para>
<function>fsm_page_contents</function> shows the internal node structure
of an <acronym>FSM</acronym> page. For example:
<screen>
test=# SELECT fsm_page_contents(get_raw_page('pg_class', 'fsm', 0));
</screen>
The output is a multiline string, with one line per node in the binary
tree within the page. Only those nodes that are not zero are printed.
The so-called "next" pointer, which points to the next slot to be
returned from the page, is also printed.
</para>
<para>
See <filename>src/backend/storage/freespace/README</filename> for more
information on the structure of an <acronym>FSM</acronym> page.
</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>
<sect2 id="pageinspect-heap-funcs">
<title>Heap Functions</title>
<variablelist>
<varlistentry>
<term>
<function>heap_page_items(page bytea) returns setof record</function>
<indexterm>
<primary>heap_page_items</primary>
</indexterm>
</term>
<listitem>
<para>
<function>heap_page_items</function> 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.
</para>
<para>
A heap page image obtained with <function>get_raw_page</function> should
be passed as argument. For example:
<screen>
test=# SELECT * FROM heap_page_items(get_raw_page('pg_class', 0));
</screen>
See <filename>src/include/storage/itemid.h</filename> and
<filename>src/include/access/htup_details.h</filename> for explanations of the fields
returned.
</para>
<para>
The <function>heap_tuple_infomask_flags</function> function can be
used to unpack the flag bits of <structfield>t_infomask</structfield>
and <structfield>t_infomask2</structfield> for heap tuples.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<function>tuple_data_split(rel_oid oid, t_data bytea, t_infomask integer, t_infomask2 integer, t_bits text [, do_detoast bool]) returns bytea[]</function>
<indexterm>
<primary>tuple_data_split</primary>
</indexterm>
</term>
<listitem>
<para>
<function>tuple_data_split</function> splits tuple data into attributes
in the same way as backend internals.