Commit 67d88e81 authored by unknown's avatar unknown

row0sel.c:

  Fix the patch of Jan to optimize next-key locking in searches of type 'primary key >= some value'


innobase/row/row0sel.c:
  Fix the patch of Jan to optimize next-key locking in searches of type 'primary key >= some value'
parent a7de2795
...@@ -3686,16 +3686,23 @@ rec_loop: ...@@ -3686,16 +3686,23 @@ rec_loop:
} }
} }
/* If a constant search tuple is found directly from /* If we are doing a 'greater or equal than a primary key
the cluster index we lock only a record. value' search from a clustered index, and we find a record
For example: WHERE a >= 100, where a is primary key */ that has that exact primary key value, then there is no need
to lock the gap before the record, because no insert in the
if(index == clust_index && gap can be in our search range. That is, no phantom row can
match_mode == ROW_SEL_OPEN_CURSOR && appear that way.
mode == PAGE_CUR_GE &&
dtuple_get_n_fields_cmp(search_tuple) An example: if col1 is the primary key, the search is WHERE
== dict_index_get_n_unique(index) && col1 >= 100, and we find a record where col1 = 100, then no
!cmp_dtuple_rec(search_tuple, rec, offsets)) { need to lock the gap before that record. */
if (index == clust_index
&& mode == PAGE_CUR_GE
&& direction == 0
&& dtuple_get_n_fields_cmp(search_tuple)
== dict_index_get_n_unique(index)
&& 0 == cmp_dtuple_rec(search_tuple, rec, offsets)) {
lock_type = LOCK_REC_NOT_GAP; lock_type = LOCK_REC_NOT_GAP;
} }
......
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