PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
decode.c File Reference
Include dependency graph for decode.c:

Go to the source code of this file.

Functions

static void DecodeInsert (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
static void DecodeUpdate (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
static void DecodeDelete (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
static void DecodeTruncate (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
static void DecodeMultiInsert (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
static void DecodeSpecConfirm (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
static void DecodeCommit (LogicalDecodingContext *ctx, XLogRecordBuffer *buf, xl_xact_parsed_commit *parsed, TransactionId xid, bool two_phase)
 
static void DecodeAbort (LogicalDecodingContext *ctx, XLogRecordBuffer *buf, xl_xact_parsed_abort *parsed, TransactionId xid, bool two_phase)
 
static void DecodePrepare (LogicalDecodingContext *ctx, XLogRecordBuffer *buf, xl_xact_parsed_prepare *parsed)
 
static void DecodeXLogTuple (char *data, Size len, HeapTuple tuple)
 
static bool FilterPrepare (LogicalDecodingContext *ctx, TransactionId xid, const char *gid)
 
static bool DecodeTXNNeedSkip (LogicalDecodingContext *ctx, XLogRecordBuffer *buf, Oid txn_dbid, RepOriginId origin_id)
 
void LogicalDecodingProcessRecord (LogicalDecodingContext *ctx, XLogReaderState *record)
 
void xlog_decode (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
void xact_decode (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
void standby_decode (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
void heap2_decode (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
void heap_decode (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
static bool FilterByOrigin (LogicalDecodingContext *ctx, RepOriginId origin_id)
 
void logicalmsg_decode (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 

Function Documentation

◆ DecodeAbort()

static void DecodeAbort ( LogicalDecodingContext ctx,
XLogRecordBuffer buf,
xl_xact_parsed_abort parsed,
TransactionId  xid,
bool  two_phase 
)
static

Definition at line 847 of file decode.c.

850{
851 int i;
852 XLogRecPtr origin_lsn = InvalidXLogRecPtr;
853 TimestampTz abort_time = parsed->xact_time;
854 RepOriginId origin_id = XLogRecGetOrigin(buf->record);
855 bool skip_xact;
856
857 if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
858 {
859 origin_lsn = parsed->origin_lsn;
860 abort_time = parsed->origin_timestamp;
861 }
862
863 /*
864 * Check whether we need to process this transaction. See
865 * DecodeTXNNeedSkip for the reasons why we sometimes want to skip the
866 * transaction.
867 */
868 skip_xact = DecodeTXNNeedSkip(ctx, buf, parsed->dbId, origin_id);
869
870 /*
871 * Send the final rollback record for a prepared transaction unless we
872 * need to skip it. For non-two-phase xacts, simply forget the xact.
873 */
874 if (two_phase && !skip_xact)
875 {
876 ReorderBufferFinishPrepared(ctx->reorder, xid, buf->origptr, buf->endptr,
878 abort_time, origin_id, origin_lsn,
879 parsed->twophase_gid, false);
880 }
881 else
882 {
883 for (i = 0; i < parsed->nsubxacts; i++)
884 {
885 ReorderBufferAbort(ctx->reorder, parsed->subxacts[i],
886 buf->record->EndRecPtr, abort_time);
887 }
888
889 ReorderBufferAbort(ctx->reorder, xid, buf->record->EndRecPtr,
890 abort_time);
891 }
892
893 /* update the decoding stats */
895}
int64 TimestampTz
Definition: timestamp.h:39
static bool DecodeTXNNeedSkip(LogicalDecodingContext *ctx, XLogRecordBuffer *buf, Oid txn_dbid, RepOriginId origin_id)
Definition: decode.c:1305
int i
Definition: isn.c:77
void UpdateDecodingStats(LogicalDecodingContext *ctx)
Definition: logical.c:1915
static bool two_phase
static char * buf
Definition: pg_test_fsync.c:72
void ReorderBufferAbort(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, TimestampTz abort_time)
void ReorderBufferFinishPrepared(ReorderBuffer *rb, TransactionId xid, XLogRecPtr commit_lsn, XLogRecPtr end_lsn, XLogRecPtr two_phase_at, TimestampTz commit_time, RepOriginId origin_id, XLogRecPtr origin_lsn, char *gid, bool is_commit)
struct ReorderBuffer * reorder
Definition: logical.h:43
TimestampTz xact_time
Definition: xact.h:412
TransactionId * subxacts
Definition: xact.h:419
XLogRecPtr origin_lsn
Definition: xact.h:430
char twophase_gid[GIDSIZE]
Definition: xact.h:428
TimestampTz origin_timestamp
Definition: xact.h:431
#define XACT_XINFO_HAS_ORIGIN
Definition: xact.h:193
uint16 RepOriginId
Definition: xlogdefs.h:65
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
#define XLogRecGetOrigin(decoder)
Definition: xlogreader.h:413

References buf, xl_xact_parsed_abort::dbId, DecodeTXNNeedSkip(), i, InvalidXLogRecPtr, xl_xact_parsed_abort::nsubxacts, xl_xact_parsed_abort::origin_lsn, xl_xact_parsed_abort::origin_timestamp, LogicalDecodingContext::reorder, ReorderBufferAbort(), ReorderBufferFinishPrepared(), xl_xact_parsed_abort::subxacts, two_phase, xl_xact_parsed_abort::twophase_gid, UpdateDecodingStats(), xl_xact_parsed_abort::xact_time, XACT_XINFO_HAS_ORIGIN, xl_xact_parsed_abort::xinfo, and XLogRecGetOrigin.

Referenced by xact_decode().

◆ DecodeCommit()

static void DecodeCommit ( LogicalDecodingContext ctx,
XLogRecordBuffer buf,
xl_xact_parsed_commit parsed,
TransactionId  xid,
bool  two_phase 
)
static

Definition at line 676 of file decode.c.

679{
680 XLogRecPtr origin_lsn = InvalidXLogRecPtr;
681 TimestampTz commit_time = parsed->xact_time;
682 RepOriginId origin_id = XLogRecGetOrigin(buf->record);
683 int i;
684
685 if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
686 {
687 origin_lsn = parsed->origin_lsn;
688 commit_time = parsed->origin_timestamp;
689 }
690
691 SnapBuildCommitTxn(ctx->snapshot_builder, buf->origptr, xid,
692 parsed->nsubxacts, parsed->subxacts,
693 parsed->xinfo);
694
695 /* ----
696 * Check whether we are interested in this specific transaction, and tell
697 * the reorderbuffer to forget the content of the (sub-)transactions
698 * if not.
699 *
700 * We can't just use ReorderBufferAbort() here, because we need to execute
701 * the transaction's invalidations. This currently won't be needed if
702 * we're just skipping over the transaction because currently we only do
703 * so during startup, to get to the first transaction the client needs. As
704 * we have reset the catalog caches before starting to read WAL, and we
705 * haven't yet touched any catalogs, there can't be anything to invalidate.
706 * But if we're "forgetting" this commit because it happened in another
707 * database, the invalidations might be important, because they could be
708 * for shared catalogs and we might have loaded data into the relevant
709 * syscaches.
710 * ---
711 */
712 if (DecodeTXNNeedSkip(ctx, buf, parsed->dbId, origin_id))
713 {
714 for (i = 0; i < parsed->nsubxacts; i++)
715 {
716 ReorderBufferForget(ctx->reorder, parsed->subxacts[i], buf->origptr);
717 }
718 ReorderBufferForget(ctx->reorder, xid, buf->origptr);
719
720 return;
721 }
722
723 /* tell the reorderbuffer about the surviving subtransactions */
724 for (i = 0; i < parsed->nsubxacts; i++)
725 {
726 ReorderBufferCommitChild(ctx->reorder, xid, parsed->subxacts[i],
727 buf->origptr, buf->endptr);
728 }
729
730 /*
731 * Send the final commit record if the transaction data is already
732 * decoded, otherwise, process the entire transaction.
733 */
734 if (two_phase)
735 {
736 ReorderBufferFinishPrepared(ctx->reorder, xid, buf->origptr, buf->endptr,
738 commit_time, origin_id, origin_lsn,
739 parsed->twophase_gid, true);
740 }
741 else
742 {
743 ReorderBufferCommit(ctx->reorder, xid, buf->origptr, buf->endptr,
744 commit_time, origin_id, origin_lsn);
745 }
746
747 /*
748 * Update the decoding stats at transaction prepare/commit/abort.
749 * Additionally we send the stats when we spill or stream the changes to
750 * avoid losing them in case the decoding is interrupted. It is not clear
751 * that sending more or less frequently than this would be better.
752 */
754}
void ReorderBufferForget(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
void ReorderBufferCommitChild(ReorderBuffer *rb, TransactionId xid, TransactionId subxid, XLogRecPtr commit_lsn, XLogRecPtr end_lsn)
void ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid, XLogRecPtr commit_lsn, XLogRecPtr end_lsn, TimestampTz commit_time, RepOriginId origin_id, XLogRecPtr origin_lsn)
XLogRecPtr SnapBuildGetTwoPhaseAt(SnapBuild *builder)
Definition: snapbuild.c:286
void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, int nsubxacts, TransactionId *subxacts, uint32 xinfo)
Definition: snapbuild.c:932
struct SnapBuild * snapshot_builder
Definition: logical.h:44
TimestampTz xact_time
Definition: xact.h:379
TimestampTz origin_timestamp
Definition: xact.h:405
TransactionId * subxacts
Definition: xact.h:386
char twophase_gid[GIDSIZE]
Definition: xact.h:398
XLogRecPtr origin_lsn
Definition: xact.h:404

References buf, xl_xact_parsed_commit::dbId, DecodeTXNNeedSkip(), i, InvalidXLogRecPtr, xl_xact_parsed_commit::nsubxacts, xl_xact_parsed_commit::origin_lsn, xl_xact_parsed_commit::origin_timestamp, LogicalDecodingContext::reorder, ReorderBufferCommit(), ReorderBufferCommitChild(), ReorderBufferFinishPrepared(), ReorderBufferForget(), SnapBuildCommitTxn(), SnapBuildGetTwoPhaseAt(), LogicalDecodingContext::snapshot_builder, xl_xact_parsed_commit::subxacts, two_phase, xl_xact_parsed_commit::twophase_gid, UpdateDecodingStats(), xl_xact_parsed_commit::xact_time, XACT_XINFO_HAS_ORIGIN, xl_xact_parsed_commit::xinfo, and XLogRecGetOrigin.

Referenced by xact_decode().

◆ DecodeDelete()

static void DecodeDelete ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)
static

Definition at line 1029 of file decode.c.

1030{
1031 XLogReaderState *r = buf->record;
1032 xl_heap_delete *xlrec;
1033 ReorderBufferChange *change;
1034 RelFileLocator target_locator;
1035
1036 xlrec = (xl_heap_delete *) XLogRecGetData(r);
1037
1038 /* only interested in our database */
1039 XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL);
1040 if (target_locator.dbOid != ctx->slot->data.database)
1041 return;
1042
1043 /* output plugin doesn't look for this origin, no need to queue */
1044 if (FilterByOrigin(ctx, XLogRecGetOrigin(r)))
1045 return;
1046
1047 change = ReorderBufferAllocChange(ctx->reorder);
1048
1049 if (xlrec->flags & XLH_DELETE_IS_SUPER)
1051 else
1053
1054 change->origin_id = XLogRecGetOrigin(r);
1055
1056 memcpy(&change->data.tp.rlocator, &target_locator, sizeof(RelFileLocator));
1057
1058 /* old primary key stored */
1059 if (xlrec->flags & XLH_DELETE_CONTAINS_OLD)
1060 {
1062 Size tuplelen = datalen - SizeOfHeapHeader;
1063
1065
1066 change->data.tp.oldtuple =
1067 ReorderBufferAllocTupleBuf(ctx->reorder, tuplelen);
1068
1069 DecodeXLogTuple((char *) xlrec + SizeOfHeapDelete,
1070 datalen, change->data.tp.oldtuple);
1071 }
1072
1073 change->data.tp.clear_toast_afterwards = true;
1074
1076 change, false);
1077}
size_t Size
Definition: c.h:576
static void DecodeXLogTuple(char *data, Size len, HeapTuple tuple)
Definition: decode.c:1261
static bool FilterByOrigin(LogicalDecodingContext *ctx, RepOriginId origin_id)
Definition: decode.c:583
Assert(PointerIsAligned(start, uint64))
#define XLH_DELETE_CONTAINS_OLD
Definition: heapam_xlog.h:109
#define SizeOfHeapHeader
Definition: heapam_xlog.h:157
#define SizeOfHeapDelete
Definition: heapam_xlog.h:121
#define XLH_DELETE_IS_SUPER
Definition: heapam_xlog.h:105
void ReorderBufferQueueChange(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, ReorderBufferChange *change, bool toast_insert)
HeapTuple ReorderBufferAllocTupleBuf(ReorderBuffer *rb, Size tuple_len)
ReorderBufferChange * ReorderBufferAllocChange(ReorderBuffer *rb)
@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT
Definition: reorderbuffer.h:62
@ REORDER_BUFFER_CHANGE_DELETE
Definition: reorderbuffer.h:54
ReplicationSlot * slot
Definition: logical.h:39
ReorderBufferChangeType action
Definition: reorderbuffer.h:81
RelFileLocator rlocator
Definition: reorderbuffer.h:98
union ReorderBufferChange::@110 data
RepOriginId origin_id
Definition: reorderbuffer.h:86
struct ReorderBufferChange::@110::@111 tp
ReplicationSlotPersistentData data
Definition: slot.h:185
void XLogRecGetBlockTag(XLogReaderState *record, uint8 block_id, RelFileLocator *rlocator, ForkNumber *forknum, BlockNumber *blknum)
Definition: xlogreader.c:1981
#define XLogRecGetDataLen(decoder)
Definition: xlogreader.h:416
#define XLogRecGetData(decoder)
Definition: xlogreader.h:415
#define XLogRecGetXid(decoder)
Definition: xlogreader.h:412

References ReorderBufferChange::action, Assert(), buf, ReorderBufferChange::clear_toast_afterwards, ReorderBufferChange::data, ReplicationSlot::data, ReplicationSlotPersistentData::database, RelFileLocator::dbOid, DecodeXLogTuple(), FilterByOrigin(), xl_heap_delete::flags, ReorderBufferChange::oldtuple, ReorderBufferChange::origin_id, LogicalDecodingContext::reorder, REORDER_BUFFER_CHANGE_DELETE, REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT, ReorderBufferAllocChange(), ReorderBufferAllocTupleBuf(), ReorderBufferQueueChange(), ReorderBufferChange::rlocator, SizeOfHeapDelete, SizeOfHeapHeader, LogicalDecodingContext::slot, ReorderBufferChange::tp, XLH_DELETE_CONTAINS_OLD, XLH_DELETE_IS_SUPER, XLogRecGetBlockTag(), XLogRecGetData, XLogRecGetDataLen, XLogRecGetOrigin, and XLogRecGetXid.

Referenced by heap_decode().

◆ DecodeInsert()

static void DecodeInsert ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)
static

Definition at line 903 of file decode.c.

904{
905 Size datalen;
906 char *tupledata;
907 Size tuplelen;
908 XLogReaderState *r = buf->record;
909 xl_heap_insert *xlrec;
910 ReorderBufferChange *change;
911 RelFileLocator target_locator;
912
913 xlrec = (xl_heap_insert *) XLogRecGetData(r);
914
915 /*
916 * Ignore insert records without new tuples (this does happen when
917 * raw_heap_insert marks the TOAST record as HEAP_INSERT_NO_LOGICAL).
918 */
919 if (!(xlrec->flags & XLH_INSERT_CONTAINS_NEW_TUPLE))
920 return;
921
922 /* only interested in our database */
923 XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL);
924 if (target_locator.dbOid != ctx->slot->data.database)
925 return;
926
927 /* output plugin doesn't look for this origin, no need to queue */
928 if (FilterByOrigin(ctx, XLogRecGetOrigin(r)))
929 return;
930
931 change = ReorderBufferAllocChange(ctx->reorder);
932 if (!(xlrec->flags & XLH_INSERT_IS_SPECULATIVE))
934 else
936 change->origin_id = XLogRecGetOrigin(r);
937
938 memcpy(&change->data.tp.rlocator, &target_locator, sizeof(RelFileLocator));
939
940 tupledata = XLogRecGetBlockData(r, 0, &datalen);
941 tuplelen = datalen - SizeOfHeapHeader;
942
943 change->data.tp.newtuple =
944 ReorderBufferAllocTupleBuf(ctx->reorder, tuplelen);
945
946 DecodeXLogTuple(tupledata, datalen, change->data.tp.newtuple);
947
948 change->data.tp.clear_toast_afterwards = true;
949
951 change,
953}
#define XLH_INSERT_ON_TOAST_RELATION
Definition: heapam_xlog.h:76
#define XLH_INSERT_IS_SPECULATIVE
Definition: heapam_xlog.h:74
#define XLH_INSERT_CONTAINS_NEW_TUPLE
Definition: heapam_xlog.h:75
@ REORDER_BUFFER_CHANGE_INSERT
Definition: reorderbuffer.h:52
@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT
Definition: reorderbuffer.h:60
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
Definition: xlogreader.c:2035

References ReorderBufferChange::action, buf, ReorderBufferChange::clear_toast_afterwards, ReorderBufferChange::data, ReplicationSlot::data, ReplicationSlotPersistentData::database, RelFileLocator::dbOid, DecodeXLogTuple(), FilterByOrigin(), xl_heap_insert::flags, ReorderBufferChange::newtuple, ReorderBufferChange::origin_id, LogicalDecodingContext::reorder, REORDER_BUFFER_CHANGE_INSERT, REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT, ReorderBufferAllocChange(), ReorderBufferAllocTupleBuf(), ReorderBufferQueueChange(), ReorderBufferChange::rlocator, SizeOfHeapHeader, LogicalDecodingContext::slot, ReorderBufferChange::tp, XLH_INSERT_CONTAINS_NEW_TUPLE, XLH_INSERT_IS_SPECULATIVE, XLH_INSERT_ON_TOAST_RELATION, XLogRecGetBlockData(), XLogRecGetBlockTag(), XLogRecGetData, XLogRecGetOrigin, and XLogRecGetXid.

Referenced by heap_decode().

◆ DecodeMultiInsert()

static void DecodeMultiInsert ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)
static

Definition at line 1121 of file decode.c.

1122{
1123 XLogReaderState *r = buf->record;
1124 xl_heap_multi_insert *xlrec;
1125 int i;
1126 char *data;
1127 char *tupledata;
1128 Size tuplelen;
1129 RelFileLocator rlocator;
1130
1131 xlrec = (xl_heap_multi_insert *) XLogRecGetData(r);
1132
1133 /*
1134 * Ignore insert records without new tuples. This happens when a
1135 * multi_insert is done on a catalog or on a non-persistent relation.
1136 */
1137 if (!(xlrec->flags & XLH_INSERT_CONTAINS_NEW_TUPLE))
1138 return;
1139
1140 /* only interested in our database */
1141 XLogRecGetBlockTag(r, 0, &rlocator, NULL, NULL);
1142 if (rlocator.dbOid != ctx->slot->data.database)
1143 return;
1144
1145 /* output plugin doesn't look for this origin, no need to queue */
1146 if (FilterByOrigin(ctx, XLogRecGetOrigin(r)))
1147 return;
1148
1149 /*
1150 * We know that this multi_insert isn't for a catalog, so the block should
1151 * always have data even if a full-page write of it is taken.
1152 */
1153 tupledata = XLogRecGetBlockData(r, 0, &tuplelen);
1154 Assert(tupledata != NULL);
1155
1156 data = tupledata;
1157 for (i = 0; i < xlrec->ntuples; i++)
1158 {
1159 ReorderBufferChange *change;
1160 xl_multi_insert_tuple *xlhdr;
1161 int datalen;
1162 HeapTuple tuple;
1163 HeapTupleHeader header;
1164
1165 change = ReorderBufferAllocChange(ctx->reorder);
1167 change->origin_id = XLogRecGetOrigin(r);
1168
1169 memcpy(&change->data.tp.rlocator, &rlocator, sizeof(RelFileLocator));
1170
1172 data = ((char *) xlhdr) + SizeOfMultiInsertTuple;
1173 datalen = xlhdr->datalen;
1174
1175 change->data.tp.newtuple =
1176 ReorderBufferAllocTupleBuf(ctx->reorder, datalen);
1177
1178 tuple = change->data.tp.newtuple;
1179 header = tuple->t_data;
1180
1181 /* not a disk based tuple */
1183
1184 /*
1185 * We can only figure this out after reassembling the transactions.
1186 */
1187 tuple->t_tableOid = InvalidOid;
1188
1189 tuple->t_len = datalen + SizeofHeapTupleHeader;
1190
1191 memset(header, 0, SizeofHeapTupleHeader);
1192
1193 memcpy((char *) tuple->t_data + SizeofHeapTupleHeader, data, datalen);
1194 header->t_infomask = xlhdr->t_infomask;
1195 header->t_infomask2 = xlhdr->t_infomask2;
1196 header->t_hoff = xlhdr->t_hoff;
1197
1198 /*
1199 * Reset toast reassembly state only after the last row in the last
1200 * xl_multi_insert_tuple record emitted by one heap_multi_insert()
1201 * call.
1202 */
1203 if (xlrec->flags & XLH_INSERT_LAST_IN_MULTI &&
1204 (i + 1) == xlrec->ntuples)
1205 change->data.tp.clear_toast_afterwards = true;
1206 else
1207 change->data.tp.clear_toast_afterwards = false;
1208
1210 buf->origptr, change, false);
1211
1212 /* move to the next xl_multi_insert_tuple entry */
1213 data += datalen;
1214 }
1215 Assert(data == tupledata + tuplelen);
1216}
#define SHORTALIGN(LEN)
Definition: c.h:778
#define XLH_INSERT_LAST_IN_MULTI
Definition: heapam_xlog.h:73
#define SizeOfMultiInsertTuple
Definition: heapam_xlog.h:199
#define SizeofHeapTupleHeader
Definition: htup_details.h:185
static void ItemPointerSetInvalid(ItemPointerData *pointer)
Definition: itemptr.h:184
const void * data
#define InvalidOid
Definition: postgres_ext.h:35
ItemPointerData t_self
Definition: htup.h:65
uint32 t_len
Definition: htup.h:64
HeapTupleHeader t_data
Definition: htup.h:68
Oid t_tableOid
Definition: htup.h:66

References ReorderBufferChange::action, Assert(), buf, ReorderBufferChange::clear_toast_afterwards, ReorderBufferChange::data, ReplicationSlot::data, data, ReplicationSlotPersistentData::database, xl_multi_insert_tuple::datalen, RelFileLocator::dbOid, FilterByOrigin(), xl_heap_multi_insert::flags, i, InvalidOid, ItemPointerSetInvalid(), ReorderBufferChange::newtuple, xl_heap_multi_insert::ntuples, ReorderBufferChange::origin_id, LogicalDecodingContext::reorder, REORDER_BUFFER_CHANGE_INSERT, ReorderBufferAllocChange(), ReorderBufferAllocTupleBuf(), ReorderBufferQueueChange(), ReorderBufferChange::rlocator, SHORTALIGN, SizeofHeapTupleHeader, SizeOfMultiInsertTuple, LogicalDecodingContext::slot, HeapTupleData::t_data, xl_multi_insert_tuple::t_hoff, HeapTupleHeaderData::t_hoff, xl_multi_insert_tuple::t_infomask, HeapTupleHeaderData::t_infomask, xl_multi_insert_tuple::t_infomask2, HeapTupleHeaderData::t_infomask2, HeapTupleData::t_len, HeapTupleData::t_self, HeapTupleData::t_tableOid, ReorderBufferChange::tp, XLH_INSERT_CONTAINS_NEW_TUPLE, XLH_INSERT_LAST_IN_MULTI, XLogRecGetBlockData(), XLogRecGetBlockTag(), XLogRecGetData, XLogRecGetOrigin, and XLogRecGetXid.

Referenced by heap2_decode().

◆ DecodePrepare()

static void DecodePrepare ( LogicalDecodingContext ctx,
XLogRecordBuffer buf,
xl_xact_parsed_prepare parsed 
)
static

Definition at line 772 of file decode.c.

774{
775 SnapBuild *builder = ctx->snapshot_builder;
776 XLogRecPtr origin_lsn = parsed->origin_lsn;
777 TimestampTz prepare_time = parsed->xact_time;
778 RepOriginId origin_id = XLogRecGetOrigin(buf->record);
779 int i;
780 TransactionId xid = parsed->twophase_xid;
781
782 if (parsed->origin_timestamp != 0)
783 prepare_time = parsed->origin_timestamp;
784
785 /*
786 * Remember the prepare info for a txn so that it can be used later in
787 * commit prepared if required. See ReorderBufferFinishPrepared.
788 */
789 if (!ReorderBufferRememberPrepareInfo(ctx->reorder, xid, buf->origptr,
790 buf->endptr, prepare_time, origin_id,
791 origin_lsn))
792 return;
793
794 /* We can't start streaming unless a consistent state is reached. */
796 {
798 return;
799 }
800
801 /*
802 * Check whether we need to process this transaction. See
803 * DecodeTXNNeedSkip for the reasons why we sometimes want to skip the
804 * transaction.
805 *
806 * We can't call ReorderBufferForget as we did in DecodeCommit as the txn
807 * hasn't yet been committed, removing this txn before a commit might
808 * result in the computation of an incorrect restart_lsn. See
809 * SnapBuildProcessRunningXacts. But we need to process cache
810 * invalidations if there are any for the reasons mentioned in
811 * DecodeCommit.
812 */
813 if (DecodeTXNNeedSkip(ctx, buf, parsed->dbId, origin_id))
814 {
816 ReorderBufferInvalidate(ctx->reorder, xid, buf->origptr);
817 return;
818 }
819
820 /* Tell the reorderbuffer about the surviving subtransactions. */
821 for (i = 0; i < parsed->nsubxacts; i++)
822 {
823 ReorderBufferCommitChild(ctx->reorder, xid, parsed->subxacts[i],
824 buf->origptr, buf->endptr);
825 }
826
827 /* replay actions of all transaction + subtransactions in order */
828 ReorderBufferPrepare(ctx->reorder, xid, parsed->twophase_gid);
829
830 /*
831 * Update the decoding stats at transaction prepare/commit/abort.
832 * Additionally we send the stats when we spill or stream the changes to
833 * avoid losing them in case the decoding is interrupted. It is not clear
834 * that sending more or less frequently than this would be better.
835 */
837}
uint32 TransactionId
Definition: c.h:623
void ReorderBufferInvalidate(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
void ReorderBufferPrepare(ReorderBuffer *rb, TransactionId xid, char *gid)
void ReorderBufferSkipPrepare(ReorderBuffer *rb, TransactionId xid)
bool ReorderBufferRememberPrepareInfo(ReorderBuffer *rb, TransactionId xid, XLogRecPtr prepare_lsn, XLogRecPtr end_lsn, TimestampTz prepare_time, RepOriginId origin_id, XLogRecPtr origin_lsn)
SnapBuildState SnapBuildCurrentState(SnapBuild *builder)
Definition: snapbuild.c:277
@ SNAPBUILD_CONSISTENT
Definition: snapbuild.h:50
TransactionId twophase_xid
Definition: xact.h:397

References buf, xl_xact_parsed_commit::dbId, DecodeTXNNeedSkip(), i, xl_xact_parsed_commit::nsubxacts, xl_xact_parsed_commit::origin_lsn, xl_xact_parsed_commit::origin_timestamp, LogicalDecodingContext::reorder, ReorderBufferCommitChild(), ReorderBufferInvalidate(), ReorderBufferPrepare(), ReorderBufferRememberPrepareInfo(), ReorderBufferSkipPrepare(), SNAPBUILD_CONSISTENT, SnapBuildCurrentState(), LogicalDecodingContext::snapshot_builder, xl_xact_parsed_commit::subxacts, xl_xact_parsed_commit::twophase_gid, xl_xact_parsed_commit::twophase_xid, UpdateDecodingStats(), xl_xact_parsed_commit::xact_time, and XLogRecGetOrigin.

Referenced by xact_decode().

◆ DecodeSpecConfirm()

static void DecodeSpecConfirm ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)
static

Definition at line 1225 of file decode.c.

1226{
1227 XLogReaderState *r = buf->record;
1228 ReorderBufferChange *change;
1229 RelFileLocator target_locator;
1230
1231 /* only interested in our database */
1232 XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL);
1233 if (target_locator.dbOid != ctx->slot->data.database)
1234 return;
1235
1236 /* output plugin doesn't look for this origin, no need to queue */
1237 if (FilterByOrigin(ctx, XLogRecGetOrigin(r)))
1238 return;
1239
1240 change = ReorderBufferAllocChange(ctx->reorder);
1242 change->origin_id = XLogRecGetOrigin(r);
1243
1244 memcpy(&change->data.tp.rlocator, &target_locator, sizeof(RelFileLocator));
1245
1246 change->data.tp.clear_toast_afterwards = true;
1247
1249 change, false);
1250}
@ REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM
Definition: reorderbuffer.h:61

References ReorderBufferChange::action, buf, ReorderBufferChange::clear_toast_afterwards, ReorderBufferChange::data, ReplicationSlot::data, ReplicationSlotPersistentData::database, RelFileLocator::dbOid, FilterByOrigin(), ReorderBufferChange::origin_id, LogicalDecodingContext::reorder, REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM, ReorderBufferAllocChange(), ReorderBufferQueueChange(), ReorderBufferChange::rlocator, LogicalDecodingContext::slot, ReorderBufferChange::tp, XLogRecGetBlockTag(), XLogRecGetOrigin, and XLogRecGetXid.

Referenced by heap_decode().

◆ DecodeTruncate()

static void DecodeTruncate ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)
static

Definition at line 1083 of file decode.c.

1084{
1085 XLogReaderState *r = buf->record;
1086 xl_heap_truncate *xlrec;
1087 ReorderBufferChange *change;
1088
1089 xlrec = (xl_heap_truncate *) XLogRecGetData(r);
1090
1091 /* only interested in our database */
1092 if (xlrec->dbId != ctx->slot->data.database)
1093 return;
1094
1095 /* output plugin doesn't look for this origin, no need to queue */
1096 if (FilterByOrigin(ctx, XLogRecGetOrigin(r)))
1097 return;
1098
1099 change = ReorderBufferAllocChange(ctx->reorder);
1101 change->origin_id = XLogRecGetOrigin(r);
1102 if (xlrec->flags & XLH_TRUNCATE_CASCADE)
1103 change->data.truncate.cascade = true;
1104 if (xlrec->flags & XLH_TRUNCATE_RESTART_SEQS)
1105 change->data.truncate.restart_seqs = true;
1106 change->data.truncate.nrelids = xlrec->nrelids;
1108 xlrec->nrelids);
1109 memcpy(change->data.truncate.relids, xlrec->relids,
1110 xlrec->nrelids * sizeof(Oid));
1112 buf->origptr, change, false);
1113}
#define XLH_TRUNCATE_RESTART_SEQS
Definition: heapam_xlog.h:127
#define XLH_TRUNCATE_CASCADE
Definition: heapam_xlog.h:126
unsigned int Oid
Definition: postgres_ext.h:30
Oid * ReorderBufferAllocRelids(ReorderBuffer *rb, int nrelids)
@ REORDER_BUFFER_CHANGE_TRUNCATE
Definition: reorderbuffer.h:63
struct ReorderBufferChange::@110::@112 truncate
Oid relids[FLEXIBLE_ARRAY_MEMBER]
Definition: heapam_xlog.h:139

References ReorderBufferChange::action, buf, ReorderBufferChange::cascade, ReorderBufferChange::data, ReplicationSlot::data, ReplicationSlotPersistentData::database, xl_heap_truncate::dbId, FilterByOrigin(), xl_heap_truncate::flags, xl_heap_truncate::nrelids, ReorderBufferChange::nrelids, ReorderBufferChange::origin_id, xl_heap_truncate::relids, ReorderBufferChange::relids, LogicalDecodingContext::reorder, REORDER_BUFFER_CHANGE_TRUNCATE, ReorderBufferAllocChange(), ReorderBufferAllocRelids(), ReorderBufferQueueChange(), ReorderBufferChange::restart_seqs, LogicalDecodingContext::slot, ReorderBufferChange::truncate, XLH_TRUNCATE_CASCADE, XLH_TRUNCATE_RESTART_SEQS, XLogRecGetData, XLogRecGetOrigin, and XLogRecGetXid.

Referenced by heap_decode().

◆ DecodeTXNNeedSkip()

static bool DecodeTXNNeedSkip ( LogicalDecodingContext ctx,
XLogRecordBuffer buf,
Oid  txn_dbid,
RepOriginId  origin_id 
)
static

Definition at line 1305 of file decode.c.

1307{
1308 if (SnapBuildXactNeedsSkip(ctx->snapshot_builder, buf->origptr) ||
1309 (txn_dbid != InvalidOid && txn_dbid != ctx->slot->data.database) ||
1310 FilterByOrigin(ctx, origin_id))
1311 return true;
1312
1313 /*
1314 * We also skip decoding in fast_forward mode. In passing set the
1315 * processing_required flag to indicate that if it were not for
1316 * fast_forward mode, processing would have been required.
1317 */
1318 if (ctx->fast_forward)
1319 {
1320 ctx->processing_required = true;
1321 return true;
1322 }
1323
1324 return false;
1325}
bool SnapBuildXactNeedsSkip(SnapBuild *builder, XLogRecPtr ptr)
Definition: snapbuild.c:304

References buf, ReplicationSlot::data, ReplicationSlotPersistentData::database, LogicalDecodingContext::fast_forward, FilterByOrigin(), InvalidOid, LogicalDecodingContext::processing_required, LogicalDecodingContext::slot, SnapBuildXactNeedsSkip(), and LogicalDecodingContext::snapshot_builder.

Referenced by DecodeAbort(), DecodeCommit(), and DecodePrepare().

◆ DecodeUpdate()

static void DecodeUpdate ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)
static

Definition at line 962 of file decode.c.

963{
964 XLogReaderState *r = buf->record;
965 xl_heap_update *xlrec;
966 ReorderBufferChange *change;
967 char *data;
968 RelFileLocator target_locator;
969
970 xlrec = (xl_heap_update *) XLogRecGetData(r);
971
972 /* only interested in our database */
973 XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL);
974 if (target_locator.dbOid != ctx->slot->data.database)
975 return;
976
977 /* output plugin doesn't look for this origin, no need to queue */
978 if (FilterByOrigin(ctx, XLogRecGetOrigin(r)))
979 return;
980
981 change = ReorderBufferAllocChange(ctx->reorder);
983 change->origin_id = XLogRecGetOrigin(r);
984 memcpy(&change->data.tp.rlocator, &target_locator, sizeof(RelFileLocator));
985
987 {
988 Size datalen;
989 Size tuplelen;
990
991 data = XLogRecGetBlockData(r, 0, &datalen);
992
993 tuplelen = datalen - SizeOfHeapHeader;
994
995 change->data.tp.newtuple =
996 ReorderBufferAllocTupleBuf(ctx->reorder, tuplelen);
997
998 DecodeXLogTuple(data, datalen, change->data.tp.newtuple);
999 }
1000
1001 if (xlrec->flags & XLH_UPDATE_CONTAINS_OLD)
1002 {
1003 Size datalen;
1004 Size tuplelen;
1005
1006 /* caution, remaining data in record is not aligned */
1008 datalen = XLogRecGetDataLen(r) - SizeOfHeapUpdate;
1009 tuplelen = datalen - SizeOfHeapHeader;
1010
1011 change->data.tp.oldtuple =
1012 ReorderBufferAllocTupleBuf(ctx->reorder, tuplelen);
1013
1014 DecodeXLogTuple(data, datalen, change->data.tp.oldtuple);
1015 }
1016
1017 change->data.tp.clear_toast_afterwards = true;
1018
1020 change, false);
1021}
#define SizeOfHeapUpdate
Definition: heapam_xlog.h:233
#define XLH_UPDATE_CONTAINS_NEW_TUPLE
Definition: heapam_xlog.h:90
#define XLH_UPDATE_CONTAINS_OLD
Definition: heapam_xlog.h:95
@ REORDER_BUFFER_CHANGE_UPDATE
Definition: reorderbuffer.h:53

References ReorderBufferChange::action, buf, ReorderBufferChange::clear_toast_afterwards, ReorderBufferChange::data, ReplicationSlot::data, data, ReplicationSlotPersistentData::database, RelFileLocator::dbOid, DecodeXLogTuple(), FilterByOrigin(), xl_heap_update::flags, ReorderBufferChange::newtuple, ReorderBufferChange::oldtuple, ReorderBufferChange::origin_id, LogicalDecodingContext::reorder, REORDER_BUFFER_CHANGE_UPDATE, ReorderBufferAllocChange(), ReorderBufferAllocTupleBuf(), ReorderBufferQueueChange(), ReorderBufferChange::rlocator, SizeOfHeapHeader, SizeOfHeapUpdate, LogicalDecodingContext::slot, ReorderBufferChange::tp, XLH_UPDATE_CONTAINS_NEW_TUPLE, XLH_UPDATE_CONTAINS_OLD, XLogRecGetBlockData(), XLogRecGetBlockTag(), XLogRecGetData, XLogRecGetDataLen, XLogRecGetOrigin, and XLogRecGetXid.

Referenced by heap_decode().

◆ DecodeXLogTuple()

static void DecodeXLogTuple ( char *  data,
Size  len,
HeapTuple  tuple 
)
static

Definition at line 1261 of file decode.c.

1262{
1263 xl_heap_header xlhdr;
1264 int datalen = len - SizeOfHeapHeader;
1265 HeapTupleHeader header;
1266
1267 Assert(datalen >= 0);
1268
1269 tuple->t_len = datalen + SizeofHeapTupleHeader;
1270 header = tuple->t_data;
1271
1272 /* not a disk based tuple */
1274
1275 /* we can only figure this out after reassembling the transactions */
1276 tuple->t_tableOid = InvalidOid;
1277
1278 /* data is not stored aligned, copy to aligned storage */
1279 memcpy(&xlhdr, data, SizeOfHeapHeader);
1280
1281 memset(header, 0, SizeofHeapTupleHeader);
1282
1283 memcpy(((char *) tuple->t_data) + SizeofHeapTupleHeader,
1285 datalen);
1286
1287 header->t_infomask = xlhdr.t_infomask;
1288 header->t_infomask2 = xlhdr.t_infomask2;
1289 header->t_hoff = xlhdr.t_hoff;
1290}
const void size_t len
uint16 t_infomask
Definition: heapam_xlog.h:153
uint16 t_infomask2
Definition: heapam_xlog.h:152

References Assert(), data, InvalidOid, ItemPointerSetInvalid(), len, SizeOfHeapHeader, SizeofHeapTupleHeader, HeapTupleData::t_data, xl_heap_header::t_hoff, HeapTupleHeaderData::t_hoff, xl_heap_header::t_infomask, HeapTupleHeaderData::t_infomask, xl_heap_header::t_infomask2, HeapTupleHeaderData::t_infomask2, HeapTupleData::t_len, HeapTupleData::t_self, and HeapTupleData::t_tableOid.

Referenced by DecodeDelete(), DecodeInsert(), and DecodeUpdate().

◆ FilterByOrigin()

static bool FilterByOrigin ( LogicalDecodingContext ctx,
RepOriginId  origin_id 
)
inlinestatic

Definition at line 583 of file decode.c.

584{
585 if (ctx->callbacks.filter_by_origin_cb == NULL)
586 return false;
587
588 return filter_by_origin_cb_wrapper(ctx, origin_id);
589}
bool filter_by_origin_cb_wrapper(LogicalDecodingContext *ctx, RepOriginId origin_id)
Definition: logical.c:1197
OutputPluginCallbacks callbacks
Definition: logical.h:53
LogicalDecodeFilterByOriginCB filter_by_origin_cb

References LogicalDecodingContext::callbacks, OutputPluginCallbacks::filter_by_origin_cb, and filter_by_origin_cb_wrapper().

Referenced by DecodeDelete(), DecodeInsert(), DecodeMultiInsert(), DecodeSpecConfirm(), DecodeTruncate(), DecodeTXNNeedSkip(), DecodeUpdate(), and logicalmsg_decode().

◆ FilterPrepare()

static bool FilterPrepare ( LogicalDecodingContext ctx,
TransactionId  xid,
const char *  gid 
)
inlinestatic

Definition at line 560 of file decode.c.

562{
563 /*
564 * Skip if decoding of two-phase transactions at PREPARE time is not
565 * enabled. In that case, all two-phase transactions are considered
566 * filtered out and will be applied as regular transactions at COMMIT
567 * PREPARED.
568 */
569 if (!ctx->twophase)
570 return true;
571
572 /*
573 * The filter_prepare callback is optional. When not supplied, all
574 * prepared transactions should go through.
575 */
576 if (ctx->callbacks.filter_prepare_cb == NULL)
577 return false;
578
579 return filter_prepare_cb_wrapper(ctx, xid, gid);
580}
bool filter_prepare_cb_wrapper(LogicalDecodingContext *ctx, TransactionId xid, const char *gid)
Definition: logical.c:1165
LogicalDecodeFilterPrepareCB filter_prepare_cb

References LogicalDecodingContext::callbacks, OutputPluginCallbacks::filter_prepare_cb, filter_prepare_cb_wrapper(), and LogicalDecodingContext::twophase.

Referenced by xact_decode().

◆ heap2_decode()

void heap2_decode ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)

Definition at line 405 of file decode.c.

406{
407 uint8 info = XLogRecGetInfo(buf->record) & XLOG_HEAP_OPMASK;
408 TransactionId xid = XLogRecGetXid(buf->record);
409 SnapBuild *builder = ctx->snapshot_builder;
410
411 ReorderBufferProcessXid(ctx->reorder, xid, buf->origptr);
412
413 /*
414 * If we don't have snapshot or we are just fast-forwarding, there is no
415 * point in decoding data changes. However, it's crucial to build the base
416 * snapshot during fast-forward mode (as is done in
417 * SnapBuildProcessChange()) because we require the snapshot's xmin when
418 * determining the candidate catalog_xmin for the replication slot. See
419 * SnapBuildProcessRunningXacts().
420 */
422 return;
423
424 switch (info)
425 {
427 if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
428 !ctx->fast_forward)
430 break;
432 if (!ctx->fast_forward)
433 {
434 xl_heap_new_cid *xlrec;
435
436 xlrec = (xl_heap_new_cid *) XLogRecGetData(buf->record);
437 SnapBuildProcessNewCid(builder, xid, buf->origptr, xlrec);
438
439 break;
440 }
442
443 /*
444 * Although these records only exist to serve the needs of logical
445 * decoding, all the work happens as part of crash or archive
446 * recovery, so we don't need to do anything here.
447 */
448 break;
449
450 /*
451 * Everything else here is just low level physical stuff we're not
452 * interested in.
453 */
459 break;
460 default:
461 elog(ERROR, "unexpected RM_HEAP2_ID record type: %u", info);
462 }
463}
uint8_t uint8
Definition: c.h:500
static void DecodeMultiInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:1121
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:225
#define XLOG_HEAP2_MULTI_INSERT
Definition: heapam_xlog.h:64
#define XLOG_HEAP2_REWRITE
Definition: heapam_xlog.h:59
#define XLOG_HEAP_OPMASK
Definition: heapam_xlog.h:42
#define XLOG_HEAP2_PRUNE_VACUUM_SCAN
Definition: heapam_xlog.h:61
#define XLOG_HEAP2_LOCK_UPDATED
Definition: heapam_xlog.h:65
#define XLOG_HEAP2_PRUNE_ON_ACCESS
Definition: heapam_xlog.h:60
#define XLOG_HEAP2_NEW_CID
Definition: heapam_xlog.h:66
#define XLOG_HEAP2_PRUNE_VACUUM_CLEANUP
Definition: heapam_xlog.h:62
#define XLOG_HEAP2_VISIBLE
Definition: heapam_xlog.h:63
void ReorderBufferProcessXid(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn)
Definition: snapbuild.c:639
void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn, xl_heap_new_cid *xlrec)
Definition: snapbuild.c:689
@ SNAPBUILD_FULL_SNAPSHOT
Definition: snapbuild.h:43
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:410

References buf, DecodeMultiInsert(), elog, ERROR, LogicalDecodingContext::fast_forward, LogicalDecodingContext::reorder, ReorderBufferProcessXid(), SNAPBUILD_FULL_SNAPSHOT, SnapBuildCurrentState(), SnapBuildProcessChange(), SnapBuildProcessNewCid(), LogicalDecodingContext::snapshot_builder, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_PRUNE_ON_ACCESS, XLOG_HEAP2_PRUNE_VACUUM_CLEANUP, XLOG_HEAP2_PRUNE_VACUUM_SCAN, XLOG_HEAP2_REWRITE, XLOG_HEAP2_VISIBLE, XLOG_HEAP_OPMASK, XLogRecGetData, XLogRecGetInfo, and XLogRecGetXid.

◆ heap_decode()

void heap_decode ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)

Definition at line 469 of file decode.c.

470{
471 uint8 info = XLogRecGetInfo(buf->record) & XLOG_HEAP_OPMASK;
472 TransactionId xid = XLogRecGetXid(buf->record);
473 SnapBuild *builder = ctx->snapshot_builder;
474
475 ReorderBufferProcessXid(ctx->reorder, xid, buf->origptr);
476
477 /*
478 * If we don't have snapshot or we are just fast-forwarding, there is no
479 * point in decoding data changes. However, it's crucial to build the base
480 * snapshot during fast-forward mode (as is done in
481 * SnapBuildProcessChange()) because we require the snapshot's xmin when
482 * determining the candidate catalog_xmin for the replication slot. See
483 * SnapBuildProcessRunningXacts().
484 */
486 return;
487
488 switch (info)
489 {
490 case XLOG_HEAP_INSERT:
491 if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
492 !ctx->fast_forward)
493 DecodeInsert(ctx, buf);
494 break;
495
496 /*
497 * Treat HOT update as normal updates. There is no useful
498 * information in the fact that we could make it a HOT update
499 * locally and the WAL layout is compatible.
500 */
502 case XLOG_HEAP_UPDATE:
503 if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
504 !ctx->fast_forward)
505 DecodeUpdate(ctx, buf);
506 break;
507
508 case XLOG_HEAP_DELETE:
509 if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
510 !ctx->fast_forward)
511 DecodeDelete(ctx, buf);
512 break;
513
515 if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
516 !ctx->fast_forward)
517 DecodeTruncate(ctx, buf);
518 break;
519
521
522 /*
523 * Inplace updates are only ever performed on catalog tuples and
524 * can, per definition, not change tuple visibility. Inplace
525 * updates don't affect storage or interpretation of table rows,
526 * so they don't affect logicalrep_write_tuple() outcomes. Hence,
527 * we don't process invalidations from the original operation. If
528 * inplace updates did affect those things, invalidations wouldn't
529 * make it work, since there are no snapshot-specific versions of
530 * inplace-updated values. Since we also don't decode catalog
531 * tuples, we're not interested in the record's contents.
532 *
533 * WAL contains likely-unnecessary commit-time invals from the
534 * CacheInvalidateHeapTuple() call in
535 * heap_inplace_update_and_unlock(). Excess invalidation is safe.
536 */
537 break;
538
540 if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
541 !ctx->fast_forward)
543 break;
544
545 case XLOG_HEAP_LOCK:
546 /* we don't care about row level locks for now */
547 break;
548
549 default:
550 elog(ERROR, "unexpected RM_HEAP_ID record type: %u", info);
551 break;
552 }
553}
static void DecodeDelete(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:1029
static void DecodeInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:903
static void DecodeTruncate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:1083
static void DecodeUpdate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:962
static void DecodeSpecConfirm(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition: decode.c:1225
#define XLOG_HEAP_HOT_UPDATE
Definition: heapam_xlog.h:37
#define XLOG_HEAP_DELETE
Definition: heapam_xlog.h:34
#define XLOG_HEAP_TRUNCATE
Definition: heapam_xlog.h:36
#define XLOG_HEAP_UPDATE
Definition: heapam_xlog.h:35
#define XLOG_HEAP_INPLACE
Definition: heapam_xlog.h:40
#define XLOG_HEAP_LOCK
Definition: heapam_xlog.h:39
#define XLOG_HEAP_INSERT
Definition: heapam_xlog.h:33
#define XLOG_HEAP_CONFIRM
Definition: heapam_xlog.h:38

References buf, DecodeDelete(), DecodeInsert(), DecodeSpecConfirm(), DecodeTruncate(), DecodeUpdate(), elog, ERROR, LogicalDecodingContext::fast_forward, LogicalDecodingContext::reorder, ReorderBufferProcessXid(), SNAPBUILD_FULL_SNAPSHOT, SnapBuildCurrentState(), SnapBuildProcessChange(), LogicalDecodingContext::snapshot_builder, XLOG_HEAP_CONFIRM, XLOG_HEAP_DELETE, XLOG_HEAP_HOT_UPDATE, XLOG_HEAP_INPLACE, XLOG_HEAP_INSERT, XLOG_HEAP_LOCK, XLOG_HEAP_OPMASK, XLOG_HEAP_TRUNCATE, XLOG_HEAP_UPDATE, XLogRecGetInfo, and XLogRecGetXid.

◆ LogicalDecodingProcessRecord()

void LogicalDecodingProcessRecord ( LogicalDecodingContext ctx,
XLogReaderState record 
)

Definition at line 88 of file decode.c.

89{
91 TransactionId txid;
92 RmgrData rmgr;
93
94 buf.origptr = ctx->reader->ReadRecPtr;
95 buf.endptr = ctx->reader->EndRecPtr;
96 buf.record = record;
97
98 txid = XLogRecGetTopXid(record);
99
100 /*
101 * If the top-level xid is valid, we need to assign the subxact to the
102 * top-level xact. We need to do this for all records, hence we do it
103 * before the switch.
104 */
105 if (TransactionIdIsValid(txid))
106 {
108 txid,
109 XLogRecGetXid(record),
110 buf.origptr);
111 }
112
113 rmgr = GetRmgr(XLogRecGetRmid(record));
114
115 if (rmgr.rm_decode != NULL)
116 rmgr.rm_decode(ctx, &buf);
117 else
118 {
119 /* just deal with xid, and done */
121 buf.origptr);
122 }
123}
void ReorderBufferAssignChild(ReorderBuffer *rb, TransactionId xid, TransactionId subxid, XLogRecPtr lsn)
XLogReaderState * reader
Definition: logical.h:42
void(* rm_decode)(struct LogicalDecodingContext *ctx, struct XLogRecordBuffer *buf)
XLogRecPtr EndRecPtr
Definition: xlogreader.h:207
XLogRecPtr ReadRecPtr
Definition: xlogreader.h:206
#define TransactionIdIsValid(xid)
Definition: transam.h:41
static RmgrData GetRmgr(RmgrId rmid)
#define XLogRecGetRmid(decoder)
Definition: xlogreader.h:411
#define XLogRecGetTopXid(decoder)
Definition: xlogreader.h:414

References buf, XLogReaderState::EndRecPtr, GetRmgr(), LogicalDecodingContext::reader, XLogReaderState::ReadRecPtr, LogicalDecodingContext::reorder, ReorderBufferAssignChild(), ReorderBufferProcessXid(), RmgrData::rm_decode, TransactionIdIsValid, XLogRecGetRmid, XLogRecGetTopXid, and XLogRecGetXid.

Referenced by DecodingContextFindStartpoint(), LogicalReplicationSlotHasPendingWal(), LogicalSlotAdvanceAndCheckSnapState(), pg_logical_slot_get_changes_guts(), and XLogSendLogical().

◆ logicalmsg_decode()

void logicalmsg_decode ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)

Definition at line 595 of file decode.c.

596{
597 SnapBuild *builder = ctx->snapshot_builder;
598 XLogReaderState *r = buf->record;
600 uint8 info = XLogRecGetInfo(r) & ~XLR_INFO_MASK;
601 RepOriginId origin_id = XLogRecGetOrigin(r);
602 Snapshot snapshot = NULL;
603 xl_logical_message *message;
604
605 if (info != XLOG_LOGICAL_MESSAGE)
606 elog(ERROR, "unexpected RM_LOGICALMSG_ID record type: %u", info);
607
609
610 /* If we don't have snapshot, there is no point in decoding messages */
612 return;
613
614 message = (xl_logical_message *) XLogRecGetData(r);
615
616 if (message->dbId != ctx->slot->data.database ||
617 FilterByOrigin(ctx, origin_id))
618 return;
619
620 if (message->transactional &&
621 !SnapBuildProcessChange(builder, xid, buf->origptr))
622 return;
623 else if (!message->transactional &&
625 SnapBuildXactNeedsSkip(builder, buf->origptr)))
626 return;
627
628 /*
629 * We also skip decoding in fast_forward mode. This check must be last
630 * because we don't want to set the processing_required flag unless we
631 * have a decodable message.
632 */
633 if (ctx->fast_forward)
634 {
635 /*
636 * We need to set processing_required flag to notify the message's
637 * existence to the caller. Usually, the flag is set when either the
638 * COMMIT or ABORT records are decoded, but this must be turned on
639 * here because the non-transactional logical message is decoded
640 * without waiting for these records.
641 */
642 if (!message->transactional)
643 ctx->processing_required = true;
644
645 return;
646 }
647
648 /*
649 * If this is a non-transactional change, get the snapshot we're expected
650 * to use. We only get here when the snapshot is consistent, and the
651 * change is not meant to be skipped.
652 *
653 * For transactional changes we don't need a snapshot, we'll use the
654 * regular snapshot maintained by ReorderBuffer. We just leave it NULL.
655 */
656 if (!message->transactional)
657 snapshot = SnapBuildGetOrBuildSnapshot(builder);
658
659 ReorderBufferQueueMessage(ctx->reorder, xid, snapshot, buf->endptr,
660 message->transactional,
661 message->message, /* first part of message is
662 * prefix */
663 message->message_size,
664 message->message + message->prefix_size);
665}
#define XLOG_LOGICAL_MESSAGE
Definition: message.h:37
void ReorderBufferQueueMessage(ReorderBuffer *rb, TransactionId xid, Snapshot snap, XLogRecPtr lsn, bool transactional, const char *prefix, Size message_size, const char *message)
Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder)
Definition: snapbuild.c:579
bool transactional
Definition: message.h:23
char message[FLEXIBLE_ARRAY_MEMBER]
Definition: message.h:27

References buf, ReplicationSlot::data, ReplicationSlotPersistentData::database, xl_logical_message::dbId, elog, ERROR, LogicalDecodingContext::fast_forward, FilterByOrigin(), xl_logical_message::message, xl_logical_message::message_size, xl_logical_message::prefix_size, LogicalDecodingContext::processing_required, LogicalDecodingContext::reorder, ReorderBufferProcessXid(), ReorderBufferQueueMessage(), LogicalDecodingContext::slot, SNAPBUILD_CONSISTENT, SNAPBUILD_FULL_SNAPSHOT, SnapBuildCurrentState(), SnapBuildGetOrBuildSnapshot(), SnapBuildProcessChange(), SnapBuildXactNeedsSkip(), LogicalDecodingContext::snapshot_builder, xl_logical_message::transactional, XLOG_LOGICAL_MESSAGE, XLogRecGetData, XLogRecGetInfo, XLogRecGetOrigin, and XLogRecGetXid.

◆ standby_decode()

void standby_decode ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)

Definition at line 359 of file decode.c.

360{
361 SnapBuild *builder = ctx->snapshot_builder;
362 XLogReaderState *r = buf->record;
363 uint8 info = XLogRecGetInfo(r) & ~XLR_INFO_MASK;
364
366
367 switch (info)
368 {
370 {
372
373 SnapBuildProcessRunningXacts(builder, buf->origptr, running);
374
375 /*
376 * Abort all transactions that we keep track of, that are
377 * older than the record's oldestRunningXid. This is the most
378 * convenient spot for doing so since, in contrast to shutdown
379 * or end-of-recovery checkpoints, we have information about
380 * all running transactions which includes prepared ones,
381 * while shutdown checkpoints just know that no non-prepared
382 * transactions are in progress.
383 */
385 }
386 break;
388 break;
390
391 /*
392 * We are processing the invalidations at the command level via
393 * XLOG_XACT_INVALIDATIONS. So we don't need to do anything here.
394 */
395 break;
396 default:
397 elog(ERROR, "unexpected RM_STANDBY_ID record type: %u", info);
398 }
399}
void ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *running)
Definition: snapbuild.c:1128
#define XLOG_INVALIDATIONS
Definition: standbydefs.h:36
#define XLOG_STANDBY_LOCK
Definition: standbydefs.h:34
#define XLOG_RUNNING_XACTS
Definition: standbydefs.h:35
TransactionId oldestRunningXid
Definition: standbydefs.h:53

References buf, elog, ERROR, xl_running_xacts::oldestRunningXid, LogicalDecodingContext::reorder, ReorderBufferAbortOld(), ReorderBufferProcessXid(), SnapBuildProcessRunningXacts(), LogicalDecodingContext::snapshot_builder, XLOG_INVALIDATIONS, XLOG_RUNNING_XACTS, XLOG_STANDBY_LOCK, XLogRecGetData, XLogRecGetInfo, and XLogRecGetXid.

◆ xact_decode()

void xact_decode ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)

Definition at line 201 of file decode.c.

202{
203 SnapBuild *builder = ctx->snapshot_builder;
204 ReorderBuffer *reorder = ctx->reorder;
205 XLogReaderState *r = buf->record;
207
208 /*
209 * If the snapshot isn't yet fully built, we cannot decode anything, so
210 * bail out.
211 */
213 return;
214
215 switch (info)
216 {
217 case XLOG_XACT_COMMIT:
219 {
220 xl_xact_commit *xlrec;
222 TransactionId xid;
223 bool two_phase = false;
224
225 xlrec = (xl_xact_commit *) XLogRecGetData(r);
226 ParseCommitRecord(XLogRecGetInfo(buf->record), xlrec, &parsed);
227
229 xid = XLogRecGetXid(r);
230 else
231 xid = parsed.twophase_xid;
232
233 /*
234 * We would like to process the transaction in a two-phase
235 * manner iff output plugin supports two-phase commits and
236 * doesn't filter the transaction at prepare time.
237 */
238 if (info == XLOG_XACT_COMMIT_PREPARED)
239 two_phase = !(FilterPrepare(ctx, xid,
240 parsed.twophase_gid));
241
242 DecodeCommit(ctx, buf, &parsed, xid, two_phase);
243 break;
244 }
245 case XLOG_XACT_ABORT:
247 {
248 xl_xact_abort *xlrec;
250 TransactionId xid;
251 bool two_phase = false;
252
253 xlrec = (xl_xact_abort *) XLogRecGetData(r);
254 ParseAbortRecord(XLogRecGetInfo(buf->record), xlrec, &parsed);
255
257 xid = XLogRecGetXid(r);
258 else
259 xid = parsed.twophase_xid;
260
261 /*
262 * We would like to process the transaction in a two-phase
263 * manner iff output plugin supports two-phase commits and
264 * doesn't filter the transaction at prepare time.
265 */
266 if (info == XLOG_XACT_ABORT_PREPARED)
267 two_phase = !(FilterPrepare(ctx, xid,
268 parsed.twophase_gid));
269
270 DecodeAbort(ctx, buf, &parsed, xid, two_phase);
271 break;
272 }
274
275 /*
276 * We assign subxact to the toplevel xact while processing each
277 * record if required. So, we don't need to do anything here. See
278 * LogicalDecodingProcessRecord.
279 */
280 break;
282 {
283 TransactionId xid;
284 xl_xact_invals *invals;
285
286 xid = XLogRecGetXid(r);
287 invals = (xl_xact_invals *) XLogRecGetData(r);
288
289 /*
290 * Execute the invalidations for xid-less transactions,
291 * otherwise, accumulate them so that they can be processed at
292 * the commit time.
293 */
294 if (TransactionIdIsValid(xid))
295 {
296 if (!ctx->fast_forward)
298 buf->origptr,
299 invals->nmsgs,
300 invals->msgs);
302 buf->origptr);
303 }
304 else if (!ctx->fast_forward)
306 invals->nmsgs,
307 invals->msgs);
308
309 break;
310 }
312 {
314 xl_xact_prepare *xlrec;
315
316 /* ok, parse it */
317 xlrec = (xl_xact_prepare *) XLogRecGetData(r);
319 xlrec, &parsed);
320
321 /*
322 * We would like to process the transaction in a two-phase
323 * manner iff output plugin supports two-phase commits and
324 * doesn't filter the transaction at prepare time.
325 */
326 if (FilterPrepare(ctx, parsed.twophase_xid,
327 parsed.twophase_gid))
328 {
330 buf->origptr);
331 break;
332 }
333
334 /*
335 * Note that if the prepared transaction has locked [user]
336 * catalog tables exclusively then decoding prepare can block
337 * till the main transaction is committed because it needs to
338 * lock the catalog tables.
339 *
340 * XXX Now, this can even lead to a deadlock if the prepare
341 * transaction is waiting to get it logically replicated for
342 * distributed 2PC. This can be avoided by disallowing
343 * preparing transactions that have locked [user] catalog
344 * tables exclusively but as of now, we ask users not to do
345 * such an operation.
346 */
347 DecodePrepare(ctx, buf, &parsed);
348 break;
349 }
350 default:
351 elog(ERROR, "unexpected RM_XACT_ID record type: %u", info);
352 }
353}
static void DecodeAbort(LogicalDecodingContext *ctx, XLogRecordBuffer *buf, xl_xact_parsed_abort *parsed, TransactionId xid, bool two_phase)
Definition: decode.c:847
static bool FilterPrepare(LogicalDecodingContext *ctx, TransactionId xid, const char *gid)
Definition: decode.c:560
static void DecodeCommit(LogicalDecodingContext *ctx, XLogRecordBuffer *buf, xl_xact_parsed_commit *parsed, TransactionId xid, bool two_phase)
Definition: decode.c:676
static void DecodePrepare(LogicalDecodingContext *ctx, XLogRecordBuffer *buf, xl_xact_parsed_prepare *parsed)
Definition: decode.c:772
void ReorderBufferXidSetCatalogChanges(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
void ReorderBufferAddInvalidations(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, Size nmsgs, SharedInvalidationMessage *msgs)
void ReorderBufferImmediateInvalidation(ReorderBuffer *rb, uint32 ninvalidations, SharedInvalidationMessage *invalidations)
SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER]
Definition: xact.h:305
int nmsgs
Definition: xact.h:304
TransactionId twophase_xid
Definition: xact.h:427
#define XLOG_XACT_COMMIT_PREPARED
Definition: xact.h:172
#define XLOG_XACT_INVALIDATIONS
Definition: xact.h:175
#define XLOG_XACT_PREPARE
Definition: xact.h:170
#define XLOG_XACT_COMMIT
Definition: xact.h:169
#define XLOG_XACT_OPMASK
Definition: xact.h:179
#define XLOG_XACT_ABORT
Definition: xact.h:171
#define XLOG_XACT_ASSIGNMENT
Definition: xact.h:174
#define XLOG_XACT_ABORT_PREPARED
Definition: xact.h:173
void ParseCommitRecord(uint8 info, xl_xact_commit *xlrec, xl_xact_parsed_commit *parsed)
Definition: xactdesc.c:35
void ParseAbortRecord(uint8 info, xl_xact_abort *xlrec, xl_xact_parsed_abort *parsed)
Definition: xactdesc.c:141
void ParsePrepareRecord(uint8 info, xl_xact_prepare *xlrec, xl_xact_parsed_prepare *parsed)
Definition: xactdesc.c:239

References buf, DecodeAbort(), DecodeCommit(), DecodePrepare(), elog, ERROR, LogicalDecodingContext::fast_forward, FilterPrepare(), xl_xact_invals::msgs, xl_xact_invals::nmsgs, ParseAbortRecord(), ParseCommitRecord(), ParsePrepareRecord(), LogicalDecodingContext::reorder, ReorderBufferAddInvalidations(), ReorderBufferImmediateInvalidation(), ReorderBufferProcessXid(), ReorderBufferXidSetCatalogChanges(), SNAPBUILD_FULL_SNAPSHOT, SnapBuildCurrentState(), LogicalDecodingContext::snapshot_builder, TransactionIdIsValid, two_phase, xl_xact_parsed_commit::twophase_gid, xl_xact_parsed_abort::twophase_gid, xl_xact_parsed_commit::twophase_xid, xl_xact_parsed_abort::twophase_xid, XLOG_XACT_ABORT, XLOG_XACT_ABORT_PREPARED, XLOG_XACT_ASSIGNMENT, XLOG_XACT_COMMIT, XLOG_XACT_COMMIT_PREPARED, XLOG_XACT_INVALIDATIONS, XLOG_XACT_OPMASK, XLOG_XACT_PREPARE, XLogRecGetData, XLogRecGetInfo, and XLogRecGetXid.

◆ xlog_decode()

void xlog_decode ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)

Definition at line 129 of file decode.c.

130{
131 SnapBuild *builder = ctx->snapshot_builder;
132 uint8 info = XLogRecGetInfo(buf->record) & ~XLR_INFO_MASK;
133
135 buf->origptr);
136
137 switch (info)
138 {
139 /* this is also used in END_OF_RECOVERY checkpoints */
142 SnapBuildSerializationPoint(builder, buf->origptr);
143
144 break;
146
147 /*
148 * a RUNNING_XACTS record will have been logged near to this, we
149 * can restart from there.
150 */
151 break;
153 {
154 xl_parameter_change *xlrec =
156
157 /*
158 * If wal_level on the primary is reduced to less than
159 * logical, we want to prevent existing logical slots from
160 * being used. Existing logical slots on the standby get
161 * invalidated when this WAL record is replayed; and further,
162 * slot creation fails when wal_level is not sufficient; but
163 * all these operations are not synchronized, so a logical
164 * slot may creep in while the wal_level is being reduced.
165 * Hence this extra check.
166 */
167 if (xlrec->wal_level < WAL_LEVEL_LOGICAL)
168 {
169 /*
170 * This can occur only on a standby, as a primary would
171 * not allow to restart after changing wal_level < logical
172 * if there is pre-existing logical slot.
173 */
176 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
177 errmsg("logical decoding on standby requires \"wal_level\" >= \"logical\" on the primary")));
178 }
179 break;
180 }
181 case XLOG_NOOP:
182 case XLOG_NEXTOID:
183 case XLOG_SWITCH:
184 case XLOG_BACKUP_END:
186 case XLOG_FPW_CHANGE:
188 case XLOG_FPI:
191 break;
192 default:
193 elog(ERROR, "unexpected RM_XLOG_ID record type: %u", info);
194 }
195}
int errcode(int sqlerrcode)
Definition: elog.c:854
int errmsg(const char *fmt,...)
Definition: elog.c:1071
#define ereport(elevel,...)
Definition: elog.h:149
#define XLOG_RESTORE_POINT
Definition: pg_control.h:75
#define XLOG_FPW_CHANGE
Definition: pg_control.h:76
#define XLOG_CHECKPOINT_REDO
Definition: pg_control.h:82
#define XLOG_OVERWRITE_CONTRECORD
Definition: pg_control.h:81
#define XLOG_FPI
Definition: pg_control.h:79
#define XLOG_FPI_FOR_HINT
Definition: pg_control.h:78
#define XLOG_NEXTOID
Definition: pg_control.h:71
#define XLOG_NOOP
Definition: pg_control.h:70
#define XLOG_CHECKPOINT_SHUTDOWN
Definition: pg_control.h:68
#define XLOG_SWITCH
Definition: pg_control.h:72
#define XLOG_BACKUP_END
Definition: pg_control.h:73
#define XLOG_PARAMETER_CHANGE
Definition: pg_control.h:74
#define XLOG_CHECKPOINT_ONLINE
Definition: pg_control.h:69
#define XLOG_END_OF_RECOVERY
Definition: pg_control.h:77
void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn)
Definition: snapbuild.c:1476
bool RecoveryInProgress(void)
Definition: xlog.c:6522
@ WAL_LEVEL_LOGICAL
Definition: xlog.h:76

References Assert(), buf, elog, ereport, errcode(), errmsg(), ERROR, RecoveryInProgress(), LogicalDecodingContext::reorder, ReorderBufferProcessXid(), SnapBuildSerializationPoint(), LogicalDecodingContext::snapshot_builder, xl_parameter_change::wal_level, WAL_LEVEL_LOGICAL, XLOG_BACKUP_END, XLOG_CHECKPOINT_ONLINE, XLOG_CHECKPOINT_REDO, XLOG_CHECKPOINT_SHUTDOWN, XLOG_END_OF_RECOVERY, XLOG_FPI, XLOG_FPI_FOR_HINT, XLOG_FPW_CHANGE, XLOG_NEXTOID, XLOG_NOOP, XLOG_OVERWRITE_CONTRECORD, XLOG_PARAMETER_CHANGE, XLOG_RESTORE_POINT, XLOG_SWITCH, XLogRecGetData, XLogRecGetInfo, and XLogRecGetXid.