PostgreSQL Source Code git master
Loading...
Searching...
No Matches
output_plugin.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 * output_plugin.h
3 * PostgreSQL Logical Decode Plugin Interface
4 *
5 * Copyright (c) 2012-2026, PostgreSQL Global Development Group
6 *
7 *-------------------------------------------------------------------------
8 */
9#ifndef OUTPUT_PLUGIN_H
10#define OUTPUT_PLUGIN_H
11
13
16
22
23/*
24 * Options set by the output plugin, in the startup callback.
25 */
32
33/*
34 * Type of the shared library symbol _PG_output_plugin_init that is looked up
35 * when loading an output plugin shared library.
36 */
38
40
41/*
42 * Callback that gets called in a user-defined plugin. ctx->private_data can
43 * be set to some private data.
44 *
45 * "is_init" will be set to "true" if the decoding slot just got defined. When
46 * the same slot is used from there one, it will be "false".
47 */
50 bool is_init);
51
52/*
53 * Callback called for every (explicit or implicit) BEGIN of a successful
54 * transaction.
55 */
57 ReorderBufferTXN *txn);
58
59/*
60 * Callback for every individual change in a successful transaction.
61 */
64 Relation relation,
65 ReorderBufferChange *change);
66
67/*
68 * Callback for every TRUNCATE in a successful transaction.
69 */
72 int nrelations,
73 Relation relations[],
74 ReorderBufferChange *change);
75
76/*
77 * Called for every (explicit or implicit) COMMIT of a successful transaction.
78 */
81 XLogRecPtr commit_lsn);
82
83/*
84 * Called for the generic logical decoding messages.
85 */
89 bool transactional,
90 const char *prefix,
91 Size message_size,
92 const char *message);
93
94/*
95 * Filter changes by origin.
96 */
98 ReplOriginId origin_id);
99
100/*
101 * Called to shutdown an output plugin.
102 */
104
105/*
106 * Called before decoding of PREPARE record to decide whether this
107 * transaction should be decoded with separate calls to prepare and
108 * commit_prepared/rollback_prepared callbacks or wait till COMMIT PREPARED
109 * and sent as usual transaction.
110 */
112 TransactionId xid,
113 const char *gid);
114
115/*
116 * Callback called for every BEGIN of a prepared transaction.
117 */
119 ReorderBufferTXN *txn);
120
121/*
122 * Called for PREPARE record unless it was filtered by filter_prepare()
123 * callback.
124 */
126 ReorderBufferTXN *txn,
127 XLogRecPtr prepare_lsn);
128
129/*
130 * Called for COMMIT PREPARED.
131 */
133 ReorderBufferTXN *txn,
134 XLogRecPtr commit_lsn);
135
136/*
137 * Called for ROLLBACK PREPARED.
138 */
140 ReorderBufferTXN *txn,
141 XLogRecPtr prepare_end_lsn,
142 TimestampTz prepare_time);
143
144
145/*
146 * Called when starting to stream a block of changes from in-progress
147 * transaction (may be called repeatedly, if it's streamed in multiple
148 * chunks).
149 */
151 ReorderBufferTXN *txn);
152
153/*
154 * Called when stopping to stream a block of changes from in-progress
155 * transaction to a remote node (may be called repeatedly, if it's streamed
156 * in multiple chunks).
157 */
159 ReorderBufferTXN *txn);
160
161/*
162 * Called to discard changes streamed to remote node from in-progress
163 * transaction.
164 */
166 ReorderBufferTXN *txn,
167 XLogRecPtr abort_lsn);
168
169/*
170 * Called to prepare changes streamed to remote node from in-progress
171 * transaction. This is called as part of a two-phase commit.
172 */
174 ReorderBufferTXN *txn,
175 XLogRecPtr prepare_lsn);
176
177/*
178 * Called to apply changes streamed to remote node from in-progress
179 * transaction.
180 */
182 ReorderBufferTXN *txn,
183 XLogRecPtr commit_lsn);
184
185/*
186 * Callback for streaming individual changes from in-progress transactions.
187 */
189 ReorderBufferTXN *txn,
190 Relation relation,
191 ReorderBufferChange *change);
192
193/*
194 * Callback for streaming generic logical decoding messages from in-progress
195 * transactions.
196 */
198 ReorderBufferTXN *txn,
200 bool transactional,
201 const char *prefix,
202 Size message_size,
203 const char *message);
204
205/*
206 * Callback for streaming truncates from in-progress transactions.
207 */
209 ReorderBufferTXN *txn,
210 int nrelations,
211 Relation relations[],
212 ReorderBufferChange *change);
213
214/*
215 * Output plugin callbacks
216 */
245
246/* Functions in replication/logical/logical.c */
247extern void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write);
248extern void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write);
250
251#endif /* OUTPUT_PLUGIN_H */
#define PGDLLEXPORT
Definition c.h:1436
uint32 TransactionId
Definition c.h:736
size_t Size
Definition c.h:689
int64 TimestampTz
Definition timestamp.h:39
void(* LogicalDecodeStreamCommitCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
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)
bool(* LogicalDecodeFilterByOriginCB)(struct LogicalDecodingContext *ctx, ReplOriginId origin_id)
void(* LogicalDecodePrepareCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr prepare_lsn)
OutputPluginOutputType
@ 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)
Definition logical.c:701
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)
Definition logical.c:714
PGDLLEXPORT void _PG_output_plugin_init(struct OutputPluginCallbacks *cb)
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)
Definition logical.c:688
void(* LogicalDecodeStreamStopCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
static int fb(int x)
OutputPluginOptions options
Definition logical.h:54
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
uint16 ReplOriginId
Definition xlogdefs.h:69
uint64 XLogRecPtr
Definition xlogdefs.h:21