Commit 8ab05ab1 authored by marko's avatar marko

branches/zip: Minor cleanup of B-tree cursor operations.

btr_pcur_get_rel_pos(): Add a const qualifier.

btr_pcur_get_btr_cur(), btr_pcur_get_page_cur(): btr_cur_get_page_cur():
Define as const-preserving macros.

btr_pcur_is_on_user_rec(), btr_pcur_is_after_last_on_page(),
btr_pcur_is_before_first_on_page(): Remove the unused parameter mtr.
Add a const qualifier.

btr_pcur_move_to_next_on_page(), btr_pcur_move_to_prev_on_page():
Remove the unused parameter mtr.

page_cur_search(): Add const qualifiers.

page_cur_get_page(), page_cur_is_before_first(), page_cur_is_after_last():
Add debug assertions.
parent a2aac2f6
...@@ -303,7 +303,7 @@ btr_pcur_restore_position( ...@@ -303,7 +303,7 @@ btr_pcur_restore_position(
cursor->search_mode = old_mode; cursor->search_mode = old_mode;
if (cursor->rel_pos == BTR_PCUR_ON if (cursor->rel_pos == BTR_PCUR_ON
&& btr_pcur_is_on_user_rec(cursor, mtr) && btr_pcur_is_on_user_rec(cursor)
&& 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor), && 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor),
rec_get_offsets( rec_get_offsets(
btr_pcur_get_rec(cursor), index, btr_pcur_get_rec(cursor), index,
...@@ -383,7 +383,7 @@ btr_pcur_move_to_next_page( ...@@ -383,7 +383,7 @@ btr_pcur_move_to_next_page(
ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
ut_ad(btr_pcur_is_after_last_on_page(cursor, mtr)); ut_ad(btr_pcur_is_after_last_on_page(cursor));
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
...@@ -438,7 +438,7 @@ btr_pcur_move_backward_from_page( ...@@ -438,7 +438,7 @@ btr_pcur_move_backward_from_page(
ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
ut_ad(btr_pcur_is_before_first_on_page(cursor, mtr)); ut_ad(btr_pcur_is_before_first_on_page(cursor));
ut_ad(!btr_pcur_is_before_first_in_tree(cursor, mtr)); ut_ad(!btr_pcur_is_before_first_in_tree(cursor, mtr));
latch_mode = cursor->latch_mode; latch_mode = cursor->latch_mode;
...@@ -469,7 +469,7 @@ btr_pcur_move_backward_from_page( ...@@ -469,7 +469,7 @@ btr_pcur_move_backward_from_page(
space = buf_block_get_space(btr_pcur_get_block(cursor)); space = buf_block_get_space(btr_pcur_get_block(cursor));
if (prev_page_no == FIL_NULL) { if (prev_page_no == FIL_NULL) {
} else if (btr_pcur_is_before_first_on_page(cursor, mtr)) { } else if (btr_pcur_is_before_first_on_page(cursor)) {
prev_block = btr_pcur_get_btr_cur(cursor)->left_block; prev_block = btr_pcur_get_btr_cur(cursor)->left_block;
...@@ -512,7 +512,7 @@ btr_pcur_move_to_prev( ...@@ -512,7 +512,7 @@ btr_pcur_move_to_prev(
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
if (btr_pcur_is_before_first_on_page(cursor, mtr)) { if (btr_pcur_is_before_first_on_page(cursor)) {
if (btr_pcur_is_before_first_in_tree(cursor, mtr)) { if (btr_pcur_is_before_first_in_tree(cursor, mtr)) {
...@@ -524,7 +524,7 @@ btr_pcur_move_to_prev( ...@@ -524,7 +524,7 @@ btr_pcur_move_to_prev(
return(TRUE); return(TRUE);
} }
btr_pcur_move_to_prev_on_page(cursor, mtr); btr_pcur_move_to_prev_on_page(cursor);
return(TRUE); return(TRUE);
} }
...@@ -553,7 +553,7 @@ btr_pcur_open_on_user_rec( ...@@ -553,7 +553,7 @@ btr_pcur_open_on_user_rec(
if ((mode == PAGE_CUR_GE) || (mode == PAGE_CUR_G)) { if ((mode == PAGE_CUR_GE) || (mode == PAGE_CUR_G)) {
if (btr_pcur_is_after_last_on_page(cursor, mtr)) { if (btr_pcur_is_after_last_on_page(cursor)) {
btr_pcur_move_to_next_user_rec(cursor, mtr); btr_pcur_move_to_next_user_rec(cursor, mtr);
} }
......
...@@ -88,7 +88,7 @@ dict_get_first_table_name_in_db( ...@@ -88,7 +88,7 @@ dict_get_first_table_name_in_db(
loop: loop:
rec = btr_pcur_get_rec(&pcur); rec = btr_pcur_get_rec(&pcur);
if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { if (!btr_pcur_is_on_user_rec(&pcur)) {
/* Not found */ /* Not found */
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
...@@ -167,7 +167,7 @@ loop: ...@@ -167,7 +167,7 @@ loop:
rec = btr_pcur_get_rec(&pcur); rec = btr_pcur_get_rec(&pcur);
if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { if (!btr_pcur_is_on_user_rec(&pcur)) {
/* end of index */ /* end of index */
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
...@@ -297,7 +297,7 @@ loop: ...@@ -297,7 +297,7 @@ loop:
rec = btr_pcur_get_rec(&pcur); rec = btr_pcur_get_rec(&pcur);
if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { if (!btr_pcur_is_on_user_rec(&pcur)) {
/* end of index */ /* end of index */
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
...@@ -418,7 +418,7 @@ dict_load_columns( ...@@ -418,7 +418,7 @@ dict_load_columns(
rec = btr_pcur_get_rec(&pcur); rec = btr_pcur_get_rec(&pcur);
ut_a(btr_pcur_is_on_user_rec(&pcur, &mtr)); ut_a(btr_pcur_is_on_user_rec(&pcur));
ut_a(!rec_get_deleted_flag(rec, 0)); ut_a(!rec_get_deleted_flag(rec, 0));
...@@ -522,7 +522,7 @@ dict_load_fields( ...@@ -522,7 +522,7 @@ dict_load_fields(
rec = btr_pcur_get_rec(&pcur); rec = btr_pcur_get_rec(&pcur);
ut_a(btr_pcur_is_on_user_rec(&pcur, &mtr)); ut_a(btr_pcur_is_on_user_rec(&pcur));
/* There could be delete marked records in SYS_FIELDS /* There could be delete marked records in SYS_FIELDS
because SYS_FIELDS.INDEX_ID can be updated because SYS_FIELDS.INDEX_ID can be updated
...@@ -636,7 +636,7 @@ dict_load_indexes( ...@@ -636,7 +636,7 @@ dict_load_indexes(
btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
BTR_SEARCH_LEAF, &pcur, &mtr); BTR_SEARCH_LEAF, &pcur, &mtr);
for (;;) { for (;;) {
if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { if (!btr_pcur_is_on_user_rec(&pcur)) {
break; break;
} }
...@@ -791,7 +791,7 @@ dict_load_table( ...@@ -791,7 +791,7 @@ dict_load_table(
BTR_SEARCH_LEAF, &pcur, &mtr); BTR_SEARCH_LEAF, &pcur, &mtr);
rec = btr_pcur_get_rec(&pcur); rec = btr_pcur_get_rec(&pcur);
if (!btr_pcur_is_on_user_rec(&pcur, &mtr) if (!btr_pcur_is_on_user_rec(&pcur)
|| rec_get_deleted_flag(rec, 0)) { || rec_get_deleted_flag(rec, 0)) {
/* Not found */ /* Not found */
err_exit: err_exit:
...@@ -973,7 +973,7 @@ dict_load_table_on_id( ...@@ -973,7 +973,7 @@ dict_load_table_on_id(
BTR_SEARCH_LEAF, &pcur, &mtr); BTR_SEARCH_LEAF, &pcur, &mtr);
rec = btr_pcur_get_rec(&pcur); rec = btr_pcur_get_rec(&pcur);
if (!btr_pcur_is_on_user_rec(&pcur, &mtr) if (!btr_pcur_is_on_user_rec(&pcur)
|| rec_get_deleted_flag(rec, 0)) { || rec_get_deleted_flag(rec, 0)) {
/* Not found */ /* Not found */
...@@ -1082,7 +1082,7 @@ dict_load_foreign_cols( ...@@ -1082,7 +1082,7 @@ dict_load_foreign_cols(
rec = btr_pcur_get_rec(&pcur); rec = btr_pcur_get_rec(&pcur);
ut_a(btr_pcur_is_on_user_rec(&pcur, &mtr)); ut_a(btr_pcur_is_on_user_rec(&pcur));
ut_a(!rec_get_deleted_flag(rec, 0)); ut_a(!rec_get_deleted_flag(rec, 0));
field = rec_get_nth_field_old(rec, 0, &len); field = rec_get_nth_field_old(rec, 0, &len);
...@@ -1153,7 +1153,7 @@ dict_load_foreign( ...@@ -1153,7 +1153,7 @@ dict_load_foreign(
BTR_SEARCH_LEAF, &pcur, &mtr); BTR_SEARCH_LEAF, &pcur, &mtr);
rec = btr_pcur_get_rec(&pcur); rec = btr_pcur_get_rec(&pcur);
if (!btr_pcur_is_on_user_rec(&pcur, &mtr) if (!btr_pcur_is_on_user_rec(&pcur)
|| rec_get_deleted_flag(rec, 0)) { || rec_get_deleted_flag(rec, 0)) {
/* Not found */ /* Not found */
...@@ -1297,7 +1297,7 @@ start_load: ...@@ -1297,7 +1297,7 @@ start_load:
loop: loop:
rec = btr_pcur_get_rec(&pcur); rec = btr_pcur_get_rec(&pcur);
if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { if (!btr_pcur_is_on_user_rec(&pcur)) {
/* End of index */ /* End of index */
goto load_next_index; goto load_next_index;
......
...@@ -2558,7 +2558,7 @@ ibuf_update_max_tablespace_id(void) ...@@ -2558,7 +2558,7 @@ ibuf_update_max_tablespace_id(void)
&pcur, TRUE, &mtr); &pcur, TRUE, &mtr);
btr_pcur_move_to_prev(&pcur, &mtr); btr_pcur_move_to_prev(&pcur, &mtr);
if (btr_pcur_is_before_first_on_page(&pcur, &mtr)) { if (btr_pcur_is_before_first_on_page(&pcur)) {
/* The tree is empty */ /* The tree is empty */
max_space_id = 0; max_space_id = 0;
...@@ -3333,14 +3333,14 @@ loop: ...@@ -3333,14 +3333,14 @@ loop:
index page */ index page */
btr_pcur_open_on_user_rec(ibuf_data->index, search_tuple, PAGE_CUR_GE, btr_pcur_open_on_user_rec(ibuf_data->index, search_tuple, PAGE_CUR_GE,
BTR_MODIFY_LEAF, &pcur, &mtr); BTR_MODIFY_LEAF, &pcur, &mtr);
if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { if (!btr_pcur_is_on_user_rec(&pcur)) {
ut_ad(btr_pcur_is_after_last_in_tree(&pcur, &mtr)); ut_ad(btr_pcur_is_after_last_in_tree(&pcur, &mtr));
goto reset_bit; goto reset_bit;
} }
for (;;) { for (;;) {
ut_ad(btr_pcur_is_on_user_rec(&pcur, &mtr)); ut_ad(btr_pcur_is_on_user_rec(&pcur));
ibuf_rec = btr_pcur_get_rec(&pcur); ibuf_rec = btr_pcur_get_rec(&pcur);
...@@ -3393,7 +3393,7 @@ loop: ...@@ -3393,7 +3393,7 @@ loop:
goto loop; goto loop;
} }
if (btr_pcur_is_after_last_on_page(&pcur, &mtr)) { if (btr_pcur_is_after_last_on_page(&pcur)) {
mtr_commit(&mtr); mtr_commit(&mtr);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
...@@ -3505,14 +3505,14 @@ loop: ...@@ -3505,14 +3505,14 @@ loop:
space */ space */
btr_pcur_open_on_user_rec(ibuf_data->index, search_tuple, PAGE_CUR_GE, btr_pcur_open_on_user_rec(ibuf_data->index, search_tuple, PAGE_CUR_GE,
BTR_MODIFY_LEAF, &pcur, &mtr); BTR_MODIFY_LEAF, &pcur, &mtr);
if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { if (!btr_pcur_is_on_user_rec(&pcur)) {
ut_ad(btr_pcur_is_after_last_in_tree(&pcur, &mtr)); ut_ad(btr_pcur_is_after_last_in_tree(&pcur, &mtr));
goto leave_loop; goto leave_loop;
} }
for (;;) { for (;;) {
ut_ad(btr_pcur_is_on_user_rec(&pcur, &mtr)); ut_ad(btr_pcur_is_on_user_rec(&pcur));
ibuf_rec = btr_pcur_get_rec(&pcur); ibuf_rec = btr_pcur_get_rec(&pcur);
...@@ -3538,7 +3538,7 @@ loop: ...@@ -3538,7 +3538,7 @@ loop:
goto loop; goto loop;
} }
if (btr_pcur_is_after_last_on_page(&pcur, &mtr)) { if (btr_pcur_is_after_last_on_page(&pcur)) {
mtr_commit(&mtr); mtr_commit(&mtr);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
......
...@@ -27,14 +27,19 @@ Created 10/16/1994 Heikki Tuuri ...@@ -27,14 +27,19 @@ Created 10/16/1994 Heikki Tuuri
#define BTR_CUR_ADAPT #define BTR_CUR_ADAPT
#define BTR_CUR_HASH_ADAPT #define BTR_CUR_HASH_ADAPT
#ifdef UNIV_DEBUG
/************************************************************* /*************************************************************
Returns the page cursor component of a tree cursor. */ Returns the page cursor component of a tree cursor. */
UNIV_INLINE UNIV_INLINE
page_cur_t* page_cur_t*
btr_cur_get_page_cur( btr_cur_get_page_cur(
/*=================*/ /*=================*/
/* out: pointer to page cursor component */ /* out: pointer to page cursor
btr_cur_t* cursor);/* in: tree cursor */ component */
const btr_cur_t* cursor);/* in: tree cursor */
#else /* UNIV_DEBUG */
# define btr_cur_get_page_cur(cursor) (&(cursor)->page_cur)
#endif /* UNIV_DEBUG */
/************************************************************* /*************************************************************
Returns the buffer block on which the tree cursor is positioned. */ Returns the buffer block on which the tree cursor is positioned. */
UNIV_INLINE UNIV_INLINE
......
...@@ -8,17 +8,20 @@ Created 10/16/1994 Heikki Tuuri ...@@ -8,17 +8,20 @@ Created 10/16/1994 Heikki Tuuri
#include "btr0btr.h" #include "btr0btr.h"
#ifdef UNIV_DEBUG
/************************************************************* /*************************************************************
Returns the page cursor component of a tree cursor. */ Returns the page cursor component of a tree cursor. */
UNIV_INLINE UNIV_INLINE
page_cur_t* page_cur_t*
btr_cur_get_page_cur( btr_cur_get_page_cur(
/*=================*/ /*=================*/
/* out: pointer to page cursor component */ /* out: pointer to page cursor
btr_cur_t* cursor) /* in: tree cursor */ component */
const btr_cur_t* cursor) /* in: tree cursor */
{ {
return(&(cursor->page_cur)); return(&((btr_cur_t*) cursor)->page_cur);
} }
#endif /* UNIV_DEBUG */
/************************************************************* /*************************************************************
Returns the buffer block on which the tree cursor is positioned. */ Returns the buffer block on which the tree cursor is positioned. */
UNIV_INLINE UNIV_INLINE
......
...@@ -228,8 +228,8 @@ UNIV_INLINE ...@@ -228,8 +228,8 @@ UNIV_INLINE
ulint ulint
btr_pcur_get_rel_pos( btr_pcur_get_rel_pos(
/*=================*/ /*=================*/
/* out: BTR_PCUR_ON, ... */ /* out: BTR_PCUR_ON, ... */
btr_pcur_t* cursor);/* in: persistent cursor */ const btr_pcur_t* cursor);/* in: persistent cursor */
/************************************************************* /*************************************************************
Sets the mtr field for a pcur. */ Sets the mtr field for a pcur. */
UNIV_INLINE UNIV_INLINE
...@@ -346,22 +346,29 @@ btr_pcur_move_backward_from_page( ...@@ -346,22 +346,29 @@ btr_pcur_move_backward_from_page(
btr_pcur_t* cursor, /* in: persistent cursor, must be on the btr_pcur_t* cursor, /* in: persistent cursor, must be on the
first record of the current page */ first record of the current page */
mtr_t* mtr); /* in: mtr */ mtr_t* mtr); /* in: mtr */
#ifdef UNIV_DEBUG
/************************************************************* /*************************************************************
Returns the btr cursor component of a persistent cursor. */ Returns the btr cursor component of a persistent cursor. */
UNIV_INLINE UNIV_INLINE
btr_cur_t* btr_cur_t*
btr_pcur_get_btr_cur( btr_pcur_get_btr_cur(
/*=================*/ /*=================*/
/* out: pointer to btr cursor component */ /* out: pointer to
btr_pcur_t* cursor); /* in: persistent cursor */ btr cursor component */
const btr_pcur_t* cursor); /* in: persistent cursor */
/************************************************************* /*************************************************************
Returns the page cursor component of a persistent cursor. */ Returns the page cursor component of a persistent cursor. */
UNIV_INLINE UNIV_INLINE
page_cur_t* page_cur_t*
btr_pcur_get_page_cur( btr_pcur_get_page_cur(
/*==================*/ /*==================*/
/* out: pointer to page cursor component */ /* out: pointer to
btr_pcur_t* cursor); /* in: persistent cursor */ page cursor component */
const btr_pcur_t* cursor); /* in: persistent cursor */
#else /* UNIV_DEBUG */
# define btr_pcur_get_btr_cur(cursor) (&(cursor)->btr_cur)
# define btr_pcur_get_page_cur(cursor) (&(cursor)->btr_cur.page_cur)
#endif /* UNIV_DEBUG */
/************************************************************* /*************************************************************
Returns the page of a persistent cursor. */ Returns the page of a persistent cursor. */
UNIV_INLINE UNIV_INLINE
...@@ -392,8 +399,7 @@ UNIV_INLINE ...@@ -392,8 +399,7 @@ UNIV_INLINE
ibool ibool
btr_pcur_is_on_user_rec( btr_pcur_is_on_user_rec(
/*====================*/ /*====================*/
btr_pcur_t* cursor, /* in: persistent cursor */ const btr_pcur_t* cursor);/* in: persistent cursor */
mtr_t* mtr); /* in: mtr */
/************************************************************* /*************************************************************
Checks if the persistent cursor is after the last user record on Checks if the persistent cursor is after the last user record on
a page. */ a page. */
...@@ -401,8 +407,7 @@ UNIV_INLINE ...@@ -401,8 +407,7 @@ UNIV_INLINE
ibool ibool
btr_pcur_is_after_last_on_page( btr_pcur_is_after_last_on_page(
/*===========================*/ /*===========================*/
btr_pcur_t* cursor, /* in: persistent cursor */ const btr_pcur_t* cursor);/* in: persistent cursor */
mtr_t* mtr); /* in: mtr */
/************************************************************* /*************************************************************
Checks if the persistent cursor is before the first user record on Checks if the persistent cursor is before the first user record on
a page. */ a page. */
...@@ -410,8 +415,7 @@ UNIV_INLINE ...@@ -410,8 +415,7 @@ UNIV_INLINE
ibool ibool
btr_pcur_is_before_first_on_page( btr_pcur_is_before_first_on_page(
/*=============================*/ /*=============================*/
btr_pcur_t* cursor, /* in: persistent cursor */ const btr_pcur_t* cursor);/* in: persistent cursor */
mtr_t* mtr); /* in: mtr */
/************************************************************* /*************************************************************
Checks if the persistent cursor is before the first user record in Checks if the persistent cursor is before the first user record in
the index tree. */ the index tree. */
...@@ -436,16 +440,14 @@ UNIV_INLINE ...@@ -436,16 +440,14 @@ UNIV_INLINE
void void
btr_pcur_move_to_next_on_page( btr_pcur_move_to_next_on_page(
/*==========================*/ /*==========================*/
btr_pcur_t* cursor, /* in: persistent cursor */ btr_pcur_t* cursor);/* in/out: persistent cursor */
mtr_t* mtr); /* in: mtr */
/************************************************************* /*************************************************************
Moves the persistent cursor to the previous record on the same page. */ Moves the persistent cursor to the previous record on the same page. */
UNIV_INLINE UNIV_INLINE
void void
btr_pcur_move_to_prev_on_page( btr_pcur_move_to_prev_on_page(
/*==========================*/ /*==========================*/
btr_pcur_t* cursor, /* in: persistent cursor */ btr_pcur_t* cursor);/* in/out: persistent cursor */
mtr_t* mtr); /* in: mtr */
/* The persistent B-tree cursor structure. This is used mainly for SQL /* The persistent B-tree cursor structure. This is used mainly for SQL
......
...@@ -13,8 +13,8 @@ UNIV_INLINE ...@@ -13,8 +13,8 @@ UNIV_INLINE
ulint ulint
btr_pcur_get_rel_pos( btr_pcur_get_rel_pos(
/*=================*/ /*=================*/
/* out: BTR_PCUR_ON, ... */ /* out: BTR_PCUR_ON, ... */
btr_pcur_t* cursor) /* in: persistent cursor */ const btr_pcur_t* cursor) /* in: persistent cursor */
{ {
ut_ad(cursor); ut_ad(cursor);
ut_ad(cursor->old_rec); ut_ad(cursor->old_rec);
...@@ -53,16 +53,19 @@ btr_pcur_get_mtr( ...@@ -53,16 +53,19 @@ btr_pcur_get_mtr(
return(cursor->mtr); return(cursor->mtr);
} }
#ifdef UNIV_DEBUG
/************************************************************* /*************************************************************
Returns the btr cursor component of a persistent cursor. */ Returns the btr cursor component of a persistent cursor. */
UNIV_INLINE UNIV_INLINE
btr_cur_t* btr_cur_t*
btr_pcur_get_btr_cur( btr_pcur_get_btr_cur(
/*=================*/ /*=================*/
/* out: pointer to btr cursor component */ /* out: pointer to
btr_pcur_t* cursor) /* in: persistent cursor */ btr cursor component */
const btr_pcur_t* cursor) /* in: persistent cursor */
{ {
return(&(cursor->btr_cur)); const btr_cur_t* btr_cur = &cursor->btr_cur;
return((btr_cur_t*) btr_cur);
} }
/************************************************************* /*************************************************************
...@@ -71,12 +74,13 @@ UNIV_INLINE ...@@ -71,12 +74,13 @@ UNIV_INLINE
page_cur_t* page_cur_t*
btr_pcur_get_page_cur( btr_pcur_get_page_cur(
/*==================*/ /*==================*/
/* out: pointer to page cursor component */ /* out: pointer to page cursor
btr_pcur_t* cursor) /* in: persistent cursor */ component */
const btr_pcur_t* cursor) /* in: persistent cursor */
{ {
return(btr_cur_get_page_cur(&(cursor->btr_cur))); return(btr_cur_get_page_cur(btr_pcur_get_btr_cur(cursor)));
} }
#endif /* UNIV_DEBUG */
/************************************************************* /*************************************************************
Returns the page of a persistent cursor. */ Returns the page of a persistent cursor. */
UNIV_INLINE UNIV_INLINE
...@@ -172,10 +176,8 @@ UNIV_INLINE ...@@ -172,10 +176,8 @@ UNIV_INLINE
ibool ibool
btr_pcur_is_after_last_on_page( btr_pcur_is_after_last_on_page(
/*===========================*/ /*===========================*/
btr_pcur_t* cursor, /* in: persistent cursor */ const btr_pcur_t* cursor) /* in: persistent cursor */
mtr_t* mtr) /* in: mtr */
{ {
UT_NOT_USED(mtr);
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
...@@ -189,10 +191,8 @@ UNIV_INLINE ...@@ -189,10 +191,8 @@ UNIV_INLINE
ibool ibool
btr_pcur_is_before_first_on_page( btr_pcur_is_before_first_on_page(
/*=============================*/ /*=============================*/
btr_pcur_t* cursor, /* in: persistent cursor */ const btr_pcur_t* cursor) /* in: persistent cursor */
mtr_t* mtr) /* in: mtr */
{ {
UT_NOT_USED(mtr);
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
...@@ -205,14 +205,13 @@ UNIV_INLINE ...@@ -205,14 +205,13 @@ UNIV_INLINE
ibool ibool
btr_pcur_is_on_user_rec( btr_pcur_is_on_user_rec(
/*====================*/ /*====================*/
btr_pcur_t* cursor, /* in: persistent cursor */ const btr_pcur_t* cursor) /* in: persistent cursor */
mtr_t* mtr) /* in: mtr */
{ {
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
if ((btr_pcur_is_before_first_on_page(cursor, mtr)) if (btr_pcur_is_before_first_on_page(cursor)
|| (btr_pcur_is_after_last_on_page(cursor, mtr))) { || btr_pcur_is_after_last_on_page(cursor)) {
return(FALSE); return(FALSE);
} }
...@@ -268,10 +267,8 @@ UNIV_INLINE ...@@ -268,10 +267,8 @@ UNIV_INLINE
void void
btr_pcur_move_to_next_on_page( btr_pcur_move_to_next_on_page(
/*==========================*/ /*==========================*/
btr_pcur_t* cursor, /* in: persistent cursor */ btr_pcur_t* cursor) /* in/out: persistent cursor */
mtr_t* mtr) /* in: mtr */
{ {
UT_NOT_USED(mtr);
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
...@@ -286,10 +283,8 @@ UNIV_INLINE ...@@ -286,10 +283,8 @@ UNIV_INLINE
void void
btr_pcur_move_to_prev_on_page( btr_pcur_move_to_prev_on_page(
/*==========================*/ /*==========================*/
btr_pcur_t* cursor, /* in: persistent cursor */ btr_pcur_t* cursor) /* in/out: persistent cursor */
mtr_t* mtr) /* in: mtr */
{ {
UT_NOT_USED(mtr);
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
...@@ -333,7 +328,7 @@ btr_pcur_move_to_next_user_rec( ...@@ -333,7 +328,7 @@ btr_pcur_move_to_next_user_rec(
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
loop: loop:
if (btr_pcur_is_after_last_on_page(cursor, mtr)) { if (btr_pcur_is_after_last_on_page(cursor)) {
if (btr_pcur_is_after_last_in_tree(cursor, mtr)) { if (btr_pcur_is_after_last_in_tree(cursor, mtr)) {
...@@ -342,10 +337,10 @@ loop: ...@@ -342,10 +337,10 @@ loop:
btr_pcur_move_to_next_page(cursor, mtr); btr_pcur_move_to_next_page(cursor, mtr);
} else { } else {
btr_pcur_move_to_next_on_page(cursor, mtr); btr_pcur_move_to_next_on_page(cursor);
} }
if (btr_pcur_is_on_user_rec(cursor, mtr)) { if (btr_pcur_is_on_user_rec(cursor)) {
return(TRUE); return(TRUE);
} }
...@@ -371,7 +366,7 @@ btr_pcur_move_to_next( ...@@ -371,7 +366,7 @@ btr_pcur_move_to_next(
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
if (btr_pcur_is_after_last_on_page(cursor, mtr)) { if (btr_pcur_is_after_last_on_page(cursor)) {
if (btr_pcur_is_after_last_in_tree(cursor, mtr)) { if (btr_pcur_is_after_last_in_tree(cursor, mtr)) {
...@@ -383,7 +378,7 @@ btr_pcur_move_to_next( ...@@ -383,7 +378,7 @@ btr_pcur_move_to_next(
return(TRUE); return(TRUE);
} }
btr_pcur_move_to_next_on_page(cursor, mtr); btr_pcur_move_to_next_on_page(cursor);
return(TRUE); return(TRUE);
} }
......
...@@ -238,13 +238,15 @@ UNIV_INLINE ...@@ -238,13 +238,15 @@ UNIV_INLINE
ulint ulint
page_cur_search( page_cur_search(
/*============*/ /*============*/
/* out: number of matched fields on the left */ /* out: number of matched
buf_block_t* block, /* in: buffer block */ fields on the left */
dict_index_t* index, /* in: record descriptor */ const buf_block_t* block, /* in: buffer block */
const dtuple_t* tuple, /* in: data tuple */ const dict_index_t* index, /* in: record descriptor */
ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, const dtuple_t* tuple, /* in: data tuple */
or PAGE_CUR_GE */ ulint mode, /* in: PAGE_CUR_L,
page_cur_t* cursor);/* out: page cursor */ PAGE_CUR_LE, PAGE_CUR_G, or
PAGE_CUR_GE */
page_cur_t* cursor);/* out: page cursor */
/******************************************************************** /********************************************************************
Searches the right position for a page cursor. */ Searches the right position for a page cursor. */
......
...@@ -20,6 +20,7 @@ page_cur_get_page( ...@@ -20,6 +20,7 @@ page_cur_get_page(
page_cur_t* cur) /* in: page cursor */ page_cur_t* cur) /* in: page cursor */
{ {
ut_ad(cur); ut_ad(cur);
ut_ad(page_align(cur->rec) == cur->block->frame);
return(page_align(cur->rec)); return(page_align(cur->rec));
} }
...@@ -103,6 +104,8 @@ page_cur_is_before_first( ...@@ -103,6 +104,8 @@ page_cur_is_before_first(
/* out: TRUE if at start */ /* out: TRUE if at start */
const page_cur_t* cur) /* in: cursor */ const page_cur_t* cur) /* in: cursor */
{ {
ut_ad(cur);
ut_ad(page_align(cur->rec) == cur->block->frame);
return(page_rec_is_infimum(cur->rec)); return(page_rec_is_infimum(cur->rec));
} }
...@@ -115,6 +118,8 @@ page_cur_is_after_last( ...@@ -115,6 +118,8 @@ page_cur_is_after_last(
/* out: TRUE if at end */ /* out: TRUE if at end */
const page_cur_t* cur) /* in: cursor */ const page_cur_t* cur) /* in: cursor */
{ {
ut_ad(cur);
ut_ad(page_align(cur->rec) == cur->block->frame);
return(page_rec_is_supremum(cur->rec)); return(page_rec_is_supremum(cur->rec));
} }
...@@ -182,13 +187,15 @@ UNIV_INLINE ...@@ -182,13 +187,15 @@ UNIV_INLINE
ulint ulint
page_cur_search( page_cur_search(
/*============*/ /*============*/
/* out: number of matched fields on the left */ /* out: number of matched
buf_block_t* block, /* in: buffer block */ fields on the left */
dict_index_t* index, /* in: record descriptor */ const buf_block_t* block, /* in: buffer block */
const dtuple_t* tuple, /* in: data tuple */ const dict_index_t* index, /* in: record descriptor */
ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, const dtuple_t* tuple, /* in: data tuple */
or PAGE_CUR_GE */ ulint mode, /* in: PAGE_CUR_L,
page_cur_t* cursor) /* out: page cursor */ PAGE_CUR_LE, PAGE_CUR_G, or
PAGE_CUR_GE */
page_cur_t* cursor) /* out: page cursor */
{ {
ulint low_matched_fields = 0; ulint low_matched_fields = 0;
ulint low_matched_bytes = 0; ulint low_matched_bytes = 0;
......
...@@ -1127,12 +1127,12 @@ row_merge_read_clustered_index( ...@@ -1127,12 +1127,12 @@ row_merge_read_clustered_index(
row_ext_t* ext; row_ext_t* ext;
ibool has_next = TRUE; ibool has_next = TRUE;
btr_pcur_move_to_next_on_page(&pcur, &mtr); btr_pcur_move_to_next_on_page(&pcur);
/* When switching pages, commit the mini-transaction /* When switching pages, commit the mini-transaction
in order to release the latch on the old page. */ in order to release the latch on the old page. */
if (btr_pcur_is_after_last_on_page(&pcur, &mtr)) { if (btr_pcur_is_after_last_on_page(&pcur)) {
btr_pcur_store_position(&pcur, &mtr); btr_pcur_store_position(&pcur, &mtr);
mtr_commit(&mtr); mtr_commit(&mtr);
mtr_start(&mtr); mtr_start(&mtr);
......
...@@ -2928,7 +2928,7 @@ row_truncate_table_for_mysql( ...@@ -2928,7 +2928,7 @@ row_truncate_table_for_mysql(
ulint len; ulint len;
ulint root_page_no; ulint root_page_no;
if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { if (!btr_pcur_is_on_user_rec(&pcur)) {
/* The end of SYS_INDEXES has been reached. */ /* The end of SYS_INDEXES has been reached. */
break; break;
} }
......
...@@ -1752,7 +1752,7 @@ next_rec: ...@@ -1752,7 +1752,7 @@ next_rec:
} }
if (leaf_contains_updates if (leaf_contains_updates
&& btr_pcur_is_after_last_on_page(&(plan->pcur), &mtr)) { && btr_pcur_is_after_last_on_page(&plan->pcur)) {
/* We must commit &mtr if we are moving to a different page, /* We must commit &mtr if we are moving to a different page,
because we have done updates to the x-latched leaf page, and because we have done updates to the x-latched leaf page, and
...@@ -1785,7 +1785,7 @@ next_table: ...@@ -1785,7 +1785,7 @@ next_table:
/* We found a record which satisfies the conditions: we can move to /* We found a record which satisfies the conditions: we can move to
the next table or return a row in the result set */ the next table or return a row in the result set */
ut_ad(btr_pcur_is_on_user_rec(&(plan->pcur), &mtr)); ut_ad(btr_pcur_is_on_user_rec(&plan->pcur));
if (plan->unique_search && !node->can_get_updated) { if (plan->unique_search && !node->can_get_updated) {
...@@ -1922,8 +1922,7 @@ commit_mtr_for_a_while: ...@@ -1922,8 +1922,7 @@ commit_mtr_for_a_while:
lock_wait_or_error: lock_wait_or_error:
/* See the note at stop_for_a_while: the same holds for this case */ /* See the note at stop_for_a_while: the same holds for this case */
ut_ad(!btr_pcur_is_before_first_on_page(&(plan->pcur), &mtr) ut_ad(!btr_pcur_is_before_first_on_page(&plan->pcur) || !node->asc);
|| !node->asc);
ut_ad(!search_latch_locked); ut_ad(!search_latch_locked);
plan->stored_cursor_rec_processed = FALSE; plan->stored_cursor_rec_processed = FALSE;
...@@ -3065,7 +3064,7 @@ sel_restore_position_for_mysql( ...@@ -3065,7 +3064,7 @@ sel_restore_position_for_mysql(
return(TRUE); return(TRUE);
} }
if (btr_pcur_is_on_user_rec(pcur, mtr)) { if (btr_pcur_is_on_user_rec(pcur)) {
btr_pcur_move_to_prev(pcur, mtr); btr_pcur_move_to_prev(pcur, mtr);
} }
...@@ -3075,7 +3074,7 @@ sel_restore_position_for_mysql( ...@@ -3075,7 +3074,7 @@ sel_restore_position_for_mysql(
ut_ad(relative_position == BTR_PCUR_BEFORE ut_ad(relative_position == BTR_PCUR_BEFORE
|| relative_position == BTR_PCUR_BEFORE_FIRST_IN_TREE); || relative_position == BTR_PCUR_BEFORE_FIRST_IN_TREE);
if (moves_up && btr_pcur_is_on_user_rec(pcur, mtr)) { if (moves_up && btr_pcur_is_on_user_rec(pcur)) {
btr_pcur_move_to_next(pcur, mtr); btr_pcur_move_to_next(pcur, mtr);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment