mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-20740: Odd computations in calculate_cond_selectivity_for_table
Make SEL_ARG graph traversal code in sel_arg_range_seq_next() set max_key_parts first. (Pushing to 10.4 first)
This commit is contained in:
@ -315,7 +315,7 @@ public:
|
||||
*/
|
||||
key_map possible_keys;
|
||||
longlong baseflag;
|
||||
uint max_key_part, range_count;
|
||||
uint max_key_parts, range_count;
|
||||
|
||||
bool quick; // Don't calulate possible keys
|
||||
|
||||
@ -7387,7 +7387,7 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree,
|
||||
index_scan->idx= idx;
|
||||
index_scan->keynr= keynr;
|
||||
index_scan->key_info= ¶m->table->key_info[keynr];
|
||||
index_scan->used_key_parts= param->max_key_part+1;
|
||||
index_scan->used_key_parts= param->max_key_parts;
|
||||
index_scan->range_count= param->range_count;
|
||||
index_scan->records= found_records;
|
||||
index_scan->sel_arg= key;
|
||||
@ -11042,7 +11042,7 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only,
|
||||
seq.start= tree;
|
||||
|
||||
param->range_count=0;
|
||||
param->max_key_part=0;
|
||||
param->max_key_parts=0;
|
||||
|
||||
seq.is_ror_scan= TRUE;
|
||||
if (file->index_flags(keynr, 0, TRUE) & HA_KEY_SCAN_NOT_ROR)
|
||||
@ -11055,9 +11055,13 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only,
|
||||
*mrr_flags|= HA_MRR_NO_ASSOCIATION | HA_MRR_SORTED;
|
||||
|
||||
bool pk_is_clustered= file->primary_key_is_clustered();
|
||||
// TODO: param->max_key_parts holds 0 now, and not the #keyparts used.
|
||||
// Passing wrong second argument to index_flags() makes no difference for
|
||||
// most storage engines but might be an issue for MyRocks with certain
|
||||
// datatypes.
|
||||
if (index_only &&
|
||||
(file->index_flags(keynr, param->max_key_part, 1) & HA_KEYREAD_ONLY) &&
|
||||
!(file->index_flags(keynr, param->max_key_part, 1) & HA_CLUSTERED_INDEX))
|
||||
(file->index_flags(keynr, param->max_key_parts, 1) & HA_KEYREAD_ONLY) &&
|
||||
!(file->index_flags(keynr, param->max_key_parts, 1) & HA_CLUSTERED_INDEX))
|
||||
*mrr_flags |= HA_MRR_INDEX_ONLY;
|
||||
|
||||
if (param->thd->lex->sql_command != SQLCOM_SELECT)
|
||||
@ -11088,7 +11092,7 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only,
|
||||
if (update_tbl_stats)
|
||||
{
|
||||
param->table->quick_keys.set_bit(keynr);
|
||||
param->table->quick_key_parts[keynr]= param->max_key_part+1;
|
||||
param->table->quick_key_parts[keynr]= param->max_key_parts;
|
||||
param->table->quick_n_ranges[keynr]= param->range_count;
|
||||
param->table->quick_condition_rows=
|
||||
MY_MIN(param->table->quick_condition_rows, rows);
|
||||
|
Reference in New Issue
Block a user