Skip to content

Add pgoutput as an optional logical decoding plugin - #56

Closed
teknogeek0 wants to merge 3 commits into
mainfrom
feat/pgoutput-plugin
Closed

Add pgoutput as an optional logical decoding plugin#56
teknogeek0 wants to merge 3 commits into
mainfrom
feat/pgoutput-plugin

Conversation

@teknogeek0

Copy link
Copy Markdown
Collaborator

Summary

Adds pgoutput as a logical decoding plugin option. pgoutput ships with
Postgres core, so CDC now works against source servers where wal2json
cannot be installed — managed providers that do not allow extensions.

test_decoding stays the default. Opt in with --plugin pgoutput.

How it works

The receive step decodes the pgoutput binary protocol and writes a
wal2json-shaped JSON message, so the transform and apply steps are unchanged.

pgoutput only sends the tables of a publication. Without --publication,
pgcopydb builds one from the --filters table list and drops it during
pgcopydb stream cleanup. Filtering therefore happens on the source server:
excluded tables are never decoded or sent.

The binary protocol is also compact. On a mixed INSERT/UPDATE/DELETE workload
it used 4.5x less network volume and about 4x less CPU on the source server
than wal2json.

Usage

pgcopydb clone --follow --plugin pgoutput --filters filters.ini

Multi-step migrations pass the filters at the snapshot step, since the
publication is created with the replication slot:

pgcopydb snapshot --follow --plugin pgoutput --filters filters.ini
pgcopydb stream setup
pgcopydb clone --filters filters.ini

New options

  • --publication — use a publication that already exists instead of letting
    pgcopydb manage one
  • --filters on pgcopydb snapshot

Tests

New suites cdc-pgoutput, cdc-filtering-pgoutput and follow-pgoutput,
added to the CI matrix. They cover INSERT/UPDATE/DELETE/TRUNCATE, REPLICA
IDENTITY DEFAULT and FULL, unchanged TOAST values, json and bytea round
trips, and both include-only and exclude filters.

pgoutput ships with Postgres core. It lets pgcopydb follow a source server
where wal2json cannot be installed. test_decoding stays the default.

The receive step decodes the binary protocol and writes a wal2json-shaped
JSON message. The transform and apply steps are unchanged.

pgoutput only sends the tables of a publication. Without --publication,
pgcopydb creates one from the --filters table list, then drops it in
"pgcopydb stream cleanup". CREATE PUBLICATION needs a read-write source, so
a standby source now fails with a clear message.

Add --filters to "pgcopydb snapshot". The publication is created with the
replication slot, so a multi-step migration must pass the filters at that
step. Without it the publication lists every table.

New tests cdc-pgoutput, cdc-filtering-pgoutput and follow-pgoutput run on
PG16 and PG18, and are added to the CI matrix.
citus_indent formats a pointer return type differently on arm64 and amd64.
CI runs amd64, so match that.
@teknogeek0 teknogeek0 closed this Aug 26, 2026
@teknogeek0
teknogeek0 deleted the feat/pgoutput-plugin branch August 26, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant