summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/btr/btr0btr.cc6
-rw-r--r--storage/innobase/btr/btr0cur.cc86
-rw-r--r--storage/innobase/btr/btr0pcur.cc6
-rw-r--r--storage/innobase/btr/btr0sea.cc116
-rw-r--r--storage/innobase/dict/dict0dict.cc4
-rw-r--r--storage/innobase/fts/fts0fts.cc4
-rw-r--r--storage/innobase/gis/gis0sea.cc8
-rw-r--r--storage/innobase/include/btr0cur.h77
-rw-r--r--storage/innobase/include/btr0pcur.h55
-rw-r--r--storage/innobase/include/btr0pcur.inl58
-rw-r--r--storage/innobase/include/btr0sea.h1
-rw-r--r--storage/innobase/include/trx0rec.h26
-rw-r--r--storage/innobase/row/row0ins.cc10
-rw-r--r--storage/innobase/row/row0log.cc6
-rw-r--r--storage/innobase/row/row0merge.cc7
-rw-r--r--storage/innobase/row/row0purge.cc137
-rw-r--r--storage/innobase/row/row0sel.cc18
-rw-r--r--storage/innobase/trx/trx0rec.cc177
-rw-r--r--storage/innobase/trx/trx0trx.cc2
-rw-r--r--storage/maria/aria_ftdump.c4
-rw-r--r--storage/myisam/myisam_ftdump.c4
21 files changed, 315 insertions, 497 deletions
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
index a3151e69410..2b4bc0e9ed5 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -834,7 +834,7 @@ btr_page_get_father_node_ptr_func(
err = btr_cur_search_to_nth_level(
index, level + 1, tuple,
- PAGE_CUR_LE, latch_mode, cursor, 0,
+ PAGE_CUR_LE, latch_mode, cursor,
file, line, mtr);
if (err != DB_SUCCESS) {
@@ -2380,7 +2380,7 @@ btr_insert_on_non_leaf_level_func(
dberr_t err = btr_cur_search_to_nth_level(
index, level, tuple, PAGE_CUR_LE,
BTR_CONT_MODIFY_TREE,
- &cursor, 0, file, line, mtr);
+ &cursor, file, line, mtr);
if (err != DB_SUCCESS) {
ib::warn() << " Error code: " << err
@@ -2401,7 +2401,7 @@ btr_insert_on_non_leaf_level_func(
btr_cur_search_to_nth_level(index, level, tuple,
PAGE_CUR_RTREE_INSERT,
BTR_CONT_MODIFY_TREE,
- &cursor, 0, file, line, mtr);
+ &cursor, file, line, mtr);
}
ut_ad(cursor.flag == BTR_CUR_BINARY);
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index a33596509c1..463b9da9744 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -1229,38 +1229,36 @@ If mode is PAGE_CUR_GE, then up_match will a have a sensible value.
If mode is PAGE_CUR_LE , cursor is left at the place where an insert of the
search tuple should be performed in the B-tree. InnoDB does an insert
immediately after the cursor. Thus, the cursor may end up on a user record,
-or on a page infimum record. */
-dberr_t
-btr_cur_search_to_nth_level_func(
- dict_index_t* index, /*!< in: index */
- ulint level, /*!< in: the tree level of search */
- const dtuple_t* tuple, /*!< in: data tuple; NOTE: n_fields_cmp in
- tuple must be set so that it cannot get
- compared to the node ptr page number field! */
- page_cur_mode_t mode, /*!< in: PAGE_CUR_L, ...;
- Inserts should always be made using
- PAGE_CUR_LE to search the position! */
- ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ..., ORed with
- at most one of BTR_INSERT, BTR_DELETE_MARK,
- BTR_DELETE, or BTR_ESTIMATE;
- cursor->left_block is used to store a pointer
- to the left neighbor page, in the cases
- BTR_SEARCH_PREV and BTR_MODIFY_PREV;
- NOTE that if ahi_latch, we might not have a
- cursor page latch, we assume that ahi_latch
- protects the record! */
- btr_cur_t* cursor, /*!< in/out: tree cursor; the cursor page is
- s- or x-latched, but see also above! */
-#ifdef BTR_CUR_HASH_ADAPT
- rw_lock_t* ahi_latch,
- /*!< in: currently held btr_search_latch
- (in RW_S_LATCH mode), or NULL */
-#endif /* BTR_CUR_HASH_ADAPT */
- const char* file, /*!< in: file name */
- unsigned line, /*!< in: line where called */
- mtr_t* mtr, /*!< in: mtr */
- ib_uint64_t autoinc)/*!< in: PAGE_ROOT_AUTO_INC to be written
- (0 if none) */
+or on a page infimum record.
+@param index index
+@param level the tree level of search
+@param tuple data tuple; NOTE: n_fields_cmp in tuple must be set so that
+ it cannot get compared to the node ptr page number field!
+@param mode PAGE_CUR_L, NOTE that if the search is made using a unique
+ prefix of a record, mode should be PAGE_CUR_LE, not
+ PAGE_CUR_GE, as the latter may end up on the previous page of
+ the record! Inserts should always be made using PAGE_CUR_LE
+ to search the position!
+@param latch_mode BTR_SEARCH_LEAF, ..., ORed with at most one of BTR_INSERT,
+ BTR_DELETE_MARK, BTR_DELETE, or BTR_ESTIMATE;
+ cursor->left_block is used to store a pointer to the left
+ neighbor page, in the cases BTR_SEARCH_PREV and
+ BTR_MODIFY_PREV; NOTE that if ahi_latch, we might not have a
+ cursor page latch, we assume that ahi_latch protects the
+ record!
+@param cursor tree cursor; the cursor page is s- or x-latched, but see also
+ above!
+@param file file name
+@param line line where called
+@param mtr mini-transaction
+@param autoinc PAGE_ROOT_AUTO_INC to be written (0 if none)
+@return DB_SUCCESS on success or error code otherwise */
+dberr_t btr_cur_search_to_nth_level(dict_index_t *index, ulint level,
+ const dtuple_t *tuple,
+ page_cur_mode_t mode, ulint latch_mode,
+ btr_cur_t *cursor, const char *file,
+ unsigned line, mtr_t *mtr,
+ ib_uint64_t autoinc)
{
page_t* page = NULL; /* remove warning */
buf_block_t* block;
@@ -1424,15 +1422,14 @@ btr_cur_search_to_nth_level_func(
&& mode != PAGE_CUR_LE_OR_EXTENDS
# endif /* PAGE_CUR_LE_OR_EXTENDS */
&& !dict_index_is_spatial(index)
- /* If !ahi_latch, we do a dirty read of
+ /* We do a dirty read of
btr_search_enabled below, and btr_search_guess_on_hash()
will have to check it again. */
&& btr_search_enabled
&& !modify_external
&& !(tuple->info_bits & REC_INFO_MIN_REC_FLAG)
&& btr_search_guess_on_hash(index, info, tuple, mode,
- latch_mode, cursor,
- ahi_latch, mtr)) {
+ latch_mode, cursor, mtr)) {
/* Search using the hash index succeeded */
@@ -1453,13 +1450,6 @@ btr_cur_search_to_nth_level_func(
/* If the hash search did not succeed, do binary search down the
tree */
-#ifdef BTR_CUR_HASH_ADAPT
- if (ahi_latch) {
- /* Release possible search latch to obey latching order */
- rw_lock_s_unlock(ahi_latch);
- }
-#endif /* BTR_CUR_HASH_ADAPT */
-
/* Store the position of the tree latch we push to mtr so that we
know how to release it when we have latched leaf node(s) */
@@ -2507,12 +2497,6 @@ func_exit:
cursor->rtr_info->mbr_adj = true;
}
-#ifdef BTR_CUR_HASH_ADAPT
- if (ahi_latch) {
- rw_lock_s_lock(ahi_latch);
- }
-#endif /* BTR_CUR_HASH_ADAPT */
-
DBUG_RETURN(err);
}
@@ -6224,8 +6208,7 @@ btr_estimate_n_rows_in_range_low(
btr_cur_search_to_nth_level(index, 0, tuple1->tuple,
tuple1->mode,
BTR_SEARCH_LEAF | BTR_ESTIMATE,
- &cursor, 0,
- __FILE__, __LINE__, &mtr);
+ &cursor, __FILE__, __LINE__, &mtr);
ut_ad(!page_rec_is_infimum(btr_cur_get_rec(&cursor)));
@@ -6281,8 +6264,7 @@ btr_estimate_n_rows_in_range_low(
btr_cur_search_to_nth_level(index, 0, tuple2->tuple,
mode2,
BTR_SEARCH_LEAF | BTR_ESTIMATE,
- &cursor, 0,
- __FILE__, __LINE__, &mtr);
+ &cursor, __FILE__, __LINE__, &mtr);
const rec_t* rec = btr_cur_get_rec(&cursor);
diff --git a/storage/innobase/btr/btr0pcur.cc b/storage/innobase/btr/btr0pcur.cc
index 76d2be211f8..2d538d69d04 100644
--- a/storage/innobase/btr/btr0pcur.cc
+++ b/storage/innobase/btr/btr0pcur.cc
@@ -426,11 +426,7 @@ btr_pcur_t::restore_position(ulint restore_latch_mode, const char *file,
}
btr_pcur_open_with_no_init_func(index, tuple, mode, restore_latch_mode,
- this,
-#ifdef BTR_CUR_HASH_ADAPT
- NULL,
-#endif /* BTR_CUR_HASH_ADAPT */
- file, line, mtr);
+ this, file, line, mtr);
/* Restore the old search mode */
search_mode = old_mode;
diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc
index 866166d218b..81794676af1 100644
--- a/storage/innobase/btr/btr0sea.cc
+++ b/storage/innobase/btr/btr0sea.cc
@@ -1010,8 +1010,6 @@ both have sensible values.
we assume the caller uses his search latch
to protect the record!
@param[out] cursor tree cursor
-@param[in] ahi_latch the adaptive hash index latch being held,
- or NULL
@param[in] mtr mini transaction
@return whether the search succeeded */
bool
@@ -1022,23 +1020,18 @@ btr_search_guess_on_hash(
ulint mode,
ulint latch_mode,
btr_cur_t* cursor,
- rw_lock_t* ahi_latch,
mtr_t* mtr)
{
ulint fold;
index_id_t index_id;
ut_ad(mtr->is_active());
- ut_ad(!ahi_latch || rw_lock_own_flagged(
- ahi_latch, RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
if (!btr_search_enabled) {
return false;
}
ut_ad(!index->is_ibuf());
- ut_ad(!ahi_latch
- || ahi_latch == &btr_search_sys.get_part(*index)->latch);
ut_ad((latch_mode == BTR_SEARCH_LEAF)
|| (latch_mode == BTR_MODIFY_LEAF));
compile_time_assert(ulint{BTR_SEARCH_LEAF} == ulint{RW_S_LATCH});
@@ -1074,25 +1067,18 @@ btr_search_guess_on_hash(
auto part = btr_search_sys.get_part(*index);
const rec_t* rec;
- if (!ahi_latch) {
- rw_lock_s_lock(&part->latch);
+ rw_lock_s_lock(&part->latch);
- if (!btr_search_enabled) {
- goto fail;
- }
- } else {
- ut_ad(btr_search_enabled);
- ut_ad(rw_lock_own(ahi_latch, RW_LOCK_S));
+ if (!btr_search_enabled) {
+ goto fail;
}
rec = static_cast<const rec_t*>(
ha_search_and_get_data(&part->table, fold));
if (!rec) {
- if (!ahi_latch) {
fail:
- rw_lock_s_unlock(&part->latch);
- }
+ rw_lock_s_unlock(&part->latch);
btr_search_failure(info, cursor);
return false;
@@ -1100,59 +1086,51 @@ fail:
buf_block_t* block = buf_pool.block_from_ahi(rec);
- if (!ahi_latch) {
- page_hash_latch* hash_lock = buf_pool.hash_lock_get(
- block->page.id());
- hash_lock->read_lock();
+ page_hash_latch* hash_lock = buf_pool.hash_lock_get(block->page.id());
+ hash_lock->read_lock();
- if (block->page.state() == BUF_BLOCK_REMOVE_HASH) {
- /* Another thread is just freeing the block
- from the LRU list of the buffer pool: do not
- try to access this page. */
- hash_lock->read_unlock();
- goto fail;
- }
+ if (block->page.state() == BUF_BLOCK_REMOVE_HASH) {
+ /* Another thread is just freeing the block
+ from the LRU list of the buffer pool: do not
+ try to access this page. */
+ hash_lock->read_unlock();
+ goto fail;
+ }
- const bool fail = index != block->index
- && index_id == block->index->id;
- ut_a(!fail || block->index->freed());
- ut_ad(block->page.state() == BUF_BLOCK_FILE_PAGE);
- DBUG_ASSERT(fail || block->page.status != buf_page_t::FREED);
+ const bool fail = index != block->index
+ && index_id == block->index->id;
+ ut_a(!fail || block->index->freed());
+ ut_ad(block->page.state() == BUF_BLOCK_FILE_PAGE);
+ DBUG_ASSERT(fail || block->page.status != buf_page_t::FREED);
- buf_block_buf_fix_inc(block, __FILE__, __LINE__);
- hash_lock->read_unlock();
- block->page.set_accessed();
+ buf_block_buf_fix_inc(block, __FILE__, __LINE__);
+ hash_lock->read_unlock();
+ block->page.set_accessed();
- buf_page_make_young_if_needed(&block->page);
- mtr_memo_type_t fix_type;
- if (latch_mode == BTR_SEARCH_LEAF) {
- if (!rw_lock_s_lock_nowait(&block->lock,
- __FILE__, __LINE__)) {
+ buf_page_make_young_if_needed(&block->page);
+ mtr_memo_type_t fix_type;
+ if (latch_mode == BTR_SEARCH_LEAF) {
+ if (!rw_lock_s_lock_nowait(&block->lock, __FILE__, __LINE__)) {
got_no_latch:
- buf_block_buf_fix_dec(block);
- goto fail;
- }
- fix_type = MTR_MEMO_PAGE_S_FIX;
- } else {
- if (!rw_lock_x_lock_func_nowait_inline(
- &block->lock, __FILE__, __LINE__)) {
- goto got_no_latch;
- }
- fix_type = MTR_MEMO_PAGE_X_FIX;
+ buf_block_buf_fix_dec(block);
+ goto fail;
}
- mtr->memo_push(block, fix_type);
+ fix_type = MTR_MEMO_PAGE_S_FIX;
+ } else {
+ if (!rw_lock_x_lock_func_nowait_inline(
+ &block->lock, __FILE__, __LINE__)) {
+ goto got_no_latch;
+ }
+ fix_type = MTR_MEMO_PAGE_X_FIX;
+ }
+ mtr->memo_push(block, fix_type);
- buf_pool.stat.n_page_gets++;
+ buf_pool.stat.n_page_gets++;
- rw_lock_s_unlock(&part->latch);
+ rw_lock_s_unlock(&part->latch);
- buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
- if (UNIV_UNLIKELY(fail)) {
- goto fail_and_release_page;
- }
- } else if (UNIV_UNLIKELY(index != block->index
- && index_id == block->index->id)) {
- ut_a(block->index->freed());
+ buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
+ if (UNIV_UNLIKELY(fail)) {
goto fail_and_release_page;
}
@@ -1161,9 +1139,7 @@ got_no_latch:
ut_ad(block->page.state() == BUF_BLOCK_REMOVE_HASH);
fail_and_release_page:
- if (!ahi_latch) {
- btr_leaf_page_release(block, latch_mode, mtr);
- }
+ btr_leaf_page_release(block, latch_mode, mtr);
btr_search_failure(info, cursor);
return false;
@@ -1181,7 +1157,7 @@ fail_and_release_page:
record to determine if our guess for the cursor position is
right. */
if (index_id != btr_page_get_index_id(block->frame)
- || !btr_search_check_guess(cursor, !!ahi_latch, tuple, mode)) {
+ || !btr_search_check_guess(cursor, 0, tuple, mode)) {
goto fail_and_release_page;
}
@@ -1230,14 +1206,6 @@ fail_and_release_page:
#ifdef UNIV_SEARCH_PERF_STAT
btr_search_n_succ++;
#endif
- /* Increment the page get statistics though we did not really
- fix the page: for user info only */
- ++buf_pool.stat.n_page_gets;
-
- if (!ahi_latch) {
- buf_page_make_young_if_needed(&block->page);
- }
-
return true;
}
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index 67161b27b4c..d0289748be3 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -4276,7 +4276,7 @@ dict_set_corrupted(
btr_cur_search_to_nth_level(sys_index, 0, tuple, PAGE_CUR_LE,
BTR_MODIFY_LEAF,
- &cursor, 0, __FILE__, __LINE__, &mtr);
+ &cursor, __FILE__, __LINE__, &mtr);
if (cursor.low_match == dtuple_get_n_fields(tuple)) {
/* UPDATE SYS_INDEXES SET TYPE=index->type
@@ -4378,7 +4378,7 @@ dict_index_set_merge_threshold(
btr_cur_search_to_nth_level(sys_index, 0, tuple, PAGE_CUR_GE,
BTR_MODIFY_LEAF,
- &cursor, 0, __FILE__, __LINE__, &mtr);
+ &cursor, __FILE__, __LINE__, &mtr);
if (cursor.up_match == dtuple_get_n_fields(tuple)
&& rec_get_n_fields_old(btr_cur_get_rec(&cursor))
diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc
index 15c16fa5707..bd677a6da86 100644
--- a/storage/innobase/fts/fts0fts.cc
+++ b/storage/innobase/fts/fts0fts.cc
@@ -3402,7 +3402,7 @@ fts_add_doc_by_id(
btr_pcur_open_with_no_init(
fts_id_index, tuple, PAGE_CUR_LE, BTR_SEARCH_LEAF,
- &pcur, 0, &mtr);
+ &pcur, &mtr);
/* If we have a match, add the data to doc structure */
if (btr_pcur_get_low_match(&pcur) == 1) {
@@ -3440,7 +3440,7 @@ fts_add_doc_by_id(
btr_pcur_open_with_no_init(
clust_index, clust_ref, PAGE_CUR_LE,
- BTR_SEARCH_LEAF, &clust_pcur, 0, &mtr);
+ BTR_SEARCH_LEAF, &clust_pcur, &mtr);
doc_pcur = &clust_pcur;
clust_rec = btr_pcur_get_rec(&clust_pcur);
diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc
index 1c22aab4d00..7432aab1a29 100644
--- a/storage/innobase/gis/gis0sea.cc
+++ b/storage/innobase/gis/gis0sea.cc
@@ -587,7 +587,7 @@ rtr_pcur_open_low(
}
btr_cur_search_to_nth_level(index, level, tuple, mode, latch_mode,
- btr_cursor, 0, file, line, mtr);
+ btr_cursor, file, line, mtr);
cursor->pos_state = BTR_PCUR_IS_POSITIONED;
cursor->trx_if_known = NULL;
@@ -751,8 +751,7 @@ static void rtr_get_father_node(
/* root split, and search the new root */
btr_cur_search_to_nth_level(
index, level, tuple, PAGE_CUR_RTREE_LOCATE,
- BTR_CONT_MODIFY_TREE, btr_cur, 0,
- __FILE__, __LINE__, mtr);
+ BTR_CONT_MODIFY_TREE, btr_cur, __FILE__, __LINE__, mtr);
} else {
/* btr_validate */
@@ -761,8 +760,7 @@ static void rtr_get_father_node(
btr_cur_search_to_nth_level(
index, level, tuple, PAGE_CUR_RTREE_LOCATE,
- BTR_CONT_MODIFY_TREE, btr_cur, 0,
- __FILE__, __LINE__, mtr);
+ BTR_CONT_MODIFY_TREE, btr_cur, __FILE__, __LINE__, mtr);
rec = btr_cur_get_rec(btr_cur);
n_fields = dtuple_get_n_fields_cmp(tuple);
diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h
index 923eea0daa5..2cc7eb726a4 100644
--- a/storage/innobase/include/btr0cur.h
+++ b/storage/innobase/include/btr0cur.h
@@ -169,56 +169,41 @@ btr_cur_optimistic_latch_leaves(
unsigned line,
mtr_t* mtr);
-/********************************************************************//**
-Searches an index tree and positions a tree cursor on a given level.
+/** Searches an index tree and positions a tree cursor on a given level.
NOTE: n_fields_cmp in tuple must be set so that it cannot be compared
to node pointer page number fields on the upper levels of the tree!
Note that if mode is PAGE_CUR_LE, which is used in inserts, then
cursor->up_match and cursor->low_match both will have sensible values.
-If mode is PAGE_CUR_GE, then up_match will a have a sensible value. */
-dberr_t
-btr_cur_search_to_nth_level_func(
- dict_index_t* index, /*!< in: index */
- ulint level, /*!< in: the tree level of search */
- const dtuple_t* tuple, /*!< in: data tuple; NOTE: n_fields_cmp in
- tuple must be set so that it cannot get
- compared to the node ptr page number field! */
- page_cur_mode_t mode, /*!< in: PAGE_CUR_L, ...;
- NOTE that if the search is made using a unique
- prefix of a record, mode should be PAGE_CUR_LE,
- not PAGE_CUR_GE, as the latter may end up on
- the previous page of the record! Inserts
- should always be made using PAGE_CUR_LE to
- search the position! */
- ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ..., ORed with
- at most one of BTR_INSERT, BTR_DELETE_MARK,
- BTR_DELETE, or BTR_ESTIMATE;
- cursor->left_block is used to store a pointer
- to the left neighbor page, in the cases
- BTR_SEARCH_PREV and BTR_MODIFY_PREV;
- NOTE that if ahi_latch, we might not have a
- cursor page latch, we assume that ahi_latch
- protects the record! */
- btr_cur_t* cursor, /*!< in/out: tree cursor; the cursor page is
- s- or x-latched, but see also above! */
-#ifdef BTR_CUR_HASH_ADAPT
- rw_lock_t* ahi_latch,
- /*!< in: currently held btr_search_latch
- (in RW_S_LATCH mode), or NULL */
-#endif /* BTR_CUR_HASH_ADAPT */
- const char* file, /*!< in: file name */
- unsigned line, /*!< in: line where called */
- mtr_t* mtr, /*!< in/out: mini-transaction */
- ib_uint64_t autoinc = 0);
- /*!< in: PAGE_ROOT_AUTO_INC to be written
- (0 if none) */
-#ifdef BTR_CUR_HASH_ADAPT
-# define btr_cur_search_to_nth_level(i,l,t,m,lm,c,a,fi,li,mtr) \
- btr_cur_search_to_nth_level_func(i,l,t,m,lm,c,a,fi,li,mtr)
-#else /* BTR_CUR_HASH_ADAPT */
-# define btr_cur_search_to_nth_level(i,l,t,m,lm,c,a,fi,li,mtr) \
- btr_cur_search_to_nth_level_func(i,l,t,m,lm,c,fi,li,mtr)
-#endif /* BTR_CUR_HASH_ADAPT */
+If mode is PAGE_CUR_GE, then up_match will a have a sensible value.
+@param index index
+@param level the tree level of search
+@param tuple data tuple; NOTE: n_fields_cmp in tuple must be set so that
+ it cannot get compared to the node ptr page number field!
+@param mode PAGE_CUR_L, NOTE that if the search is made using a unique
+ prefix of a record, mode should be PAGE_CUR_LE, not
+ PAGE_CUR_GE, as the latter may end up on the previous page of
+ the record! Inserts should always be made using PAGE_CUR_LE
+ to search the position!
+@param latch_mode BTR_SEARCH_LEAF, ..., ORed with at most one of BTR_INSERT,
+ BTR_DELETE_MARK, BTR_DELETE, or BTR_ESTIMATE;
+ cursor->left_block is used to store a pointer to the left
+ neighbor page, in the cases BTR_SEARCH_PREV and
+ BTR_MODIFY_PREV; NOTE that if ahi_latch, we might not have a
+ cursor page latch, we assume that ahi_latch protects the
+ record!
+@param cursor tree cursor; the cursor page is s- or x-latched, but see also
+ above!
+@param file file name
+@param line line where called
+@param mtr mini-transaction
+@param autoinc PAGE_ROOT_AUTO_INC to be written (0 if none)
+@return DB_SUCCESS on success or error code otherwise */
+dberr_t btr_cur_search_to_nth_level(dict_index_t *index, ulint level,
+ const dtuple_t *tuple,
+ page_cur_mode_t mode, ulint latch_mode,
+ btr_cur_t *cursor, const char *file,
+ unsigned line, mtr_t *mtr,
+ ib_uint64_t autoinc= 0);
/*****************************************************************//**
Opens a cursor at either end of an index.
diff --git a/storage/innobase/include/btr0pcur.h b/storage/innobase/include/btr0pcur.h
index e50a97a6b1d..584cc143359 100644
--- a/storage/innobase/include/btr0pcur.h
+++ b/storage/innobase/include/btr0pcur.h
@@ -116,41 +116,30 @@ btr_pcur_open_low(
mtr_t* mtr); /*!< in: mtr */
#define btr_pcur_open(i,t,md,l,c,m) \
btr_pcur_open_low(i,0,t,md,l,c,__FILE__,__LINE__,0,m)
-/**************************************************************//**
-Opens an persistent cursor to an index tree without initializing the
-cursor. */
+/** Opens an persistent cursor to an index tree without initializing the
+cursor.
+@param index index
+@param tuple tuple on which search done
+@param mode PAGE_CUR_L, ...; NOTE that if the search is made using a
+ unique prefix of a record, mode should be PAGE_CUR_LE, not
+ PAGE_CUR_GE, as the latter may end up on the previous page of
+ the record!
+@param latch_mode BTR_SEARCH_LEAF, ...; NOTE that if ahi_latch then we might
+ not acquire a cursor page latch, but assume that the
+ ahi_latch protects the record!
+@param cursor memory buffer for persistent cursor
+@param file file name
+@param line line where called
+@param mtr mtr
+@return DB_SUCCESS on success or error code otherwise. */
UNIV_INLINE
-dberr_t
-btr_pcur_open_with_no_init_func(
-/*============================*/
- dict_index_t* index, /*!< in: index */
- const dtuple_t* tuple, /*!< in: tuple on which search done */
- page_cur_mode_t mode, /*!< in: PAGE_CUR_L, ...;
- NOTE that if the search is made using a unique
- prefix of a record, mode should be
- PAGE_CUR_LE, not PAGE_CUR_GE, as the latter
- may end up on the previous page of the
- record! */
- ulint latch_mode,/*!< in: BTR_SEARCH_LEAF, ...;
- NOTE that if ahi_latch then we might not
- acquire a cursor page latch, but assume
- that the ahi_latch protects the record! */
- btr_pcur_t* cursor, /*!< in: memory buffer for persistent cursor */
-#ifdef BTR_CUR_HASH_ADAPT
- rw_lock_t* ahi_latch,
- /*!< in: adaptive hash index latch held
- by the caller, or NULL if none */
-#endif /* BTR_CUR_HASH_ADAPT */
- const char* file, /*!< in: file name */
- unsigned line, /*!< in: line where called */
- mtr_t* mtr); /*!< in: mtr */
-#ifdef BTR_CUR_HASH_ADAPT
-# define btr_pcur_open_with_no_init(ix,t,md,l,cur,ahi,m) \
- btr_pcur_open_with_no_init_func(ix,t,md,l,cur,ahi,__FILE__,__LINE__,m)
-#else /* BTR_CUR_HASH_ADAPT */
-# define btr_pcur_open_with_no_init(ix,t,md,l,cur,ahi,m) \
+dberr_t btr_pcur_open_with_no_init_func(dict_index_t *index,
+ const dtuple_t *tuple,
+ page_cur_mode_t mode, ulint latch_mode,
+ btr_pcur_t *cursor, const char *file,
+ unsigned line, mtr_t *mtr);
+# define btr_pcur_open_with_no_init(ix,t,md,l,cur,m) \
btr_pcur_open_with_no_init_func(ix,t,md,l,cur,__FILE__,__LINE__,m)
-#endif /* BTR_CUR_HASH_ADAPT */
/*****************************************************************//**
Opens a persistent cursor at either end of an index. */
diff --git a/storage/innobase/include/btr0pcur.inl b/storage/innobase/include/btr0pcur.inl
index d93da475a1f..05f61b903ff 100644
--- a/storage/innobase/include/btr0pcur.inl
+++ b/storage/innobase/include/btr0pcur.inl
@@ -438,11 +438,8 @@ btr_pcur_open_low(
ut_ad(!dict_index_is_spatial(index));
- err = btr_cur_search_to_nth_level_func(
+ err = btr_cur_search_to_nth_level(
index, level, tuple, mode, latch_mode, btr_cursor,
-#ifdef BTR_CUR_HASH_ADAPT
- NULL,
-#endif /* BTR_CUR_HASH_ADAPT */
file, line, mtr, autoinc);
if (UNIV_UNLIKELY(err != DB_SUCCESS)) {
@@ -462,34 +459,28 @@ btr_pcur_open_low(
return(err);
}
-/**************************************************************//**
-Opens an persistent cursor to an index tree without initializing the
-cursor. */
+/** Opens an persistent cursor to an index tree without initializing the
+cursor.
+@param index index
+@param tuple tuple on which search done
+@param mode PAGE_CUR_L, ...; NOTE that if the search is made using a
+ unique prefix of a record, mode should be PAGE_CUR_LE, not
+ PAGE_CUR_GE, as the latter may end up on the previous page of
+ the record!
+@param latch_mode BTR_SEARCH_LEAF, ...; NOTE that if ahi_latch then we might
+ not acquire a cursor page latch, but assume that the
+ ahi_latch protects the record!
+@param cursor memory buffer for persistent cursor
+@param file file name
+@param line line where called
+@param mtr mtr
+@return DB_SUCCESS on success or error code otherwise. */
UNIV_INLINE
-dberr_t
-btr_pcur_open_with_no_init_func(
-/*============================*/
- dict_index_t* index, /*!< in: index */
- const dtuple_t* tuple, /*!< in: tuple on which search done */
- page_cur_mode_t mode, /*!< in: PAGE_CUR_L, ...;
- NOTE that if the search is made using a unique
- prefix of a record, mode should be
- PAGE_CUR_LE, not PAGE_CUR_GE, as the latter
- may end up on the previous page of the
- record! */
- ulint latch_mode,/*!< in: BTR_SEARCH_LEAF, ...;
- NOTE that if ahi_latch then we might not
- acquire a cursor page latch, but assume
- that the ahi_latch protects the record! */
- btr_pcur_t* cursor, /*!< in: memory buffer for persistent cursor */
-#ifdef BTR_CUR_HASH_ADAPT
- rw_lock_t* ahi_latch,
- /*!< in: adaptive hash index latch held
- by the caller, or NULL if none */
-#endif /* BTR_CUR_HASH_ADAPT */
- const char* file, /*!< in: file name */
- unsigned line, /*!< in: line where called */
- mtr_t* mtr) /*!< in: mtr */
+dberr_t btr_pcur_open_with_no_init_func(dict_index_t *index,
+ const dtuple_t *tuple,
+ page_cur_mode_t mode, ulint latch_mode,
+ btr_pcur_t *cursor, const char *file,
+ unsigned line, mtr_t *mtr)
{
btr_cur_t* btr_cursor;
dberr_t err = DB_SUCCESS;
@@ -501,11 +492,8 @@ btr_pcur_open_with_no_init_func(
btr_cursor = btr_pcur_get_btr_cur(cursor);
- err = btr_cur_search_to_nth_level_func(
+ err = btr_cur_search_to_nth_level(
index, 0, tuple, mode, latch_mode, btr_cursor,
-#ifdef BTR_CUR_HASH_ADAPT
- ahi_latch,
-#endif /* BTR_CUR_HASH_ADAPT */
file, line, mtr);
cursor->pos_state = BTR_PCUR_IS_POSITIONED;
diff --git a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h
index af01b9a9fba..be0dc69b4cb 100644
--- a/storage/innobase/include/btr0sea.h
+++ b/storage/innobase/include/btr0sea.h
@@ -77,7 +77,6 @@ btr_search_guess_on_hash(
ulint mode,
ulint latch_mode,
btr_cur_t* cursor,
- rw_lock_t* ahi_latch,
mtr_t* mtr);
/** Move or delete hash entries for moved records, usually in a page split.
diff --git a/storage/innobase/include/trx0rec.h b/storage/innobase/include/trx0rec.h
index 665c987adff..66b2220a457 100644
--- a/storage/innobase/include/trx0rec.h
+++ b/storage/innobase/include/trx0rec.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2020, MariaDB Corporation.
+Copyright (c) 2017, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -136,30 +136,6 @@ trx_undo_update_rec_get_update(
mem_heap_t* heap, /*!< in: memory heap from which the memory
needed is allocated */
upd_t** upd); /*!< out, own: update vector */
-/*******************************************************************//**
-Builds a partial row from an update undo log record, for purge.
-It contains the columns which occur as ordering in any index of the table.
-Any missing columns are indicated by col->mtype == DATA_MISSING.
-@return pointer to remaining part of undo record */
-byte*
-trx_undo_rec_get_partial_row(
-/*=========================*/
- const byte* ptr, /*!< in: remaining part in update undo log
- record of a suitable type, at the start of
- the stored index columns;
- NOTE that this copy of the undo log record must
- be preserved as long as the partial row is
- used, as we do NOT copy the data in the
- record! */
- dict_index_t* index, /*!< in: clustered index */
- const upd_t* update, /*!< in: updated columns */
- dtuple_t** row, /*!< out, own: partial row */
- ibool ignore_prefix, /*!< in: flag to indicate if we
- expect blob prefixes in undo. Used
- only in the assertion. */
- mem_heap_t* heap) /*!< in: memory heap from which the memory
- needed is allocated */
- MY_ATTRIBUTE((nonnull, warn_unused_result));
/** Report a RENAME TABLE operation.
@param[in,out] trx transaction
@param[in] table table that is being renamed
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index 46fcb5d6ef7..18c56031e29 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -1135,7 +1135,7 @@ row_ins_foreign_check_on_constraint(
tmp_heap);
btr_pcur_open_with_no_init(clust_index, ref,
PAGE_CUR_LE, BTR_SEARCH_LEAF,
- cascade->pcur, 0, mtr);
+ cascade->pcur, mtr);
clust_rec = btr_pcur_get_rec(cascade->pcur);
clust_block = btr_pcur_get_block(cascade->pcur);
@@ -2945,7 +2945,7 @@ row_ins_sec_index_entry_low(
err = btr_cur_search_to_nth_level(
index, 0, entry, PAGE_CUR_RTREE_INSERT,
search_mode,
- &cursor, 0, __FILE__, __LINE__, &mtr);
+ &cursor, __FILE__, __LINE__, &mtr);
if (mode == BTR_MODIFY_LEAF && rtr_info.mbr_adj) {
mtr_commit(&mtr);
@@ -2964,7 +2964,7 @@ row_ins_sec_index_entry_low(
err = btr_cur_search_to_nth_level(
index, 0, entry, PAGE_CUR_RTREE_INSERT,
search_mode,
- &cursor, 0, __FILE__, __LINE__, &mtr);
+ &cursor, __FILE__, __LINE__, &mtr);
mode = BTR_MODIFY_TREE;
}
@@ -2976,7 +2976,7 @@ row_ins_sec_index_entry_low(
err = btr_cur_search_to_nth_level(
index, 0, entry, PAGE_CUR_LE,
search_mode,
- &cursor, 0, __FILE__, __LINE__, &mtr);
+ &cursor, __FILE__, __LINE__, &mtr);
}
if (err != DB_SUCCESS) {
@@ -3070,7 +3070,7 @@ row_ins_sec_index_entry_low(
index, 0, entry, PAGE_CUR_LE,
(search_mode
& ~(BTR_INSERT | BTR_IGNORE_SEC_UNIQUE)),
- &cursor, 0, __FILE__, __LINE__, &mtr);
+ &cursor, __FILE__, __LINE__, &mtr);
}
if (row_ins_must_modify_rec(&cursor)) {
diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc
index 42d37473755..51b40876f65 100644
--- a/storage/innobase/row/row0log.cc
+++ b/storage/innobase/row/row0log.cc
@@ -3358,7 +3358,7 @@ row_log_apply_op_low(
has_index_lock
? BTR_MODIFY_TREE
: BTR_MODIFY_LEAF,
- &cursor, 0, __FILE__, __LINE__,
+ &cursor, __FILE__, __LINE__,
&mtr);
ut_ad(dict_index_get_n_unique(index) > 0);
@@ -3407,7 +3407,7 @@ row_log_apply_op_low(
index->set_modified(mtr);
btr_cur_search_to_nth_level(
index, 0, entry, PAGE_CUR_LE,
- BTR_MODIFY_TREE, &cursor, 0,
+ BTR_MODIFY_TREE, &cursor,
__FILE__, __LINE__, &mtr);
/* No other thread than the current one
@@ -3510,7 +3510,7 @@ insert_the_rec:
index->set_modified(mtr);
btr_cur_search_to_nth_level(
index, 0, entry, PAGE_CUR_LE,
- BTR_MODIFY_TREE, &cursor, 0,
+ BTR_MODIFY_TREE, &cursor,
__FILE__, __LINE__, &mtr);
}
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index cf1aff37039..8ec7cd91975 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -157,7 +157,7 @@ public:
btr_cur_search_to_nth_level(m_index, 0, dtuple,
PAGE_CUR_RTREE_INSERT,
BTR_MODIFY_LEAF, &ins_cur,
- 0, __FILE__, __LINE__,
+ __FILE__, __LINE__,
&mtr);
/* It need to update MBR in parent entry,
@@ -173,7 +173,7 @@ public:
btr_cur_search_to_nth_level(
m_index, 0, dtuple,
PAGE_CUR_RTREE_INSERT,
- BTR_MODIFY_TREE, &ins_cur, 0,
+ BTR_MODIFY_TREE, &ins_cur,
__FILE__, __LINE__, &mtr);
}
@@ -196,8 +196,7 @@ public:
m_index, 0, dtuple,
PAGE_CUR_RTREE_INSERT,
BTR_MODIFY_TREE,
- &ins_cur, 0,
- __FILE__, __LINE__, &mtr);
+ &ins_cur, __FILE__, __LINE__, &mtr);
error = btr_cur_pessimistic_insert(
flag, &ins_cur, &ins_offsets,
diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc
index a268317c7c7..74bbc61df52 100644
--- a/storage/innobase/row/row0purge.cc
+++ b/storage/innobase/row/row0purge.cc
@@ -865,6 +865,138 @@ skip_secondaries:
row_purge_upd_exist_or_extern_func(node,undo_rec)
#endif /* UNIV_DEBUG */
+/** Build a partial row from an update undo log record for purge.
+Any columns which occur as ordering in any index of the table are present.
+Any missing columns are indicated by col->mtype == DATA_MISSING.
+
+@param ptr remaining part of the undo log record
+@param index clustered index
+@param node purge node
+@return pointer to remaining part of undo record */
+static byte *row_purge_get_partial(const byte *ptr, const dict_index_t &index,
+ purge_node_t *node)
+{
+ bool first_v_col= true;
+ bool is_undo_log= true;
+
+ ut_ad(index.is_primary());
+ ut_ad(index.n_uniq == node->ref->n_fields);
+
+ node->row= dtuple_create_with_vcol(node->heap, index.table->n_cols,
+ index.table->n_v_cols);
+
+ /* Mark all columns in the row uninitialized, so that
+ we can distinguish missing fields from fields that are SQL NULL. */
+ for (ulint i= 0; i < index.table->n_cols; i++)
+ node->row->fields[i].type.mtype= DATA_MISSING;
+
+ dtuple_init_v_fld(node->row);
+
+ for (const upd_field_t *uf= node->update->fields, *const ue=
+ node->update->fields + node->update->n_fields; uf != ue; uf++)
+ {
+ if (!uf->old_v_val)
+ {
+ const dict_col_t &c= *dict_index_get_nth_col(&index, uf->field_no);
+ if (!c.is_dropped())
+ node->row->fields[c.ind]= uf->new_val;
+ }
+ }
+
+ const byte *end_ptr= ptr + mach_read_from_2(ptr);
+ ptr+= 2;
+
+ while (ptr != end_ptr)
+ {
+ dfield_t *dfield;
+ const byte *field;
+ const dict_col_t *col;
+ uint32_t len, orig_len, field_no= mach_read_next_compressed(&ptr);
+
+ if (field_no >= REC_MAX_N_FIELDS)
+ {
+ ptr= trx_undo_read_v_idx(index.table, ptr, first_v_col, &is_undo_log,
+ &field_no);
+ first_v_col= false;
+
+ ptr= trx_undo_rec_get_col_val(ptr, &field, &len, &orig_len);
+
+ if (field_no == FIL_NULL)
+ continue; /* there no longer is an index on the virtual column */
+
+ dict_v_col_t *vcol= dict_table_get_nth_v_col(index.table, field_no);
+ col =&vcol->m_col;
+ dfield= dtuple_get_nth_v_field(node->row, vcol->v_pos);
+ dict_col_copy_type(&vcol->m_col, &dfield->type);
+ }
+ else
+ {
+ ptr= trx_undo_rec_get_col_val(ptr, &field, &len, &orig_len);
+ col= dict_index_get_nth_col(&index, field_no);
+ if (col->is_dropped())
+ continue;
+ dfield= dtuple_get_nth_field(node->row, col->ind);
+ ut_ad(dfield->type.mtype == DATA_MISSING ||
+ dict_col_type_assert_equal(col, &dfield->type));
+ ut_ad(dfield->type.mtype == DATA_MISSING ||
+ dfield->len == len ||
+ (len != UNIV_SQL_NULL && len >= UNIV_EXTERN_STORAGE_FIELD));
+ dict_col_copy_type(dict_table_get_nth_col(index.table, col->ind),
+ &dfield->type);
+ }
+
+ dfield_set_data(dfield, field, len);
+
+ if (len == UNIV_SQL_NULL || len < UNIV_EXTERN_STORAGE_FIELD)
+ continue;
+
+ spatial_status_t spatial_status= static_cast<spatial_status_t>
+ ((len & SPATIAL_STATUS_MASK) >> SPATIAL_STATUS_SHIFT);
+ len&= ~SPATIAL_STATUS_MASK;
+
+ /* Keep compatible with 5.7.9 format. */
+ if (spatial_status == SPATIAL_UNKNOWN)
+ spatial_status= dict_col_get_spatial_status(col);
+
+ switch (UNIV_EXPECT(spatial_status, SPATIAL_NONE)) {
+ case SPATIAL_ONLY:
+ ut_ad(len - UNIV_EXTERN_STORAGE_FIELD == DATA_MBR_LEN);
+ dfield_set_len(dfield, len - UNIV_EXTERN_STORAGE_FIELD);
+ break;
+
+ case SPATIAL_MIXED:
+ dfield_set_len(dfield, len - UNIV_EXTERN_STORAGE_FIELD - DATA_MBR_LEN);
+ break;
+
+ default:
+ dfield_set_len(dfield, len - UNIV_EXTERN_STORAGE_FIELD);
+ break;
+ }
+
+ dfield_set_ext(dfield);
+ dfield_set_spatial_status(dfield, spatial_status);
+
+ if (!col->ord_part || spatial_status == SPATIAL_ONLY ||
+ node->rec_type == TRX_UNDO_UPD_DEL_REC)
+ continue;
+ /* If the prefix of this BLOB column is indexed, ensure that enough
+ prefix is stored in the undo log record. */
+ ut_a(dfield_get_len(dfield) >= BTR_EXTERN_FIELD_REF_SIZE);
+ ut_a(dict_table_has_atomic_blobs(index.table) ||
+ dfield_get_len(dfield) >=
+ REC_ANTELOPE_MAX_INDEX_COL_LEN + BTR_EXTERN_FIELD_REF_SIZE);
+ }
+
+ for (ulint i= 0; i < index.n_uniq; i++)
+ {
+ dfield_t &field= node->row->fields[index.fields[i].col->ind];
+ if (field.type.mtype == DATA_MISSING)
+ field= node->ref->fields[i];
+ }
+
+ return const_cast<byte*>(ptr);
+}
+
/** Parses the row reference and other info in a modify undo log record.
@param[in] node row undo node
@param[in] undo_rec record to purge
@@ -1008,10 +1140,7 @@ err_exit:
if (!(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
ut_ad(!(node->update->info_bits & REC_INFO_MIN_REC_FLAG));
- ptr = trx_undo_rec_get_partial_row(
- ptr, clust_index, node->update, &node->row,
- type == TRX_UNDO_UPD_DEL_REC,
- node->heap);
+ ptr = row_purge_get_partial(ptr, *clust_index, node);
} else if (node->update->info_bits & REC_INFO_MIN_REC_FLAG) {
node->ref = &trx_undo_metadata;
}
diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc
index 1dae2edbc01..9c11898f70c 100644
--- a/storage/innobase/row/row0sel.cc
+++ b/storage/innobase/row/row0sel.cc
@@ -988,8 +988,7 @@ row_sel_get_clust_rec(
index = dict_table_get_first_index(plan->table);
btr_pcur_open_with_no_init(index, plan->clust_ref, PAGE_CUR_LE,
- BTR_SEARCH_LEAF, &plan->clust_pcur,
- 0, mtr);
+ BTR_SEARCH_LEAF, &plan->clust_pcur, mtr);
clust_rec = btr_pcur_get_rec(&(plan->clust_pcur));
@@ -1385,8 +1384,7 @@ row_sel_open_pcur(
/* Open pcur to the index */
btr_pcur_open_with_no_init(index, plan->tuple, plan->mode,
- BTR_SEARCH_LEAF, &plan->pcur,
- NULL, mtr);
+ BTR_SEARCH_LEAF, &plan->pcur, mtr);
} else {
/* Open the cursor to the start or the end of the index
(FALSE: no init) */
@@ -3332,7 +3330,7 @@ Row_sel_get_clust_rec_for_mysql::operator()(
btr_pcur_open_with_no_init(clust_index, prebuilt->clust_ref,
PAGE_CUR_LE, BTR_SEARCH_LEAF,
- prebuilt->clust_pcur, 0, mtr);
+ prebuilt->clust_pcur, mtr);
clust_rec = btr_pcur_get_rec(prebuilt->clust_pcur);
@@ -3914,15 +3912,12 @@ row_sel_try_search_shortcut_for_mysql(
ut_ad(dict_index_is_clust(index));
ut_ad(!prebuilt->templ_contains_blob);
- rw_lock_t* ahi_latch = btr_search_sys.get_latch(*index);
- rw_lock_s_lock(ahi_latch);
btr_pcur_open_with_no_init(index, search_tuple, PAGE_CUR_GE,
- BTR_SEARCH_LEAF, pcur, ahi_latch, mtr);
+ BTR_SEARCH_LEAF, pcur, mtr);
rec = btr_pcur_get_rec(pcur);
if (!page_rec_is_user_rec(rec) || rec_is_metadata(rec, *index)) {
retry:
- rw_lock_s_unlock(ahi_latch);
return(SEL_RETRY);
}
@@ -3932,7 +3927,6 @@ retry:
if (btr_pcur_get_up_match(pcur) < dtuple_get_n_fields(search_tuple)) {
exhausted:
- rw_lock_s_unlock(ahi_latch);
return(SEL_EXHAUSTED);
}
@@ -3956,7 +3950,6 @@ exhausted:
*out_rec = rec;
- rw_lock_s_unlock(ahi_latch);
return(SEL_FOUND);
}
#endif /* BTR_CUR_HASH_ADAPT */
@@ -4715,8 +4708,7 @@ wait_table_again:
}
err = btr_pcur_open_with_no_init(index, search_tuple, mode,
- BTR_SEARCH_LEAF,
- pcur, 0, &mtr);
+ BTR_SEARCH_LEAF, pcur, &mtr);
if (err != DB_SUCCESS) {
rec = NULL;
diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc
index 834ad29a0e9..33a3962047f 100644
--- a/storage/innobase/trx/trx0rec.cc
+++ b/storage/innobase/trx/trx0rec.cc
@@ -1664,183 +1664,6 @@ trx_undo_update_rec_get_update(
return(const_cast<byte*>(ptr));
}
-/*******************************************************************//**
-Builds a partial row from an update undo log record, for purge.
-It contains the columns which occur as ordering in any index of the table.
-Any missing columns are indicated by col->mtype == DATA_MISSING.
-@return pointer to remaining part of undo record */
-byte*
-trx_undo_rec_get_partial_row(
-/*=========================*/
- const byte* ptr, /*!< in: remaining part in update undo log
- record of a suitable type, at the start of
- the stored index columns;
- NOTE that this copy of the undo log record must
- be preserved as long as the partial row is
- used, as we do NOT copy the data in the
- record! */
- dict_index_t* index, /*!< in: clustered index */
- const upd_t* update, /*!< in: updated columns */
- dtuple_t** row, /*!< out, own: partial row */
- ibool ignore_prefix, /*!< in: flag to indicate if we
- expect blob prefixes in undo. Used
- only in the assertion. */
- mem_heap_t* heap) /*!< in: memory heap from which the memory
- needed is allocated */
-{
- const byte* end_ptr;
- bool first_v_col = true;
- bool is_undo_log = true;
-
- ut_ad(index->is_primary());
-
- *row = dtuple_create_with_vcol(
- heap, dict_table_get_n_cols(index->table),
- dict_table_get_n_v_cols(index->table));
-
- /* Mark all columns in the row uninitialized, so that
- we can distinguish missing fields from fields that are SQL NULL. */
- for (ulint i = 0; i < dict_table_get_n_cols(index->table); i++) {
- dfield_get_type(dtuple_get_nth_field(*row, i))
- ->mtype = DATA_MISSING;
- }
-
- dtuple_init_v_fld(*row);
-
- for (const upd_field_t* uf = update->fields, * const ue
- = update->fields + update->n_fields;
- uf != ue; uf++) {
- if (uf->old_v_val) {
- continue;
- }
- const dict_col_t& c = *dict_index_get_nth_col(index,
- uf->field_no);
- if (!c.is_dropped()) {
- *dtuple_get_nth_field(*row, c.ind) = uf->new_val;
- }
- }
-
- end_ptr = ptr + mach_read_from_2(ptr);
- ptr += 2;
-
- while (ptr != end_ptr) {
- dfield_t* dfield;
- const byte* field;
- uint32_t field_no;
- const dict_col_t* col;
- uint32_t len, orig_len;
-
- field_no = mach_read_next_compressed(&ptr);
-
- const bool is_virtual = (field_no >= REC_MAX_N_FIELDS);
-
- if (is_virtual) {
- ptr = trx_undo_read_v_idx(
- index->table, ptr, first_v_col, &is_undo_log,
- &field_no);
- first_v_col = false;
- }
-
- ptr = trx_undo_rec_get_col_val(ptr, &field, &len, &orig_len);
-
- /* This column could be dropped or no longer indexed */
- if (field_no == FIL_NULL) {
- ut_ad(is_virtual);
- continue;
- }
-
- if (is_virtual) {
- dict_v_col_t* vcol = dict_table_get_nth_v_col(
- index->table, field_no);
- col = &vcol->m_col;
- dfield = dtuple_get_nth_v_field(*row, vcol->v_pos);
- dict_col_copy_type(
- &vcol->m_col,
- dfield_get_type(dfield));
- } else {
- col = dict_index_get_nth_col(index, field_no);
-
- if (col->is_dropped()) {
- continue;
- }
-
- dfield = dtuple_get_nth_field(*row, col->ind);
- ut_ad(dfield->type.mtype == DATA_MISSING
- || dict_col_type_assert_equal(col,
- &dfield->type));
- ut_ad(dfield->type.mtype == DATA_MISSING
- || dfield->len == len
- || (len != UNIV_SQL_NULL
- && len >= UNIV_EXTERN_STORAGE_FIELD));
- dict_col_copy_type(col, dfield_get_type(dfield));
- }
-
- dfield_set_data(dfield, field, len);
-
- if (len != UNIV_SQL_NULL
- && len >= UNIV_EXTERN_STORAGE_FIELD) {
- spatial_status_t spatial_status;
-
- /* Decode spatial status. */
- spatial_status = static_cast<spatial_status_t>(
- (len & SPATIAL_STATUS_MASK)
- >> SPATIAL_STATUS_SHIFT);
- len &= ~SPATIAL_STATUS_MASK;
-
- /* Keep compatible with 5.7.9 format. */
- if (spatial_status == SPATIAL_UNKNOWN) {
- spatial_status =
- dict_col_get_spatial_status(col);
- }
-
- switch (spatial_status) {
- case SPATIAL_ONLY:
- ut_ad(len - UNIV_EXTERN_STORAGE_FIELD
- == DATA_MBR_LEN);
- dfield_set_len(
- dfield,
- len - UNIV_EXTERN_STORAGE_FIELD);
- break;
-
- case SPATIAL_MIXED:
- dfield_set_len(
- dfield,
- len - UNIV_EXTERN_STORAGE_FIELD
- - DATA_MBR_LEN);
- break;
-
- case SPATIAL_NONE:
- dfield_set_len(
- dfield,
- len - UNIV_EXTERN_STORAGE_FIELD);
- break;
-
- case SPATIAL_UNKNOWN:
- ut_ad(0);
- break;
- }
-
- dfield_set_ext(dfield);
- dfield_set_spatial_status(dfield, spatial_status);
-
- /* If the prefix of this column is indexed,
- ensure that enough prefix is stored in the
- undo log record. */
- if (!ignore_prefix && col->ord_part
- && spatial_status != SPATIAL_ONLY) {
- ut_a(dfield_get_len(dfield)
- >= BTR_EXTERN_FIELD_REF_SIZE);
- ut_a(dict_table_has_atomic_blobs(index->table)
- || dfield_get_len(dfield)
- >= REC_ANTELOPE_MAX_INDEX_COL_LEN
- + BTR_EXTERN_FIELD_REF_SIZE);
- }
- }
- }
-
- return(const_cast<byte*>(ptr));
-}
-
/** Report a RENAME TABLE operation.
@param[in,out] trx transaction
@param[in] table table that is being renamed
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index ffb514a97c4..d8c720da604 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -561,8 +561,10 @@ void trx_disconnect_prepared(trx_t *trx)
ut_ad(trx->mysql_thd);
ut_ad(!trx->mysql_log_file_name);
trx->read_view.close();
+ trx_sys.trx_list.freeze();
trx->is_recovered= true;
trx->mysql_thd= NULL;
+ trx_sys.trx_list.unfreeze();
/* todo/fixme: suggest to do it at innodb prepare */
trx->will_lock= false;
trx_sys.rw_trx_hash.put_pins(trx);
diff --git a/storage/maria/aria_ftdump.c b/storage/maria/aria_ftdump.c
index 8526f5fa74a..677d0221529 100644
--- a/storage/maria/aria_ftdump.c
+++ b/storage/maria/aria_ftdump.c
@@ -120,11 +120,7 @@ int main(int argc,char *argv[])
if (subkeys.i >= 0)
weight= subkeys.f;
-#ifdef HAVE_SNPRINTF
snprintf(buf,MAX_LEN,"%.*s",(int) keylen,info->lastkey_buff+1);
-#else
- sprintf(buf,"%.*s",(int) keylen,info->lastkey_buff+1);
-#endif
my_casedn_str(default_charset_info,buf);
total++;
lengths[keylen]++;
diff --git a/storage/myisam/myisam_ftdump.c b/storage/myisam/myisam_ftdump.c
index cc28d4a59e5..f2dc19c520a 100644
--- a/storage/myisam/myisam_ftdump.c
+++ b/storage/myisam/myisam_ftdump.c
@@ -118,11 +118,7 @@ int main(int argc,char *argv[])
if (subkeys.i >= 0)
weight= subkeys.f;
-#ifdef HAVE_SNPRINTF
snprintf(buf,MAX_LEN,"%.*s",(int) keylen,info->lastkey+1);
-#else
- sprintf(buf,"%.*s",(int) keylen,info->lastkey+1);
-#endif
my_casedn_str(default_charset_info,buf);
total++;
lengths[keylen]++;