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 105 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().

106 {
108  TransactionId txid;
109 
110  buf.origptr = ctx->reader->ReadRecPtr;
111  buf.endptr = ctx->reader->EndRecPtr;
112  buf.record = record;
113 
114  txid = XLogRecGetTopXid(record);
115 
116  /*
117  * If the top-level xid is valid, we need to assign the subxact to the
118  * top-level xact. We need to do this for all records, hence we do it
119  * before the switch.
120  */
121  if (TransactionIdIsValid(txid))
122  {
124  txid,
125  record->decoded_record->xl_xid,
126  buf.origptr);
127  }
128 
129  /* cast so we get a warning when new rmgrs are added */
130  switch ((RmgrId) XLogRecGetRmid(record))
131  {
132  /*
133  * Rmgrs we care about for logical decoding. Add new rmgrs in
134  * rmgrlist.h's order.
135  */
136  case RM_XLOG_ID:
137  DecodeXLogOp(ctx, &buf);
138  break;
139 
140  case RM_XACT_ID:
141  DecodeXactOp(ctx, &buf);
142  break;
143 
144  case RM_STANDBY_ID:
145  DecodeStandbyOp(ctx, &buf);
146  break;
147 
148  case RM_HEAP2_ID:
149  DecodeHeap2Op(ctx, &buf);
150  break;
151 
152  case RM_HEAP_ID:
153  DecodeHeapOp(ctx, &buf);
154  break;
155 
156  case RM_LOGICALMSG_ID:
157  DecodeLogicalMsgOp(ctx, &buf);
158  break;
159 
160  /*
161  * Rmgrs irrelevant for logical decoding; they describe stuff not
162  * represented in logical decoding. Add new rmgrs in rmgrlist.h's
163  * order.
164  */
165  case RM_SMGR_ID:
166  case RM_CLOG_ID:
167  case RM_DBASE_ID:
168  case RM_TBLSPC_ID:
169  case RM_MULTIXACT_ID:
170  case RM_RELMAP_ID:
171  case RM_BTREE_ID:
172  case RM_HASH_ID:
173  case RM_GIN_ID:
174  case RM_GIST_ID:
175  case RM_SEQ_ID:
176  case RM_SPGIST_ID:
177  case RM_BRIN_ID:
178  case RM_COMMIT_TS_ID:
179  case RM_REPLORIGIN_ID:
180  case RM_GENERIC_ID:
181  /* just deal with xid, and done */
183  buf.origptr);
184  break;
185  case RM_NEXT_ID:
186  elog(ERROR, "unexpected RM_NEXT_ID rmgr_id: %u", (RmgrIds) XLogRecGetRmid(buf.record));
187  }
188 }
struct ReorderBuffer * reorder
Definition: logical.h:42
uint32 TransactionId
Definition: c.h:587
XLogRecPtr EndRecPtr
Definition: xlogreader.h:176
static void DecodeXactOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:236
static void DecodeLogicalMsgOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:604
#define ERROR
Definition: elog.h:45
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:194
void ReorderBufferAssignChild(ReorderBuffer *rb, TransactionId xid, TransactionId subxid, XLogRecPtr lsn)
static void DecodeHeap2Op(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:423
#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:228
static void DecodeHeapOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:483
#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:377
#define XLogRecGetRmid(decoder)
Definition: xlogreader.h:306