1/*-------------------------------------------------------------------------
3 * PostgreSQL Logical Decode Plugin Interface
5 * Copyright (c) 2012-2025, PostgreSQL Global Development Group
7 *-------------------------------------------------------------------------
10#define OUTPUT_PLUGIN_H
24 * Options set by the output plugin, in the startup callback.
33 * Type of the shared library symbol _PG_output_plugin_init that is looked up
34 * when loading an output plugin shared library.
41 * Callback that gets called in a user-defined plugin. ctx->private_data can
42 * be set to some private data.
44 * "is_init" will be set to "true" if the decoding slot just got defined. When
45 * the same slot is used from there one, it will be "false".
52 * Callback called for every (explicit or implicit) BEGIN of a successful
59 * Callback for every individual change in a successful transaction.
67 * Callback for every TRUNCATE in a successful transaction.
76 * Called for every (explicit or implicit) COMMIT of a successful transaction.
83 * Called for the generic logical decoding messages.
94 * Filter changes by origin.
100 * Called to shutdown an output plugin.
105 * Called before decoding of PREPARE record to decide whether this
106 * transaction should be decoded with separate calls to prepare and
107 * commit_prepared/rollback_prepared callbacks or wait till COMMIT PREPARED
108 * and sent as usual transaction.
115 * Callback called for every BEGIN of a prepared transaction.
121 * Called for PREPARE record unless it was filtered by filter_prepare()
129 * Called for COMMIT PREPARED.
136 * Called for ROLLBACK PREPARED.
145 * Called when starting to stream a block of changes from in-progress
146 * transaction (may be called repeatedly, if it's streamed in multiple
153 * Called when stopping to stream a block of changes from in-progress
154 * transaction to a remote node (may be called repeatedly, if it's streamed
155 * in multiple chunks).
161 * Called to discard changes streamed to remote node from in-progress
169 * Called to prepare changes streamed to remote node from in-progress
170 * transaction. This is called as part of a two-phase commit.
177 * Called to apply changes streamed to remote node from in-progress
185 * Callback for streaming individual changes from in-progress transactions.
193 * Callback for streaming generic logical decoding messages from in-progress
202 const char *message);
205 * Callback for streaming truncates from in-progress transactions.
214 * Output plugin callbacks
227 /* streaming of changes at prepare time */
234 /* streaming of changes */
245/* Functions in replication/logical/logical.c */
250#endif /* OUTPUT_PLUGIN_H */
void(* LogicalDecodeStreamCommitCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
struct OutputPluginOptions OutputPluginOptions
bool(* LogicalDecodeFilterByOriginCB)(struct LogicalDecodingContext *ctx, RepOriginId origin_id)
void(* LogicalDecodeBeginCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
void(* LogicalDecodeBeginPrepareCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
void(* LogicalDecodeStreamAbortCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr abort_lsn)
void(* LogicalDecodeCommitPreparedCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
bool(* LogicalDecodeFilterPrepareCB)(struct LogicalDecodingContext *ctx, TransactionId xid, const char *gid)
void(* LogicalDecodePrepareCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr prepare_lsn)
@ OUTPUT_PLUGIN_BINARY_OUTPUT
@ OUTPUT_PLUGIN_TEXTUAL_OUTPUT
void(* LogicalDecodeStreamPrepareCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr prepare_lsn)
void(* LogicalDecodeChangeCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change)
void(* LogicalDecodeStreamStartCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write)
void(* LogicalDecodeStreamTruncateCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, int nrelations, Relation relations[], ReorderBufferChange *change)
void(* LogicalOutputPluginInit)(struct OutputPluginCallbacks *cb)
void(* LogicalDecodeCommitCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
void(* LogicalDecodeStreamChangeCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change)
void(* LogicalDecodeMessageCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, const char *prefix, Size message_size, const char *message)
void OutputPluginUpdateProgress(struct LogicalDecodingContext *ctx, bool skipped_xact)
PGDLLEXPORT void _PG_output_plugin_init(struct OutputPluginCallbacks *cb)
struct OutputPluginCallbacks OutputPluginCallbacks
void(* LogicalDecodeStreamMessageCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, const char *prefix, Size message_size, const char *message)
void(* LogicalDecodeRollbackPreparedCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr prepare_end_lsn, TimestampTz prepare_time)
void(* LogicalDecodeTruncateCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, int nrelations, Relation relations[], ReorderBufferChange *change)
void(* LogicalDecodeStartupCB)(struct LogicalDecodingContext *ctx, OutputPluginOptions *options, bool is_init)
void(* LogicalDecodeShutdownCB)(struct LogicalDecodingContext *ctx)
void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write)
void(* LogicalDecodeStreamStopCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
LogicalDecodeStreamChangeCB stream_change_cb
LogicalDecodeMessageCB message_cb
LogicalDecodeStreamTruncateCB stream_truncate_cb
LogicalDecodeStreamMessageCB stream_message_cb
LogicalDecodeFilterPrepareCB filter_prepare_cb
LogicalDecodeFilterByOriginCB filter_by_origin_cb
LogicalDecodeTruncateCB truncate_cb
LogicalDecodeStreamStopCB stream_stop_cb
LogicalDecodeStreamCommitCB stream_commit_cb
LogicalDecodeRollbackPreparedCB rollback_prepared_cb
LogicalDecodeStreamPrepareCB stream_prepare_cb
LogicalDecodeCommitPreparedCB commit_prepared_cb
LogicalDecodeStreamStartCB stream_start_cb
LogicalDecodePrepareCB prepare_cb
LogicalDecodeStartupCB startup_cb
LogicalDecodeCommitCB commit_cb
LogicalDecodeBeginCB begin_cb
LogicalDecodeStreamAbortCB stream_abort_cb
LogicalDecodeBeginPrepareCB begin_prepare_cb
LogicalDecodeChangeCB change_cb
LogicalDecodeShutdownCB shutdown_cb
OutputPluginOutputType output_type