# `Replicant.Decoder.Pglogical`
[🔗](https://github.com/baselabs/replicant/blob/baselabs_replicant-v4.0.0/lib/replicant/decoder/pglogical.ex#L5)

The `pglogical_output` binary-protocol decoder (pglogical 2.x, ADR-0009 §3).

Wire grammar (OBSERVED from the pglogical 2.4.8 sources; see
ADR-0009 "Plugin-fact verification"): a startup message `S` (version
byte 1 + NUL-terminated key/value pairs) precedes the first transaction; `B`/`C`
bracket transactions (flags u8, LSNs u64, commit time µs-since-2000-epoch, xid u32);
`R` relation metadata carries names and identity-key flags but NO types and NO
replica-identity field (both come from the connect-time catalog read in the cache);
row messages `I`/`U`/`D` carry flags u8, relid u32 and `K`/`N` tuple markers; a tuple
is `T`, natts u16, then per attribute `n` null, `u` unchanged TOAST, or `t` length
u32 (NUL-INCLUSIVE) + bytes.

The decoder requests text-format values only (no `binary.want_*`), so the casting
layer receives the same server text output pgoutput delivers. pglogical emits no
TRUNCATE and no logical-decoding message (it registers no such callbacks), which
`capabilities/0` expresses.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
