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 106 of file decode.c.

References buf, 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, XLogRecGetRmid, XLogRecGetTopXid, and XLogRecGetXid.

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

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