Skip to content

Commit 428dd18

Browse files
committed
Revert back private members of irt_repeat
1 parent 2a00a58 commit 428dd18

File tree

4 files changed

+37
-35
lines changed

4 files changed

+37
-35
lines changed

src/jrd/btr.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,9 @@ bool BTR_delete_index(thread_db* tdbb, WIN* window, USHORT id)
924924
{
925925
index_root_page::irt_repeat* irt_desc = root->irt_rpt + id;
926926
CCH_MARK(tdbb, window);
927-
const PageNumber next(window->win_page.getPageSpaceID(), irt_desc->irt_root);
928-
tree_exists = !irt_desc->isEmpty();
927+
const ULONG rootPage = irt_desc->getRoot();
928+
const PageNumber next(window->win_page.getPageSpaceID(), rootPage);
929+
tree_exists = (rootPage != 0);
929930

930931
// remove the pointer to the top-level index page before we delete it
931932
irt_desc->setEmpty();
@@ -961,11 +962,12 @@ bool BTR_description(thread_db* tdbb, jrd_rel* relation, index_root_page* root,
961962

962963
const index_root_page::irt_repeat* irt_desc = &root->irt_rpt[id];
963964

964-
if (irt_desc->isEmpty())
965+
const ULONG rootPage = irt_desc->getRoot();
966+
if (!rootPage)
965967
return false;
966968

967969
idx->idx_id = id;
968-
idx->idx_root = irt_desc->irt_root;
970+
idx->idx_root = rootPage;
969971
idx->idx_count = irt_desc->irt_keys;
970972
idx->idx_flags = irt_desc->irt_flags;
971973
idx->idx_runtime_flags = 0;
@@ -1450,7 +1452,7 @@ void BTR_insert(thread_db* tdbb, WIN* root_window, index_insertion* insertion)
14501452
// update the index root page. Oh boy.
14511453
index_root_page* root = (index_root_page*) CCH_FETCH(tdbb, root_window, LCK_write, pag_root);
14521454

1453-
window.win_page = root->irt_rpt[idx->idx_id].irt_root;
1455+
window.win_page = root->irt_rpt[idx->idx_id].getRoot();
14541456
bucket = (btree_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_index);
14551457

14561458
if (window.win_page.getPageNum() != idx->idx_root)
@@ -1500,7 +1502,7 @@ void BTR_insert(thread_db* tdbb, WIN* root_window, index_insertion* insertion)
15001502
BUGCHECK(204); // msg 204 index inconsistent
15011503
}
15021504

1503-
window.win_page = root->irt_rpt[idx->idx_id].irt_root;
1505+
window.win_page = root->irt_rpt[idx->idx_id].getRoot();
15041506
bucket = (btree_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_index);
15051507
key.key_length = ret_key.key_length;
15061508
memcpy(key.key_data, ret_key.key_data, ret_key.key_length);
@@ -2392,15 +2394,13 @@ void BTR_selectivity(thread_db* tdbb, jrd_rel* relation, USHORT id, SelectivityL
23922394
if (!root)
23932395
return;
23942396

2395-
if (id >= root->irt_count || root->irt_rpt[id].isEmpty())
2397+
if (id >= root->irt_count || !root->irt_rpt[id].getRoot())
23962398
{
23972399
CCH_RELEASE(tdbb, &window);
23982400
return;
23992401
}
24002402

2401-
ULONG page = root->irt_rpt[id].irt_root;
2402-
fb_assert(page);
2403-
2403+
ULONG page = root->irt_rpt[id].getRoot();
24042404
const bool descending = (root->irt_rpt[id].irt_flags & irt_descending);
24052405
const ULONG segments = root->irt_rpt[id].irt_keys;
24062406

@@ -3335,7 +3335,7 @@ static USHORT compress_root(thread_db* tdbb, index_root_page* page)
33353335
for (const index_root_page::irt_repeat* const end = root_idx + page->irt_count;
33363336
root_idx < end; root_idx++)
33373337
{
3338-
if (!root_idx->isEmpty())
3338+
if (root_idx->getRoot())
33393339
{
33403340
const USHORT len = root_idx->irt_keys * sizeof(irtd);
33413341
p -= len;

src/jrd/ods.h

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -368,24 +368,26 @@ struct index_root_page
368368
USHORT irt_count; // Number of indices
369369
struct irt_repeat
370370
{
371+
friend class index_root_page; // to allow offset check for private members
372+
private:
371373
union
372374
{
373375
FB_UINT64 irt_transaction; // transaction in progress
374376
ULONG irt_root; // page number of index root
375377
};
378+
public:
376379
USHORT irt_desc; // offset to key descriptions
377380
USHORT irt_flags; // index flags
378381
UCHAR irt_keys; // number of keys in index
379382

380383
TraNumber inProgress() const;
381-
bool isEmpty() const;
382-
bool isUsed() const;
383-
384-
void setEmpty();
385384
void setInProgress(TraNumber traNumber);
386-
void clearInProgress(ULONG rootPage);
385+
386+
ULONG getRoot() const;
387387
void setRoot(ULONG rootPage);
388388

389+
bool isUsed() const;
390+
void setEmpty();
389391
} irt_rpt[1];
390392

391393
static_assert(sizeof(struct irt_repeat) == 16, "struct irt_repeat size mismatch");
@@ -425,16 +427,6 @@ inline constexpr USHORT irt_primary = 16;
425427
inline constexpr USHORT irt_expression = 32;
426428
inline constexpr USHORT irt_condition = 64;
427429

428-
inline TraNumber index_root_page::irt_repeat::inProgress() const
429-
{
430-
return (irt_flags & irt_in_progress) ? irt_transaction : 0;
431-
}
432-
433-
inline bool index_root_page::irt_repeat::isEmpty() const
434-
{
435-
return (irt_flags & irt_in_progress) || (irt_root == 0);
436-
}
437-
438430
inline bool index_root_page::irt_repeat::isUsed() const
439431
{
440432
return (irt_flags & irt_in_progress) || (irt_root != 0);
@@ -443,15 +435,26 @@ inline bool index_root_page::irt_repeat::isUsed() const
443435
inline void index_root_page::irt_repeat::setEmpty()
444436
{
445437
irt_transaction = 0;
438+
fb_assert(irt_root == 0);
446439
irt_flags = 0;
447440
}
448441

442+
inline TraNumber index_root_page::irt_repeat::inProgress() const
443+
{
444+
return (irt_flags & irt_in_progress) ? irt_transaction : 0;
445+
}
446+
449447
inline void index_root_page::irt_repeat::setInProgress(TraNumber traNumber)
450448
{
451449
irt_transaction = traNumber;
452450
irt_flags |= irt_in_progress;
453451
}
454452

453+
inline ULONG index_root_page::irt_repeat::getRoot() const
454+
{
455+
return (irt_flags & irt_in_progress) ? 0 : irt_root;
456+
}
457+
455458
inline void index_root_page::irt_repeat::setRoot(ULONG rootPage)
456459
{
457460
irt_root = rootPage;

src/jrd/validation.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,12 +1976,10 @@ Validation::RTN Validation::walk_index(jrd_rel* relation, index_root_page* root_
19761976
**************************************/
19771977
Database* dbb = vdr_tdbb->getDatabase();
19781978

1979-
if (root_page->irt_rpt[id].isEmpty())
1979+
const ULONG page_number = root_page->irt_rpt[id].getRoot();
1980+
if (!page_number)
19801981
return rtn_ok;
19811982

1982-
const ULONG page_number = root_page->irt_rpt[id].irt_root;
1983-
fb_assert(page_number);
1984-
19851983
const bool unique = (root_page->irt_rpt[id].irt_flags & (irt_unique | idx_primary));
19861984
const bool descending = (root_page->irt_rpt[id].irt_flags & irt_descending);
19871985
const bool condition = (root_page->irt_rpt[id].irt_flags & irt_condition);
@@ -3211,13 +3209,13 @@ Validation::RTN Validation::walk_root(jrd_rel* relation, bool getInfo)
32113209
if (!relPages->rel_index_root)
32123210
return corrupt(VAL_INDEX_ROOT_MISSING, relation);
32133211

3214-
index_root_page* page = 0;
3212+
index_root_page* page = nullptr;
32153213
WIN window(DB_PAGE_SPACE, -1);
32163214
fetch_page(!getInfo, relPages->rel_index_root, pag_root, &window, &page);
32173215

32183216
for (USHORT i = 0; i < page->irt_count; i++)
32193217
{
3220-
if (page->irt_rpt[i].isEmpty())
3218+
if (!page->irt_rpt[i].getRoot())
32213219
continue;
32223220

32233221
MetaName index;

src/utilities/gstat/dba.epp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,11 +1566,12 @@ static void analyze_index( const dba_rel* relation, dba_idx* index)
15661566

15671567
const index_root_page* index_root = (const index_root_page*) db_read(relation->rel_index_root);
15681568

1569-
if (index_root->irt_count <= index->idx_id || index_root->irt_rpt[index->idx_id].isEmpty())
1569+
if (index_root->irt_count <= index->idx_id)
15701570
return;
15711571

1572-
ULONG page = index_root->irt_rpt[index->idx_id].irt_root;
1573-
fb_assert(page);
1572+
ULONG page = index_root->irt_rpt[index->idx_id].getRoot();
1573+
if (!page)
1574+
return;
15741575

15751576
// CVC: The two const_cast's for bucket can go away if BTreeNode's functions
15761577
// are overloaded for constness. They don't modify bucket and pointer's contents.

0 commit comments

Comments
 (0)