summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2020-02-20 13:35:19 +0300
committerSergei Petrunia <psergey@askmonty.org>2020-02-20 13:35:19 +0300
commite637355156cb28388a291b0e3a5e9ee863b2854d (patch)
tree7da3533b7fb0f9d8194d931be984a7113a805e7c
parentadcfea710ff0dcd8d223d41440225ebf6e64f796 (diff)
downloadmariadb-git-e637355156cb28388a291b0e3a5e9ee863b2854d.tar.gz
MDEV-21610 Different query results from 10.4.11 to 10.4.12
Part#2: cleanup: In the part 1 of the fix, DS-MRR implementation would peek into the JOIN_TAB to get the rowid filter from table->reginfo.join_tab->rowid_filter This doesn't look good from code isolation standpoint (why should a storage engine assume it is used through a JOIN_TAB?). Fixed this by storing the 'un-pushed' rowid_filter in the DsMrr_impl structure. The filter survives across multi_range_read_init() calls. It is discarded when somebody calls index_end() or rnd_end() and cleans up the DsMrr_impl.
-rw-r--r--sql/multi_range_read.cc9
-rw-r--r--sql/multi_range_read.h11
2 files changed, 16 insertions, 4 deletions
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc
index 51c3dc7a205..c000187626f 100644
--- a/sql/multi_range_read.cc
+++ b/sql/multi_range_read.cc
@@ -1015,6 +1015,7 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
primary key. Use the rowid filter outside the engine code (see
Mrr_ordered_rndpos_reader::refill_from_index_reader).
*/
+ rowid_filter= h_arg->pushed_rowid_filter;
h_arg->cancel_pushed_rowid_filter();
}
}
@@ -1096,15 +1097,18 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
goto use_default_impl;
}
+ // setup_two_handlers() will call dsmrr_close() will clears the filter.
+ // Save its value and restore afterwards.
+ Rowid_filter *tmp = rowid_filter;
if ((res= setup_two_handlers()))
goto error;
+ rowid_filter= tmp;
if ((res= index_strategy->init(secondary_file, seq_funcs, seq_init_param,
n_ranges, mode, &keypar, key_buffer,
&buf_manager)) ||
(res= disk_strategy->init(primary_file, index_strategy, mode,
- &rowid_buffer,
- table->reginfo.join_tab->rowid_filter)))
+ &rowid_buffer, rowid_filter)))
{
goto error;
}
@@ -1286,6 +1290,7 @@ void DsMrr_impl::close_second_handler()
void DsMrr_impl::dsmrr_close()
{
DBUG_ENTER("DsMrr_impl::dsmrr_close");
+ rowid_filter= NULL;
close_second_handler();
strategy= NULL;
DBUG_VOID_RETURN;
diff --git a/sql/multi_range_read.h b/sql/multi_range_read.h
index 6be95371bb2..37a00e3086f 100644
--- a/sql/multi_range_read.h
+++ b/sql/multi_range_read.h
@@ -557,7 +557,8 @@ public:
typedef void (handler::*range_check_toggle_func_t)(bool on);
DsMrr_impl()
- : secondary_file(NULL) {};
+ : secondary_file(NULL),
+ rowid_filter(NULL) {};
void init(handler *h_arg, TABLE *table_arg)
{
@@ -594,7 +595,13 @@ private:
to run both index scan and rnd_pos() scan at the same time)
*/
handler *secondary_file;
-
+
+ /*
+ The rowid filter that DS-MRR has "unpushed" from the storage engine.
+ If it's present, DS-MRR will use it.
+ */
+ Rowid_filter *rowid_filter;
+
uint keyno; /* index we're running the scan on */
/* TRUE <=> need range association, buffers hold {rowid, range_id} pairs */
bool is_mrr_assoc;