PostgreSQL Source Code  git master
decode.h File Reference
Include dependency graph for decode.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void LogicalDecodingProcessRecord (LogicalDecodingContext *ctx, XLogReaderState *record)
 

Function Documentation

◆ LogicalDecodingProcessRecord()

void LogicalDecodingProcessRecord ( LogicalDecodingContext ctx,
XLogReaderState record 
)

Definition at line 94 of file decode.c.

References buf, XLogReaderState::decoded_record, DecodeHeap2Op(), DecodeHeapOp(), DecodeLogicalMsgOp(), DecodeStandbyOp(), DecodeXactOp(), DecodeXLogOp(), elog, XLogRecordBuffer::endptr, XLogReaderState::EndRecPtr, ERROR, XLogRecordBuffer::origptr, LogicalDecodingContext::reader, XLogReaderState::ReadRecPtr, XLogRecordBuffer::record, LogicalDecodingContext::reorder, ReorderBufferAssignChild(), ReorderBufferProcessXid(), RM_NEXT_ID, TransactionIdIsValid, XLogRecord::xl_xid, XLogRecGetRmid, XLogRecGetTopXid, and XLogRecGetXid.

Referenced by DecodingContextFindStartpoint(), pg_logical_replication_slot_advance(), pg_logical_slot_get_changes_guts(), and XLogSendLogical().

95 {
97  TransactionId txid;
98 
99  buf.origptr = ctx->reader->ReadRecPtr;
100  buf.endptr = ctx->reader->EndRecPtr;
101  buf.record = record;
102 
103  txid = XLogRecGetTopXid(record);
104 
105  /*
106  * If the top-level xid is valid, we need to assign the subxact to the
107  * top-level xact. We need to do this for all records, hence we do it
108  * before the switch.
109  */
110  if (TransactionIdIsValid(txid))
111  {
113  txid,
114  record->decoded_record->xl_xid,
115  buf.origptr);
116  }
117 
118  /* cast so we get a warning when new rmgrs are added */
119  switch ((RmgrId) XLogRecGetRmid(record))
120  {
121  /*
122  * Rmgrs we care about for logical decoding. Add new rmgrs in
123  * rmgrlist.h's order.
124  */
125  case RM_XLOG_ID:
126  DecodeXLogOp(ctx, &buf);
127  break;
128 
129  case RM_XACT_ID:
130  DecodeXactOp(ctx, &buf);
131  break;
132 
133  case RM_STANDBY_ID:
134  DecodeStandbyOp(ctx, &buf);
135  break;
136 
137  case RM_HEAP2_ID:
138  DecodeHeap2Op(ctx, &buf);
139  break;
140 
141  case RM_HEAP_ID:
142  DecodeHeapOp(ctx, &buf);
143  break;
144 
145  case RM_LOGICALMSG_ID:
146  DecodeLogicalMsgOp(ctx, &buf);
147  break;
148 
149  /*
150  * Rmgrs irrelevant for logical decoding; they describe stuff not
151  * represented in logical decoding. Add new rmgrs in rmgrlist.h's
152  * order.
153  */
154  case RM_SMGR_ID:
155  case RM_CLOG_ID:
156  case RM_DBASE_ID:
157  case RM_TBLSPC_ID:
158  case RM_MULTIXACT_ID:
159  case RM_RELMAP_ID:
160  case RM_BTREE_ID:
161  case RM_HASH_ID:
162  case RM_GIN_ID:
163  case RM_GIST_ID:
164  case RM_SEQ_ID:
165  case RM_SPGIST_ID:
166  case RM_BRIN_ID:
167  case RM_COMMIT_TS_ID:
168  case RM_REPLORIGIN_ID:
169  case RM_GENERIC_ID:
170  /* just deal with xid, and done */
172  buf.origptr);
173  break;
174  case RM_NEXT_ID:
175  elog(ERROR, "unexpected RM_NEXT_ID rmgr_id: %u", (RmgrIds) XLogRecGetRmid(buf.record));
176  }
177 }
struct ReorderBuffer * reorder
Definition: logical.h:42
uint32 TransactionId
Definition: c.h:521
XLogRecPtr EndRecPtr
Definition: xlogreader.h:176
static void DecodeXactOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:225
static void DecodeLogicalMsgOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:536
#define ERROR
Definition: elog.h:43
XLogRecPtr endptr
Definition: decode.c:49
static char * buf
Definition: pg_test_fsync.c:68
XLogRecPtr ReadRecPtr
Definition: xlogreader.h:175
XLogRecord * decoded_record
Definition: xlogreader.h:186
XLogReaderState * record
Definition: decode.c:50
static void DecodeXLogOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:183
void ReorderBufferAssignChild(ReorderBuffer *rb, TransactionId xid, TransactionId subxid, XLogRecPtr lsn)
static void DecodeHeap2Op(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:381
#define XLogRecGetXid(decoder)
Definition: xlogreader.h:307
uint8 RmgrId
Definition: rmgr.h:11
TransactionId xl_xid
Definition: xlogrecord.h:44
XLogRecPtr origptr
Definition: decode.c:48
XLogReaderState * reader
Definition: logical.h:41
#define elog(elevel,...)
Definition: elog.h:214
static void DecodeHeapOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:441
#define XLogRecGetTopXid(decoder)
Definition: xlogreader.h:309
#define TransactionIdIsValid(xid)
Definition: transam.h:41
void ReorderBufferProcessXid(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
RmgrIds
Definition: rmgr.h:25
static void DecodeStandbyOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:335
#define XLogRecGetRmid(decoder)
Definition: xlogreader.h:306