Skip to content

Commit 42b5b75

Browse files
laurynas-biveinisinikep
authored andcommitted
Index read fixes (percona#1292)
Upstream commit ID: facebook/mysql-5.6@4c5fa16 PS-8951: Merge percona-202305 (https://jira.percona.com/browse/PS-8951) Summary: Minor index access cleanups for MyRocks: - `ha_rocksdb::index_init`: remove duplicate `active_index` assignment. Move `m_need_build_decoder` assignment past the error exit so that taking it does not result in any state changes. - `ha_rocksdb::index_next_same`: add an assert for `active_index` value to prevent out-of-bound accesses in the next line. Pull Request resolved: facebook/mysql-5.6#1292 Reviewed By: sunshine-Chun Differential Revision: D45277614 Pulled By: hermanlee fbshipit-source-id: 8624b6e99a85065f6fda2da126c7935294baebee
1 parent 279d0f7 commit 42b5b75

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

storage/rocksdb/ha_rocksdb.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9862,6 +9862,7 @@ int ha_rocksdb::index_next_same(uchar *const buf,
98629862

98639863
if (m_full_key_lookup) {
98649864
#ifndef NDEBUG
9865+
assert(active_index != MAX_KEY);
98659866
uint len = calculate_key_len(table, active_index, HA_WHOLE_KEY);
98669867
assert(len == keylen);
98679868
#endif
@@ -11406,9 +11407,6 @@ void ha_rocksdb::check_build_decoder() {
1140611407
int ha_rocksdb::index_init(uint idx, bool sorted) {
1140711408
DBUG_ENTER_FUNC();
1140811409

11409-
m_need_build_decoder = true;
11410-
active_index = idx;
11411-
1141211410
THD *thd = ha_thd();
1141311411
if (thd && thd->killed) {
1141411412
DBUG_RETURN(HA_ERR_QUERY_INTERRUPTED);
@@ -11417,6 +11415,8 @@ int ha_rocksdb::index_init(uint idx, bool sorted) {
1141711415
Rdb_transaction *const tx = get_or_create_tx(thd);
1141811416
assert(tx != nullptr);
1141911417

11418+
m_need_build_decoder = true;
11419+
1142011420
active_index = idx;
1142111421
if (idx != table->s->primary_key &&
1142211422
m_key_descr_arr[idx]->is_partial_index()) {

0 commit comments

Comments
 (0)