diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-10-17 17:12:23 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-10-17 17:12:23 +0300 |
commit | fa929f7cdf71e351a64639815d84ae5d4f3dc053 (patch) | |
tree | 855104223ee18f09ac57f4ddb1cc9ca4fe3318f8 /storage | |
parent | b0278302327ee46715107ce1f9d3e7c3da0c3ba5 (diff) | |
download | mariadb-git-fa929f7cdf71e351a64639815d84ae5d4f3dc053.tar.gz |
Simplify row_undo_ins_remove_sec_low()
Reduce the scope of some variables, remove a goto and a redundant
assertion.
For B-tree secondary indexes, this function can remove a delete-marked
purgeable record, in case a row rollback of the INSERT was initiated
due to an error in an earlier secondary index.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/row/row0uins.cc | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc index bc4e7d3c380..62a6f013255 100644 --- a/storage/innobase/row/row0uins.cc +++ b/storage/innobase/row/row0uins.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2019, 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 @@ -196,10 +196,8 @@ row_undo_ins_remove_sec_low( que_thr_t* thr) /*!< in: query thread */ { btr_pcur_t pcur; - btr_cur_t* btr_cur; dberr_t err = DB_SUCCESS; mtr_t mtr; - enum row_search_result search_result; const bool modify_leaf = mode == BTR_MODIFY_LEAF; row_mtr_start(&mtr, index, !modify_leaf); @@ -224,12 +222,15 @@ row_undo_ins_remove_sec_low( mode |= BTR_RTREE_UNDO_INS; } - search_result = row_search_index_entry(index, entry, mode, - &pcur, &mtr); - - switch (search_result) { + switch (row_search_index_entry(index, entry, mode, &pcur, &mtr)) { + case ROW_BUFFERED: + case ROW_NOT_DELETED_REF: + /* These are invalid outcomes, because the mode passed + to row_search_index_entry() did not include any of the + flags BTR_INSERT, BTR_DELETE, or BTR_DELETE_MARK. */ + ut_error; case ROW_NOT_FOUND: - goto func_exit; + break; case ROW_FOUND: if (dict_index_is_spatial(index) && rec_get_deleted_flag( @@ -239,31 +240,22 @@ row_undo_ins_remove_sec_low( << " is deleted marked on insert rollback."; ut_ad(0); } - break; - case ROW_BUFFERED: - case ROW_NOT_DELETED_REF: - /* These are invalid outcomes, because the mode passed - to row_search_index_entry() did not include any of the - flags BTR_INSERT, BTR_DELETE, or BTR_DELETE_MARK. */ - ut_error; - } - - btr_cur = btr_pcur_get_btr_cur(&pcur); + btr_cur_t* btr_cur = btr_pcur_get_btr_cur(&pcur); - if (modify_leaf) { - err = btr_cur_optimistic_delete(btr_cur, 0, &mtr) - ? DB_SUCCESS : DB_FAIL; - } else { - /* Passing rollback=false here, because we are - deleting a secondary index record: the distinction - only matters when deleting a record that contains - externally stored columns. */ - ut_ad(!dict_index_is_clust(index)); - btr_cur_pessimistic_delete(&err, FALSE, btr_cur, 0, - false, &mtr); + if (modify_leaf) { + err = btr_cur_optimistic_delete(btr_cur, 0, &mtr) + ? DB_SUCCESS : DB_FAIL; + } else { + /* Passing rollback=false here, because we are + deleting a secondary index record: the distinction + only matters when deleting a record that contains + externally stored columns. */ + btr_cur_pessimistic_delete(&err, FALSE, btr_cur, 0, + false, &mtr); + } } -func_exit: + btr_pcur_close(&pcur); func_exit_no_pcur: mtr_commit(&mtr); |