[Commits] 5ff6694d70b: enum btr_latch_mode: Incorporate some flags.

marko.makela at mariadb.com marko.makela at mariadb.com
Thu Mar 9 10:32:39 EET 2017


revision-id: 5ff6694d70be9d29af1d188e46ce16534c4d1858 (mariadb-10.2.4-31-g5ff6694d70b)
parent(s): e88f6f47612b39a915af75390a93a007df955934
author: Marko Mäkelä
committer: Marko Mäkelä
timestamp: 2017-03-09 10:30:36 +0200
message:

enum btr_latch_mode: Incorporate some flags.

This fixes some GCC 6.3.0 warnings and makes the code a little
more debugging-friendly.

---
 storage/innobase/dict/dict0stats.cc |  4 +--
 storage/innobase/include/btr0btr.h  | 65 +++++++++++++++++++++++++------------
 storage/innobase/row/row0ins.cc     |  4 +--
 storage/innobase/row/row0purge.cc   | 18 ++++------
 storage/innobase/row/row0upd.cc     |  7 ++--
 5 files changed, 58 insertions(+), 40 deletions(-)

diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc
index 87502ef130c..b4d668ebbcb 100644
--- a/storage/innobase/dict/dict0stats.cc
+++ b/storage/innobase/dict/dict0stats.cc
@@ -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);
 
diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h
index 4a80b5e4913..3e9c639f602 100644
--- a/storage/innobase/include/btr0btr.h
+++ b/storage/innobase/include/btr0btr.h
@@ -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
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index db8a91ed21e..bd776815abd 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -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);
 		}
 
diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc
index b41e3642cf0..99df94f93b0 100644
--- a/storage/innobase/row/row0purge.cc
+++ b/storage/innobase/row/row0purge.cc
@@ -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(). */
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index 048f75e413f..72271598a6c 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -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)) {


More information about the commits mailing list