Commit a4885dde authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-13535 Query on MyISAM table corrupts the table

don't assume that the table always has a primary key,
head->s->primary_key might be MAX_KEY, which won't start keyread.
parent 1b7e5590
......@@ -64,6 +64,8 @@ explain
select * from t0 where key1 < 3 or key2 > 1020;
select * from t0 where key1 < 3 or key2 > 1020;
select * from t0 where key1=1022; # MDEV-13535 no-key-read select after keyread
explain select * from t0 where key1 < 3 or key2 <4;
explain
......
......@@ -34,6 +34,9 @@ key1 key2 key3 key4 key5 key6 key7 key8
1022 1022 1022 1022 1022 1022 1022 2
1023 1023 1023 1023 1023 1023 1023 1
1024 1024 1024 1024 1024 1024 1024 0
select * from t0 where key1=1022;
key1 key2 key3 key4 key5 key6 key7 key8
1022 1022 1022 1022 1022 1022 1022 2
explain select * from t0 where key1 < 3 or key2 <4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 7 Using sort_union(i1,i2); Using where
......
......@@ -10889,13 +10889,13 @@ int read_keys_and_merge_scans(THD *thd,
DBUG_ENTER("read_keys_and_merge");
/* We're going to just read rowids. */
head->file->ha_start_keyread(head->s->primary_key);
head->prepare_for_position();
cur_quick_it.rewind();
cur_quick= cur_quick_it++;
bool first_quick= TRUE;
DBUG_ASSERT(cur_quick != 0);
head->file->ha_start_keyread(cur_quick->index);
/*
We reuse the same instance of handler so we need to call both init and
......
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