Commit d6616966 authored by Sergei Petrunia's avatar Sergei Petrunia Committed by Monty

MDEV-30568: Assertion `cond_selectivity <= 1.000000001' failed in get_range_limit_read_cost

In get_range_limit_read_cost(), handle the case where range_rows=0.
parent cc81ea1c
......@@ -3945,5 +3945,14 @@ SELECT DISTINCT a FROM tm WHERE a > 50;
a
DROP TABLE tm, t1, t2;
#
# MDEV-30568 Assertion `cond_selectivity <= 1.000000001' failed in get_range_limit_read_cost
#
CREATE TABLE t1 (f INT, KEY(f)) ENGINE=MyISAM;
CREATE TABLE t2 (f INT, KEY(f)) ENGINE=MyISAM;
CREATE TABLE tm (f INT, KEY(f)) ENGINE=MERGE UNION = (t1, t2);
SELECT DISTINCT f FROM tm WHERE f IN (47, 126, 97, 48, 73, 0);
f
DROP TABLE tm, t1, t2;
#
# End of 11.0 tests
#
......@@ -2905,6 +2905,15 @@ CREATE TABLE tm (a INT, KEY(a)) ENGINE=MRG_MyISAM UNION=(t1,t2);
SELECT DISTINCT a FROM tm WHERE a > 50;
DROP TABLE tm, t1, t2;
--echo #
--echo # MDEV-30568 Assertion `cond_selectivity <= 1.000000001' failed in get_range_limit_read_cost
--echo #
CREATE TABLE t1 (f INT, KEY(f)) ENGINE=MyISAM;
CREATE TABLE t2 (f INT, KEY(f)) ENGINE=MyISAM;
CREATE TABLE tm (f INT, KEY(f)) ENGINE=MERGE UNION = (t1, t2);
SELECT DISTINCT f FROM tm WHERE f IN (47, 126, 97, 48, 73, 0);
DROP TABLE tm, t1, t2;
--echo #
--echo # End of 11.0 tests
--echo #
......@@ -30475,7 +30475,15 @@ static bool get_range_limit_read_cost(const POSITION *pos,
account that using key2 we have to examine much fewer rows.
*/
best_rows= pos->records_out; // Best rows with any key/keys
double cond_selectivity= best_rows / range_rows;
double cond_selectivity;
/*
We assign "double range_rows" from integer #rows a few lines above
so comparison with 0.0 makes sense
*/
if (range_rows > 0.0)
cond_selectivity= best_rows / range_rows;
else
cond_selectivity= 1.0;
DBUG_ASSERT(cond_selectivity <= 1.000000001);
set_if_smaller(cond_selectivity, 1.0);
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