MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / transaction_start

Function transaction_start

src/jrd/tra.cpp:3509–3809  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3507
3508
3509static void transaction_start(thread_db* tdbb, jrd_tra* trans)
3510{
3511/**************************************
3512 *
3513 * t r a n s a c t i o n _ s t a r t
3514 *
3515 **************************************
3516 *
3517 * Functional description
3518 * Start a transaction.
3519 *
3520 **************************************/
3521 SET_TDBB(tdbb);
3522 Database* const dbb = tdbb->getDatabase();
3523 Jrd::Attachment* const attachment = tdbb->getAttachment();
3524 WIN window(DB_PAGE_SPACE, -1);
3525
3526 Lock* lock = FB_NEW_RPT(*tdbb->getDefaultPool(), 0) Lock(tdbb, sizeof(TraNumber), LCK_tra);
3527
3528 // Read header page and allocate transaction number. Since
3529 // the transaction inventory page was initialized to zero, it
3530 // transaction is automatically marked active.
3531
3532 TraNumber oldest, number, active, oldest_active;
3533
3534#ifdef SUPERSERVER_V2
3535 number = bump_transaction_id(tdbb, &window);
3536 oldest = dbb->dbb_oldest_transaction;
3537 active = MAX(dbb->dbb_oldest_active, dbb->dbb_oldest_transaction);
3538 oldest_active = dbb->dbb_oldest_active;
3539
3540#else // SUPERSERVER_V2
3541 if (dbb->readOnly())
3542 {
3543 number = dbb->generateTransactionId();
3544 oldest = dbb->dbb_oldest_transaction;
3545 oldest_active = dbb->dbb_oldest_active;
3546 }
3547 else
3548 {
3549 const bool dontWrite = (dbb->dbb_flags & DBB_shared) &&
3550 (trans->tra_flags & TRA_readonly);
3551
3552 const header_page* header = bump_transaction_id(tdbb, &window, dontWrite);
3553 number = Ods::getNT(header);
3554 oldest = Ods::getOIT(header);
3555 oldest_active = Ods::getOAT(header);
3556 }
3557
3558 // oldest (OIT) > oldest_active (OAT) if OIT was advanced by sweep
3559 // and no transactions was started after the sweep starts
3560 active = MAX(oldest_active, oldest);
3561
3562#endif // SUPERSERVER_V2
3563
3564 // Allocate pool and transactions block. Since, by policy,
3565 // all transactions older than the oldest are either committed
3566 // or cleaned up, they can be all considered as committed. To

Callers 1

TRA_startFunction · 0.85

Calls 15

SET_TDBBFunction · 0.85
bump_transaction_idFunction · 0.85
getNTFunction · 0.85
getOITFunction · 0.85
getOATFunction · 0.85
LCK_lockFunction · 0.85
CCH_RELEASEFunction · 0.85
GdsClass · 0.85
TPC_find_statesFunction · 0.85
LCK_read_dataFunction · 0.85
TRA_waitFunction · 0.85
LCK_write_dataFunction · 0.85

Tested by

no test coverage detected