/* * Take every XLogReadRecord()ed record and perform the actions required to * decode it using the output plugin already setup in the logical decoding * context. */ void LogicalDecodingProcessRecord(LogicalDecodingContext *ctx, XLogReaderState *record) { XLogRecordBuffer buf; buf.origptr = ctx->reader->ReadRecPtr; buf.endptr = ctx->reader->EndRecPtr; buf.record = record; /* cast so we get a warning when new rmgrs are added */ switch ((RmgrIds) XLogRecGetRmid(record)) { /* * Rmgrs we care about for logical decoding. Add new rmgrs in * rmgrlist.h's order. */ case RM_XLOG_ID: DecodeXLogOp(ctx, &buf); break; case RM_XACT_ID: DecodeXactOp(ctx, &buf); break; case RM_STANDBY_ID: DecodeStandbyOp(ctx, &buf); break; case RM_HEAP2_ID: DecodeHeap2Op(ctx, &buf); break; case RM_HEAP_ID: DecodeHeapOp(ctx, &buf); break; /* * Rmgrs irrelevant for logical decoding; they describe stuff not * represented in logical decoding. Add new rmgrs in rmgrlist.h's * order. */ case RM_SMGR_ID: case RM_CLOG_ID: case RM_DBASE_ID: case RM_TBLSPC_ID: case RM_MULTIXACT_ID: case RM_RELMAP_ID: case RM_BTREE_ID: case RM_HASH_ID: case RM_GIN_ID: case RM_GIST_ID: case RM_SEQ_ID: case RM_SPGIST_ID: case RM_BRIN_ID: break; case RM_NEXT_ID: elog(ERROR, "unexpected RM_NEXT_ID rmgr_id: %u", (RmgrIds) XLogRecGetRmid(buf.record)); } }
/* * Take every XLogReadRecord()ed record and perform the actions required to * decode it using the output plugin already setup in the logical decoding * context. * * NB: Note that every record's xid needs to be processed by reorderbuffer * (xids contained in the content of records are not relevant for this rule). * That means that for records which'd otherwise not go through the * reorderbuffer ReorderBufferProcessXid() has to be called. We don't want to * call ReorderBufferProcessXid for each record type by default, because * e.g. empty xacts can be handled more efficiently if there's no previous * state for them. */ void LogicalDecodingProcessRecord(LogicalDecodingContext *ctx, XLogRecord *record) { XLogRecordBuffer buf; buf.origptr = ctx->reader->ReadRecPtr; buf.endptr = ctx->reader->EndRecPtr; buf.record = *record; buf.record_data = XLogRecGetData(record); /* cast so we get a warning when new rmgrs are added */ switch ((RmgrIds) buf.record.xl_rmid) { /* * Rmgrs we care about for logical decoding. Add new rmgrs in * rmgrlist.h's order. */ case RM_XLOG_ID: DecodeXLogOp(ctx, &buf); break; case RM_XACT_ID: DecodeXactOp(ctx, &buf); break; case RM_STANDBY_ID: DecodeStandbyOp(ctx, &buf); break; case RM_HEAP2_ID: DecodeHeap2Op(ctx, &buf); break; case RM_HEAP_ID: DecodeHeapOp(ctx, &buf); break; /* * Rmgrs irrelevant for logical decoding; they describe stuff not * represented in logical decoding. Add new rmgrs in rmgrlist.h's * order. */ case RM_SMGR_ID: case RM_CLOG_ID: case RM_DBASE_ID: case RM_TBLSPC_ID: case RM_MULTIXACT_ID: case RM_RELMAP_ID: case RM_BTREE_ID: case RM_HASH_ID: case RM_GIN_ID: case RM_GIST_ID: case RM_SEQ_ID: case RM_SPGIST_ID: case RM_BITMAP_ID: case RM_DISTRIBUTEDLOG_ID: /* just deal with xid, and done */ ReorderBufferProcessXid(ctx->reorder, record->xl_xid, buf.origptr); break; case RM_APPEND_ONLY_ID: /* * GPDB_94_MERGE_FIXME: logical decoding hasn't been implemented for * append-only tables yet. */ break; case RM_NEXT_ID: elog(ERROR, "unexpected RM_NEXT_ID rmgr_id: %u", (RmgrIds) buf.record.xl_rmid); } }