Commit c158c47a authored by marko's avatar marko

branches/innodb+: btr_cur_search_to_nth_level(): Treat BTR_DELETE in

the same way as BTR_INSERT and BTR_DELETE_MARK: only perform (buffer)
the operation when the page is not in the buffer pool.

BTR_INSERT, BTR_DELETE_MARK, BTR_DELETE: Make the documentation say that
these flags are ignored when the page is in the buffer pool.

enum row_search_result: Remove ROW_NOT_DELETED, which
BTR_CUR_DELETE_FAILED was mapped to.

enum btr_cur_method: Remove BTR_CUR_DELETE_FAILED.  The
btr_cur_search_to_nth_level() will no longer attempt to execute the
BTR_DELETE when the page is in the buffer pool.

row_search_index_entry(): Remove the mapping from
BTR_CUR_DELETE_FAILED to ROW_NOT_DELETED.  The caller will have to
attempt purge when the record is in the buffer pool.

row_purge_remove_sec_if_poss_leaf(): Attempt to purge the record if it
was found in the buffer pool.

This addresses Issue #466.
rb://268
parent 95567a75
...@@ -338,7 +338,8 @@ btr_cur_search_to_nth_level( ...@@ -338,7 +338,8 @@ btr_cur_search_to_nth_level(
Inserts should always be made using Inserts should always be made using
PAGE_CUR_LE to search the position! */ PAGE_CUR_LE to search the position! */
ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ..., ORed with ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ..., ORed with
BTR_INSERT and BTR_ESTIMATE; at most one of BTR_INSERT, BTR_DELETE_MARK,
BTR_DELETE, or BTR_ESTIMATE;
cursor->left_block is used to store a pointer cursor->left_block is used to store a pointer
to the left neighbor page, in the cases to the left neighbor page, in the cases
BTR_SEARCH_PREV and BTR_MODIFY_PREV; BTR_SEARCH_PREV and BTR_MODIFY_PREV;
...@@ -773,35 +774,6 @@ retry_page_get: ...@@ -773,35 +774,6 @@ retry_page_get:
|| mode != PAGE_CUR_LE); || mode != PAGE_CUR_LE);
ut_ad(cursor->low_match != ULINT_UNDEFINED ut_ad(cursor->low_match != ULINT_UNDEFINED
|| mode != PAGE_CUR_LE); || mode != PAGE_CUR_LE);
/* If this was a delete operation, the leaf page was
in the buffer pool, and a matching record was found in
the leaf page, attempt to delete it. If the deletion
fails, set the cursor flag accordingly. */
if (UNIV_UNLIKELY(btr_op == BTR_DELETE_OP)
&& low_match == dtuple_get_n_fields(tuple)
&& !page_cur_is_before_first(page_cursor)) {
/* Before attempting to purge a record, check
if it is safe to do so. */
if (!row_purge_poss_sec(cursor->purge_node,
index, tuple)) {
cursor->flag = BTR_CUR_DELETE_REF;
} else {
/* Only delete-marked records should
be purged. */
ut_ad(REC_INFO_DELETED_FLAG
& rec_get_info_bits(
btr_cur_get_rec(cursor),
page_is_comp(page)));
if (!btr_cur_optimistic_delete(cursor, mtr)) {
cursor->flag = BTR_CUR_DELETE_FAILED;
}
}
}
} }
func_exit: func_exit:
......
...@@ -71,7 +71,8 @@ enum btr_latch_mode { ...@@ -71,7 +71,8 @@ enum btr_latch_mode {
/* BTR_INSERT, BTR_DELETE and BTR_DELETE_MARK are mutually exclusive. */ /* BTR_INSERT, BTR_DELETE and BTR_DELETE_MARK are mutually exclusive. */
/** If this is ORed to btr_latch_mode, it means that the search tuple /** If this is ORed to btr_latch_mode, it means that the search tuple
will be inserted to the index, at the searched position */ will be inserted to the index, at the searched position.
When the record is not in the buffer pool, try to use the insert buffer. */
#define BTR_INSERT 512 #define BTR_INSERT 512
/** This flag ORed to btr_latch_mode says that we do the search in query /** This flag ORed to btr_latch_mode says that we do the search in query
...@@ -84,11 +85,11 @@ the insert buffer to speed up inserts */ ...@@ -84,11 +85,11 @@ the insert buffer to speed up inserts */
#define BTR_IGNORE_SEC_UNIQUE 2048 #define BTR_IGNORE_SEC_UNIQUE 2048
/** Try to delete mark the record at the searched position using the /** Try to delete mark the record at the searched position using the
insert/delete buffer. */ insert/delete buffer when the record is not in the buffer pool. */
#define BTR_DELETE_MARK 4096 #define BTR_DELETE_MARK 4096
/** Try to delete the record at the searched position using the insert/delete /** Try to purge the record at the searched position using the insert/delete
buffer. */ buffer when the record is not in the buffer pool. */
#define BTR_DELETE 8192 #define BTR_DELETE 8192
/**************************************************************//** /**************************************************************//**
......
...@@ -138,7 +138,8 @@ btr_cur_search_to_nth_level( ...@@ -138,7 +138,8 @@ btr_cur_search_to_nth_level(
should always be made using PAGE_CUR_LE to should always be made using PAGE_CUR_LE to
search the position! */ search the position! */
ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ..., ORed with ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ..., ORed with
BTR_INSERT and BTR_ESTIMATE; at most one of BTR_INSERT, BTR_DELETE_MARK,
BTR_DELETE, or BTR_ESTIMATE;
cursor->left_block is used to store a pointer cursor->left_block is used to store a pointer
to the left neighbor page, in the cases to the left neighbor page, in the cases
BTR_SEARCH_PREV and BTR_MODIFY_PREV; BTR_SEARCH_PREV and BTR_MODIFY_PREV;
...@@ -634,9 +635,7 @@ enum btr_cur_method { ...@@ -634,9 +635,7 @@ enum btr_cur_method {
mark in the insert/delete buffer */ mark in the insert/delete buffer */
BTR_CUR_DELETE_IBUF, /*!< performed the intended delete in BTR_CUR_DELETE_IBUF, /*!< performed the intended delete in
the insert/delete buffer */ the insert/delete buffer */
BTR_CUR_DELETE_REF, /*!< row_purge_poss_sec() failed */ BTR_CUR_DELETE_REF /*!< row_purge_poss_sec() failed */
BTR_CUR_DELETE_FAILED /*!< an optimistic delete could not be
performed */
}; };
/** The tree cursor: the definition appears here only for the compiler /** The tree cursor: the definition appears here only for the compiler
......
...@@ -269,8 +269,6 @@ enum row_search_result { ...@@ -269,8 +269,6 @@ enum row_search_result {
enqueued in the insert/delete buffer */ enqueued in the insert/delete buffer */
ROW_NOT_DELETED_REF, /*!< BTR_DELETE was specified, and ROW_NOT_DELETED_REF, /*!< BTR_DELETE was specified, and
row_purge_poss_sec() failed */ row_purge_poss_sec() failed */
ROW_NOT_DELETED, /*!< BTR_DELETE was specified, and the
optimistic delete failed */
}; };
/***************************************************************//** /***************************************************************//**
......
...@@ -297,7 +297,6 @@ row_purge_remove_sec_if_poss_tree( ...@@ -297,7 +297,6 @@ row_purge_remove_sec_if_poss_tree(
break; break;
case ROW_BUFFERED: case ROW_BUFFERED:
case ROW_NOT_DELETED_REF: case ROW_NOT_DELETED_REF:
case ROW_NOT_DELETED:
/* These are invalid outcomes, because the mode passed /* These are invalid outcomes, because the mode passed
to row_search_index_entry() did not include any of the to row_search_index_entry() did not include any of the
flags BTR_INSERT, BTR_DELETE, or BTR_DELETE_MARK. */ flags BTR_INSERT, BTR_DELETE, or BTR_DELETE_MARK. */
...@@ -366,24 +365,40 @@ row_purge_remove_sec_if_poss_leaf( ...@@ -366,24 +365,40 @@ row_purge_remove_sec_if_poss_leaf(
search_result = row_search_index_entry( search_result = row_search_index_entry(
index, entry, BTR_MODIFY_LEAF | BTR_DELETE, &pcur, &mtr); index, entry, BTR_MODIFY_LEAF | BTR_DELETE, &pcur, &mtr);
btr_pcur_close(&pcur);
mtr_commit(&mtr);
switch (search_result) { switch (search_result) {
case ROW_NOT_DELETED: ibool success;
/* The index entry could not be deleted. */ case ROW_FOUND:
return(FALSE); /* Before attempting to purge a record, check
if it is safe to do so. */
if (row_purge_poss_sec(node, index, entry)) {
btr_cur_t* btr_cur = btr_pcur_get_btr_cur(&pcur);
/* Only delete-marked records should be purged. */
ut_ad(REC_INFO_DELETED_FLAG
& rec_get_info_bits(
btr_cur_get_rec(btr_cur),
dict_table_is_comp(index->table)));
if (!btr_cur_optimistic_delete(btr_cur, &mtr)) {
/* The index entry could not be deleted. */
success = FALSE;
goto func_exit;
}
}
/* fall through (the index entry is still needed,
or the deletion succeeded) */
case ROW_NOT_DELETED_REF: case ROW_NOT_DELETED_REF:
/* The index entry is still needed. */ /* The index entry is still needed. */
case ROW_NOT_FOUND:
/* The index entry does not exist, nothing to do. */
case ROW_FOUND:
/* The index entry existed in the buffer pool
and was deleted because of the BTR_DELETE. */
case ROW_BUFFERED: case ROW_BUFFERED:
/* The deletion was buffered. */ /* The deletion was buffered. */
return(TRUE); case ROW_NOT_FOUND:
/* The index entry does not exist, nothing to do. */
success = TRUE;
func_exit:
btr_pcur_close(&pcur);
mtr_commit(&mtr);
return(success);
} }
ut_error; ut_error;
......
...@@ -755,10 +755,6 @@ row_search_index_entry( ...@@ -755,10 +755,6 @@ row_search_index_entry(
ut_a(mode & BTR_DELETE); ut_a(mode & BTR_DELETE);
return(ROW_NOT_DELETED_REF); return(ROW_NOT_DELETED_REF);
case BTR_CUR_DELETE_FAILED:
ut_a(mode & BTR_DELETE);
return(ROW_NOT_DELETED);
case BTR_CUR_DEL_MARK_IBUF: case BTR_CUR_DEL_MARK_IBUF:
case BTR_CUR_DELETE_IBUF: case BTR_CUR_DELETE_IBUF:
case BTR_CUR_INSERT_TO_IBUF: case BTR_CUR_INSERT_TO_IBUF:
......
...@@ -168,7 +168,6 @@ row_undo_ins_remove_sec_low( ...@@ -168,7 +168,6 @@ row_undo_ins_remove_sec_low(
case ROW_FOUND: case ROW_FOUND:
break; break;
case ROW_BUFFERED: case ROW_BUFFERED:
case ROW_NOT_DELETED:
case ROW_NOT_DELETED_REF: case ROW_NOT_DELETED_REF:
/* These are invalid outcomes, because the mode passed /* These are invalid outcomes, because the mode passed
to row_search_index_entry() did not include any of the to row_search_index_entry() did not include any of the
......
...@@ -350,7 +350,6 @@ row_undo_mod_del_mark_or_remove_sec_low( ...@@ -350,7 +350,6 @@ row_undo_mod_del_mark_or_remove_sec_low(
case ROW_FOUND: case ROW_FOUND:
break; break;
case ROW_BUFFERED: case ROW_BUFFERED:
case ROW_NOT_DELETED:
case ROW_NOT_DELETED_REF: case ROW_NOT_DELETED_REF:
/* These are invalid outcomes, because the mode passed /* These are invalid outcomes, because the mode passed
to row_search_index_entry() did not include any of the to row_search_index_entry() did not include any of the
...@@ -487,7 +486,6 @@ row_undo_mod_del_unmark_sec_and_undo_update( ...@@ -487,7 +486,6 @@ row_undo_mod_del_unmark_sec_and_undo_update(
switch (search_result) { switch (search_result) {
case ROW_BUFFERED: case ROW_BUFFERED:
case ROW_NOT_DELETED:
case ROW_NOT_DELETED_REF: case ROW_NOT_DELETED_REF:
/* These are invalid outcomes, because the mode passed /* These are invalid outcomes, because the mode passed
to row_search_index_entry() did not include any of the to row_search_index_entry() did not include any of the
......
...@@ -1476,7 +1476,6 @@ row_upd_sec_index_entry( ...@@ -1476,7 +1476,6 @@ row_upd_sec_index_entry(
rec = btr_cur_get_rec(btr_cur); rec = btr_cur_get_rec(btr_cur);
switch (search_result) { switch (search_result) {
case ROW_NOT_DELETED: /* should only occur for BTR_DELETE */
case ROW_NOT_DELETED_REF: /* should only occur for BTR_DELETE */ case ROW_NOT_DELETED_REF: /* should only occur for BTR_DELETE */
ut_error; ut_error;
break; break;
......
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