PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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.

Data Structures

struct  XLogRecordBuffer
 

Typedefs

typedef struct XLogRecordBuffer XLogRecordBuffer
 

Functions

void xlog_decode (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
void xlog2_decode (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
void heap_decode (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
void heap2_decode (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
void xact_decode (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
void standby_decode (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
void logicalmsg_decode (LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 
void LogicalDecodingProcessRecord (LogicalDecodingContext *ctx, XLogReaderState *record)
 
bool change_useless_for_repack (XLogRecordBuffer *buf)
 

Typedef Documentation

◆ XLogRecordBuffer

Function Documentation

◆ change_useless_for_repack()

bool change_useless_for_repack ( XLogRecordBuffer buf)
extern

Definition at line 500 of file repack_worker.c.

501{
503 RelFileLocator locator;
504
505 /* TOAST locator should not be set unless the main is. */
508
509 /*
510 * Backends not involved in REPACK (CONCURRENTLY) should not do the
511 * filtering.
512 */
514 return false;
515
516 /*
517 * If the record does not contain the block 0, it's probably not INSERT /
518 * UPDATE / DELETE. In any case, we do not have enough information to
519 * filter the change out.
520 */
521 if (!XLogRecGetBlockTagExtended(r, 0, &locator, NULL, NULL, NULL))
522 return false;
523
524 /*
525 * Decode the change if it belongs to the table we are repacking, or if it
526 * belongs to its TOAST relation.
527 */
529 return false;
532 return false;
533
534 /* Filter out changes of other tables. */
535 return true;
536}
#define Assert(condition)
Definition c.h:943
#define OidIsValid(objectId)
Definition c.h:858
static char buf[DEFAULT_XLOG_SEG_SIZE]
static int fb(int x)
#define RelFileLocatorEquals(locator1, locator2)
static RelFileLocator repacked_rel_toast_locator
static RelFileLocator repacked_rel_locator
RelFileNumber relNumber
DecodedXLogRecord * record
Definition xlogreader.h:235
bool XLogRecGetBlockTagExtended(XLogReaderState *record, uint8 block_id, RelFileLocator *rlocator, ForkNumber *forknum, BlockNumber *blknum, Buffer *prefetch_buffer)

References Assert, buf, fb(), OidIsValid, XLogReaderState::record, RelFileLocatorEquals, RelFileLocator::relNumber, repacked_rel_locator, repacked_rel_toast_locator, and XLogRecGetBlockTagExtended().

Referenced by heap2_decode(), and heap_decode().

◆ heap2_decode()

void heap2_decode ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)
extern

Definition at line 422 of file decode.c.

423{
424 uint8 info = XLogRecGetInfo(buf->record) & XLOG_HEAP_OPMASK;
425 TransactionId xid = XLogRecGetXid(buf->record);
426 SnapBuild *builder = ctx->snapshot_builder;
427
428 ReorderBufferProcessXid(ctx->reorder, xid, buf->origptr);
429
430 /*
431 * If we don't have snapshot or we are just fast-forwarding, there is no
432 * point in decoding data changes. However, it's crucial to build the base
433 * snapshot during fast-forward mode (as is done in
434 * SnapBuildProcessChange()) because we require the snapshot's xmin when
435 * determining the candidate catalog_xmin for the replication slot. See
436 * SnapBuildProcessRunningXacts().
437 */
439 return;
440
441 switch (info)
442 {
444 if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
445 !ctx->fast_forward &&
448 break;
450 if (!ctx->fast_forward)
451 {
453
455 SnapBuildProcessNewCid(builder, xid, buf->origptr, xlrec);
456 }
457 break;
459
460 /*
461 * Although these records only exist to serve the needs of logical
462 * decoding, all the work happens as part of crash or archive
463 * recovery, so we don't need to do anything here.
464 */
465 break;
466
467 /*
468 * Everything else here is just low level physical stuff we're not
469 * interested in.
470 */
475 break;
476 default:
477 elog(ERROR, "unexpected RM_HEAP2_ID record type: %u", info);
478 }
479}
uint8_t uint8
Definition c.h:622
uint32 TransactionId
Definition c.h:736
static void DecodeMultiInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition decode.c:1142
#define ERROR
Definition elog.h:40
#define elog(elevel,...)
Definition elog.h:228
#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
void ReorderBufferProcessXid(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
bool change_useless_for_repack(XLogRecordBuffer *buf)
bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn)
Definition snapbuild.c:642
SnapBuildState SnapBuildCurrentState(SnapBuild *builder)
Definition snapbuild.c:281
void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn, xl_heap_new_cid *xlrec)
Definition snapbuild.c:692
@ SNAPBUILD_FULL_SNAPSHOT
Definition snapbuild.h:51
struct SnapBuild * snapshot_builder
Definition logical.h:44
struct ReorderBuffer * reorder
Definition logical.h:43
#define XLogRecGetInfo(decoder)
Definition xlogreader.h:410
#define XLogRecGetData(decoder)
Definition xlogreader.h:415
#define XLogRecGetXid(decoder)
Definition xlogreader.h:412

References buf, change_useless_for_repack(), DecodeMultiInsert(), elog, ERROR, LogicalDecodingContext::fast_forward, fb(), 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_HEAP_OPMASK, XLogRecGetData, XLogRecGetInfo, and XLogRecGetXid.

◆ heap_decode()

void heap_decode ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)
extern

Definition at line 485 of file decode.c.

486{
487 uint8 info = XLogRecGetInfo(buf->record) & XLOG_HEAP_OPMASK;
488 TransactionId xid = XLogRecGetXid(buf->record);
489 SnapBuild *builder = ctx->snapshot_builder;
490
491 ReorderBufferProcessXid(ctx->reorder, xid, buf->origptr);
492
493 /*
494 * If we don't have snapshot or we are just fast-forwarding, there is no
495 * point in decoding data changes. However, it's crucial to build the base
496 * snapshot during fast-forward mode (as is done in
497 * SnapBuildProcessChange()) because we require the snapshot's xmin when
498 * determining the candidate catalog_xmin for the replication slot. See
499 * SnapBuildProcessRunningXacts().
500 */
502 return;
503
504 switch (info)
505 {
506 case XLOG_HEAP_INSERT:
507 if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
508 !ctx->fast_forward &&
510 DecodeInsert(ctx, buf);
511 break;
512
513 /*
514 * Treat HOT update as normal updates. There is no useful
515 * information in the fact that we could make it a HOT update
516 * locally and the WAL layout is compatible.
517 */
519 case XLOG_HEAP_UPDATE:
520 if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
521 !ctx->fast_forward &&
523 DecodeUpdate(ctx, buf);
524 break;
525
526 case XLOG_HEAP_DELETE:
527 if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
528 !ctx->fast_forward &&
530 DecodeDelete(ctx, buf);
531 break;
532
534 if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
535 !ctx->fast_forward &&
537 DecodeTruncate(ctx, buf);
538 break;
539
541
542 /*
543 * Inplace updates are only ever performed on catalog tuples and
544 * can, per definition, not change tuple visibility. Since we
545 * also don't decode catalog tuples, we're not interested in the
546 * record's contents.
547 */
548 break;
549
551 if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
552 !ctx->fast_forward &&
555 break;
556
557 case XLOG_HEAP_LOCK:
558 /* we don't care about row level locks for now */
559 break;
560
561 default:
562 elog(ERROR, "unexpected RM_HEAP_ID record type: %u", info);
563 break;
564 }
565}
static void DecodeDelete(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition decode.c:1041
static void DecodeInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition decode.c:915
static void DecodeTruncate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition decode.c:1104
static void DecodeUpdate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition decode.c:974
static void DecodeSpecConfirm(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
Definition decode.c:1246
#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, change_useless_for_repack(), 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 
)
extern

Definition at line 89 of file decode.c.

90{
94
95 buf.origptr = ctx->reader->ReadRecPtr;
96 buf.endptr = ctx->reader->EndRecPtr;
97 buf.record = record;
98
99 txid = XLogRecGetTopXid(record);
100
101 /*
102 * If the top-level xid is valid, we need to assign the subxact to the
103 * top-level xact. We need to do this for all records, hence we do it
104 * before the switch.
105 */
107 {
109 txid,
110 XLogRecGetXid(record),
111 buf.origptr);
112 }
113
114 rmgr = GetRmgr(XLogRecGetRmid(record));
115
116 if (rmgr.rm_decode != NULL)
117 rmgr.rm_decode(ctx, &buf);
118 else
119 {
120 /* just deal with xid, and done */
122 buf.origptr);
123 }
124}
void ReorderBufferAssignChild(ReorderBuffer *rb, TransactionId xid, TransactionId subxid, XLogRecPtr lsn)
XLogReaderState * reader
Definition logical.h:42
XLogRecPtr EndRecPtr
Definition xlogreader.h:206
XLogRecPtr ReadRecPtr
Definition xlogreader.h:205
#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, fb(), GetRmgr(), LogicalDecodingContext::reader, XLogReaderState::ReadRecPtr, LogicalDecodingContext::reorder, ReorderBufferAssignChild(), ReorderBufferProcessXid(), TransactionIdIsValid, XLogRecGetRmid, XLogRecGetTopXid, and XLogRecGetXid.

Referenced by decode_concurrent_changes(), DecodingContextFindStartpoint(), LogicalReplicationSlotCheckPendingWal(), LogicalSlotAdvanceAndCheckSnapState(), pg_logical_slot_get_changes_guts(), and XLogSendLogical().

◆ logicalmsg_decode()

void logicalmsg_decode ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)
extern

Definition at line 607 of file decode.c.

608{
609 SnapBuild *builder = ctx->snapshot_builder;
613 ReplOriginId origin_id = XLogRecGetOrigin(r);
614 Snapshot snapshot = NULL;
615 xl_logical_message *message;
616
617 if (info != XLOG_LOGICAL_MESSAGE)
618 elog(ERROR, "unexpected RM_LOGICALMSG_ID record type: %u", info);
619
621
622 /* If we don't have snapshot, there is no point in decoding messages */
624 return;
625
626 message = (xl_logical_message *) XLogRecGetData(r);
627
628 if (message->dbId != ctx->slot->data.database ||
629 FilterByOrigin(ctx, origin_id))
630 return;
631
632 if (message->transactional &&
633 !SnapBuildProcessChange(builder, xid, buf->origptr))
634 return;
635 else if (!message->transactional &&
637 SnapBuildXactNeedsSkip(builder, buf->origptr)))
638 return;
639
640 /*
641 * We also skip decoding in fast_forward mode. This check must be last
642 * because we don't want to set the processing_required flag unless we
643 * have a decodable message.
644 */
645 if (ctx->fast_forward)
646 {
647 /*
648 * We need to set processing_required flag to notify the message's
649 * existence to the caller. Usually, the flag is set when either the
650 * COMMIT or ABORT records are decoded, but this must be turned on
651 * here because the non-transactional logical message is decoded
652 * without waiting for these records.
653 */
654 if (!message->transactional)
655 ctx->processing_required = true;
656
657 return;
658 }
659
660 /*
661 * If this is a non-transactional change, get the snapshot we're expected
662 * to use. We only get here when the snapshot is consistent, and the
663 * change is not meant to be skipped.
664 *
665 * For transactional changes we don't need a snapshot, we'll use the
666 * regular snapshot maintained by ReorderBuffer. We just leave it NULL.
667 */
668 if (!message->transactional)
669 snapshot = SnapBuildGetOrBuildSnapshot(builder);
670
671 ReorderBufferQueueMessage(ctx->reorder, xid, snapshot, buf->endptr,
672 message->transactional,
673 message->message, /* first part of message is
674 * prefix */
675 message->message_size,
676 message->message + message->prefix_size);
677}
static bool FilterByOrigin(LogicalDecodingContext *ctx, ReplOriginId origin_id)
Definition decode.c:595
#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)
bool SnapBuildXactNeedsSkip(SnapBuild *builder, XLogRecPtr ptr)
Definition snapbuild.c:308
Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder)
Definition snapbuild.c:582
@ SNAPBUILD_CONSISTENT
Definition snapbuild.h:58
ReplicationSlot * slot
Definition logical.h:39
ReplicationSlotPersistentData data
Definition slot.h:213
char message[FLEXIBLE_ARRAY_MEMBER]
Definition message.h:27
uint16 ReplOriginId
Definition xlogdefs.h:69
#define XLogRecGetOrigin(decoder)
Definition xlogreader.h:413

References buf, ReplicationSlot::data, ReplicationSlotPersistentData::database, xl_logical_message::dbId, elog, ERROR, LogicalDecodingContext::fast_forward, fb(), FilterByOrigin(), xl_logical_message::message, xl_logical_message::message_size, xl_logical_message::prefix_size, LogicalDecodingContext::processing_required, XLogReaderState::record, 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 
)
extern

Definition at line 371 of file decode.c.

372{
373 SnapBuild *builder = ctx->snapshot_builder;
376
378
379 switch (info)
380 {
382 {
384
385 /*
386 * Update this decoder's idea of transactions currently
387 * running. In doing so we will determine whether we have
388 * reached consistent status.
389 */
390 SnapBuildProcessRunningXacts(builder, buf->origptr, running);
391
392 /*
393 * Abort all transactions that we keep track of, that are
394 * older than the record's oldestRunningXid. This is the most
395 * convenient spot for doing so since, in contrast to shutdown
396 * or end-of-recovery checkpoints, we have information about
397 * all running transactions which includes prepared ones,
398 * while shutdown checkpoints just know that no non-prepared
399 * transactions are in progress.
400 */
402 }
403 break;
405 break;
407
408 /*
409 * We are processing the invalidations at the command level via
410 * XLOG_XACT_INVALIDATIONS. So we don't need to do anything here.
411 */
412 break;
413 default:
414 elog(ERROR, "unexpected RM_STANDBY_ID record type: %u", info);
415 }
416}
void ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *running)
Definition snapbuild.c:1140
#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, fb(), xl_running_xacts::oldestRunningXid, XLogReaderState::record, 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 
)
extern

Definition at line 213 of file decode.c.

214{
215 SnapBuild *builder = ctx->snapshot_builder;
216 ReorderBuffer *reorder = ctx->reorder;
219
220 /*
221 * If the snapshot isn't yet fully built, we cannot decode anything, so
222 * bail out.
223 */
225 return;
226
227 switch (info)
228 {
229 case XLOG_XACT_COMMIT:
231 {
234 TransactionId xid;
235 bool two_phase = false;
236
239
240 if (!TransactionIdIsValid(parsed.twophase_xid))
241 xid = XLogRecGetXid(r);
242 else
243 xid = parsed.twophase_xid;
244
245 /*
246 * We would like to process the transaction in a two-phase
247 * manner iff output plugin supports two-phase commits and
248 * doesn't filter the transaction at prepare time.
249 */
250 if (info == XLOG_XACT_COMMIT_PREPARED)
251 two_phase = !(FilterPrepare(ctx, xid,
252 parsed.twophase_gid));
253
254 DecodeCommit(ctx, buf, &parsed, xid, two_phase);
255 break;
256 }
257 case XLOG_XACT_ABORT:
259 {
262 TransactionId xid;
263 bool two_phase = false;
264
267
268 if (!TransactionIdIsValid(parsed.twophase_xid))
269 xid = XLogRecGetXid(r);
270 else
271 xid = parsed.twophase_xid;
272
273 /*
274 * We would like to process the transaction in a two-phase
275 * manner iff output plugin supports two-phase commits and
276 * doesn't filter the transaction at prepare time.
277 */
278 if (info == XLOG_XACT_ABORT_PREPARED)
279 two_phase = !(FilterPrepare(ctx, xid,
280 parsed.twophase_gid));
281
282 DecodeAbort(ctx, buf, &parsed, xid, two_phase);
283 break;
284 }
286
287 /*
288 * We assign subxact to the toplevel xact while processing each
289 * record if required. So, we don't need to do anything here. See
290 * LogicalDecodingProcessRecord.
291 */
292 break;
294 {
295 TransactionId xid;
297
298 xid = XLogRecGetXid(r);
300
301 /*
302 * Execute the invalidations for xid-less transactions,
303 * otherwise, accumulate them so that they can be processed at
304 * the commit time.
305 */
306 if (TransactionIdIsValid(xid))
307 {
308 if (!ctx->fast_forward)
310 buf->origptr,
311 invals->nmsgs,
312 invals->msgs);
314 buf->origptr);
315 }
316 else if (!ctx->fast_forward)
318 invals->nmsgs,
319 invals->msgs);
320
321 break;
322 }
324 {
327
328 /* ok, parse it */
331 xlrec, &parsed);
332
333 /*
334 * We would like to process the transaction in a two-phase
335 * manner iff output plugin supports two-phase commits and
336 * doesn't filter the transaction at prepare time.
337 */
338 if (FilterPrepare(ctx, parsed.twophase_xid,
339 parsed.twophase_gid))
340 {
341 ReorderBufferProcessXid(reorder, parsed.twophase_xid,
342 buf->origptr);
343 break;
344 }
345
346 /*
347 * Note that if the prepared transaction has locked [user]
348 * catalog tables exclusively then decoding prepare can block
349 * till the main transaction is committed because it needs to
350 * lock the catalog tables.
351 *
352 * XXX Now, this can even lead to a deadlock if the prepare
353 * transaction is waiting to get it logically replicated for
354 * distributed 2PC. This can be avoided by disallowing
355 * preparing transactions that have locked [user] catalog
356 * tables exclusively but as of now, we ask users not to do
357 * such an operation.
358 */
359 DecodePrepare(ctx, buf, &parsed);
360 break;
361 }
362 default:
363 elog(ERROR, "unexpected RM_XACT_ID record type: %u", info);
364 }
365}
static void DecodeAbort(LogicalDecodingContext *ctx, XLogRecordBuffer *buf, xl_xact_parsed_abort *parsed, TransactionId xid, bool two_phase)
Definition decode.c:859
static bool FilterPrepare(LogicalDecodingContext *ctx, TransactionId xid, const char *gid)
Definition decode.c:572
static void DecodeCommit(LogicalDecodingContext *ctx, XLogRecordBuffer *buf, xl_xact_parsed_commit *parsed, TransactionId xid, bool two_phase)
Definition decode.c:688
static void DecodePrepare(LogicalDecodingContext *ctx, XLogRecordBuffer *buf, xl_xact_parsed_prepare *parsed)
Definition decode.c:784
static bool two_phase
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)
#define XLOG_XACT_COMMIT_PREPARED
Definition xact.h:173
#define XLOG_XACT_INVALIDATIONS
Definition xact.h:176
#define XLOG_XACT_PREPARE
Definition xact.h:171
#define XLOG_XACT_COMMIT
Definition xact.h:170
#define XLOG_XACT_OPMASK
Definition xact.h:180
#define XLOG_XACT_ABORT
Definition xact.h:172
#define XLOG_XACT_ASSIGNMENT
Definition xact.h:175
#define XLOG_XACT_ABORT_PREPARED
Definition xact.h:174
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, fb(), FilterPrepare(), ParseAbortRecord(), ParseCommitRecord(), ParsePrepareRecord(), XLogReaderState::record, LogicalDecodingContext::reorder, ReorderBufferAddInvalidations(), ReorderBufferImmediateInvalidation(), ReorderBufferProcessXid(), ReorderBufferXidSetCatalogChanges(), SNAPBUILD_FULL_SNAPSHOT, SnapBuildCurrentState(), LogicalDecodingContext::snapshot_builder, TransactionIdIsValid, two_phase, 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.

◆ xlog2_decode()

void xlog2_decode ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)
extern

Definition at line 194 of file decode.c.

195{
196 uint8 info = XLogRecGetInfo(buf->record) & ~XLR_INFO_MASK;
197
198 ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(buf->record), buf->origptr);
199
200 switch (info)
201 {
202 case XLOG2_CHECKSUMS:
203 break;
204 default:
205 elog(ERROR, "unexpected RM_XLOG2_ID record type: %u", info);
206 }
207}
#define XLOG2_CHECKSUMS
Definition pg_control.h:90

References buf, elog, ERROR, fb(), LogicalDecodingContext::reorder, ReorderBufferProcessXid(), XLOG2_CHECKSUMS, XLogRecGetInfo, and XLogRecGetXid.

◆ xlog_decode()

void xlog_decode ( LogicalDecodingContext ctx,
XLogRecordBuffer buf 
)
extern

Definition at line 130 of file decode.c.

131{
132 SnapBuild *builder = ctx->snapshot_builder;
133 uint8 info = XLogRecGetInfo(buf->record) & ~XLR_INFO_MASK;
134
136 buf->origptr);
137
138 switch (info)
139 {
140 /* this is also used in END_OF_RECOVERY checkpoints */
143 SnapBuildSerializationPoint(builder, buf->origptr);
144
145 break;
147
148 /*
149 * a RUNNING_XACTS record will have been logged near to this, we
150 * can restart from there.
151 */
152 break;
154 {
155 bool logical_decoding;
156
157 memcpy(&logical_decoding, XLogRecGetData(buf->record), sizeof(bool));
158
159 /*
160 * Error out as we should not decode this WAL record.
161 *
162 * Logical decoding is disabled, and existing logical slots on
163 * the standby are invalidated when this WAL record is
164 * replayed. No logical decoder can process this WAL record
165 * until replay completes, and by then the slots are already
166 * invalidated. Furthermore, no new logical slots can be
167 * created while logical decoding is disabled. This cannot
168 * occur even on primary either, since it will not restart
169 * with wal_level < replica if any logical slots exist.
170 */
171 elog(ERROR, "unexpected logical decoding status change %d",
173
174 break;
175 }
176 case XLOG_NOOP:
177 case XLOG_NEXTOID:
178 case XLOG_SWITCH:
179 case XLOG_BACKUP_END:
182 case XLOG_FPW_CHANGE:
184 case XLOG_FPI:
187 break;
188 default:
189 elog(ERROR, "unexpected RM_XLOG_ID record type: %u", info);
190 }
191}
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
#define XLOG_RESTORE_POINT
Definition pg_control.h:79
#define XLOG_FPW_CHANGE
Definition pg_control.h:80
#define XLOG_CHECKPOINT_REDO
Definition pg_control.h:86
#define XLOG_OVERWRITE_CONTRECORD
Definition pg_control.h:85
#define XLOG_FPI
Definition pg_control.h:83
#define XLOG_FPI_FOR_HINT
Definition pg_control.h:82
#define XLOG_NEXTOID
Definition pg_control.h:75
#define XLOG_NOOP
Definition pg_control.h:74
#define XLOG_CHECKPOINT_SHUTDOWN
Definition pg_control.h:72
#define XLOG_SWITCH
Definition pg_control.h:76
#define XLOG_BACKUP_END
Definition pg_control.h:77
#define XLOG_PARAMETER_CHANGE
Definition pg_control.h:78
#define XLOG_LOGICAL_DECODING_STATUS_CHANGE
Definition pg_control.h:87
#define XLOG_CHECKPOINT_ONLINE
Definition pg_control.h:73
#define XLOG_END_OF_RECOVERY
Definition pg_control.h:81
void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn)
Definition snapbuild.c:1488

References buf, elog, ERROR, fb(), memcpy(), LogicalDecodingContext::reorder, ReorderBufferProcessXid(), SnapBuildSerializationPoint(), LogicalDecodingContext::snapshot_builder, 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_LOGICAL_DECODING_STATUS_CHANGE, XLOG_NEXTOID, XLOG_NOOP, XLOG_OVERWRITE_CONTRECORD, XLOG_PARAMETER_CHANGE, XLOG_RESTORE_POINT, XLOG_SWITCH, XLogRecGetData, XLogRecGetInfo, and XLogRecGetXid.