2 F.45. test_decoding — SQL-based test/example module for WAL logical decoding
5 test_decoding is an example of a logical decoding output plugin. It
6 doesn't do anything especially useful, but can serve as a starting
7 point for developing your own output plugin.
9 test_decoding receives WAL through the logical decoding mechanism and
10 decodes it into text representations of the operations performed.
12 Typical output from this plugin, used over the SQL logical decoding
14 postgres=# SELECT * FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'i
17 -----------+-----+--------------------------------------------------
18 0/16D30F8 | 691 | BEGIN
19 0/16D32A0 | 691 | table public.data: INSERT: id[int4]:2 data[text]:'arg'
20 0/16D32A0 | 691 | table public.data: INSERT: id[int4]:3 data[text]:'demo'
21 0/16D32A0 | 691 | COMMIT
22 0/16D32D8 | 692 | BEGIN
23 0/16D3398 | 692 | table public.data: DELETE: id[int4]:2
24 0/16D3398 | 692 | table public.data: DELETE: id[int4]:3
25 0/16D3398 | 692 | COMMIT
28 We can also get the changes of the in-progress transaction, and the
29 typical output might be:
30 postgres[33712]=#* SELECT * FROM pg_logical_slot_get_changes('test_slot', NULL,
31 NULL, 'stream-changes', '1');
33 -----------+-----+--------------------------------------------------
34 0/16B21F8 | 503 | opening a streamed block for transaction TXN 503
35 0/16B21F8 | 503 | streaming change for TXN 503
36 0/16B2300 | 503 | streaming change for TXN 503
37 0/16B2408 | 503 | streaming change for TXN 503
38 0/16BEBA0 | 503 | closing a streamed block for transaction TXN 503
39 0/16B21F8 | 503 | opening a streamed block for transaction TXN 503
40 0/16BECA8 | 503 | streaming change for TXN 503
41 0/16BEDB0 | 503 | streaming change for TXN 503
42 0/16BEEB8 | 503 | streaming change for TXN 503
43 0/16BEBA0 | 503 | closing a streamed block for transaction TXN 503