Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
7b1f0820
Commit
7b1f0820
authored
17 years ago
by
gkodinov/kgeorge@magare.gmz
Browse files
Options
Browse Files
Download
Plain Diff
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into magare.gmz:/home/kgeorge/mysql/autopush/B32268-5.0-opt
parents
410cc112
50d85111
Branches unavailable
Tags unavailable
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
1 deletion
+72
-1
mysql-test/r/group_min_max.result
mysql-test/r/group_min_max.result
+46
-0
mysql-test/t/group_min_max.test
mysql-test/t/group_min_max.test
+24
-0
sql/sql_select.cc
sql/sql_select.cc
+2
-1
No files found.
mysql-test/r/group_min_max.result
View file @
7b1f0820
...
@@ -2307,3 +2307,49 @@ a
...
@@ -2307,3 +2307,49 @@ a
2
2
4
4
DROP TABLE t1;
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;
This diff is collapsed.
Click to expand it.
mysql-test/t/group_min_max.test
View file @
7b1f0820
...
@@ -888,7 +888,31 @@ SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
...
@@ -888,7 +888,31 @@ SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
DROP
TABLE
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
;
This diff is collapsed.
Click to expand it.
sql/sql_select.cc
View file @
7b1f0820
...
@@ -10261,7 +10261,8 @@ Next_select_func setup_end_select_func(JOIN *join)
...
@@ -10261,7 +10261,8 @@ Next_select_func setup_end_select_func(JOIN *join)
/* Set up select_end */
/* Set up select_end */
if
(
table
)
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
)
if
(
table
->
s
->
keys
)
{
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment