diff options
author | Igor Babaev <igor@askmonty.org> | 2013-01-11 20:26:34 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2013-01-11 20:26:34 -0800 |
commit | 12bf6fe85893f6a69a74ec1c733e533051058dd3 (patch) | |
tree | e6e05cb8a6417543474391eca64ac00493f7e60c | |
parent | d8acafcbf273120726dea27507a1a3ab7b0bd821 (diff) | |
download | mariadb-git-12bf6fe85893f6a69a74ec1c733e533051058dd3.tar.gz |
Fixed bug mdev-4025.
The bug could lead to a wrong estimate of the number of expected rows
in the output of the EXPLAIN commands for queries with GROUP BY.
This could be observed in the test case for LP bug 934348.
-rw-r--r-- | mysql-test/r/subselect_sj_jcl6.result | 4 | ||||
-rw-r--r-- | sql/sql_select.cc | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result index a189132b11a..6247688d635 100644 --- a/mysql-test/r/subselect_sj_jcl6.result +++ b/mysql-test/r/subselect_sj_jcl6.result @@ -2978,7 +2978,7 @@ EXPLAIN SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a) GROUP BY a HAVING a != 'z'; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t index idx_a idx_a 4 NULL 1 Using index +1 PRIMARY t index idx_a idx_a 4 NULL 3 Using index 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where 2 MATERIALIZED t1 ref idx_a idx_a 4 test.t2.b 2 Using index @@ -2992,7 +2992,7 @@ EXPLAIN SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a) GROUP BY a HAVING a != 'z'; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t index idx_a idx_a 4 NULL 1 Using index +1 PRIMARY t index idx_a idx_a 4 NULL 3 Using index 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where 2 MATERIALIZED t1 ref idx_a idx_a 4 test.t2.b 2 Using index diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ca7e1bf2a66..aa47793df8f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -18371,8 +18371,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit_arg, and as result we'll choose an index scan when using ref/range access + filesort will be cheaper. */ - select_limit= (ha_rows) (select_limit < fanout ? - 1 : select_limit/fanout); + if (select_limit_arg != HA_POS_ERROR) + select_limit= (ha_rows) (select_limit < fanout ? + 1 : select_limit/fanout); /* We assume that each of the tested indexes is not correlated with ref_key. Thus, to select first N records we have to scan |