Skip to content

Commit ebc2f0d

Browse files
committed
Avoid using HA_POS_ERROR constant when passing around values of type double.
This is error-prone and causes warnings on Windows
1 parent 325e071 commit ebc2f0d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

sql/opt_range.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,7 +2827,7 @@ double records_in_column_ranges(PARAM *param, uint idx,
28272827

28282828
/* Handle cases when we don't have a valid non-empty list of range */
28292829
if (!tree)
2830-
return HA_POS_ERROR;
2830+
return DBL_MAX;
28312831
if (tree->type == SEL_ARG::IMPOSSIBLE)
28322832
return (0L);
28332833

@@ -2847,9 +2847,9 @@ double records_in_column_ranges(PARAM *param, uint idx,
28472847
max_endp= range.end_key.length? &range.end_key : NULL;
28482848
rows= get_column_range_cardinality(field, min_endp, max_endp,
28492849
range.range_flag);
2850-
if (HA_POS_ERROR == rows)
2850+
if (DBL_MAX == rows)
28512851
{
2852-
total_rows= HA_POS_ERROR;
2852+
total_rows= DBL_MAX;
28532853
break;
28542854
}
28552855
total_rows += rows;
@@ -3083,7 +3083,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
30833083
else
30843084
{
30853085
rows= records_in_column_ranges(&param, idx, key);
3086-
if (rows != HA_POS_ERROR)
3086+
if (rows != DBL_MAX)
30873087
key->field->cond_selectivity= rows/table_records;
30883088
}
30893089
}

sql/sql_statistics.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3752,7 +3752,10 @@ double get_column_avg_frequency(Field * field)
37523752
using the statistical data from the table column_stats.
37533753
37543754
@retval
3755-
The required estimate of the rows in the column range
3755+
- The required estimate of the rows in the column range
3756+
- If there is some kind of error, this function should return DBL_MAX (and
3757+
not HA_POS_ERROR as that is an integer constant).
3758+
37563759
*/
37573760

37583761
double get_column_range_cardinality(Field *field,

0 commit comments

Comments
 (0)