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

Function BTR_next_index

src/jrd/btr.cpp:2104–2173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2102
2103
2104bool BTR_next_index(thread_db* tdbb, jrd_rel* relation, jrd_tra* transaction, index_desc* idx, WIN* window)
2105{
2106/**************************************
2107 *
2108 * B T R _ n e x t _ i n d e x
2109 *
2110 **************************************
2111 *
2112 * Functional description
2113 * Get next index for relation. Index ids
2114 * recently changed from UCHAR to SHORT
2115 *
2116 **************************************/
2117 SET_TDBB(tdbb);
2118
2119 USHORT id;
2120 if (idx->idx_id == idx_invalid)
2121 {
2122 id = 0;
2123 window->win_bdb = NULL;
2124 }
2125 else
2126 id = idx->idx_id + 1;
2127
2128 index_root_page* root;
2129 if (window->win_bdb)
2130 root = (index_root_page*) window->win_buffer;
2131 else
2132 {
2133 RelationPages* const relPages = transaction ?
2134 relation->getPages(tdbb, transaction->tra_number) : relation->getPages(tdbb);
2135
2136 if (!(root = fetch_root(tdbb, window, relation, relPages)))
2137 return false;
2138 }
2139
2140 for (; id < root->irt_count; ++id)
2141 {
2142 const index_root_page::irt_repeat* irt_desc = root->irt_rpt + id;
2143 if (irt_desc->getTransaction() && transaction)
2144 {
2145 const TraNumber trans = irt_desc->getTransaction();
2146 CCH_RELEASE(tdbb, window);
2147 const int trans_state = TRA_wait(tdbb, transaction, trans, jrd_tra::tra_wait);
2148 if ((trans_state == tra_dead) || (trans_state == tra_committed))
2149 {
2150 // clean up this left-over index
2151 root = (index_root_page*) CCH_FETCH(tdbb, window, LCK_write, pag_root);
2152 irt_desc = root->irt_rpt + id;
2153
2154 if (irt_desc->getTransaction() == trans)
2155 BTR_delete_index(tdbb, window, id);
2156 else
2157 CCH_RELEASE(tdbb, window);
2158
2159 root = (index_root_page*) CCH_FETCH(tdbb, window, LCK_read, pag_root);
2160 continue;
2161 }

Callers 6

IDX_check_accessFunction · 0.85
IDX_eraseFunction · 0.85
IDX_modifyFunction · 0.85
IDX_storeFunction · 0.85

Calls 9

SET_TDBBFunction · 0.85
fetch_rootFunction · 0.85
CCH_RELEASEFunction · 0.85
TRA_waitFunction · 0.85
CCH_FETCHFunction · 0.85
BTR_delete_indexFunction · 0.85
BTR_descriptionFunction · 0.85
getPagesMethod · 0.45
getTransactionMethod · 0.45

Tested by

no test coverage detected