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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
baba405c
Commit
baba405c
authored
May 09, 2006
by
gkodinov@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/home/kgeorge/mysql/5.0/B18068
into mysql.com:/home/kgeorge/mysql/5.1/B18068
parents
c4f34104
7bae0de3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
0 deletions
+77
-0
mysql-test/r/distinct.result
mysql-test/r/distinct.result
+12
-0
mysql-test/r/group_min_max.result
mysql-test/r/group_min_max.result
+22
-0
mysql-test/t/distinct.test
mysql-test/t/distinct.test
+16
-0
mysql-test/t/group_min_max.test
mysql-test/t/group_min_max.test
+16
-0
sql/sql_select.cc
sql/sql_select.cc
+11
-0
No files found.
mysql-test/r/distinct.result
View file @
baba405c
...
...
@@ -533,3 +533,15 @@ select count(distinct concat(x,y)) from t1;
count(distinct concat(x,y))
2
drop table t1;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b));
INSERT INTO t1 VALUES (1, 101);
INSERT INTO t1 SELECT a + 1, a + 101 FROM t1;
INSERT INTO t1 SELECT a + 2, a + 102 FROM t1;
INSERT INTO t1 SELECT a + 4, a + 104 FROM t1;
INSERT INTO t1 SELECT a + 8, a + 108 FROM t1;
EXPLAIN SELECT DISTINCT a,a FROM t1 WHERE b < 12 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 8 NULL 16 Using where; Using index
SELECT DISTINCT a,a FROM t1 WHERE b < 12 ORDER BY a;
a a
DROP TABLE t1;
mysql-test/r/group_min_max.result
View file @
baba405c
...
...
@@ -2116,3 +2116,25 @@ COUNT(DISTINCT a)
1
DROP TABLE t1;
DROP PROCEDURE a;
CREATE TABLE t1 (a varchar(64) NOT NULL default '', PRIMARY KEY(a));
INSERT INTO t1 (a) VALUES
(''), ('CENTRAL'), ('EASTERN'), ('GREATER LONDON'),
('NORTH CENTRAL'), ('NORTH EAST'), ('NORTH WEST'), ('SCOTLAND'),
('SOUTH EAST'), ('SOUTH WEST'), ('WESTERN');
EXPLAIN SELECT DISTINCT a,a FROM t1 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL PRIMARY 66 NULL 12 Using index for group-by
SELECT DISTINCT a,a FROM t1 ORDER BY a;
a a
CENTRAL CENTRAL
EASTERN EASTERN
GREATER LONDON GREATER LONDON
NORTH CENTRAL NORTH CENTRAL
NORTH EAST NORTH EAST
NORTH WEST NORTH WEST
SCOTLAND SCOTLAND
SOUTH EAST SOUTH EAST
SOUTH WEST SOUTH WEST
WESTERN WESTERN
DROP TABLE t1;
mysql-test/t/distinct.test
View file @
baba405c
...
...
@@ -382,3 +382,19 @@ INSERT INTO t1 VALUES
select
count
(
distinct
x
,
y
)
from
t1
;
select
count
(
distinct
concat
(
x
,
y
))
from
t1
;
drop
table
t1
;
#
# Bug #18068: SELECT DISTINCT
#
CREATE
TABLE
t1
(
a
INT
,
b
INT
,
PRIMARY
KEY
(
a
,
b
));
INSERT
INTO
t1
VALUES
(
1
,
101
);
INSERT
INTO
t1
SELECT
a
+
1
,
a
+
101
FROM
t1
;
INSERT
INTO
t1
SELECT
a
+
2
,
a
+
102
FROM
t1
;
INSERT
INTO
t1
SELECT
a
+
4
,
a
+
104
FROM
t1
;
INSERT
INTO
t1
SELECT
a
+
8
,
a
+
108
FROM
t1
;
EXPLAIN
SELECT
DISTINCT
a
,
a
FROM
t1
WHERE
b
<
12
ORDER
BY
a
;
SELECT
DISTINCT
a
,
a
FROM
t1
WHERE
b
<
12
ORDER
BY
a
;
DROP
TABLE
t1
;
mysql-test/t/group_min_max.test
View file @
baba405c
...
...
@@ -782,3 +782,19 @@ SELECT COUNT(DISTINCT a) FROM t1 WHERE a=0;
DROP
TABLE
t1
;
DROP
PROCEDURE
a
;
#
# Bug #18068: SELECT DISTINCT
#
CREATE
TABLE
t1
(
a
varchar
(
64
)
NOT
NULL
default
''
,
PRIMARY
KEY
(
a
));
INSERT
INTO
t1
(
a
)
VALUES
(
''
),
(
'CENTRAL'
),
(
'EASTERN'
),
(
'GREATER LONDON'
),
(
'NORTH CENTRAL'
),
(
'NORTH EAST'
),
(
'NORTH WEST'
),
(
'SCOTLAND'
),
(
'SOUTH EAST'
),
(
'SOUTH WEST'
),
(
'WESTERN'
);
EXPLAIN
SELECT
DISTINCT
a
,
a
FROM
t1
ORDER
BY
a
;
SELECT
DISTINCT
a
,
a
FROM
t1
ORDER
BY
a
;
DROP
TABLE
t1
;
sql/sql_select.cc
View file @
baba405c
...
...
@@ -12803,6 +12803,17 @@ create_distinct_group(THD *thd, Item **ref_pointer_array,
{
if
(
!
item
->
const_item
()
&&
!
item
->
with_sum_func
&&
!
item
->
marker
)
{
/*
Don't put duplicate columns from the SELECT list into the
GROUP BY list.
*/
ORDER
*
ord_iter
;
for
(
ord_iter
=
group
;
ord_iter
;
ord_iter
=
ord_iter
->
next
)
if
((
*
ord_iter
->
item
)
->
eq
(
item
,
1
))
break
;
if
(
ord_iter
)
continue
;
ORDER
*
ord
=
(
ORDER
*
)
thd
->
calloc
(
sizeof
(
ORDER
));
if
(
!
ord
)
return
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