Commit 5ff6694d authored by Marko Mäkelä's avatar Marko Mäkelä

enum btr_latch_mode: Incorporate some flags.

This fixes some GCC 6.3.0 warnings and makes the code a little
more debugging-friendly.
parent e88f6f47
......@@ -1083,7 +1083,7 @@ dict_stats_analyze_index_level(
on the desired level. */
btr_pcur_open_at_index_side(
true, index, BTR_SEARCH_TREE | BTR_ALREADY_S_LATCHED,
true, index, BTR_SEARCH_TREE_ALREADY_S_LATCHED,
&pcur, true, level, mtr);
btr_pcur_move_to_next_on_page(&pcur);
......@@ -1700,7 +1700,7 @@ dict_stats_analyze_index_for_n_prefix(
on the desired level. */
btr_pcur_open_at_index_side(
true, index, BTR_SEARCH_TREE | BTR_ALREADY_S_LATCHED,
true, index, BTR_SEARCH_TREE_ALREADY_S_LATCHED,
&pcur, true, n_diff_data->level, mtr);
btr_pcur_move_to_next_on_page(&pcur);
......
......@@ -71,16 +71,53 @@ enum btr_latch_mode {
/** Start searching the entire B-tree. */
BTR_SEARCH_TREE = 37,
/** Continue searching the entire B-tree. */
BTR_CONT_SEARCH_TREE = 38
BTR_CONT_SEARCH_TREE = 38,
/* BTR_INSERT, BTR_DELETE and BTR_DELETE_MARK are mutually
exclusive. */
/** The search tuple will be inserted to the secondary index
at the searched position. When the leaf page is not in the
buffer pool, try to use the change buffer. */
BTR_INSERT = 512,
/** Try to delete mark a secondary index leaf page record at
the searched position using the change buffer when the page is
not in the buffer pool. */
BTR_DELETE_MARK = 4096,
/** Try to purge the record using the change buffer when the
secondary index leaf page is not in the buffer pool. */
BTR_DELETE = 8192,
/** The caller is already holding dict_index_t::lock S-latch. */
BTR_ALREADY_S_LATCHED = 16384,
/** Search and S-latch a leaf page, assuming that the
dict_index_t::lock S-latch is being held. */
BTR_SEARCH_LEAF_ALREADY_S_LATCHED = BTR_SEARCH_LEAF
| BTR_ALREADY_S_LATCHED,
/** Search the entire index tree, assuming that the
dict_index_t::lock S-latch is being held. */
BTR_SEARCH_TREE_ALREADY_S_LATCHED = BTR_SEARCH_TREE
| BTR_ALREADY_S_LATCHED,
/** Search and X-latch a leaf page, assuming that the
dict_index_t::lock S-latch is being held. */
BTR_MODIFY_LEAF_ALREADY_S_LATCHED = BTR_MODIFY_LEAF
| BTR_ALREADY_S_LATCHED,
/** Attempt to delete-mark a secondary index record. */
BTR_DELETE_MARK_LEAF = BTR_MODIFY_LEAF | BTR_DELETE_MARK,
/** Attempt to delete-mark a secondary index record
while holding the dict_index_t::lock S-latch. */
BTR_DELETE_MARK_LEAF_ALREADY_S_LATCHED = BTR_DELETE_MARK_LEAF
| BTR_ALREADY_S_LATCHED,
/** Attempt to purge a secondary index record. */
BTR_PURGE_LEAF = BTR_MODIFY_LEAF | BTR_DELETE,
/** Attempt to purge a secondary index record
while holding the dict_index_t::lock S-latch. */
BTR_PURGE_LEAF_ALREADY_S_LATCHED = BTR_PURGE_LEAF
| BTR_ALREADY_S_LATCHED
};
/* 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
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 512U
/** This flag ORed to btr_latch_mode says that we do the search in query
optimization */
#define BTR_ESTIMATE 1024U
......@@ -90,18 +127,6 @@ UNIQUE definition on secondary indexes when we decide if we can use
the insert buffer to speed up inserts */
#define BTR_IGNORE_SEC_UNIQUE 2048U
/** Try to delete mark the record at the searched position using the
insert/delete buffer when the record is not in the buffer pool. */
#define BTR_DELETE_MARK 4096U
/** Try to purge the record at the searched position using the insert/delete
buffer when the record is not in the buffer pool. */
#define BTR_DELETE 8192U
/** In the case of BTR_SEARCH_LEAF or BTR_MODIFY_LEAF, the caller is
already holding an S latch on the index tree */
#define BTR_ALREADY_S_LATCHED 16384U
/** In the case of BTR_MODIFY_TREE, the caller specifies the intention
to insert record only. It is used to optimize block->lock range.*/
#define BTR_LATCH_FOR_INSERT 32768U
......
......@@ -2087,7 +2087,7 @@ row_ins_scan_sec_index_for_duplicate(
btr_pcur_open(index, entry, PAGE_CUR_GE,
s_latch
? BTR_SEARCH_LEAF | BTR_ALREADY_S_LATCHED
? BTR_SEARCH_LEAF_ALREADY_S_LATCHED
: BTR_SEARCH_LEAF,
&pcur, mtr);
......@@ -2505,7 +2505,7 @@ row_ins_clust_index_entry_low(
if (mode == BTR_MODIFY_LEAF
&& dict_index_is_online_ddl(index)) {
mode = BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED;
mode = BTR_MODIFY_LEAF_ALREADY_S_LATCHED;
mtr_s_lock(dict_index_get_lock(index), &mtr);
}
......
......@@ -407,12 +407,12 @@ row_purge_remove_sec_if_poss_leaf(
{
mtr_t mtr;
btr_pcur_t pcur;
ulint mode;
enum btr_latch_mode mode;
enum row_search_result search_result;
bool success = true;
log_free_check();
ut_ad(!dict_table_is_temporary(index->table));
mtr_start(&mtr);
mtr.set_named_space(index->space);
......@@ -436,23 +436,17 @@ row_purge_remove_sec_if_poss_leaf(
goto func_exit_no_pcur;
}
/* Change buffering is disabled for temporary tables. */
mode = (dict_table_is_temporary(index->table))
? BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED
: BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED
| BTR_DELETE;
mode = BTR_PURGE_LEAF_ALREADY_S_LATCHED;
} else {
/* For secondary indexes,
index->online_status==ONLINE_INDEX_COMPLETE if
index->is_committed(). */
ut_ad(!dict_index_is_online_ddl(index));
/* Change buffering is disabled for temporary tables
and spatial index. */
mode = (dict_table_is_temporary(index->table)
|| dict_index_is_spatial(index))
/* Change buffering is disabled for spatial index. */
mode = dict_index_is_spatial(index)
? BTR_MODIFY_LEAF
: BTR_MODIFY_LEAF | BTR_DELETE;
: BTR_PURGE_LEAF;
}
/* Set the purge node for the call to row_purge_poss_sec(). */
......
......@@ -2309,9 +2309,8 @@ row_upd_sec_index_entry(
spatial index. */
mode = (referenced || dict_table_is_temporary(index->table)
|| dict_index_is_spatial(index))
? BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED
: BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED
| BTR_DELETE_MARK;
? BTR_MODIFY_LEAF_ALREADY_S_LATCHED
: BTR_DELETE_MARK_LEAF_ALREADY_S_LATCHED;
} else {
/* For secondary indexes,
index->online_status==ONLINE_INDEX_COMPLETE if
......@@ -2325,7 +2324,7 @@ row_upd_sec_index_entry(
mode = (referenced || dict_table_is_temporary(index->table)
|| dict_index_is_spatial(index))
? BTR_MODIFY_LEAF
: BTR_MODIFY_LEAF | BTR_DELETE_MARK;
: BTR_DELETE_MARK_LEAF;
}
if (dict_index_is_spatial(index)) {
......
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