diff options
author | Sergei Petrunia <sergey@mariadb.com> | 2023-02-03 14:20:22 +0200 |
---|---|---|
committer | Sergei Petrunia <sergey@mariadb.com> | 2023-02-03 15:42:20 +0300 |
commit | f4c09baf1067e9c649b11cb7e414cb074af47706 (patch) | |
tree | 7d529b90688f029c94ec19e739818b749a280c42 | |
parent | a2f581ecb93ede1ba8dedc4f31452e8bb38b4797 (diff) | |
download | mariadb-git-bb-11.0-jan23-rebase-try3.tar.gz |
MDEV-30525: Assertion `ranges > 0' fails in IO_AND_CPU_COST handler::keyread_timebb-11.0-jan23-rebase-try3
Make get_best_group_min_max() exit early if the table has
table->records()=0. Attempting to compute loose scan over 0
groups eventually causes an assert when trying to get the
cost of reading 0 ranges.
-rw-r--r-- | mysql-test/main/merge.result | 9 | ||||
-rw-r--r-- | mysql-test/main/merge.test | 9 | ||||
-rw-r--r-- | sql/opt_range.cc | 2 |
3 files changed, 20 insertions, 0 deletions
diff --git a/mysql-test/main/merge.result b/mysql-test/main/merge.result index 335d06fd062..307b445ab50 100644 --- a/mysql-test/main/merge.result +++ b/mysql-test/main/merge.result @@ -3936,5 +3936,14 @@ SELECT a, COUNT(*) FROM t1 WHERE a >= '2000-01-01 00:00:00' GROUP BY a; a COUNT(*) DROP TABLE t1; # +# MDEV-30525: Assertion `ranges > 0' fails in IO_AND_CPU_COST handler::keyread_time +# +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=MRG_MyISAM UNION=(t1,t2); +SELECT DISTINCT a FROM tm WHERE a > 50; +a +DROP TABLE tm, t1, t2; +# # End of 11.0 tests # diff --git a/mysql-test/main/merge.test b/mysql-test/main/merge.test index aef2fa364d6..83173a46a8f 100644 --- a/mysql-test/main/merge.test +++ b/mysql-test/main/merge.test @@ -2897,5 +2897,14 @@ SELECT a, COUNT(*) FROM t1 WHERE a >= '2000-01-01 00:00:00' GROUP BY a; DROP TABLE t1; --echo # +--echo # MDEV-30525: Assertion `ranges > 0' fails in IO_AND_CPU_COST handler::keyread_time +--echo # +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=MRG_MyISAM UNION=(t1,t2); +SELECT DISTINCT a FROM tm WHERE a > 50; +DROP TABLE tm, t1, t2; + +--echo # --echo # End of 11.0 tests --echo # diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 93e37d732d4..f2696683124 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -14049,6 +14049,8 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) else if (join->conds && join->conds->used_tables() & OUTER_REF_TABLE_BIT) // Cannot execute with correlated conditions. cause= "correlated conditions"; + else if (table->stat_records() == 0) + cause= "Empty table"; // Exit now, records=0 messes up cost computations if (cause) { |