>> In the testcase (added to the .inc file), TRP_RANGE::key is set here
>> (opt_range.cc:5367):
>>
>> if (key_to_read)
>> {
>> idx= key_to_read - tree->keys;
>> if ((read_plan= new (param->mem_root) TRP_RANGE(*key_to_read, idx,
>> best_mrr_flags)))
>> (the constructor sets TRP_RANGE::key to *key_to_read).
>> Is there, in the existing code, some place where we take this
>> TRP_RANGE::key and go up following the "prev" pointers?
>
> When constructing QUICK_SELECT (get_quick_keys()) we recursively call
> get_quick_keys() on the left-pointer until it's left pointer is
> null_element. So this is a good point... maybe I should replace prev
> with left (and then do the !null_element thingy) in my patch. Do you
> prefer that?
Thinking a bit more about it, there will be fewer steps to reach the
first range if I walk down the left pointer instead of prev. Probably
not worth much considering that we normally don't have tens of ranges to
walk down, but log2(N) is better than N/2 even when N is small...
So I will change it...