- Table of Contents
- 46.1. Logical Decoding Example
- 46.2. Logical Decoding Concepts
- 46.3. Streaming Replication Protocol Interface
- 46.4. Logical Decoding SQL Interface
- 46.5. System catalogs related to logical decoding
- 46.6. Logical Decoding Output Plugins
- 46.6.1. Initialization Function
- 46.6.2. Capabilities
- 46.6.3. Output Plugin Callbacks
- 46.6.4. Functions for producing output from an output plugin
- 46.7. Logical Decoding Output Writers
- 46.8. Synchronous replication support for Logical Decoding
PostgreSQL provides infrastructure to stream the modifications performed via SQL to external consumers. This functionality can be used to for a variety of purposes, including replication solutions and auditing.
Changes are sent out in streams identified by logical replication slots. Each stream outputs each change exactly once.
The format in which those changes are streamed is determined by the output plugin used. An example plugin is provided, and additional plugins can be written to extend the choice of available formats without modifying any core code. Every output plugin has access to each individual new row produced by INSERT and the new row version created by UPDATE. Availability of old row versions for UPDATE and DELETE depends on the configured REPLICA IDENTITY.
Changes can be consumed either using the streaming replication protocol (see Section 49.3 and Section 46.3), or by calling functions via SQL (see Section 46.4). It is also possible to write additional methods of consuming the output of a replication slot without modifying core code (see Section 46.7).