Skip to content

Commit 4076791

Browse files
committed
Address review input part #3
1 parent fdf47b0 commit 4076791

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

storage/rocksdb/ha_rocksdb.cc

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9530,40 +9530,29 @@ int ha_rocksdb::set_range_lock(Rdb_transaction *tx,
95309530
Figure out the right endpoint.
95319531
*/
95329532

9533-
if (find_flag == HA_READ_KEY_EXACT) {
9533+
if (find_flag == HA_READ_KEY_EXACT ||
9534+
find_flag == HA_READ_PREFIX_LAST) {
95349535
if (slice.size() == Rdb_key_def::INDEX_NUMBER_SIZE) {
95359536
// This is a full table/index scan
9537+
// (in case of HA_READ_PREFIX_LAST, a reverse-ordered one)
95369538
start_has_inf_suffix= false;
95379539
big_range = true;
95389540
} else {
95399541
/*
9540-
This is "key_part= const" interval. We need to lock this range:
9541-
(lookup_value, -inf) < key < (lookup_value, +inf)
9542-
*/
9543-
start_has_inf_suffix= false;
9544-
end_has_inf_suffix= true;
9545-
end_slice= slice;
9546-
}
9547-
}
9548-
else if (find_flag == HA_READ_PREFIX_LAST) {
9549-
if (slice.size() == Rdb_key_def::INDEX_NUMBER_SIZE) {
9550-
/* Reverse-ordered full index scan */
9551-
start_has_inf_suffix= true;
9552-
big_range = true;
9553-
} else {
9554-
/*
9555-
We get here for queries like:
9556-
9557-
select * from t1 where pk1=const order by pk1 desc for update
9542+
HA_READ_KEY_EXACT:
9543+
This is "key_part= const" interval. We need to lock this range:
9544+
(lookup_value, -inf) < key < (lookup_value, +inf)
9545+
HA_READ_PREFIX_LAST:
9546+
We get here for queries like:
95589547

9559-
assuming this uses an index on (pk1, ...)
9560-
We get end_key=nullptr.
9548+
select * from t1 where pk1=const order by pk1 desc for update
95619549

9562-
The range to lock is the same as with HA_READ_KEY_EXACT above.
9550+
assuming this uses an index on (pk1, ...).
9551+
We get end_key=nullptr.
95639552
*/
9564-
end_slice= slice;
95659553
start_has_inf_suffix= false;
95669554
end_has_inf_suffix= true;
9555+
end_slice= slice;
95679556
}
95689557
}
95699558
else if (find_flag == HA_READ_PREFIX_LAST_OR_PREV) {
@@ -9629,8 +9618,11 @@ int ha_rocksdb::set_range_lock(Rdb_transaction *tx,
96299618
start_has_inf_suffix= false;
96309619
else if (find_flag == HA_READ_AFTER_KEY)
96319620
start_has_inf_suffix= true;
9632-
else
9621+
else {
9622+
// Unknown type of range, shouldn't happen
96339623
DBUG_ASSERT(0);
9624+
big_range = true;
9625+
}
96349626

96359627
// Known end range bounds: HA_READ_AFTER_KEY, HA_READ_BEFORE_KEY
96369628
if (end_key->flag == HA_READ_AFTER_KEY) {
@@ -9639,8 +9631,11 @@ int ha_rocksdb::set_range_lock(Rdb_transaction *tx,
96399631
} else if (end_key->flag == HA_READ_BEFORE_KEY) {
96409632
// this is "key_part < const", non-inclusive.
96419633
end_has_inf_suffix= false;
9642-
} else
9634+
} else {
9635+
// Unknown type of range, shouldn't happen
96439636
DBUG_ASSERT(0);
9637+
big_range = true;
9638+
}
96449639

96459640
uchar pack_buffer[MAX_KEY_LENGTH];
96469641
uint end_slice_size= kd.pack_index_tuple(table, pack_buffer, end_slice_buf,

0 commit comments

Comments
 (0)