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

Function TRA_get_inventory

src/jrd/tra.cpp:650–709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

648
649
650void TRA_get_inventory(thread_db* tdbb, UCHAR* bit_vector, TraNumber base, TraNumber top)
651{
652/**************************************
653 *
654 * T R A _ g e t _ i n v e n t o r y
655 *
656 **************************************
657 *
658 * Functional description
659 * Get an inventory of the state of all transactions
660 * between the base and top (included) transactions passed.
661 * To get a consistent view of the transaction
662 * inventory (in case we ever implement sub-transactions),
663 * do handoffs to read the pages in order.
664 *
665 **************************************/
666 SET_TDBB(tdbb);
667 Database* dbb = tdbb->getDatabase();
668 CHECK_DBB(dbb);
669
670 // It does not make sence to call this function without bit_vector now
671 fb_assert(bit_vector);
672
673 const ULONG trans_per_tip = dbb->dbb_page_manager.transPerTIP;
674 ULONG sequence = base / trans_per_tip;
675 const ULONG last = top / trans_per_tip;
676
677 // fetch the first inventory page
678
679 WIN window(DB_PAGE_SPACE, -1);
680 const tx_inv_page* tip = fetch_inventory_page(tdbb, &window, sequence++, LCK_read);
681
682 // move the first page into the bit vector
683
684 UCHAR* p = bit_vector;
685 ULONG l = base % trans_per_tip;
686 const UCHAR* q = tip->tip_transactions + TRANS_OFFSET(l);
687 l = TRANS_OFFSET(MIN((top + TRA_MASK + 1 - base), trans_per_tip - l));
688 memcpy(p, q, l);
689 p += l;
690
691 // move successive pages into the bit vector
692
693 while (sequence <= last)
694 {
695 base = (TraNumber) sequence * trans_per_tip;
696
697 // release the read lock as we go, so that some one else can
698 // commit without having to signal all other transactions.
699
700 tip = (tx_inv_page*) CCH_HANDOFF(tdbb, &window, inventory_page(tdbb, sequence++),
701 LCK_read, pag_transactions);
702
703 l = TRANS_OFFSET(MIN((top + TRA_MASK + 1 - base), trans_per_tip));
704 memcpy(p, tip->tip_transactions, l);
705 p += l;
706 }
707

Callers 1

loadInventoryPagesMethod · 0.85

Calls 7

SET_TDBBFunction · 0.85
CHECK_DBBFunction · 0.85
fetch_inventory_pageFunction · 0.85
CCH_HANDOFFFunction · 0.85
inventory_pageFunction · 0.85
CCH_RELEASEFunction · 0.85
getDatabaseMethod · 0.80

Tested by

no test coverage detected