Skip to content

Commit 6b2d6a8

Browse files
committed
Cleanup: Remove btr_pcur_t::old_stored
The Boolean field btr_pcur_t::old_stored mostly duplicates old_rec. Let us remove it.
1 parent 8442bc6 commit 6b2d6a8

File tree

9 files changed

+34
-45
lines changed

9 files changed

+34
-45
lines changed

storage/innobase/btr/btr0pcur.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ btr_pcur_reset(
6363
cursor->old_rec = NULL;
6464
cursor->old_n_core_fields = 0;
6565
cursor->old_n_fields = 0;
66-
cursor->old_stored = false;
6766

6867
cursor->latch_mode = BTR_NO_LATCHES;
6968
cursor->pos_state = BTR_PCUR_NOT_POSITIONED;
@@ -125,8 +124,6 @@ btr_pcur_store_position(
125124
&& mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK
126125
| MTR_MEMO_SX_LOCK)));
127126

128-
cursor->old_stored = true;
129-
130127
if (page_is_empty(block->page.frame)) {
131128
/* It must be an empty index tree; NOTE that in this case
132129
we do not store the modify_clock, but always do a search
@@ -301,7 +298,6 @@ btr_pcur_t::restore_position(ulint restore_latch_mode, mtr_t *mtr)
301298
mem_heap_t* heap;
302299

303300
ut_ad(mtr->is_active());
304-
//ut_ad(cursor->old_stored);
305301
ut_ad(pos_state == BTR_PCUR_WAS_POSITIONED
306302
|| pos_state == BTR_PCUR_IS_POSITIONED);
307303

@@ -450,7 +446,6 @@ btr_pcur_t::restore_position(ulint restore_latch_mode, mtr_t *mtr)
450446
block_when_stored.store(btr_pcur_get_block(this));
451447
modify_clock= buf_block_get_modify_clock(
452448
block_when_stored.block());
453-
old_stored= true;
454449

455450
mem_heap_free(heap);
456451

@@ -487,7 +482,7 @@ btr_pcur_move_to_next_page(
487482
ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
488483
ut_ad(btr_pcur_is_after_last_on_page(cursor));
489484

490-
cursor->old_stored = false;
485+
cursor->old_rec = nullptr;
491486

492487
const page_t* page = btr_pcur_get_page(cursor);
493488
const uint32_t next_page_no = btr_page_get_next(page);
@@ -594,7 +589,7 @@ btr_pcur_move_backward_from_page(
594589
}
595590

596591
cursor->latch_mode = latch_mode;
597-
cursor->old_stored = false;
592+
cursor->old_rec = nullptr;
598593
return false;
599594
}
600595

@@ -612,7 +607,7 @@ btr_pcur_move_to_prev(
612607
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
613608
ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
614609

615-
cursor->old_stored = false;
610+
cursor->old_rec = nullptr;
616611

617612
if (btr_pcur_is_before_first_on_page(cursor)) {
618613
return (!btr_pcur_is_before_first_in_tree(cursor)

storage/innobase/fts/fts0fts.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3347,7 +3347,6 @@ fts_add_doc_by_id(
33473347
is_id_cluster = (clust_index == fts_id_index);
33483348

33493349
mtr_start(&mtr);
3350-
btr_pcur_init(&pcur);
33513350

33523351
/* Search based on Doc ID. Here, we'll need to consider the case
33533352
when there is no primary index on Doc ID */

storage/innobase/ibuf/ibuf0ibuf.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,8 +2402,8 @@ ulint ibuf_contract()
24022402
/* Open a cursor to a randomly chosen leaf of the tree, at a random
24032403
position within the leaf */
24042404
pcur.pos_state = BTR_PCUR_IS_POSITIONED;
2405-
pcur.old_stored = false;
2406-
pcur.trx_if_known = NULL;
2405+
pcur.old_rec = nullptr;
2406+
pcur.trx_if_known = nullptr;
24072407
pcur.search_mode = PAGE_CUR_G;
24082408
pcur.latch_mode = BTR_SEARCH_LEAF;
24092409

storage/innobase/include/btr0pcur.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,6 @@ struct btr_pcur_t{
381381
we say then that the cursor is detached; it can be restored to
382382
attached if the old position was stored in old_rec */
383383
ulint latch_mode;
384-
/** true if old_rec is stored */
385-
bool old_stored;
386384
/** if cursor position is stored, contains an initial segment of the
387385
latest record cursor was positioned either on, before or after */
388386
rec_t* old_rec;
@@ -416,7 +414,7 @@ struct btr_pcur_t{
416414

417415
btr_pcur_t() :
418416
btr_cur(), latch_mode(RW_NO_LATCH),
419-
old_stored(false), old_rec(NULL),
417+
old_rec(NULL),
420418
old_n_fields(0), rel_pos(btr_pcur_pos_t(0)),
421419
block_when_stored(),
422420
modify_clock(0), pos_state(BTR_PCUR_NOT_POSITIONED),

storage/innobase/include/btr0pcur.inl

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ btr_pcur_get_rel_pos(
3636
{
3737
ut_ad(cursor);
3838
ut_ad(cursor->old_rec);
39-
ut_ad(cursor->old_stored);
4039
ut_ad(cursor->pos_state == BTR_PCUR_WAS_POSITIONED
4140
|| cursor->pos_state == BTR_PCUR_IS_POSITIONED);
4241

@@ -163,7 +162,7 @@ btr_pcur_move_to_next_on_page(
163162
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
164163
ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
165164

166-
cursor->old_stored = false;
165+
cursor->old_rec = nullptr;
167166
return page_cur_move_to_next(btr_pcur_get_page_cur(cursor));
168167
}
169168

@@ -177,7 +176,7 @@ btr_pcur_move_to_prev_on_page(
177176
{
178177
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
179178
ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
180-
cursor->old_stored = false;
179+
cursor->old_rec = nullptr;
181180

182181
return page_cur_move_to_prev(btr_pcur_get_page_cur(cursor));
183182
}
@@ -196,7 +195,7 @@ btr_pcur_move_to_next_user_rec(
196195
{
197196
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
198197
ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
199-
cursor->old_stored = false;
198+
cursor->old_rec = nullptr;
200199
loop:
201200
if (btr_pcur_is_after_last_on_page(cursor)) {
202201
if (btr_pcur_is_after_last_in_tree(cursor)
@@ -230,7 +229,7 @@ btr_pcur_move_to_next(
230229
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
231230
ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
232231

233-
cursor->old_stored= false;
232+
cursor->old_rec= nullptr;
234233

235234
if (btr_pcur_is_after_last_on_page(cursor))
236235
return !btr_pcur_is_after_last_in_tree(cursor) &&
@@ -294,7 +293,6 @@ btr_pcur_init(
294293
/*==========*/
295294
btr_pcur_t* pcur) /*!< in: persistent cursor */
296295
{
297-
pcur->old_stored = false;
298296
pcur->old_rec_buf = NULL;
299297
pcur->old_rec = NULL;
300298

@@ -363,7 +361,6 @@ dberr_t btr_pcur_open_with_no_init(dict_index_t *index, const dtuple_t *tuple,
363361
cursor->latch_mode= BTR_LATCH_MODE_WITHOUT_INTENTION(latch_mode);
364362
cursor->search_mode= mode;
365363
cursor->pos_state= BTR_PCUR_IS_POSITIONED;
366-
cursor->old_stored= false;
367364
cursor->trx_if_known= nullptr;
368365

369366
/* Search with the tree cursor */
@@ -402,7 +399,7 @@ btr_pcur_open_at_index_side(
402399
btr_pcur_get_btr_cur(pcur), level, mtr);
403400
pcur->pos_state = BTR_PCUR_IS_POSITIONED;
404401

405-
pcur->old_stored = false;
402+
pcur->old_rec = nullptr;
406403

407404
pcur->trx_if_known = NULL;
408405

@@ -425,25 +422,21 @@ btr_pcur_close(
425422
/*===========*/
426423
btr_pcur_t* cursor) /*!< in: persistent cursor */
427424
{
428-
ut_free(cursor->old_rec_buf);
425+
ut_free(cursor->old_rec_buf);
429426

430-
if (cursor->btr_cur.rtr_info) {
431-
rtr_clean_rtr_info(cursor->btr_cur.rtr_info, true);
432-
cursor->btr_cur.rtr_info = NULL;
433-
}
434-
435-
cursor->old_rec = NULL;
436-
cursor->old_rec_buf = NULL;
437-
cursor->btr_cur.page_cur.rec = NULL;
438-
cursor->btr_cur.page_cur.block = NULL;
427+
if (cursor->btr_cur.rtr_info)
428+
rtr_clean_rtr_info(cursor->btr_cur.rtr_info, true);
439429

440-
cursor->old_rec = NULL;
441-
cursor->old_stored = false;
430+
cursor->btr_cur.rtr_info= nullptr;
431+
cursor->old_rec = nullptr;
432+
cursor->old_rec_buf = nullptr;
433+
cursor->btr_cur.page_cur.rec = nullptr;
434+
cursor->btr_cur.page_cur.block = nullptr;
442435

443-
cursor->latch_mode = BTR_NO_LATCHES;
444-
cursor->pos_state = BTR_PCUR_NOT_POSITIONED;
436+
cursor->latch_mode = BTR_NO_LATCHES;
437+
cursor->pos_state = BTR_PCUR_NOT_POSITIONED;
445438

446-
cursor->trx_if_known = NULL;
439+
cursor->trx_if_known = nullptr;
447440
}
448441

449442
/*********************************************************//**
@@ -459,5 +452,5 @@ btr_pcur_move_before_first_on_page(
459452
page_cur_set_before_first(btr_pcur_get_block(cursor),
460453
btr_pcur_get_page_cur(cursor));
461454

462-
cursor->old_stored = false;
455+
cursor->old_rec = nullptr;
463456
}

storage/innobase/row/row0import.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ dberr_t IndexPurge::next() noexcept
15711571
return DB_CORRUPTION;
15721572
}
15731573
/* The following is based on btr_pcur_move_to_next_user_rec(). */
1574-
m_pcur.old_stored = false;
1574+
m_pcur.old_rec = nullptr;
15751575
ut_ad(m_pcur.latch_mode == BTR_MODIFY_LEAF);
15761576
do {
15771577
if (btr_pcur_is_after_last_on_page(&m_pcur)) {

storage/innobase/row/row0ins.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,7 @@ row_ins_foreign_check_on_constraint(
11381138

11391139
ref = row_build_row_ref(ROW_COPY_POINTERS, index, rec,
11401140
tmp_heap);
1141+
cascade->pcur->old_rec = nullptr;
11411142
err = btr_pcur_open_with_no_init(clust_index, ref,
11421143
PAGE_CUR_LE, BTR_SEARCH_LEAF,
11431144
cascade->pcur, mtr);

storage/innobase/row/row0purge.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ purge_node_t::validate_pcur()
13401340
return(true);
13411341
}
13421342

1343-
if (!pcur.old_stored) {
1343+
if (!pcur.old_rec) {
13441344
return(true);
13451345
}
13461346

storage/innobase/row/row0sel.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ row_sel_get_clust_rec(
10181018
row_build_row_ref_fast(plan->clust_ref, plan->clust_map, rec, offsets);
10191019

10201020
index = dict_table_get_first_index(plan->table);
1021-
1021+
plan->clust_pcur.old_rec = nullptr;
10221022
dberr_t err = btr_pcur_open_with_no_init(index, plan->clust_ref,
10231023
PAGE_CUR_LE, BTR_SEARCH_LEAF,
10241024
&plan->clust_pcur, mtr);
@@ -1411,6 +1411,8 @@ row_sel_open_pcur(
14111411
cond = UT_LIST_GET_NEXT(cond_list, cond);
14121412
}
14131413

1414+
plan->pcur.old_rec = nullptr;
1415+
14141416
dberr_t err;
14151417

14161418
if (plan->tuple) {
@@ -3371,6 +3373,7 @@ Row_sel_get_clust_rec_for_mysql::operator()(
33713373
rec_t* old_vers;
33723374
trx_t* trx;
33733375

3376+
prebuilt->clust_pcur->old_rec = nullptr;
33743377
*out_rec = NULL;
33753378
trx = thr_get_trx(thr);
33763379

@@ -3965,6 +3968,7 @@ row_sel_try_search_shortcut_for_mysql(
39653968
ut_ad(!index->table->is_temporary());
39663969
ut_ad(!prebuilt->templ_contains_blob);
39673970
ut_ad(trx->read_view.is_open());
3971+
pcur->old_rec = nullptr;
39683972

39693973
if (btr_pcur_open_with_no_init(index, search_tuple, PAGE_CUR_GE,
39703974
BTR_SEARCH_LEAF, pcur, mtr)
@@ -4767,6 +4771,7 @@ row_search_mvcc(
47674771

47684772
} else if (dtuple_get_n_fields(search_tuple) > 0) {
47694773
pcur->btr_cur.thr = thr;
4774+
pcur->old_rec = nullptr;
47704775

47714776
if (dict_index_is_spatial(index)) {
47724777
if (!prebuilt->rtr_info) {
@@ -5020,7 +5025,7 @@ row_search_mvcc(
50205025

50215026
page_cur_set_after_last(btr_pcur_get_block(pcur),
50225027
btr_pcur_get_page_cur(pcur));
5023-
pcur->old_stored = false;
5028+
pcur->old_rec = nullptr;
50245029
goto next_rec;
50255030
}
50265031
}
@@ -5786,7 +5791,7 @@ row_search_mvcc(
57865791
/* This is based on btr_pcur_move_to_next() */
57875792
ut_ad(pcur->pos_state == BTR_PCUR_IS_POSITIONED);
57885793
ut_ad(pcur->latch_mode != BTR_NO_LATCHES);
5789-
pcur->old_stored = false;
5794+
pcur->old_rec = nullptr;
57905795
if (btr_pcur_is_after_last_on_page(pcur)) {
57915796
if (btr_pcur_is_after_last_in_tree(pcur)) {
57925797
goto not_moved;
@@ -6198,8 +6203,6 @@ dberr_t row_check_index(row_prebuilt_t *prebuilt, ulint *n_rows)
61986203
*n_rows= 0;
61996204
dict_index_t *const index= prebuilt->index;
62006205

6201-
prebuilt->fetch_direction= ROW_SEL_NEXT;
6202-
62036206
if (!index->is_btree())
62046207
return DB_CORRUPTION;
62056208

0 commit comments

Comments
 (0)