Skip to content

Commit

Permalink
MDEV-21610 Different query results from 10.4.11 to 10.4.12
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
spetrunia committed Feb 20, 2020
1 parent adcfea7 commit e637355
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 7 additions & 2 deletions sql/multi_range_read.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 9 additions & 2 deletions sql/multi_range_read.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,8 @@ class DsMrr_impl
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)
{
Expand Down Expand Up @@ -594,7 +595,13 @@ class DsMrr_impl
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;
Expand Down

0 comments on commit e637355

Please sign in to comment.