Home Explore Blog CI



postgresql

2nd chunk of `doc/src/sgml/pgwalinspect.sgml`
984a12deb62743b429b42fa046651bc648db95ee1ee816d30000000100000eae
 3, 4, 5]
block_ref        | blkref #0: rel 1663/16385/1249 fork main blk 364
</screen>
     </para>
     <para>
      If <replaceable>in_lsn</replaceable> isn't at the start of a WAL
      record, information about the next valid WAL record is shown
      instead.  If there is no next valid WAL record, the function
      raises an error.
     </para>
    </listitem>
   </varlistentry>

    <varlistentry id="pgwalinspect-funcs-pg-get-wal-records-info">
    <term>
     <function>
      pg_get_wal_records_info(start_lsn pg_lsn, end_lsn pg_lsn)
      returns setof record
     </function>
    </term>

    <listitem>
     <para>
      Gets information of all the valid WAL records between
      <replaceable>start_lsn</replaceable> and <replaceable>end_lsn</replaceable>.
      Returns one row per WAL record.  For example:
<screen>
postgres=# SELECT * FROM pg_get_wal_records_info('0/1E913618', '0/1E913740') LIMIT 1;
-[ RECORD 1 ]----+--------------------------------------------------------------
start_lsn        | 0/1E913618
end_lsn          | 0/1E913650
prev_lsn         | 0/1E9135A0
xid              | 0
resource_manager | Standby
record_type      | RUNNING_XACTS
record_length    | 50
main_data_length | 24
fpi_length       | 0
description      | nextXid 33775 latestCompletedXid 33774 oldestRunningXid 33775
block_ref        |
</screen>
     </para>
     <para>
      The function raises an error if
      <replaceable>start_lsn</replaceable> is not available.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="pgwalinspect-funcs-pg-get-wal-block-info">
    <term>
     <function>pg_get_wal_block_info(start_lsn pg_lsn, end_lsn pg_lsn, show_data boolean DEFAULT true) returns setof record</function>
    </term>

    <listitem>
     <para>
      Gets information about each block reference from all the valid
      WAL records between <replaceable>start_lsn</replaceable> and
      <replaceable>end_lsn</replaceable> with one or more block
      references.  Returns one row per block reference per WAL record.
      For example:
<screen>
postgres=# SELECT * FROM pg_get_wal_block_info('0/1230278', '0/12302B8');
-[ RECORD 1 ]-----+-----------------------------------
start_lsn         | 0/1230278
end_lsn           | 0/12302B8
prev_lsn          | 0/122FD40
block_id          | 0
reltablespace     | 1663
reldatabase       | 1
relfilenode       | 2658
relforknumber     | 0
relblocknumber    | 11
xid               | 341
resource_manager  | Btree
record_type       | INSERT_LEAF
record_length     | 64
main_data_length  | 2
block_data_length | 16
block_fpi_length  | 0
block_fpi_info    |
description       | off: 46
block_data        | \x00002a00070010402630000070696400
block_fpi_data    |
</screen>
     </para>
     <para>
      This example involves a WAL record that only contains one block
      reference, but many WAL records contain several block
      references.  Rows output by
      <function>pg_get_wal_block_info</function> are guaranteed to
      have a unique combination of
      <replaceable>start_lsn</replaceable> and
      <replaceable>block_id</replaceable> values.
     </para>
     <para>
      Much of the information shown here matches the output that
      <function>pg_get_wal_records_info</function> would show, given
      the same arguments.  However,
      <function>pg_get_wal_block_info</function> unnests the
      information from each WAL record into an expanded form by
      outputting one row per block reference, so certain details are
      tracked at the block reference level rather than at the
      whole-record level.  This structure is useful with queries that
      track how individual blocks changed over time.  Note that
      records with no block references (e.g.,
     

Title: pg_get_wal_block_info Function in pg_walinspect Module
Summary
The pg_get_wal_block_info function is part of the pg_walinspect module in PostgreSQL. It retrieves detailed information about block references from WAL records within a specified LSN range. The function returns one row per block reference for each WAL record, including data such as LSN, block ID, relation details, transaction ID, resource manager, record type, and block data. This function is particularly useful for tracking changes to individual blocks over time and provides a more granular view of WAL information compared to pg_get_wal_records_info. The output includes both metadata and actual block data, with an option to exclude the data display for efficiency.