Skip to content

Commit 6ecc238

Browse files
author
Tor Didriksen
committed
WL#11322 SUPPORT LOOSE INDEX RANGE SCANS FOR LOW CARDINALITY.
Post push fix sql/opt_range.cc:14196:22: runtime error: -256 is outside the range of representable values of type 'unsigned int' #0 0x4248a9d in cost_skip_scan(TABLE*, unsigned int, unsigned int, unsigned long long, Cost_estimate*, unsigned long long*, Item*, Opt_trace_object*) sql/opt_range.cc:14196:22 #1 0x41c524c in get_best_skip_scan(PARAM*, SEL_TREE*, bool) sql/opt_range.cc:14086:5 #2 0x41b7b65 in test_quick_select(THD*, Bitmap<64u>, unsigned long long, unsigned long long, bool, enum_order, QEP_shared_owner const*, Item*, Bitmap<64u>*, QUICK_SELECT_I**) sql/opt_range.cc:3352:23 #3 0x458fc08 in get_quick_record_count(THD*, JOIN_TAB*, unsigned long long) sql/sql_optimizer.cc:5542:17 #4 0x458a0cd in JOIN::estimate_rowcount() sql/sql_optimizer.cc:5290:25 The fix is to handle REC_PER_KEY_UNKNOWN explicitly, to avoid using -1.0 in computations later. Change-Id: Ie8a81bdf7323e4f66abcad0a9aca776de8acd945
1 parent 458e6d2 commit 6ecc238

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sql/opt_range.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14186,10 +14186,11 @@ void cost_skip_scan(TABLE *table, uint key, uint distinct_key_parts,
1418614186
skip_scan_records = quick_prefix_records;
1418714187

1418814188
/* Compute the number of keys in a group. */
14189-
if (index_info->has_records_per_key(distinct_key_parts))
14189+
if (index_info->has_records_per_key(distinct_key_parts)) {
1419014190
// Use index statistics
1419114191
keys_per_group = index_info->records_per_key(distinct_key_parts - 1);
14192-
else
14192+
if (keys_per_group == REC_PER_KEY_UNKNOWN) keys_per_group = 1.0;
14193+
} else
1419314194
/* If there is no statistics try to guess */
1419414195
keys_per_group = guess_rec_per_key(table, index_info, distinct_key_parts);
1419514196

0 commit comments

Comments
 (0)