GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Home
  • About
  • Download
  • Documentation
  • Community
  • Developers
  • Support
  • Donate
  • Your account

This view

  • Original page
  • New address

GeezerVison is showing www.postgresql.org — F.47. test_decoding — SQL-based test/example module for WAL logical decoding

November 19, 2026: PostgreSQL 19 Released!
Documentation → PostgreSQL 19
Supported Versions: Current (19) / 18 / 17 / 16 / 15
Development Versions: devel
Unsupported versions: 14 / 13 / 12 / 11 / 10 / 9.6 / 9.5 / 9.4
F.47. test_decoding — SQL-based test/example module for WAL logical decoding
Prev  Up Appendix F. Additional Supplied Modules and Extensions Home  Next

F.47. test_decoding — SQL-based test/example module for WAL logical decoding #

test_decoding 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.

test_decoding receives WAL through the logical decoding mechanism and decodes it into text representations of the operations performed.

Typical output from this plugin, used over the SQL logical decoding interface, might be:

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)

We can also get the changes of the in-progress transaction, and the typical output might be:

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)

Prev  Up  Next
F.46. tcn — a trigger function to notify listeners of changes to table content  Home  F.48. tsm_system_rows — the SYSTEM_ROWS sampling method for TABLESAMPLE

Submit correction

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.