PostgreSQL Source Code  git master
logical.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  * logical.h
3  * PostgreSQL logical decoding coordination
4  *
5  * Copyright (c) 2012-2021, PostgreSQL Global Development Group
6  *
7  *-------------------------------------------------------------------------
8  */
9 #ifndef LOGICAL_H
10 #define LOGICAL_H
11 
12 #include "access/xlog.h"
13 #include "access/xlogreader.h"
15 #include "replication/slot.h"
16 
18 
20  XLogRecPtr Ptr,
21  TransactionId xid,
22  bool last_write
23 );
24 
26 
28  XLogRecPtr Ptr,
29  TransactionId xid
30 );
31 
32 typedef struct LogicalDecodingContext
33 {
34  /* memory context this is all allocated in */
36 
37  /* The associated replication slot */
39 
40  /* infrastructure pieces for decoding */
44 
45  /*
46  * Marks the logical decoding context as fast forward decoding one. Such a
47  * context does not have plugin loaded so most of the following properties
48  * are unused.
49  */
51 
54 
55  /*
56  * User specified options
57  */
59 
60  /*
61  * User-Provided callback for writing/streaming out data.
62  */
66 
67  /*
68  * Output buffer.
69  */
71 
72  /*
73  * Private data pointer of the output plugin.
74  */
76 
77  /*
78  * Private data pointer for the data writer.
79  */
81 
82  /*
83  * Does the output plugin support streaming, and is it enabled?
84  */
85  bool streaming;
86 
87  /*
88  * Does the output plugin support two-phase decoding, and is it enabled?
89  */
90  bool twophase;
91 
92  /*
93  * Is two-phase option given by output plugin?
94  *
95  * This flag indicates that the plugin passed in the two-phase option as
96  * part of the START_STREAMING command. We can't rely solely on the
97  * twophase flag which only tells whether the plugin provided all the
98  * necessary two-phase callbacks.
99  */
101 
102  /*
103  * State for writing output.
104  */
110 
111 
112 extern void CheckLogicalDecodingRequirements(void);
113 
116  bool need_full_snapshot,
117  XLogRecPtr restart_lsn,
118  XLogReaderRoutine *xl_routine,
124  bool fast_forward,
125  XLogReaderRoutine *xl_routine,
132 
134 extern void LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn,
135  XLogRecPtr restart_lsn);
137 
139  TransactionId xid, const char *gid);
141 extern void ResetLogicalStreamingState(void);
143 
144 #endif
TransactionId write_xid
Definition: logical.h:108
static const char * plugin
struct ReorderBuffer * reorder
Definition: logical.h:42
uint32 TransactionId
Definition: c.h:587
OutputPluginOptions options
Definition: logical.h:53
bool DecodingContextReady(LogicalDecodingContext *ctx)
Definition: logical.c:580
OutputPluginCallbacks callbacks
Definition: logical.h:52
uint16 RepOriginId
Definition: xlogdefs.h:65
void * output_plugin_private
Definition: logical.h:75
void LogicalIncreaseXminForSlot(XLogRecPtr lsn, TransactionId xmin)
Definition: logical.c:1564
MemoryContext context
Definition: logical.h:35
List * output_plugin_options
Definition: logical.h:58
LogicalOutputPluginWriterWrite LogicalOutputPluginWriterPrepareWrite
Definition: logical.h:25
void(* LogicalOutputPluginWriterUpdateProgress)(struct LogicalDecodingContext *lr, XLogRecPtr Ptr, TransactionId xid)
Definition: logical.h:27
XLogRecPtr write_location
Definition: logical.h:107
void DecodingContextFindStartpoint(LogicalDecodingContext *ctx)
Definition: logical.c:589
LogicalOutputPluginWriterPrepareWrite prepare_write
Definition: logical.h:63
LogicalDecodingContext * CreateInitDecodingContext(const char *plugin, List *output_plugin_options, bool need_full_snapshot, XLogRecPtr restart_lsn, XLogReaderRoutine *xl_routine, LogicalOutputPluginWriterPrepareWrite prepare_write, LogicalOutputPluginWriterWrite do_write, LogicalOutputPluginWriterUpdateProgress update_progress)
Definition: logical.c:318
void ResetLogicalStreamingState(void)
Definition: logical.c:1793
bool filter_by_origin_cb_wrapper(LogicalDecodingContext *ctx, RepOriginId origin_id)
Definition: logical.c:1140
LogicalDecodingContext * CreateDecodingContext(XLogRecPtr start_lsn, List *output_plugin_options, bool fast_forward, XLogReaderRoutine *xl_routine, LogicalOutputPluginWriterPrepareWrite prepare_write, LogicalOutputPluginWriterWrite do_write, LogicalOutputPluginWriterUpdateProgress update_progress)
Definition: logical.c:478
LogicalOutputPluginWriterUpdateProgress update_progress
Definition: logical.h:65
struct LogicalDecodingContext LogicalDecodingContext
void LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart_lsn)
Definition: logical.c:1632
void UpdateDecodingStats(LogicalDecodingContext *ctx)
Definition: logical.c:1803
struct SnapBuild * snapshot_builder
Definition: logical.h:43
uint64 XLogRecPtr
Definition: xlogdefs.h:21
bool filter_prepare_cb_wrapper(LogicalDecodingContext *ctx, TransactionId xid, const char *gid)
Definition: logical.c:1109
void(* LogicalOutputPluginWriterWrite)(struct LogicalDecodingContext *lr, XLogRecPtr Ptr, TransactionId xid, bool last_write)
Definition: logical.h:19
void LogicalConfirmReceivedLocation(XLogRecPtr lsn)
Definition: logical.c:1706
XLogReaderState * reader
Definition: logical.h:41
TransactionId xmin
Definition: snapbuild.c:156
ReplicationSlot * slot
Definition: logical.h:38
LogicalOutputPluginWriterWrite write
Definition: logical.h:64
StringInfo out
Definition: logical.h:70
void FreeDecodingContext(LogicalDecodingContext *ctx)
Definition: logical.c:633
Definition: pg_list.h:50
void * output_writer_private
Definition: logical.h:80
void CheckLogicalDecodingRequirements(void)
Definition: logical.c:103