decoder_raw
decoder_raw
decoder_raw : Output plugin for logical replication in Raw SQL format
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 9660 | decoder_raw | decoder_raw | 1.0 | ETL | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s---- | No | Yes | No | No | no | no |
| Relationships | |
|---|---|
| See Also | pglogical wal2json decoderbufs test_decoding pg_failover_slots pgactive wal2mongo pgoutput |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0 | 18 17 16 15 14 | decoder_raw | - |
| RPM | PIGSTY | 1.0 | 18 17 16 15 14 | decoder_raw_$v | - |
| DEB | PIGSTY | 1.0 | 18 17 16 15 14 | postgresql-$v-decoder-raw | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
el8.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
el9.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
el9.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
el10.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | MISS | MISS | MISS |
el10.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | MISS | MISS | MISS |
d12.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
d12.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
d13.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | MISS | MISS | MISS |
d13.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | MISS | MISS | MISS |
u22.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
u22.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
u24.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
u24.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
Source
pig build pkg decoder_raw;# build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install decoder_raw;# install via package name, for the active PG version pig install decoder_raw -v 18; # install for PG 18 pig install decoder_raw -v 17; # install for PG 17 pig install decoder_raw -v 16; # install for PG 16 pig install decoder_raw -v 15; # install for PG 15 pig install decoder_raw -v 14; # install for PG 14This extension does not need CREATE EXTENSION DDL command
Usage
decoder_raw: Output plugin for logical replication in Raw SQL format
A logical decoding output plugin that converts WAL changes into raw SQL statements. Part of the pg_plugins collection by Michael Paquier.
Configuration
In postgresql.conf:
wal_level = logical max_replication_slots = 10 max_wal_senders = 10Using with SQL Functions
-- Create a logical replication slot SELECT * FROM pg_create_logical_replication_slot('raw_slot', 'decoder_raw'); -- Perform DML operations INSERT INTO my_table VALUES (1, 'hello'); UPDATE my_table SET val = 'world' WHERE id = 1; DELETE FROM my_table WHERE id = 1; -- Get changes as raw SQL SELECT data FROM pg_logical_slot_get_changes('raw_slot', NULL, NULL); -- Output: -- INSERT INTO public.my_table (id, val) VALUES (1, 'hello'); -- UPDATE public.my_table SET val = 'world' WHERE id = 1; -- DELETE FROM public.my_table WHERE id = 1; -- Drop the slot SELECT pg_drop_replication_slot('raw_slot');Using with pg_recvlogical
# Create slot pg_recvlogical -d postgres --slot raw_slot --create-slot -P decoder_raw # Stream changes as SQL statements pg_recvlogical -d postgres --slot raw_slot --start -f - # Drop slot pg_recvlogical -d postgres --slot raw_slot --drop-slotKey Features
- Outputs changes as executable SQL statements (INSERT, UPDATE, DELETE)
- Useful for debugging logical decoding or replaying changes on another database
- Tables should have REPLICA IDENTITY set for proper UPDATE/DELETE output
- Lightweight plugin designed as a template for custom logical decoding plugins
Last updated on