mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
Merge magare.gmz:/home/kgeorge/mysql/work/B32268-5.0-opt
into magare.gmz:/home/kgeorge/mysql/work/B32268-5.1-opt mysql-test/r/group_min_max.result: Auto merged mysql-test/t/group_min_max.test: Auto merged sql/sql_select.cc: Auto merged
This commit is contained in:
commit
9eb12eb945
3 changed files with 72 additions and 1 deletions
|
@ -2326,3 +2326,49 @@ a
|
|||
2
|
||||
4
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT, b INT);
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3);
|
||||
INSERT INTO t1 SELECT a + 1, b FROM t1;
|
||||
INSERT INTO t1 SELECT a + 2, b FROM t1;
|
||||
EXPLAIN
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 12 Using temporary; Using filesort
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
a MIN(b) MAX(b)
|
||||
4 1 3
|
||||
3 1 3
|
||||
2 1 3
|
||||
1 1 3
|
||||
CREATE INDEX break_it ON t1 (a, b);
|
||||
EXPLAIN
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL break_it 10 NULL 7 Using index for group-by
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
|
||||
a MIN(b) MAX(b)
|
||||
1 1 3
|
||||
2 1 3
|
||||
3 1 3
|
||||
4 1 3
|
||||
EXPLAIN
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL break_it 10 NULL 7 Using index for group-by; Using temporary; Using filesort
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
a MIN(b) MAX(b)
|
||||
4 1 3
|
||||
3 1 3
|
||||
2 1 3
|
||||
1 1 3
|
||||
EXPLAIN
|
||||
SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL break_it 10 NULL 12 Using index
|
||||
SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
a MIN(b) MAX(b) AVG(b)
|
||||
4 1 3 2.0000
|
||||
3 1 3 2.0000
|
||||
2 1 3 2.0000
|
||||
1 1 3 2.0000
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -914,7 +914,31 @@ SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
|
|||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #32268: Indexed queries give bogus MIN and MAX results
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (a INT, b INT);
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3);
|
||||
INSERT INTO t1 SELECT a + 1, b FROM t1;
|
||||
INSERT INTO t1 SELECT a + 2, b FROM t1;
|
||||
|
||||
EXPLAIN
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
|
||||
CREATE INDEX break_it ON t1 (a, b);
|
||||
|
||||
EXPLAIN
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
|
||||
|
||||
EXPLAIN
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
|
||||
EXPLAIN
|
||||
SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -10570,7 +10570,8 @@ Next_select_func setup_end_select_func(JOIN *join)
|
|||
/* Set up select_end */
|
||||
if (table)
|
||||
{
|
||||
if (table->group && tmp_tbl->sum_func_count)
|
||||
if (table->group && tmp_tbl->sum_func_count &&
|
||||
!tmp_tbl->precomputed_group_by)
|
||||
{
|
||||
if (table->s->keys)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue