diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2014-10-29 01:37:58 +0300 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2014-10-29 01:37:58 +0300 |
commit | 9cb002b359ca8281cd30b711690dd589a254db4e (patch) | |
tree | 6adedb208b9394f5d70973ac6556c2f598769131 /sql/multi_range_read.cc | |
parent | 94c8f33569ec2b8094928463150567d4dcf67398 (diff) | |
download | mariadb-git-9cb002b359ca8281cd30b711690dd589a254db4e.tar.gz |
MDEV-6878: Use of uninitialized saved_primary_key in Mrr_ordered_index_reader::resume_read()
(Backport to 5.3)
(variant #2, with fixed coding style)
- 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 | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index 727ebc29032..6dfd8bec980 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -410,6 +410,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; } @@ -418,6 +419,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() @@ -435,6 +437,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); @@ -452,6 +455,10 @@ void Mrr_ordered_index_reader::position() void Mrr_ordered_index_reader::resume_read() { TABLE *table= file->get_table(); + + if (!read_was_interrupted) + return; + KEY *used_index= &table->key_info[file->active_index]; key_restore(table->record[0], saved_key_tuple, used_index, used_index->key_length); @@ -541,8 +548,7 @@ int Mrr_ordered_index_reader::init(handler *h_arg, RANGE_SEQ_IF *seq_funcs, is_mrr_assoc= !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; } |