Commit fa929f7c authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent b0278302
/***************************************************************************** /*****************************************************************************
Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -196,10 +196,8 @@ row_undo_ins_remove_sec_low( ...@@ -196,10 +196,8 @@ row_undo_ins_remove_sec_low(
que_thr_t* thr) /*!< in: query thread */ que_thr_t* thr) /*!< in: query thread */
{ {
btr_pcur_t pcur; btr_pcur_t pcur;
btr_cur_t* btr_cur;
dberr_t err = DB_SUCCESS; dberr_t err = DB_SUCCESS;
mtr_t mtr; mtr_t mtr;
enum row_search_result search_result;
const bool modify_leaf = mode == BTR_MODIFY_LEAF; const bool modify_leaf = mode == BTR_MODIFY_LEAF;
row_mtr_start(&mtr, index, !modify_leaf); row_mtr_start(&mtr, index, !modify_leaf);
...@@ -224,12 +222,15 @@ row_undo_ins_remove_sec_low( ...@@ -224,12 +222,15 @@ row_undo_ins_remove_sec_low(
mode |= BTR_RTREE_UNDO_INS; mode |= BTR_RTREE_UNDO_INS;
} }
search_result = row_search_index_entry(index, entry, mode, switch (row_search_index_entry(index, entry, mode, &pcur, &mtr)) {
&pcur, &mtr); case ROW_BUFFERED:
case ROW_NOT_DELETED_REF:
switch (search_result) { /* 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: case ROW_NOT_FOUND:
goto func_exit; break;
case ROW_FOUND: case ROW_FOUND:
if (dict_index_is_spatial(index) if (dict_index_is_spatial(index)
&& rec_get_deleted_flag( && rec_get_deleted_flag(
...@@ -239,31 +240,22 @@ row_undo_ins_remove_sec_low( ...@@ -239,31 +240,22 @@ row_undo_ins_remove_sec_low(
<< " is deleted marked on insert rollback."; << " is deleted marked on insert rollback.";
ut_ad(0); ut_ad(0);
} }
break;
case ROW_BUFFERED: btr_cur_t* btr_cur = btr_pcur_get_btr_cur(&pcur);
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);
if (modify_leaf) { if (modify_leaf) {
err = btr_cur_optimistic_delete(btr_cur, 0, &mtr) err = btr_cur_optimistic_delete(btr_cur, 0, &mtr)
? DB_SUCCESS : DB_FAIL; ? DB_SUCCESS : DB_FAIL;
} else { } else {
/* Passing rollback=false here, because we are /* Passing rollback=false here, because we are
deleting a secondary index record: the distinction deleting a secondary index record: the distinction
only matters when deleting a record that contains only matters when deleting a record that contains
externally stored columns. */ externally stored columns. */
ut_ad(!dict_index_is_clust(index)); btr_cur_pessimistic_delete(&err, FALSE, btr_cur, 0,
btr_cur_pessimistic_delete(&err, FALSE, btr_cur, 0, false, &mtr);
false, &mtr); }
} }
func_exit:
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
func_exit_no_pcur: func_exit_no_pcur:
mtr_commit(&mtr); mtr_commit(&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