@@ -60,18 +60,18 @@ IndexRangeScanIterator::IndexRangeScanIterator(
60
60
MEM_ROOT *return_mem_root, uint mrr_flags, uint mrr_buf_size,
61
61
Bounds_checked_array<QUICK_RANGE *> ranges_arg)
62
62
: RowIDCapableRowIterator(thd, table_arg),
63
- ranges( ranges_arg) ,
64
- free_file( false ) ,
65
- cur_range( nullptr ) ,
66
- last_range( nullptr ) ,
67
- mrr_flags( mrr_flags) ,
68
- mrr_buf_size( mrr_buf_size) ,
69
- mrr_buf_desc( nullptr ) ,
70
- need_rows_in_rowid_order( need_rows_in_rowid_order) ,
71
- reuse_handler( reuse_handler) ,
72
- mem_root( return_mem_root) ,
73
- m_expected_rows( expected_rows) ,
74
- m_examined_rows( examined_rows) {
63
+ ranges{ ranges_arg} ,
64
+ free_file{ false } ,
65
+ cur_range{ nullptr } ,
66
+ last_range{ nullptr } ,
67
+ mrr_flags{ mrr_flags} ,
68
+ mrr_buf_size{ mrr_buf_size} ,
69
+ mrr_buf_desc{ nullptr } ,
70
+ need_rows_in_rowid_order{ need_rows_in_rowid_order} ,
71
+ reuse_handler{ reuse_handler} ,
72
+ mem_root{ return_mem_root} ,
73
+ m_expected_rows{ expected_rows} ,
74
+ m_examined_rows{ examined_rows} {
75
75
DBUG_TRACE;
76
76
77
77
in_ror_merged_scan = false ;
@@ -233,11 +233,19 @@ bool IndexRangeScanIterator::Init() {
233
233
// outside of the record. So don't request a buffer in this case, even
234
234
// though the current read_set gives the impression that using a
235
235
// record buffer would be fine.
236
- const bool skip_record_buffer =
237
- need_rows_in_rowid_order &&
238
- Overlaps (table ()->file ->ha_table_flags (),
239
- HA_PRIMARY_KEY_REQUIRED_FOR_POSITION) &&
240
- has_blob_primary_key (table ());
236
+ bool skip_record_buffer = need_rows_in_rowid_order &&
237
+ Overlaps (table ()->file ->ha_table_flags (),
238
+ HA_PRIMARY_KEY_REQUIRED_FOR_POSITION) &&
239
+ has_blob_primary_key (table ());
240
+ // Skip the record buffer for covering multi-valued index range scans.
241
+ // The current implementation of Field_typed_array::key_cmp() needs the
242
+ // value of the generated column for the indexed expression, and this
243
+ // column is not available in the multi-valued index, so the storage
244
+ // engine cannot safely evaluate the end range condition when filling the
245
+ // record buffer when it's a covering scan.
246
+ skip_record_buffer |=
247
+ Overlaps (table ()->key_info [index].flags , HA_MULTI_VALUED_KEY) &&
248
+ table ()->key_read ;
241
249
if (!skip_record_buffer) {
242
250
if (set_record_buffer (table (), m_expected_rows)) {
243
251
return true ; /* purecov: inspected */
0 commit comments