On 15/06/2011 15:57, Roy Lyseng wrote:
> #At file:///home/rl136806/mysql/repo/mysql-work0/ based on
> revid:jorgen.loland@stripped
>
> 3385 Roy Lyseng 2011-06-15
> Bug#12603200: Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output
>
> The problematic query is semi-join transformed and a LooseScan
> strategy is selected. setup_semijoin_dups_elimination() inspects
> the provided quick select object and attempts to set it to require
> ordering of output rows. However, the quick select object was not
> selected in the first place (see
> Loose_scan_opt::check_ref_access_part1()), hence there is a missing
> check that the index covered by the quick select matches the index
> selected for the loose scan access.
>
> Fixed by adding this check, and also deleting the quick select object
> if it was not chosen for accessing this table.
Hi,
Did you consider deleting the quick select object at the point where it
is decided to not use it?
--
Øystein
...
> === modified file 'sql/sql_select.cc'
> --- a/sql/sql_select.cc 2011-06-11 13:38:32 +0000
> +++ b/sql/sql_select.cc 2011-06-15 13:56:42 +0000
> @@ -1535,17 +1535,21 @@ bool setup_semijoin_dups_elimination(JOI
> tab->loosescan_match_tab= last_sj_tab;
>
> /* For LooseScan, duplicate elimination is based on rows being sorted
> - on key. We need to make sure that range select keep the sorted index
> + on key. We need to make sure that range select keeps the sorted index
> order. (When using MRR it may not.)
>
> Note: need_sorted_output() implementations for range select classes
> that do not support sorted output, will trigger an assert. This
> - should happen since LooseScan strategy will not be picked if sorted
> - output is not supported.
> + should not happen since LooseScan strategy is only picked if sorted
> + output is supported.
> */
> if (tab->select&& tab->select->quick)
> - tab->select->quick->need_sorted_output(true);
> -
> + {
> + if (tab->select->quick->index == pos->loosescan_key)
> + tab->select->quick->need_sorted_output(true);
> + else
> + tab->select->set_quick(NULL);
> + }
> /* Calculate key length */
> keylen= 0;
> keyno= pos->loosescan_key;