diff options
Diffstat (limited to 'storage/innobase/btr/btr0cur.cc')
-rw-r--r-- | storage/innobase/btr/btr0cur.cc | 108 |
1 files changed, 94 insertions, 14 deletions
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 1a4eb347cd2..db23b75edf1 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -3,6 +3,7 @@ Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2015, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -347,7 +348,7 @@ 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. */ UNIV_INTERN -void +dberr_t btr_cur_search_to_nth_level( /*========================*/ dict_index_t* index, /*!< in: index */ @@ -397,6 +398,7 @@ btr_cur_search_to_nth_level( page_cur_t* page_cursor; btr_op_t btr_op; ulint root_height = 0; /* remove warning */ + dberr_t err = DB_SUCCESS; #ifdef BTR_CUR_ADAPT btr_search_t* info; @@ -513,7 +515,7 @@ btr_cur_search_to_nth_level( || mode != PAGE_CUR_LE); btr_cur_n_sea++; - return; + return err; } # endif /* BTR_CUR_HASH_ADAPT */ #endif /* BTR_CUR_ADAPT */ @@ -609,7 +611,21 @@ search_loop: retry_page_get: block = buf_page_get_gen( space, zip_size, page_no, rw_latch, guess, buf_mode, - file, line, mtr); + file, line, mtr, &err); + + if (err != DB_SUCCESS) { + if (err == DB_DECRYPTION_FAILED) { + ib_push_warning((void *)NULL, + DB_DECRYPTION_FAILED, + "Table %s is encrypted but encryption service or" + " used key_id is not available. " + " Can't continue reading table.", + index->table->name); + index->table->is_encrypted = true; + } + + goto func_exit; + } if (block == NULL) { /* This must be a search to perform an insert/delete @@ -822,12 +838,14 @@ func_exit: rw_lock_s_lock(&btr_search_latch); } + + return err; } /*****************************************************************//** Opens a cursor at either end of an index. */ UNIV_INTERN -void +dberr_t btr_cur_open_at_index_side_func( /*============================*/ bool from_left, /*!< in: true if open to the low end, @@ -853,6 +871,8 @@ btr_cur_open_at_index_side_func( mem_heap_t* heap = NULL; ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint* offsets = offsets_; + dberr_t err = DB_SUCCESS; + rec_offs_init(offsets_); estimate = latch_mode & BTR_ESTIMATE; @@ -890,11 +910,26 @@ btr_cur_open_at_index_side_func( height = ULINT_UNDEFINED; for (;;) { - buf_block_t* block; - page_t* page; + buf_block_t* block=NULL; + page_t* page=NULL; + block = buf_page_get_gen(space, zip_size, page_no, RW_NO_LATCH, NULL, BUF_GET, - file, line, mtr); + file, line, mtr, &err); + if (err != DB_SUCCESS) { + if (err == DB_DECRYPTION_FAILED) { + ib_push_warning((void *)NULL, + DB_DECRYPTION_FAILED, + "Table %s is encrypted but encryption service or" + " used key_id is not available. " + " Can't continue reading table.", + index->table->name); + index->table->is_encrypted = true; + } + + goto exit_loop; + } + page = buf_block_get_frame(block); ut_ad(fil_page_get_type(page) == FIL_PAGE_INDEX); ut_ad(index->id == btr_page_get_index_id(page)); @@ -979,9 +1014,12 @@ btr_cur_open_at_index_side_func( page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets); } + exit_loop: if (heap) { mem_heap_free(heap); } + + return err; } /**********************************************************************//** @@ -1029,10 +1067,25 @@ btr_cur_open_at_rnd_pos_func( for (;;) { buf_block_t* block; page_t* page; + dberr_t err=DB_SUCCESS; block = buf_page_get_gen(space, zip_size, page_no, RW_NO_LATCH, NULL, BUF_GET, - file, line, mtr); + file, line, mtr, &err); + + if (err != DB_SUCCESS) { + if (err == DB_DECRYPTION_FAILED) { + ib_push_warning((void *)NULL, + DB_DECRYPTION_FAILED, + "Table %s is encrypted but encryption service or" + " used key_id is not available. " + " Can't continue reading table.", + index->table->name); + index->table->is_encrypted = true; + } + goto exit_loop; + } + page = buf_block_get_frame(block); ut_ad(fil_page_get_type(page) == FIL_PAGE_INDEX); ut_ad(index->id == btr_page_get_index_id(page)); @@ -1066,6 +1119,7 @@ btr_cur_open_at_rnd_pos_func( page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets); } + exit_loop: if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -1617,15 +1671,24 @@ btr_cur_pessimistic_insert( btr_cur_get_page_zip(cursor), thr_get_trx(thr)->id, mtr); } - if (!page_rec_is_infimum(btr_cur_get_rec(cursor)) - || btr_page_get_prev( - buf_block_get_frame( - btr_cur_get_block(cursor)), mtr) - == FIL_NULL) { + + if (!page_rec_is_infimum(btr_cur_get_rec(cursor))) { /* split and inserted need to call lock_update_insert() always. */ inherit = TRUE; } + + buf_block_t* block = btr_cur_get_block(cursor); + buf_frame_t* frame = NULL; + + if (block) { + frame = buf_block_get_frame(block); + } + /* split and inserted need to call + lock_update_insert() always. */ + if (frame && btr_page_get_prev(frame, mtr) == FIL_NULL) { + inherit = TRUE; + } } #ifdef BTR_CUR_ADAPT @@ -3562,6 +3625,7 @@ btr_estimate_n_rows_in_range_on_level( mtr_t mtr; page_t* page; buf_block_t* block; + dberr_t err=DB_SUCCESS; mtr_start(&mtr); @@ -3572,7 +3636,23 @@ btr_estimate_n_rows_in_range_on_level( silence a debug assertion about this. */ block = buf_page_get_gen(space, zip_size, page_no, RW_S_LATCH, NULL, BUF_GET_POSSIBLY_FREED, - __FILE__, __LINE__, &mtr); + __FILE__, __LINE__, &mtr, &err); + + if (err != DB_SUCCESS) { + if (err == DB_DECRYPTION_FAILED) { + ib_push_warning((void *)NULL, + DB_DECRYPTION_FAILED, + "Table %s is encrypted but encryption service or" + " used key_id is not available. " + " Can't continue reading table.", + index->table->name); + index->table->is_encrypted = true; + } + + mtr_commit(&mtr); + goto inexact; + } + page = buf_block_get_frame(block); |