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
f672e5bc
Commit
f672e5bc
authored
Aug 29, 2007
by
mhansson/martin@linux-st28.site
Browse files
Options
Browse Files
Download
Plain Diff
Merge mhansson@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into linux-st28.site:/home/martin/mysql/src/bugx/my50-bugx
parents
a8c7e450
a4d5d920
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
168 additions
and
3 deletions
+168
-3
.bzrignore
.bzrignore
+5
-0
mysql-test/r/distinct.result
mysql-test/r/distinct.result
+3
-3
mysql-test/r/group_by.result
mysql-test/r/group_by.result
+49
-0
mysql-test/r/innodb_mysql.result
mysql-test/r/innodb_mysql.result
+49
-0
mysql-test/t/group_by.test
mysql-test/t/group_by.test
+27
-0
mysql-test/t/innodb_mysql.test
mysql-test/t/innodb_mysql.test
+27
-0
sql/sql_select.cc
sql/sql_select.cc
+8
-0
No files found.
.bzrignore
View file @
f672e5bc
...
@@ -1345,3 +1345,8 @@ zlib/*.vcproj
...
@@ -1345,3 +1345,8 @@ zlib/*.vcproj
debian/control
debian/control
debian/defs.mk
debian/defs.mk
include/abi_check
include/abi_check
support-files/mysqld_multi.server
tests/bug25714
cscope.in.out
cscope.out
cscope.po.out
mysql-test/r/distinct.result
View file @
f672e5bc
...
@@ -526,10 +526,10 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -526,10 +526,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
EXPLAIN SELECT a,b FROM t1 GROUP BY a,b;
EXPLAIN SELECT a,b FROM t1 GROUP BY a,b;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
Using filesort
EXPLAIN SELECT DISTINCT a,b FROM t1 GROUP BY a,b;
EXPLAIN SELECT DISTINCT a,b FROM t1 GROUP BY a,b;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
Using filesort
CREATE TABLE t2(a INT, b INT NOT NULL, c INT NOT NULL, d INT,
CREATE TABLE t2(a INT, b INT NOT NULL, c INT NOT NULL, d INT,
PRIMARY KEY (a,b));
PRIMARY KEY (a,b));
INSERT INTO t2 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
INSERT INTO t2 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
...
@@ -554,7 +554,7 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -554,7 +554,7 @@ id select_type table type possible_keys key key_len ref rows Extra
CREATE UNIQUE INDEX c_b_unq ON t2 (c,b);
CREATE UNIQUE INDEX c_b_unq ON t2 (c,b);
EXPLAIN SELECT DISTINCT a,b,d FROM t2 GROUP BY c,b,d;
EXPLAIN SELECT DISTINCT a,b,d FROM t2 GROUP BY c,b,d;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
Using filesort
DROP TABLE t1,t2;
DROP TABLE t1,t2;
create table t1 (id int, dsc varchar(50));
create table t1 (id int, dsc varchar(50));
insert into t1 values (1, "line number one"), (2, "line number two"), (3, "line number three");
insert into t1 values (1, "line number one"), (2, "line number two"), (3, "line number three");
...
...
mysql-test/r/group_by.result
View file @
f672e5bc
...
@@ -1064,3 +1064,52 @@ select t1.f1,t.* from t1, t1 t group by 1;
...
@@ -1064,3 +1064,52 @@ select t1.f1,t.* from t1, t1 t group by 1;
ERROR 42000: 'test.t.f1' isn't in GROUP BY
ERROR 42000: 'test.t.f1' isn't in GROUP BY
drop table t1;
drop table t1;
SET SQL_MODE = '';
SET SQL_MODE = '';
CREATE TABLE t1(
a INT,
b INT NOT NULL,
c INT NOT NULL,
d INT,
UNIQUE KEY (c,b)
);
INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
SELECT c,b,d FROM t1 GROUP BY c,b,d;
c b d
1 1 50
3 1 4
3 2 40
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
c b d
1 1 50
3 2 40
3 1 4
EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
SELECT c,b,d FROM t1 ORDER BY c,b,d;
c b d
1 1 50
3 1 4
3 2 40
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
SELECT c,b,d FROM t1 GROUP BY c,b;
c b d
1 1 50
3 1 4
3 2 40
EXPLAIN SELECT c,b FROM t1 GROUP BY c,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL c 8 NULL 3 Using index
SELECT c,b FROM t1 GROUP BY c,b;
c b
1 1
3 1
3 2
DROP TABLE t1;
mysql-test/r/innodb_mysql.result
View file @
f672e5bc
...
@@ -1065,4 +1065,53 @@ a b
...
@@ -1065,4 +1065,53 @@ a b
ROLLBACK;
ROLLBACK;
ROLLBACK;
ROLLBACK;
DROP TABLE t1;
DROP TABLE t1;
CREATE TABLE t1(
a INT,
b INT NOT NULL,
c INT NOT NULL,
d INT,
UNIQUE KEY (c,b)
) engine=innodb;
INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
SELECT c,b,d FROM t1 GROUP BY c,b,d;
c b d
1 1 50
3 1 4
3 2 40
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
c b d
1 1 50
3 1 4
3 2 40
EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
SELECT c,b,d FROM t1 ORDER BY c,b,d;
c b d
1 1 50
3 1 4
3 2 40
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL c 8 NULL 3
SELECT c,b,d FROM t1 GROUP BY c,b;
c b d
1 1 50
3 1 4
3 2 40
EXPLAIN SELECT c,b FROM t1 GROUP BY c,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL c 8 NULL 3 Using index
SELECT c,b FROM t1 GROUP BY c,b;
c b
1 1
3 1
3 2
DROP TABLE t1;
End of 5.0 tests
End of 5.0 tests
mysql-test/t/group_by.test
View file @
f672e5bc
...
@@ -788,3 +788,30 @@ select * from t1 group by f1, f2;
...
@@ -788,3 +788,30 @@ select * from t1 group by f1, f2;
select
t1
.
f1
,
t
.*
from
t1
,
t1
t
group
by
1
;
select
t1
.
f1
,
t
.*
from
t1
,
t1
t
group
by
1
;
drop
table
t1
;
drop
table
t1
;
SET
SQL_MODE
=
''
;
SET
SQL_MODE
=
''
;
#
# Bug#30596: GROUP BY optimization gives wrong result order
#
CREATE
TABLE
t1
(
a
INT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
,
d
INT
,
UNIQUE
KEY
(
c
,
b
)
);
INSERT
INTO
t1
VALUES
(
1
,
1
,
1
,
50
),
(
1
,
2
,
3
,
40
),
(
2
,
1
,
3
,
4
);
EXPLAIN
SELECT
c
,
b
,
d
FROM
t1
GROUP
BY
c
,
b
,
d
;
SELECT
c
,
b
,
d
FROM
t1
GROUP
BY
c
,
b
,
d
;
EXPLAIN
SELECT
c
,
b
,
d
FROM
t1
GROUP
BY
c
,
b
,
d
ORDER
BY
NULL
;
SELECT
c
,
b
,
d
FROM
t1
GROUP
BY
c
,
b
,
d
ORDER
BY
NULL
;
EXPLAIN
SELECT
c
,
b
,
d
FROM
t1
ORDER
BY
c
,
b
,
d
;
SELECT
c
,
b
,
d
FROM
t1
ORDER
BY
c
,
b
,
d
;
EXPLAIN
SELECT
c
,
b
,
d
FROM
t1
GROUP
BY
c
,
b
;
SELECT
c
,
b
,
d
FROM
t1
GROUP
BY
c
,
b
;
EXPLAIN
SELECT
c
,
b
FROM
t1
GROUP
BY
c
,
b
;
SELECT
c
,
b
FROM
t1
GROUP
BY
c
,
b
;
DROP
TABLE
t1
;
mysql-test/t/innodb_mysql.test
View file @
f672e5bc
...
@@ -910,4 +910,31 @@ ROLLBACK;
...
@@ -910,4 +910,31 @@ ROLLBACK;
ROLLBACK
;
ROLLBACK
;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
#
# Bug#30596: GROUP BY optimization gives wrong result order
#
CREATE
TABLE
t1
(
a
INT
,
b
INT
NOT
NULL
,
c
INT
NOT
NULL
,
d
INT
,
UNIQUE
KEY
(
c
,
b
)
)
engine
=
innodb
;
INSERT
INTO
t1
VALUES
(
1
,
1
,
1
,
50
),
(
1
,
2
,
3
,
40
),
(
2
,
1
,
3
,
4
);
EXPLAIN
SELECT
c
,
b
,
d
FROM
t1
GROUP
BY
c
,
b
,
d
;
SELECT
c
,
b
,
d
FROM
t1
GROUP
BY
c
,
b
,
d
;
EXPLAIN
SELECT
c
,
b
,
d
FROM
t1
GROUP
BY
c
,
b
,
d
ORDER
BY
NULL
;
SELECT
c
,
b
,
d
FROM
t1
GROUP
BY
c
,
b
,
d
ORDER
BY
NULL
;
EXPLAIN
SELECT
c
,
b
,
d
FROM
t1
ORDER
BY
c
,
b
,
d
;
SELECT
c
,
b
,
d
FROM
t1
ORDER
BY
c
,
b
,
d
;
EXPLAIN
SELECT
c
,
b
,
d
FROM
t1
GROUP
BY
c
,
b
;
SELECT
c
,
b
,
d
FROM
t1
GROUP
BY
c
,
b
;
EXPLAIN
SELECT
c
,
b
FROM
t1
GROUP
BY
c
,
b
;
SELECT
c
,
b
FROM
t1
GROUP
BY
c
,
b
;
DROP
TABLE
t1
;
--
echo
End
of
5.0
tests
--
echo
End
of
5.0
tests
sql/sql_select.cc
View file @
f672e5bc
...
@@ -1053,6 +1053,14 @@ JOIN::optimize()
...
@@ -1053,6 +1053,14 @@ JOIN::optimize()
find_field_in_order_list
,
find_field_in_order_list
,
(
void
*
)
group_list
))
(
void
*
)
group_list
))
{
{
/*
We have found that grouping can be removed since groups correspond to
only one row anyway, but we still have to guarantee correct result
order. The line below effectively rewrites the query from GROUP BY
<fields> to ORDER BY <fields>. One exception is if skip_sort_order is
set (see above), then we can simply skip GROUP BY.
*/
order
=
skip_sort_order
?
0
:
group_list
;
group_list
=
0
;
group_list
=
0
;
group
=
0
;
group
=
0
;
}
}
...
...
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