Commit 9c401c8c authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-30525: Assertion `ranges > 0' fails in IO_AND_CPU_COST

Part #2: fix the case where table->stat_records()=1 (due to EITS
statistics), but the range returns rows=0.
parent d61bc94f
...@@ -3944,6 +3944,17 @@ CREATE TABLE tm (a INT, KEY(a)) ENGINE=MRG_MyISAM UNION=(t1,t2); ...@@ -3944,6 +3944,17 @@ CREATE TABLE tm (a INT, KEY(a)) ENGINE=MRG_MyISAM UNION=(t1,t2);
SELECT DISTINCT a FROM tm WHERE a > 50; SELECT DISTINCT a FROM tm WHERE a > 50;
a a
DROP TABLE tm, t1, t2; DROP TABLE tm, t1, t2;
# Testcase 2:
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM;
CREATE TABLE t2 (a INT, KEY(a)) ENGINE=MyISAM;
CREATE TABLE tm (a INT, KEY(a)) ENGINE=MERGE UNION = (t1, t2) INSERT_METHOD=FIRST;
ANALYZE TABLE tm PERSISTENT FOR ALL;
Table Op Msg_type Msg_text
test.tm analyze status Engine-independent statistics collected
test.tm analyze note The storage engine for the table doesn't support analyze
SELECT DISTINCT a FROM (SELECT * FROM tm WHERE a iS NOT NULL) AS sq;
a
DROP TABLE tm, t1, t2;
# #
# MDEV-30568 Assertion `cond_selectivity <= 1.000000001' failed in get_range_limit_read_cost # MDEV-30568 Assertion `cond_selectivity <= 1.000000001' failed in get_range_limit_read_cost
# #
......
...@@ -2905,6 +2905,14 @@ CREATE TABLE tm (a INT, KEY(a)) ENGINE=MRG_MyISAM UNION=(t1,t2); ...@@ -2905,6 +2905,14 @@ CREATE TABLE tm (a INT, KEY(a)) ENGINE=MRG_MyISAM UNION=(t1,t2);
SELECT DISTINCT a FROM tm WHERE a > 50; SELECT DISTINCT a FROM tm WHERE a > 50;
DROP TABLE tm, t1, t2; DROP TABLE tm, t1, t2;
--echo # Testcase 2:
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM;
CREATE TABLE t2 (a INT, KEY(a)) ENGINE=MyISAM;
CREATE TABLE tm (a INT, KEY(a)) ENGINE=MERGE UNION = (t1, t2) INSERT_METHOD=FIRST;
ANALYZE TABLE tm PERSISTENT FOR ALL;
SELECT DISTINCT a FROM (SELECT * FROM tm WHERE a iS NOT NULL) AS sq;
DROP TABLE tm, t1, t2;
--echo # --echo #
--echo # MDEV-30568 Assertion `cond_selectivity <= 1.000000001' failed in get_range_limit_read_cost --echo # MDEV-30568 Assertion `cond_selectivity <= 1.000000001' failed in get_range_limit_read_cost
--echo # --echo #
......
...@@ -14527,6 +14527,17 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) ...@@ -14527,6 +14527,17 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
if ((cur_index_tree= tree->keys[cur_param_idx])) if ((cur_index_tree= tree->keys[cur_param_idx]))
{ {
cur_quick_prefix_records= param->quick_rows[cur_index]; cur_quick_prefix_records= param->quick_rows[cur_index];
if (!cur_quick_prefix_records)
{
/*
Non-constant table has a range with rows=0. Can happen e.g. for
Merge tables. Regular range access will be just as good as loose
scan.
*/
if (unlikely(trace_idx.trace_started()))
trace_idx.add("aborting_search", "range with rows=0");
DBUG_RETURN(NULL);
}
if (unlikely(cur_index_tree && thd->trace_started())) if (unlikely(cur_index_tree && thd->trace_started()))
{ {
Json_writer_array trace_range(thd, "ranges"); Json_writer_array trace_range(thd, "ranges");
......
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