MCPcopy Create free account
hub / github.com/apache/cloudberry / XLogInsert_Internal

Function XLogInsert_Internal

src/backend/access/transam/xloginsert.c:438–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

436}
437
438static XLogRecPtr
439XLogInsert_Internal(RmgrId rmid, uint8 info, TransactionId headerXid)
440{
441 XLogRecPtr EndPos;
442
443 /* XLogBeginInsert() must have been called. */
444 if (!begininsert_called)
445 elog(ERROR, "XLogBeginInsert was not called");
446
447 /*
448 * The caller can set rmgr bits, XLR_SPECIAL_REL_UPDATE and
449 * XLR_CHECK_CONSISTENCY; the rest are reserved for use by me.
450 */
451 if ((info & ~(XLR_RMGR_INFO_MASK |
452 XLR_SPECIAL_REL_UPDATE |
453 XLR_CHECK_CONSISTENCY)) != 0)
454 elog(PANIC, "invalid xlog info mask %02X", info);
455
456 TRACE_POSTGRESQL_WAL_INSERT(rmid, info);
457
458 /*
459 * In bootstrap mode, we don't actually log anything but XLOG resources;
460 * return a phony record pointer.
461 */
462 if (IsBootstrapProcessingMode() && rmid != RM_XLOG_ID)
463 {
464 XLogResetInsertion();
465 EndPos = SizeOfXLogLongPHD; /* start of 1st chkpt record */
466 return EndPos;
467 }
468
469 if (XLogInsert_hook)
470 return (*XLogInsert_hook) (rmid, info, headerXid, curinsert_flags, (void *)XLogRecordAssemble);
471
472 do
473 {
474 XLogRecPtr RedoRecPtr;
475 bool doPageWrites;
476 XLogRecPtr fpw_lsn;
477 XLogRecData *rdt;
478 int num_fpi = 0;
479
480 /*
481 * Get values needed to decide whether to do full-page writes. Since
482 * we don't yet have an insertion lock, these could change under us,
483 * but XLogInsertRecord will recheck them once it has a lock.
484 */
485 GetFullPageWriteInfo(&RedoRecPtr, &doPageWrites);
486
487 rdt = XLogRecordAssemble(rmid, info, RedoRecPtr, doPageWrites,
488 &fpw_lsn, headerXid, &num_fpi);
489
490 EndPos = XLogInsertRecord(rdt, fpw_lsn, curinsert_flags, num_fpi);
491 } while (EndPos == InvalidXLogRecPtr);
492
493 XLogResetInsertion();
494
495 return EndPos;

Callers 1

XLogInsertFunction · 0.85

Calls 4

XLogResetInsertionFunction · 0.85
GetFullPageWriteInfoFunction · 0.85
XLogRecordAssembleFunction · 0.85
XLogInsertRecordFunction · 0.85

Tested by

no test coverage detected