summaryrefslogtreecommitdiff
path: root/sql/multi_range_read.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2014-12-02 22:25:16 +0100
committerSergei Golubchik <serg@mariadb.org>2014-12-02 22:25:16 +0100
commit853077ad7e81be1ade20b4beab1b95d5766d87b1 (patch)
tree4c158691947ba7beb4577f26b160f243eabf39ef /sql/multi_range_read.cc
parentbf3b4a23f75de50e0f1ab4a562e5801dabc7305b (diff)
parent2b5db1d5bcd7b46b654d59a07fc119ef6a6b8651 (diff)
downloadmariadb-git-853077ad7e81be1ade20b4beab1b95d5766d87b1.tar.gz
Merge branch '10.0' into bb-10.1-merge
Conflicts: .bzrignore VERSION cmake/plugin.cmake debian/dist/Debian/control debian/dist/Ubuntu/control mysql-test/r/join_outer.result mysql-test/r/join_outer_jcl6.result mysql-test/r/null.result mysql-test/r/old-mode.result mysql-test/r/union.result mysql-test/t/join_outer.test mysql-test/t/null.test mysql-test/t/old-mode.test mysql-test/t/union.test packaging/rpm-oel/mysql.spec.in scripts/mysql_config.sh sql/ha_ndbcluster.cc sql/ha_ndbcluster_binlog.cc sql/ha_ndbcluster_cond.cc sql/item_cmpfunc.h sql/lock.cc sql/sql_select.cc sql/sql_show.cc sql/sql_update.cc sql/sql_yacc.yy storage/innobase/buf/buf0flu.cc storage/innobase/fil/fil0fil.cc storage/innobase/include/srv0srv.h storage/innobase/lock/lock0lock.cc storage/tokudb/CMakeLists.txt storage/xtradb/buf/buf0flu.cc storage/xtradb/fil/fil0fil.cc storage/xtradb/include/srv0srv.h storage/xtradb/lock/lock0lock.cc support-files/mysql.spec.sh
Diffstat (limited to 'sql/multi_range_read.cc')
-rw-r--r--sql/multi_range_read.cc25
1 files changed, 21 insertions, 4 deletions
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc
index bb49cebb921..20b1c5d5cc1 100644
--- a/sql/multi_range_read.cc
+++ b/sql/multi_range_read.cc
@@ -420,6 +420,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;
}
@@ -428,6 +429,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()
@@ -445,6 +447,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);
@@ -462,6 +465,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);
@@ -551,8 +558,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;
}
@@ -672,8 +678,19 @@ int Mrr_ordered_rndpos_reader::refill_from_index_reader()
rowid_buffer->write_ptr2= (uchar*)&range_info;
rowid_buffer->write();
}
-
- index_reader->interrupt_read();
+
+ /*
+ When index_reader_needs_refill=TRUE, this means we've got all of index
+ tuples for lookups keys that index_reader had. We are not in the middle
+ of an index read, so there is no need to call interrupt_read.
+
+ Actually, we must not call interrupt_read(), because it could be that we
+ haven't read a single row (because all index lookups returned
+ HA_ERR_KEY_NOT_FOUND). In this case, interrupt_read() will cause [harmless]
+ valgrind warnings when trying to save garbage from table->record[0].
+ */
+ if (!index_reader_needs_refill)
+ index_reader->interrupt_read();
/* Sort the buffer contents by rowid */
rowid_buffer->sort((qsort2_cmp)rowid_cmp_reverse, (void*)file);