revision-id: 4d51009a772fdfffc6cc7ae87422a3b0b19fa06a parent(s): 45ef87ee92904316fb37e1513705cdce263c61b1 committer: Sergei Petrunia branch nick: 10.2-r11 timestamp: 2018-05-08 13:00:26 +0300 message: MyRocks: fix rocksdb.rocksdb_range test attempt 3 --- storage/rocksdb/ha_rocksdb.cc | 17 ++++++++++++++++- storage/rocksdb/ha_rocksdb.h | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index baada70..57efc71 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -7925,6 +7925,15 @@ int ha_rocksdb::prepare_range_scan(const key_range *start_key, const key_range *end_key) { range_key_part= table->key_info[active_index].key_part; + + if (start_key) + { + m_save_start_range= *start_key; + m_start_range= &m_save_start_range; + } + else + m_start_range= NULL; + set_end_range(end_key); return 0; } @@ -8054,8 +8063,12 @@ int ha_rocksdb::index_read_map_impl(uchar *const buf, const uchar *const key, packed_size); uint end_key_packed_size = 0; + const key_range *cur_end_key= end_key; + if (find_flag == HA_READ_PREFIX_LAST_OR_PREV) + cur_end_key= m_start_range; + const uint eq_cond_len = - calc_eq_cond_len(kd, find_flag, slice, bytes_changed_by_succ, end_key, + calc_eq_cond_len(kd, find_flag, slice, bytes_changed_by_succ, cur_end_key, &end_key_packed_size); bool use_all_keys = false; @@ -9996,6 +10009,7 @@ int ha_rocksdb::index_init(uint idx, bool sorted) { DBUG_ASSERT(tx != nullptr); setup_read_decoders(); + m_start_range= NULL; if (!m_keyread_only) { m_key_descr_arr[idx]->get_lookup_bitmap(table, &m_lookup_bitmap); @@ -10024,6 +10038,7 @@ int ha_rocksdb::index_end() { active_index = MAX_KEY; in_range_check_pushed_down = FALSE; + m_start_range= NULL; DBUG_RETURN(HA_EXIT_SUCCESS); } diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h index 0b008a6..6083dd7 100644 --- a/storage/rocksdb/ha_rocksdb.h +++ b/storage/rocksdb/ha_rocksdb.h @@ -493,6 +493,10 @@ class ha_rocksdb : public my_core::handler { /* Iterator used for range scans and for full table/index scans */ rocksdb::Iterator *m_scan_it; + + /* Same as handler::end_key but for start. Reverse-ordered scans need it */ + key_range m_save_start_range; + const key_range *m_start_range; /* Whether m_scan_it was created with skip_bloom=true */ bool m_scan_it_skips_bloom;