PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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-2017, PostgreSQL Global Development Group
6  *
7  *-------------------------------------------------------------------------
8  */
9 #ifndef OUTPUT_PLUGIN_H
10 #define OUTPUT_PLUGIN_H
11 
13 
16 
18 {
22 
23 /*
24  * Options set by the output plugin, in the startup callback.
25  */
26 typedef struct OutputPluginOptions
27 {
30 
31 /*
32  * Type of the shared library symbol _PG_output_plugin_init that is looked up
33  * when loading an output plugin shared library.
34  */
35 typedef void (*LogicalOutputPluginInit) (struct OutputPluginCallbacks *cb);
36 
37 /*
38  * Callback that gets called in a user-defined plugin. ctx->private_data can
39  * be set to some private data.
40  *
41  * "is_init" will be set to "true" if the decoding slot just got defined. When
42  * the same slot is used from there one, it will be "false".
43  */
44 typedef void (*LogicalDecodeStartupCB) (struct LogicalDecodingContext *ctx,
46  bool is_init);
47 
48 /*
49  * Callback called for every (explicit or implicit) BEGIN of a successful
50  * transaction.
51  */
52 typedef void (*LogicalDecodeBeginCB) (struct LogicalDecodingContext *ctx,
53  ReorderBufferTXN *txn);
54 
55 /*
56  * Callback for every individual change in a successful transaction.
57  */
58 typedef void (*LogicalDecodeChangeCB) (struct LogicalDecodingContext *ctx,
59  ReorderBufferTXN *txn,
60  Relation relation,
61  ReorderBufferChange *change);
62 
63 /*
64  * Called for every (explicit or implicit) COMMIT of a successful transaction.
65  */
66 typedef void (*LogicalDecodeCommitCB) (struct LogicalDecodingContext *ctx,
67  ReorderBufferTXN *txn,
68  XLogRecPtr commit_lsn);
69 
70 /*
71  * Called for the generic logical decoding messages.
72  */
73 typedef void (*LogicalDecodeMessageCB) (struct LogicalDecodingContext *ctx,
74  ReorderBufferTXN *txn,
75  XLogRecPtr message_lsn,
76  bool transactional,
77  const char *prefix,
78  Size message_size,
79  const char *message);
80 
81 /*
82  * Filter changes by origin.
83  */
85  RepOriginId origin_id);
86 
87 /*
88  * Called to shutdown an output plugin.
89  */
90 typedef void (*LogicalDecodeShutdownCB) (struct LogicalDecodingContext *ctx);
91 
92 /*
93  * Output plugin callbacks
94  */
95 typedef struct OutputPluginCallbacks
96 {
105 
106 /* Functions in replication/logical/logical.c */
107 extern void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write);
108 extern void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write);
109 extern void OutputPluginUpdateProgress(struct LogicalDecodingContext *ctx);
110 
111 #endif /* OUTPUT_PLUGIN_H */
void(* LogicalDecodeCommitCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
Definition: output_plugin.h:66
void(* LogicalOutputPluginInit)(struct OutputPluginCallbacks *cb)
Definition: output_plugin.h:35
LogicalDecodeMessageCB message_cb
void OutputPluginUpdateProgress(struct LogicalDecodingContext *ctx)
Definition: logical.c:516
uint16 RepOriginId
Definition: xlogdefs.h:51
struct OutputPluginOptions OutputPluginOptions
void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write)
Definition: logical.c:503
char bool
Definition: c.h:202
OutputPluginOutputType output_type
Definition: output_plugin.h:28
void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write)
Definition: logical.c:490
LogicalDecodeCommitCB commit_cb
OutputPluginOutputType
Definition: output_plugin.h:17
static char ** options
struct OutputPluginCallbacks OutputPluginCallbacks
void(* LogicalDecodeStartupCB)(struct LogicalDecodingContext *ctx, OutputPluginOptions *options, bool is_init)
Definition: output_plugin.h:44
LogicalDecodeChangeCB change_cb
Definition: output_plugin.h:99
void(* LogicalDecodeMessageCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, const char *prefix, Size message_size, const char *message)
Definition: output_plugin.h:73
uint64 XLogRecPtr
Definition: xlogdefs.h:21
size_t Size
Definition: c.h:350
LogicalDecodeShutdownCB shutdown_cb
LogicalDecodeStartupCB startup_cb
Definition: output_plugin.h:97
void(* LogicalDecodeChangeCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change)
Definition: output_plugin.h:58
void(* LogicalDecodeShutdownCB)(struct LogicalDecodingContext *ctx)
Definition: output_plugin.h:90
LogicalDecodeBeginCB begin_cb
Definition: output_plugin.h:98
void(* LogicalDecodeBeginCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
Definition: output_plugin.h:52
LogicalDecodeFilterByOriginCB filter_by_origin_cb
bool(* LogicalDecodeFilterByOriginCB)(struct LogicalDecodingContext *ctx, RepOriginId origin_id)
Definition: output_plugin.h:84