diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2014-10-16 17:57:13 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2014-10-16 17:57:13 +0400 |
commit | 8925b4a935115aef51cfff22564ee2b0d5fb5fce (patch) | |
tree | 6f093fcc91bf7e4e7c97fdb1cf201e6ae1d80aa6 /sql/multi_range_read.cc | |
parent | ec3e6cc88bc87dce52cbebd7e0c6b5b8f571cfb4 (diff) | |
download | mariadb-git-8925b4a935115aef51cfff22564ee2b0d5fb5fce.tar.gz |
MDEV-6878: Use of uninitialized saved_primary_key in Mrr_ordered_index_reader::resume_read()
- Make Mrr_ordered_index_reader::resume_read() restore index position
only if it was saved before with Mrr_ordered_index_reader::interrupt_read().
Diffstat (limited to 'sql/multi_range_read.cc')
-rw-r--r-- | sql/multi_range_read.cc | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index b63db9ecea2..4665957528f 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -426,6 +426,7 @@ bool Mrr_ordered_index_reader::set_interruption_temp_buffer(uint rowid_length, *space_start += key_len; have_saved_rowid= FALSE; + read_was_interrupted= FALSE; return FALSE; } @@ -434,6 +435,7 @@ void Mrr_ordered_index_reader::set_no_interruption_temp_buffer() support_scan_interruptions= FALSE; saved_key_tuple= saved_rowid= saved_primary_key= NULL; /* safety */ have_saved_rowid= FALSE; + read_was_interrupted= FALSE; } void Mrr_ordered_index_reader::interrupt_read() @@ -451,6 +453,7 @@ void Mrr_ordered_index_reader::interrupt_read() &table->key_info[table->s->primary_key], table->key_info[table->s->primary_key].key_length); } + read_was_interrupted= TRUE; /* Save the last rowid */ memcpy(saved_rowid, file->ref, file->ref_length); @@ -468,14 +471,17 @@ void Mrr_ordered_index_reader::position() void Mrr_ordered_index_reader::resume_read() { TABLE *table= file->get_table(); - KEY *used_index= &table->key_info[file->active_index]; - key_restore(table->record[0], saved_key_tuple, - used_index, used_index->key_length); - if (saved_primary_key) + if (read_was_interrupted) { - key_restore(table->record[0], saved_primary_key, - &table->key_info[table->s->primary_key], - table->key_info[table->s->primary_key].key_length); + KEY *used_index= &table->key_info[file->active_index]; + key_restore(table->record[0], saved_key_tuple, + used_index, used_index->key_length); + if (saved_primary_key) + { + key_restore(table->record[0], saved_primary_key, + &table->key_info[table->s->primary_key], + table->key_info[table->s->primary_key].key_length); + } } } @@ -557,8 +563,7 @@ int Mrr_ordered_index_reader::init(handler *h_arg, RANGE_SEQ_IF *seq_funcs, is_mrr_assoc= !MY_TEST(mode & HA_MRR_NO_ASSOCIATION); mrr_funcs= *seq_funcs; source_exhausted= FALSE; - if (support_scan_interruptions) - bzero(saved_key_tuple, key_info->key_length); + read_was_interrupted= false; have_saved_rowid= FALSE; return 0; } |