PostgreSQL Source Code  git master
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-2018, 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 {
31 
32 /*
33  * Type of the shared library symbol _PG_output_plugin_init that is looked up
34  * when loading an output plugin shared library.
35  */
36 typedef void (*LogicalOutputPluginInit) (struct OutputPluginCallbacks *cb);
37 
38 /*
39  * Callback that gets called in a user-defined plugin. ctx->private_data can
40  * be set to some private data.
41  *
42  * "is_init" will be set to "true" if the decoding slot just got defined. When
43  * the same slot is used from there one, it will be "false".
44  */
45 typedef void (*LogicalDecodeStartupCB) (struct LogicalDecodingContext *ctx,
47  bool is_init);
48 
49 /*
50  * Callback called for every (explicit or implicit) BEGIN of a successful
51  * transaction.
52  */
53 typedef void (*LogicalDecodeBeginCB) (struct LogicalDecodingContext *ctx,
54  ReorderBufferTXN *txn);
55 
56 /*
57  * Callback for every individual change in a successful transaction.
58  */
59 typedef void (*LogicalDecodeChangeCB) (struct LogicalDecodingContext *ctx,
60  ReorderBufferTXN *txn,
61  Relation relation,
62  ReorderBufferChange *change);
63 
64 /*
65  * Callback for every TRUNCATE in a successful transaction.
66  */
67 typedef void (*LogicalDecodeTruncateCB) (struct LogicalDecodingContext *ctx,
68  ReorderBufferTXN *txn,
69  int nrelations,
70  Relation relations[],
71  ReorderBufferChange *change);
72 
73 /*
74  * Called for every (explicit or implicit) COMMIT of a successful transaction.
75  */
76 typedef void (*LogicalDecodeCommitCB) (struct LogicalDecodingContext *ctx,
77  ReorderBufferTXN *txn,
78  XLogRecPtr commit_lsn);
79 
80 /*
81  * Called for the generic logical decoding messages.
82  */
83 typedef void (*LogicalDecodeMessageCB) (struct LogicalDecodingContext *ctx,
84  ReorderBufferTXN *txn,
85  XLogRecPtr message_lsn,
86  bool transactional,
87  const char *prefix,
88  Size message_size,
89  const char *message);
90 
91 /*
92  * Filter changes by origin.
93  */
95  RepOriginId origin_id);
96 
97 /*
98  * Called to shutdown an output plugin.
99  */
100 typedef void (*LogicalDecodeShutdownCB) (struct LogicalDecodingContext *ctx);
101 
102 /*
103  * Output plugin callbacks
104  */
105 typedef struct OutputPluginCallbacks
106 {
116 
117 /* Functions in replication/logical/logical.c */
118 extern void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write);
119 extern void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write);
120 extern void OutputPluginUpdateProgress(struct LogicalDecodingContext *ctx);
121 
122 #endif /* OUTPUT_PLUGIN_H */
LogicalDecodeTruncateCB truncate_cb
void(* LogicalDecodeStartupCB)(struct LogicalDecodingContext *ctx, OutputPluginOptions *options, bool is_init)
Definition: output_plugin.h:45
LogicalDecodeMessageCB message_cb
void OutputPluginUpdateProgress(struct LogicalDecodingContext *ctx)
Definition: logical.c:529
uint16 RepOriginId
Definition: xlogdefs.h:51
struct OutputPluginOptions OutputPluginOptions
void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write)
Definition: logical.c:516
char bool
Definition: c.h:275
OutputPluginOutputType output_type
Definition: output_plugin.h:28
void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write)
Definition: logical.c:503
LogicalDecodeCommitCB commit_cb
void(* LogicalOutputPluginInit)(struct OutputPluginCallbacks *cb)
Definition: output_plugin.h:36
void(* LogicalDecodeTruncateCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, int nrelations, Relation relations[], ReorderBufferChange *change)
Definition: output_plugin.h:67
OutputPluginOutputType
Definition: output_plugin.h:17
bool(* LogicalDecodeFilterByOriginCB)(struct LogicalDecodingContext *ctx, RepOriginId origin_id)
Definition: output_plugin.h:94
static char ** options
struct OutputPluginCallbacks OutputPluginCallbacks
LogicalDecodeChangeCB change_cb
uint64 XLogRecPtr
Definition: xlogdefs.h:21
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:83
size_t Size
Definition: c.h:433
LogicalDecodeShutdownCB shutdown_cb
LogicalDecodeStartupCB startup_cb
void(* LogicalDecodeBeginCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
Definition: output_plugin.h:53
void(* LogicalDecodeShutdownCB)(struct LogicalDecodingContext *ctx)
void(* LogicalDecodeCommitCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
Definition: output_plugin.h:76
LogicalDecodeBeginCB begin_cb
void(* LogicalDecodeChangeCB)(struct LogicalDecodingContext *ctx, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change)
Definition: output_plugin.h:59
LogicalDecodeFilterByOriginCB filter_by_origin_cb