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

Function TRA_snapshot_state

src/jrd/tra.cpp:1578–1694  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1576
1577
1578int TRA_snapshot_state(thread_db* tdbb, const jrd_tra* trans, TraNumber number, CommitNumber* snapshot)
1579{
1580/**************************************
1581 *
1582 * T R A _ s n a p s h o t _ s t a t e
1583 *
1584 **************************************
1585 *
1586 * Functional description
1587 * Get the state of a numbered transaction when a
1588 * transaction started.
1589 *
1590 **************************************/
1591
1592 SET_TDBB(tdbb);
1593 Database* dbb = tdbb->getDatabase();
1594 CHECK_DBB(dbb);
1595
1596 Attachment* att = tdbb->getAttachment();
1597
1598 // Inhibit intermediate GC by default
1599
1600 if (snapshot)
1601 *snapshot = CN_ACTIVE;
1602
1603 if (number == trans->tra_number)
1604 return tra_us;
1605
1606 // If the transaction is older than the oldest
1607 // interesting transaction, it must be committed.
1608
1609 if (number < trans->tra_oldest)
1610 {
1611 if (snapshot)
1612 *snapshot = att->att_active_snapshots.getSnapshotForVersion(CN_PREHISTORIC);
1613 return tra_committed;
1614 }
1615
1616 // If the transaction is the system transaction, it is considered committed.
1617
1618 if (number == TRA_system_transaction)
1619 {
1620 if (snapshot)
1621 *snapshot = att->att_active_snapshots.getSnapshotForVersion(CN_PREHISTORIC);
1622 return tra_committed;
1623 }
1624
1625 // Determine transaction state and commit number if any
1626
1627 int state;
1628 CommitNumber stateCn = CN_PREHISTORIC;
1629
1630 if (TipCache* tip_cache = dbb->dbb_tip_cache)
1631 {
1632 stateCn = tip_cache->snapshotState(tdbb, number);
1633 switch (stateCn)
1634 {
1635 case CN_ACTIVE:

Callers 6

VIO_chase_record_versionFunction · 0.85
VIO_garbage_collectFunction · 0.85
VIO_get_currentFunction · 0.85
prepare_updateFunction · 0.85
INF_database_infoFunction · 0.85
check_duplicatesFunction · 0.85

Calls 9

SET_TDBBFunction · 0.85
CHECK_DBBFunction · 0.85
TRA_fetch_stateFunction · 0.85
getDatabaseMethod · 0.80
getSnapshotForVersionMethod · 0.80
snapshotStateMethod · 0.80
getAttachmentMethod · 0.45
testMethod · 0.45
getRequestMethod · 0.45

Tested by

no test coverage detected