Skip to content

Commit 29d67d0

Browse files
committed
Cleanup btr_page_get_prev(), btr_page_get_next()
Remove the redundant parameter mtr_t*. Make use of page_has_prev(), page_has_next() whenever possible.
1 parent 1d2458f commit 29d67d0

File tree

13 files changed

+89
-145
lines changed

13 files changed

+89
-145
lines changed

storage/innobase/btr/btr0btr.cc

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,8 +2480,8 @@ btr_attach_half_pages(
24802480
}
24812481

24822482
/* Get the previous and next pages of page */
2483-
prev_page_no = btr_page_get_prev(page, mtr);
2484-
next_page_no = btr_page_get_next(page, mtr);
2483+
prev_page_no = btr_page_get_prev(page);
2484+
next_page_no = btr_page_get_next(page);
24852485

24862486
const ulint space = block->page.id.space();
24872487

@@ -2522,7 +2522,7 @@ btr_attach_half_pages(
25222522
if (prev_block) {
25232523
#ifdef UNIV_BTR_DEBUG
25242524
ut_a(page_is_comp(prev_block->frame) == page_is_comp(page));
2525-
ut_a(btr_page_get_next(prev_block->frame, mtr)
2525+
ut_a(btr_page_get_next(prev_block->frame)
25262526
== block->page.id.page_no());
25272527
#endif /* UNIV_BTR_DEBUG */
25282528

@@ -2534,7 +2534,7 @@ btr_attach_half_pages(
25342534
if (next_block) {
25352535
#ifdef UNIV_BTR_DEBUG
25362536
ut_a(page_is_comp(next_block->frame) == page_is_comp(page));
2537-
ut_a(btr_page_get_prev(next_block->frame, mtr)
2537+
ut_a(btr_page_get_prev(next_block->frame)
25382538
== page_get_page_no(page));
25392539
#endif /* UNIV_BTR_DEBUG */
25402540

@@ -2548,7 +2548,7 @@ btr_attach_half_pages(
25482548
btr_page_set_prev(lower_page, lower_page_zip,
25492549
prev_page_no, mtr);
25502550
} else {
2551-
ut_ad(btr_page_get_prev(lower_page, mtr) == prev_page_no);
2551+
ut_ad(btr_page_get_prev(lower_page) == prev_page_no);
25522552
}
25532553

25542554
btr_page_set_next(lower_page, lower_page_zip, upper_page_no, mtr);
@@ -2559,7 +2559,7 @@ btr_attach_half_pages(
25592559
btr_page_set_next(upper_page, upper_page_zip,
25602560
next_page_no, mtr);
25612561
} else {
2562-
ut_ad(btr_page_get_next(upper_page, mtr) == next_page_no);
2562+
ut_ad(btr_page_get_next(upper_page) == next_page_no);
25632563
}
25642564
}
25652565

@@ -2620,7 +2620,7 @@ btr_insert_into_right_sibling(
26202620
{
26212621
buf_block_t* block = btr_cur_get_block(cursor);
26222622
page_t* page = buf_block_get_frame(block);
2623-
ulint next_page_no = btr_page_get_next(page, mtr);
2623+
const uint32_t next_page_no = btr_page_get_next(page);
26242624

26252625
ut_ad(mtr_memo_contains_flagged(
26262626
mtr, dict_index_get_lock(cursor->index),
@@ -3161,8 +3161,8 @@ btr_level_list_remove_func(
31613161
ut_ad(space == page_get_space_id(page));
31623162
/* Get the previous and next page numbers of page */
31633163

3164-
const ulint prev_page_no = btr_page_get_prev(page, mtr);
3165-
const ulint next_page_no = btr_page_get_next(page, mtr);
3164+
const uint32_t prev_page_no = btr_page_get_prev(page);
3165+
const uint32_t next_page_no = btr_page_get_next(page);
31663166

31673167
/* Update page links of the level */
31683168

@@ -3175,8 +3175,8 @@ btr_level_list_remove_func(
31753175
= buf_block_get_frame(prev_block);
31763176
#ifdef UNIV_BTR_DEBUG
31773177
ut_a(page_is_comp(prev_page) == page_is_comp(page));
3178-
ut_a(btr_page_get_next(prev_page, mtr)
3179-
== page_get_page_no(page));
3178+
ut_a(!memcmp(prev_page + FIL_PAGE_NEXT, page + FIL_PAGE_OFFSET,
3179+
4));
31803180
#endif /* UNIV_BTR_DEBUG */
31813181

31823182
btr_page_set_next(prev_page,
@@ -3194,8 +3194,8 @@ btr_level_list_remove_func(
31943194
= buf_block_get_frame(next_block);
31953195
#ifdef UNIV_BTR_DEBUG
31963196
ut_a(page_is_comp(next_page) == page_is_comp(page));
3197-
ut_a(btr_page_get_prev(next_page, mtr)
3198-
== page_get_page_no(page));
3197+
ut_a(!memcmp(next_page + FIL_PAGE_PREV, page + FIL_PAGE_OFFSET,
3198+
4));
31993199
#endif /* UNIV_BTR_DEBUG */
32003200

32013201
btr_page_set_prev(next_page,
@@ -3527,8 +3527,8 @@ btr_compress(
35273527

35283528
MONITOR_INC(MONITOR_INDEX_MERGE_ATTEMPTS);
35293529

3530-
left_page_no = btr_page_get_prev(page, mtr);
3531-
right_page_no = btr_page_get_next(page, mtr);
3530+
left_page_no = btr_page_get_prev(page);
3531+
right_page_no = btr_page_get_next(page);
35323532

35333533
#ifdef UNIV_DEBUG
35343534
if (!page_is_leaf(page) && left_page_no == FIL_NULL) {
@@ -3602,10 +3602,10 @@ btr_compress(
36023602

36033603
#ifdef UNIV_BTR_DEBUG
36043604
if (is_left) {
3605-
ut_a(btr_page_get_next(merge_page, mtr)
3605+
ut_a(btr_page_get_next(merge_page)
36063606
== block->page.id.page_no());
36073607
} else {
3608-
ut_a(btr_page_get_prev(merge_page, mtr)
3608+
ut_a(btr_page_get_prev(merge_page)
36093609
== block->page.id.page_no());
36103610
}
36113611
#endif /* UNIV_BTR_DEBUG */
@@ -4126,8 +4126,8 @@ btr_discard_page(
41264126

41274127
/* Decide the page which will inherit the locks */
41284128

4129-
left_page_no = btr_page_get_prev(buf_block_get_frame(block), mtr);
4130-
right_page_no = btr_page_get_next(buf_block_get_frame(block), mtr);
4129+
left_page_no = btr_page_get_prev(buf_block_get_frame(block));
4130+
right_page_no = btr_page_get_next(buf_block_get_frame(block));
41314131

41324132
const page_size_t page_size(dict_table_page_size(index->table));
41334133
ut_d(bool parent_is_different = false);
@@ -4138,7 +4138,7 @@ btr_discard_page(
41384138

41394139
merge_page = buf_block_get_frame(merge_block);
41404140
#ifdef UNIV_BTR_DEBUG
4141-
ut_a(btr_page_get_next(merge_page, mtr)
4141+
ut_a(btr_page_get_next(merge_page)
41424142
== block->page.id.page_no());
41434143
#endif /* UNIV_BTR_DEBUG */
41444144
ut_d(parent_is_different =
@@ -4154,7 +4154,7 @@ btr_discard_page(
41544154

41554155
merge_page = buf_block_get_frame(merge_block);
41564156
#ifdef UNIV_BTR_DEBUG
4157-
ut_a(btr_page_get_prev(merge_page, mtr)
4157+
ut_a(btr_page_get_prev(merge_page)
41584158
== block->page.id.page_no());
41594159
#endif /* UNIV_BTR_DEBUG */
41604160
ut_d(parent_is_different = page_rec_is_supremum(
@@ -4776,7 +4776,7 @@ btr_validate_level(
47764776
does not use such scan for any of its DML or query
47774777
operations */
47784778
if (dict_index_is_spatial(index)) {
4779-
left_page_no = btr_page_get_prev(page, &mtr);
4779+
left_page_no = btr_page_get_prev(page);
47804780

47814781
while (left_page_no != FIL_NULL) {
47824782
page_id_t left_page_id(
@@ -4793,7 +4793,7 @@ btr_validate_level(
47934793
table_page_size,
47944794
RW_SX_LATCH, index, &mtr);
47954795
page = buf_block_get_frame(block);
4796-
left_page_no = btr_page_get_prev(page, &mtr);
4796+
left_page_no = btr_page_get_prev(page);
47974797
}
47984798
}
47994799
}
@@ -4848,8 +4848,8 @@ btr_validate_level(
48484848

48494849
ut_a(btr_page_get_level(page, &mtr) == level);
48504850

4851-
right_page_no = btr_page_get_next(page, &mtr);
4852-
left_page_no = btr_page_get_prev(page, &mtr);
4851+
right_page_no = btr_page_get_next(page);
4852+
left_page_no = btr_page_get_prev(page);
48534853

48544854
ut_a(!page_is_empty(page)
48554855
|| (level == 0
@@ -4866,9 +4866,7 @@ btr_validate_level(
48664866

48674867
right_page = buf_block_get_frame(right_block);
48684868

4869-
if (btr_page_get_prev(right_page, &mtr)
4870-
!= page_get_page_no(page)) {
4871-
4869+
if (btr_page_get_prev(right_page) != page_get_page_no(page)) {
48724870
btr_validate_report2(index, level, block, right_block);
48734871
fputs("InnoDB: broken FIL_PAGE_NEXT"
48744872
" or FIL_PAGE_PREV links\n", stderr);
@@ -4949,7 +4947,7 @@ btr_validate_level(
49494947
node_ptr = btr_cur_get_rec(&node_cur);
49504948

49514949
parent_page_no = page_get_page_no(father_page);
4952-
parent_right_page_no = btr_page_get_next(father_page, &mtr);
4950+
parent_right_page_no = btr_page_get_next(father_page);
49534951
rightmost_child = page_rec_is_supremum(
49544952
page_rec_get_next(node_ptr));
49554953

@@ -5090,7 +5088,7 @@ btr_validate_level(
50905088
}
50915089

50925090
if (page_get_page_no(right_father_page)
5093-
!= btr_page_get_next(father_page, &mtr)) {
5091+
!= btr_page_get_next(father_page)) {
50945092

50955093
ret = false;
50965094
fputs("InnoDB: node pointer 3 to"

storage/innobase/btr/btr0cur.cc

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ btr_cur_latch_leaves(
279279
dict_index_get_lock(cursor->index),
280280
MTR_MEMO_X_LOCK | MTR_MEMO_SX_LOCK));
281281
/* x-latch also siblings from left to right */
282-
left_page_no = btr_page_get_prev(page, mtr);
282+
left_page_no = btr_page_get_prev(page);
283283
mode = latch_mode;
284284

285285
if (left_page_no != FIL_NULL) {
@@ -315,10 +315,9 @@ btr_cur_latch_leaves(
315315
/* Sanity check only after both the blocks are latched. */
316316
if (latch_leaves.blocks[0] != NULL) {
317317
ut_a(page_is_comp(latch_leaves.blocks[0]->frame)
318-
== page_is_comp(page));
319-
ut_a(btr_page_get_next(
320-
latch_leaves.blocks[0]->frame, mtr)
321-
== page_get_page_no(page));
318+
== page_is_comp(page));
319+
ut_a(btr_page_get_next(latch_leaves.blocks[0]->frame)
320+
== page_get_page_no(page));
322321
}
323322
ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
324323
#endif /* UNIV_BTR_DEBUG */
@@ -328,7 +327,7 @@ btr_cur_latch_leaves(
328327
= get_block;
329328
}
330329

331-
right_page_no = btr_page_get_next(page, mtr);
330+
right_page_no = btr_page_get_next(page);
332331

333332
if (right_page_no != FIL_NULL) {
334333
if (spatial) {
@@ -344,7 +343,7 @@ btr_cur_latch_leaves(
344343
#ifdef UNIV_BTR_DEBUG
345344
ut_a(page_is_comp(get_block->frame)
346345
== page_is_comp(page));
347-
ut_a(btr_page_get_prev(get_block->frame, mtr)
346+
ut_a(btr_page_get_prev(get_block->frame)
348347
== page_get_page_no(page));
349348
#endif /* UNIV_BTR_DEBUG */
350349
if (spatial) {
@@ -360,7 +359,7 @@ btr_cur_latch_leaves(
360359
mode = latch_mode == BTR_SEARCH_PREV ? RW_S_LATCH : RW_X_LATCH;
361360
/* latch also left sibling */
362361
rw_lock_s_lock(&block->lock);
363-
left_page_no = btr_page_get_prev(page, mtr);
362+
left_page_no = btr_page_get_prev(page);
364363
rw_lock_s_unlock(&block->lock);
365364

366365
if (left_page_no != FIL_NULL) {
@@ -373,7 +372,7 @@ btr_cur_latch_leaves(
373372
#ifdef UNIV_BTR_DEBUG
374373
ut_a(page_is_comp(get_block->frame)
375374
== page_is_comp(page));
376-
ut_a(btr_page_get_next(get_block->frame, mtr)
375+
ut_a(btr_page_get_next(get_block->frame)
377376
== page_get_page_no(page));
378377
#endif /* UNIV_BTR_DEBUG */
379378
}
@@ -443,7 +442,7 @@ btr_cur_optimistic_latch_leaves(
443442
goto unpin_failed;
444443
}
445444
left_page_no = btr_page_get_prev(
446-
buf_block_get_frame(block), mtr);
445+
buf_block_get_frame(block));
447446
rw_lock_s_unlock(&block->lock);
448447

449448
if (left_page_no != FIL_NULL) {
@@ -461,7 +460,7 @@ btr_cur_optimistic_latch_leaves(
461460

462461
if (buf_page_optimistic_get(mode, block, modify_clock,
463462
file, line, mtr)) {
464-
if (btr_page_get_prev(buf_block_get_frame(block), mtr)
463+
if (btr_page_get_prev(buf_block_get_frame(block))
465464
== left_page_no) {
466465
buf_block_buf_fix_dec(block);
467466
*latch_mode = mode;
@@ -1341,8 +1340,7 @@ btr_cur_search_to_nth_level(
13411340
rw_latch = upper_rw_latch;
13421341

13431342
rw_lock_s_lock(&block->lock);
1344-
left_page_no = btr_page_get_prev(
1345-
buf_block_get_frame(block), mtr);
1343+
left_page_no = btr_page_get_prev(buf_block_get_frame(block));
13461344
rw_lock_s_unlock(&block->lock);
13471345

13481346
if (left_page_no != FIL_NULL) {
@@ -3419,10 +3417,7 @@ btr_cur_pessimistic_insert(
34193417
}
34203418

34213419
if (!page_rec_is_infimum(btr_cur_get_rec(cursor))
3422-
|| btr_page_get_prev(
3423-
buf_block_get_frame(
3424-
btr_cur_get_block(cursor)), mtr)
3425-
== FIL_NULL) {
3420+
|| !page_has_prev(btr_cur_get_page(cursor))) {
34263421
/* split and inserted need to call
34273422
lock_update_insert() always. */
34283423
inherit = TRUE;
@@ -4212,15 +4207,14 @@ btr_cur_pess_upd_restore_supremum(
42124207
return;
42134208
}
42144209

4215-
const ulint prev_page_no = btr_page_get_prev(page, mtr);
4210+
const uint32_t prev_page_no = btr_page_get_prev(page);
42164211

42174212
const page_id_t page_id(block->page.id.space(), prev_page_no);
42184213

42194214
ut_ad(prev_page_no != FIL_NULL);
42204215
prev_block = buf_page_get_with_no_latch(page_id, block->page.size, mtr);
42214216
#ifdef UNIV_BTR_DEBUG
4222-
ut_a(btr_page_get_next(prev_block->frame, mtr)
4223-
== page_get_page_no(page));
4217+
ut_a(btr_page_get_next(prev_block->frame) == block->page.id.page_no());
42244218
#endif /* UNIV_BTR_DEBUG */
42254219

42264220
/* We must already have an x-latch on prev_block! */
@@ -5627,7 +5621,7 @@ btr_estimate_n_rows_in_range_on_level(
56275621
n_rows += page_get_n_recs(page);
56285622
}
56295623

5630-
page_id.set_page_no(btr_page_get_next(page, &mtr));
5624+
page_id.set_page_no(btr_page_get_next(page));
56315625

56325626
mtr_commit(&mtr);
56335627

storage/innobase/btr/btr0defragment.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ btr_defragment_n_pages(
586586
blocks[0] = block;
587587
for (uint i = 1; i <= n_pages; i++) {
588588
page_t* page = buf_block_get_frame(blocks[i-1]);
589-
ulint page_no = btr_page_get_next(page, mtr);
589+
ulint page_no = btr_page_get_next(page);
590590
total_data_size += page_get_data_size(page);
591591
total_n_recs += page_get_n_recs(page);
592592
if (page_no == FIL_NULL) {

storage/innobase/btr/btr0pcur.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ btr_pcur_move_to_next_page(
420420
return;
421421
}
422422

423-
next_page_no = btr_page_get_next(page, mtr);
423+
next_page_no = btr_page_get_next(page);
424424

425425
ut_ad(next_page_no != FIL_NULL);
426426

@@ -447,7 +447,7 @@ btr_pcur_move_to_next_page(
447447
next_page = buf_block_get_frame(next_block);
448448
#ifdef UNIV_BTR_DEBUG
449449
ut_a(page_is_comp(next_page) == page_is_comp(page));
450-
ut_a(btr_page_get_prev(next_page, mtr)
450+
ut_a(btr_page_get_prev(next_page)
451451
== btr_pcur_get_block(cursor)->page.id.page_no());
452452
#endif /* UNIV_BTR_DEBUG */
453453

@@ -509,7 +509,7 @@ btr_pcur_move_backward_from_page(
509509

510510
page = btr_pcur_get_page(cursor);
511511

512-
prev_page_no = btr_page_get_prev(page, mtr);
512+
prev_page_no = btr_page_get_prev(page);
513513

514514
if (prev_page_no == FIL_NULL) {
515515
} else if (btr_pcur_is_before_first_on_page(cursor)) {

storage/innobase/btr/btr0scrub.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,8 @@ btr_pessimistic_scrub(
433433
/* read block variables */
434434
const ulint page_no = mach_read_from_4(page + FIL_PAGE_OFFSET);
435435
const page_id_t page_id(dict_index_get_space(index), page_no);
436-
const ulint left_page_no = btr_page_get_prev(page, mtr);
437-
const ulint right_page_no = btr_page_get_next(page, mtr);
436+
const uint32_t left_page_no = btr_page_get_prev(page);
437+
const uint32_t right_page_no = btr_page_get_next(page);
438438
const page_id_t lpage_id(dict_index_get_space(index), left_page_no);
439439
const page_id_t rpage_id(dict_index_get_space(index), right_page_no);
440440
const page_size_t page_size(dict_table_page_size(index->table));
@@ -468,8 +468,8 @@ btr_pessimistic_scrub(
468468
/**
469469
* structure should be unchanged
470470
*/
471-
ut_a(left_page_no == btr_page_get_prev(page, mtr));
472-
ut_a(right_page_no == btr_page_get_next(page, mtr));
471+
ut_a(left_page_no == btr_page_get_prev(page));
472+
ut_a(right_page_no == btr_page_get_next(page));
473473
}
474474

475475
if (right_page_no != FIL_NULL) {

0 commit comments

Comments
 (0)