decoder_raw

decoder_raw

decoder_raw : Output plugin for logical replication in Raw SQL format

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
9660
decoder_raw
decoder_raw
1.0
ETL
PostgreSQL
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s----
No
Yes
No
No
no
no
Relationships
See Also
pglogical
wal2json
decoderbufs
test_decoding
pg_failover_slots
pgactive
wal2mongo
pgoutput

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
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 / PGPG18PG17PG16PG15PG14
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
PackageVersionOSORGSIZEFile URL
decoder_raw_161.0el8.x86_64pigsty15.2 KiBdecoder_raw_16-1.0-1PIGSTY.el8.x86_64.rpm
decoder_raw_161.0el8.aarch64pigsty15.3 KiBdecoder_raw_16-1.0-1PIGSTY.el8.aarch64.rpm
decoder_raw_161.0el9.x86_64pigsty14.8 KiBdecoder_raw_16-1.0-1PIGSTY.el9.x86_64.rpm
decoder_raw_161.0el9.aarch64pigsty14.7 KiBdecoder_raw_16-1.0-1PIGSTY.el9.aarch64.rpm
postgresql-16-decoder-raw1.0d12.x86_64pigsty16.5 KiBpostgresql-16-decoder-raw_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-16-decoder-raw1.0d12.aarch64pigsty16.5 KiBpostgresql-16-decoder-raw_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-16-decoder-raw1.0u22.x86_64pigsty20.1 KiBpostgresql-16-decoder-raw_1.0-1PIGSTY~jammy_amd64.deb
postgresql-16-decoder-raw1.0u22.aarch64pigsty19.7 KiBpostgresql-16-decoder-raw_1.0-1PIGSTY~jammy_arm64.deb
postgresql-16-decoder-raw1.0u24.x86_64pigsty17.1 KiBpostgresql-16-decoder-raw_1.0-1PIGSTY~noble_amd64.deb
postgresql-16-decoder-raw1.0u24.aarch64pigsty17.3 KiBpostgresql-16-decoder-raw_1.0-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
decoder_raw_151.0el8.x86_64pigsty15.0 KiBdecoder_raw_15-1.0-1PIGSTY.el8.x86_64.rpm
decoder_raw_151.0el8.aarch64pigsty15.1 KiBdecoder_raw_15-1.0-1PIGSTY.el8.aarch64.rpm
decoder_raw_151.0el9.x86_64pigsty14.7 KiBdecoder_raw_15-1.0-1PIGSTY.el9.x86_64.rpm
decoder_raw_151.0el9.aarch64pigsty14.6 KiBdecoder_raw_15-1.0-1PIGSTY.el9.aarch64.rpm
postgresql-15-decoder-raw1.0d12.x86_64pigsty16.1 KiBpostgresql-15-decoder-raw_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-15-decoder-raw1.0d12.aarch64pigsty16.2 KiBpostgresql-15-decoder-raw_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-15-decoder-raw1.0u22.x86_64pigsty19.7 KiBpostgresql-15-decoder-raw_1.0-1PIGSTY~jammy_amd64.deb
postgresql-15-decoder-raw1.0u22.aarch64pigsty19.3 KiBpostgresql-15-decoder-raw_1.0-1PIGSTY~jammy_arm64.deb
postgresql-15-decoder-raw1.0u24.x86_64pigsty16.8 KiBpostgresql-15-decoder-raw_1.0-1PIGSTY~noble_amd64.deb
postgresql-15-decoder-raw1.0u24.aarch64pigsty17.0 KiBpostgresql-15-decoder-raw_1.0-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
decoder_raw_141.0el8.x86_64pigsty15.0 KiBdecoder_raw_14-1.0-1PIGSTY.el8.x86_64.rpm
decoder_raw_141.0el8.aarch64pigsty15.1 KiBdecoder_raw_14-1.0-1PIGSTY.el8.aarch64.rpm
decoder_raw_141.0el9.x86_64pigsty15.0 KiBdecoder_raw_14-1.0-1PIGSTY.el9.x86_64.rpm
decoder_raw_141.0el9.aarch64pigsty14.9 KiBdecoder_raw_14-1.0-1PIGSTY.el9.aarch64.rpm
postgresql-14-decoder-raw1.0d12.x86_64pigsty16.8 KiBpostgresql-14-decoder-raw_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-14-decoder-raw1.0d12.aarch64pigsty16.6 KiBpostgresql-14-decoder-raw_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-14-decoder-raw1.0u22.x86_64pigsty20.3 KiBpostgresql-14-decoder-raw_1.0-1PIGSTY~jammy_amd64.deb
postgresql-14-decoder-raw1.0u22.aarch64pigsty19.9 KiBpostgresql-14-decoder-raw_1.0-1PIGSTY~jammy_arm64.deb
postgresql-14-decoder-raw1.0u24.x86_64pigsty17.5 KiBpostgresql-14-decoder-raw_1.0-1PIGSTY~noble_amd64.deb
postgresql-14-decoder-raw1.0u24.aarch64pigsty17.4 KiBpostgresql-14-decoder-raw_1.0-1PIGSTY~noble_arm64.deb

Source

pig build pkg decoder_raw;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install 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 14

This 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 = 10

Using 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-slot

Key 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