| 1576 | |
| 1577 | |
| 1578 | int 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: |
no test coverage detected