1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-27 00:12:01 +03:00
Files
postgres/doc/src/sgml/test-decoding.sgml
Álvaro Herrera 2633dae2e4 Standardize LSN formatting by zero padding
This commit standardizes the output format for LSNs to ensure consistent
representation across various tools and messages.  Previously, LSNs were
inconsistently printed as `%X/%X` in some contexts, while others used
zero-padding.  This often led to confusion when comparing.

To address this, the LSN format is now uniformly set to `%X/%08X`,
ensuring the lower 32-bit part is always zero-padded to eight
hexadecimal digits.

Author: Japin Li <japinli@hotmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/ME0P300MB0445CA53CA0E4B8C1879AF84B641A@ME0P300MB0445.AUSP300.PROD.OUTLOOK.COM
2025-07-07 13:57:43 +02:00

65 lines
2.3 KiB
Plaintext

<!-- doc/src/sgml/test-decoding.sgml -->
<sect1 id="test-decoding" xreflabel="test_decoding">
<title>test_decoding &mdash; SQL-based test/example module for WAL logical decoding</title>
<indexterm zone="test-decoding">
<primary>test_decoding</primary>
</indexterm>
<para>
<filename>test_decoding</filename> is an example of a logical decoding
output plugin. It doesn't do anything especially useful, but can serve as
a starting point for developing your own output plugin.
</para>
<para>
<filename>test_decoding</filename> receives WAL through the logical decoding
mechanism and decodes it into text representations of the operations
performed.
</para>
<para>
Typical output from this plugin, used over the SQL logical decoding
interface, might be:
<programlisting>
postgres=# SELECT * FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'include-xids', '0');
lsn | xid | data
------------+-----+--------------------------------------------------
0/016D30F8 | 691 | BEGIN
0/016D32A0 | 691 | table public.data: INSERT: id[int4]:2 data[text]:'arg'
0/016D32A0 | 691 | table public.data: INSERT: id[int4]:3 data[text]:'demo'
0/016D32A0 | 691 | COMMIT
0/016D32D8 | 692 | BEGIN
0/016D3398 | 692 | table public.data: DELETE: id[int4]:2
0/016D3398 | 692 | table public.data: DELETE: id[int4]:3
0/016D3398 | 692 | COMMIT
(8 rows)
</programlisting>
</para>
<para>
We can also get the changes of the in-progress transaction, and the typical
output might be:
<programlisting>
postgres[33712]=#* SELECT * FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'stream-changes', '1');
lsn | xid | data
------------+-----+--------------------------------------------------
0/016B21F8 | 503 | opening a streamed block for transaction TXN 503
0/016B21F8 | 503 | streaming change for TXN 503
0/016B2300 | 503 | streaming change for TXN 503
0/016B2408 | 503 | streaming change for TXN 503
0/016BEBA0 | 503 | closing a streamed block for transaction TXN 503
0/016B21F8 | 503 | opening a streamed block for transaction TXN 503
0/016BECA8 | 503 | streaming change for TXN 503
0/016BEDB0 | 503 | streaming change for TXN 503
0/016BEEB8 | 503 | streaming change for TXN 503
0/016BEBA0 | 503 | closing a streamed block for transaction TXN 503
(10 rows)
</programlisting>
</para>
</sect1>