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 
33 
34 typedef struct LogicalDecodingContext
35 {
36  /* memory context this is all allocated in */
38 
39  /* The associated replication slot */
41 
42  /* infrastructure pieces for decoding */
47 
48  /*
49  * Marks the logical decoding context as fast forward decoding one. Such a
50  * context does not have plugin loaded so most of the following properties
51  * are unused.
52  */
54 
57 
58  /*
59  * User specified options
60  */
62 
63  /*
64  * User-Provided callback for writing/streaming out data.
65  */
69 
70  /*
71  * Output buffer.
72  */
74 
75  /*
76  * Private data pointer of the output plugin.
77  */
79 
80  /*
81  * Private data pointer for the data writer.
82  */
84 
85  /*
86  * Does the output plugin support streaming, and is it enabled?
87  */
88  bool streaming;
89 
90  /*
91  * Does the output plugin support two-phase decoding, and is it enabled?
92  */
93  bool twophase;
94 
95  /*
96  * State for writing output.
97  */
103 
104 
105 extern void CheckLogicalDecodingRequirements(void);
106 
109  bool need_full_snapshot,
110  XLogRecPtr restart_lsn,
112  WALSegmentCleanupCB cleanup_cb,
118  bool fast_forward,
120  WALSegmentCleanupCB cleanup_cb,
127 
129 extern void LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn,
130  XLogRecPtr restart_lsn);
132 
134  TransactionId xid, const char *gid);
136 extern void ResetLogicalStreamingState(void);
138 
139 #endif
TransactionId write_xid
Definition: logical.h:101
static const char * plugin
LogicalDecodingContext * CreateInitDecodingContext(const char *plugin, List *output_plugin_options, bool need_full_snapshot, XLogRecPtr restart_lsn, LogicalDecodingXLogPageReadCB page_read, WALSegmentCleanupCB cleanup_cb, LogicalOutputPluginWriterPrepareWrite prepare_write, LogicalOutputPluginWriterWrite do_write, LogicalOutputPluginWriterUpdateProgress update_progress)
Definition: logical.c:320
struct ReorderBuffer * reorder
Definition: logical.h:45
uint32 TransactionId
Definition: c.h:587
OutputPluginOptions options
Definition: logical.h:56
bool(* LogicalDecodingXLogPageReadCB)(XLogReaderState *ctx)
Definition: logical.h:32
bool DecodingContextReady(LogicalDecodingContext *ctx)
Definition: logical.c:566
OutputPluginCallbacks callbacks
Definition: logical.h:55
uint16 RepOriginId
Definition: xlogdefs.h:65
void * output_plugin_private
Definition: logical.h:78
void LogicalIncreaseXminForSlot(XLogRecPtr lsn, TransactionId xmin)
Definition: logical.c:1545
MemoryContext context
Definition: logical.h:37
List * output_plugin_options
Definition: logical.h:61
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:100
void(* WALSegmentCleanupCB)(XLogReaderState *xlogreader)
Definition: xlogreader.h:63
void DecodingContextFindStartpoint(LogicalDecodingContext *ctx)
Definition: logical.c:575
LogicalOutputPluginWriterPrepareWrite prepare_write
Definition: logical.h:66
void ResetLogicalStreamingState(void)
Definition: logical.c:1763
bool filter_by_origin_cb_wrapper(LogicalDecodingContext *ctx, RepOriginId origin_id)
Definition: logical.c:1127
LogicalOutputPluginWriterUpdateProgress update_progress
Definition: logical.h:68
struct LogicalDecodingContext LogicalDecodingContext
void LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart_lsn)
Definition: logical.c:1602
void UpdateDecodingStats(LogicalDecodingContext *ctx)
Definition: logical.c:1773
LogicalDecodingContext * CreateDecodingContext(XLogRecPtr start_lsn, List *output_plugin_options, bool fast_forward, LogicalDecodingXLogPageReadCB page_read, WALSegmentCleanupCB cleanup_cb, LogicalOutputPluginWriterPrepareWrite prepare_write, LogicalOutputPluginWriterWrite do_write, LogicalOutputPluginWriterUpdateProgress update_progress)
Definition: logical.c:479
struct SnapBuild * snapshot_builder
Definition: logical.h:46
uint64 XLogRecPtr
Definition: xlogdefs.h:21
bool filter_prepare_cb_wrapper(LogicalDecodingContext *ctx, TransactionId xid, const char *gid)
Definition: logical.c:1096
void(* LogicalOutputPluginWriterWrite)(struct LogicalDecodingContext *lr, XLogRecPtr Ptr, TransactionId xid, bool last_write)
Definition: logical.h:19
void LogicalConfirmReceivedLocation(XLogRecPtr lsn)
Definition: logical.c:1676
XLogReaderState * reader
Definition: logical.h:43
TransactionId xmin
Definition: snapbuild.c:156
ReplicationSlot * slot
Definition: logical.h:40
LogicalOutputPluginWriterWrite write
Definition: logical.h:67
StringInfo out
Definition: logical.h:73
void FreeDecodingContext(LogicalDecodingContext *ctx)
Definition: logical.c:624
LogicalDecodingXLogPageReadCB page_read
Definition: logical.h:44
Definition: pg_list.h:50
void * output_writer_private
Definition: logical.h:83
unsigned char bool
Definition: c.h:391
void CheckLogicalDecodingRequirements(void)
Definition: logical.c:103