mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Add pg_dissect_walfile_name()
This function takes in input a WAL segment name and returns a tuple made of the segment sequence number (dependent on the WAL segment size of the cluster) and its timeline, as of a thin SQL wrapper around the existing XLogFromFileName(). This function has multiple usages, like being able to compile a LSN from a file name and an offset, or finding the timeline of a segment without having to do to some maths based on the first eight characters of the segment. Bump catalog version. Author: Bharath Rupireddy Reviewed-by: Nathan Bossart, Kyotaro Horiguchi, Maxim Orlov, Michael Paquier Discussion: https://postgr.es/m/CALj2ACWV=FCddsxcGbVOA=cvPyMr75YCFbSQT6g4KDj=gcJK4g@mail.gmail.com
This commit is contained in:
@ -26098,6 +26098,22 @@ LOG: Grand total: 1651920 bytes in 201 blocks; 622360 free (88 chunks); 1029560
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<indexterm>
|
||||
<primary>pg_dissect_walfile_name</primary>
|
||||
</indexterm>
|
||||
<function>pg_dissect_walfile_name</function> ( <parameter>file_name</parameter> <type>text</type> )
|
||||
<returnvalue>record</returnvalue>
|
||||
( <parameter>segno</parameter> <type>numeric</type>,
|
||||
<parameter>timeline_id</parameter> <type>bigint</type> )
|
||||
</para>
|
||||
<para>
|
||||
Extracts the file sequence number and timeline ID from a WAL file
|
||||
name.
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<indexterm>
|
||||
@ -26155,6 +26171,23 @@ postgres=# SELECT * FROM pg_walfile_name_offset((pg_backup_stop()).lsn);
|
||||
needs to be archived.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<function>pg_dissect_walfile_name</function> is useful to compute a
|
||||
<acronym>LSN</acronym> from a file offset and WAL file name, for example:
|
||||
<programlisting>
|
||||
postgres=# \set file_name '000000010000000100C000AB'
|
||||
postgres=# \set offset 256
|
||||
postgres=# SELECT '0/0'::pg_lsn + pd.segno * ps.setting::int + :offset AS lsn
|
||||
FROM pg_dissect_walfile_name(:'file_name') pd,
|
||||
pg_show_all_settings() ps
|
||||
WHERE ps.name = 'wal_segment_size';
|
||||
lsn
|
||||
---------------
|
||||
C001/AB000100
|
||||
(1 row)
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="functions-recovery-control">
|
||||
|
Reference in New Issue
Block a user