Commit ebc2f0da authored by Sergei Petrunia's avatar Sergei Petrunia

Avoid using HA_POS_ERROR constant when passing around values of type double.

This is error-prone and causes warnings on Windows
parent 325e071c
...@@ -2827,7 +2827,7 @@ double records_in_column_ranges(PARAM *param, uint idx, ...@@ -2827,7 +2827,7 @@ double records_in_column_ranges(PARAM *param, uint idx,
/* Handle cases when we don't have a valid non-empty list of range */ /* Handle cases when we don't have a valid non-empty list of range */
if (!tree) if (!tree)
return HA_POS_ERROR; return DBL_MAX;
if (tree->type == SEL_ARG::IMPOSSIBLE) if (tree->type == SEL_ARG::IMPOSSIBLE)
return (0L); return (0L);
...@@ -2847,9 +2847,9 @@ double records_in_column_ranges(PARAM *param, uint idx, ...@@ -2847,9 +2847,9 @@ double records_in_column_ranges(PARAM *param, uint idx,
max_endp= range.end_key.length? &range.end_key : NULL; max_endp= range.end_key.length? &range.end_key : NULL;
rows= get_column_range_cardinality(field, min_endp, max_endp, rows= get_column_range_cardinality(field, min_endp, max_endp,
range.range_flag); range.range_flag);
if (HA_POS_ERROR == rows) if (DBL_MAX == rows)
{ {
total_rows= HA_POS_ERROR; total_rows= DBL_MAX;
break; break;
} }
total_rows += rows; total_rows += rows;
...@@ -3083,7 +3083,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) ...@@ -3083,7 +3083,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
else else
{ {
rows= records_in_column_ranges(&param, idx, key); rows= records_in_column_ranges(&param, idx, key);
if (rows != HA_POS_ERROR) if (rows != DBL_MAX)
key->field->cond_selectivity= rows/table_records; key->field->cond_selectivity= rows/table_records;
} }
} }
......
...@@ -3752,7 +3752,10 @@ double get_column_avg_frequency(Field * field) ...@@ -3752,7 +3752,10 @@ double get_column_avg_frequency(Field * field)
using the statistical data from the table column_stats. using the statistical data from the table column_stats.
@retval @retval
The required estimate of the rows in the column range - The required estimate of the rows in the column range
- If there is some kind of error, this function should return DBL_MAX (and
not HA_POS_ERROR as that is an integer constant).
*/ */
double get_column_range_cardinality(Field *field, double get_column_range_cardinality(Field *field,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment