Commit 368cb39d authored by unknown's avatar unknown

Merge bk-internal:/home/bk/mysql-5.1-new

into  neptunus.(none):/home/msvensson/mysql/mysql-5.1

parents f3549695 fb2477b3
......@@ -412,7 +412,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` char(10) CHARACTER SET utf8 DEFAULT NULL,
UNIQUE KEY `a` USING HASH (`c`(1))
UNIQUE KEY `a` (`c`(1)) USING HASH
) ENGINE=MEMORY DEFAULT CHARSET=latin1
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
insert into t1 values ('aa');
......@@ -448,7 +448,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` char(10) CHARACTER SET utf8 DEFAULT NULL,
UNIQUE KEY `a` USING BTREE (`c`(1))
UNIQUE KEY `a` (`c`(1)) USING BTREE
) ENGINE=MEMORY DEFAULT CHARSET=latin1
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
insert into t1 values ('aa');
......@@ -570,7 +570,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` char(10) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
UNIQUE KEY `a` USING HASH (`c`(1))
UNIQUE KEY `a` (`c`(1)) USING HASH
) ENGINE=MEMORY DEFAULT CHARSET=latin1
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
insert into t1 values ('aa');
......@@ -606,7 +606,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` char(10) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
UNIQUE KEY `a` USING BTREE (`c`(1))
UNIQUE KEY `a` (`c`(1)) USING BTREE
) ENGINE=MEMORY DEFAULT CHARSET=latin1
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
insert into t1 values ('aa');
......
......@@ -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;
......@@ -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;
......@@ -556,9 +556,9 @@ t1 CREATE TABLE `t1` (
`v` varchar(10) DEFAULT NULL,
`c` char(10) DEFAULT NULL,
`t` varchar(50) DEFAULT NULL,
KEY `v` USING BTREE (`v`),
KEY `c` USING BTREE (`c`),
KEY `t` USING BTREE (`t`(10))
KEY `v` (`v`) USING BTREE,
KEY `c` (`c`) USING BTREE,
KEY `t` (`t`(10)) USING BTREE
) ENGINE=MEMORY DEFAULT CHARSET=latin1
select count(*) from t1;
count(*)
......
......@@ -460,7 +460,7 @@ SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL,
KEY `i` USING HASH (`i`)
KEY `i` (`i`) USING HASH
) ENGINE=MEMORY DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 (i int, KEY USING BTREE (i)) ENGINE=MEMORY;
......@@ -468,7 +468,7 @@ SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL,
KEY `i` USING BTREE (`i`)
KEY `i` (`i`) USING BTREE
) ENGINE=MEMORY DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 (i int, KEY (i)) ENGINE=MyISAM;
......@@ -484,7 +484,7 @@ SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL,
KEY `i` USING BTREE (`i`)
KEY `i` (`i`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 (i int, KEY (i)) ENGINE=MyISAM;
......@@ -507,14 +507,14 @@ SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL,
KEY `i` USING BTREE (`i`)
KEY `i` (`i`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=latin1
ALTER TABLE t1 ENGINE=MEMORY;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL,
KEY `i` USING BTREE (`i`)
KEY `i` (`i`) USING BTREE
) ENGINE=MEMORY DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1(
......@@ -549,8 +549,8 @@ Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` int(11) NOT NULL,
PRIMARY KEY USING HASH (`c1`),
KEY `c2` USING BTREE (`c2`)
PRIMARY KEY (`c1`) USING HASH,
KEY `c2` (`c2`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
flush tables;
......
......@@ -18,7 +18,7 @@ t1 CREATE TABLE `t1` (
`pseudo` varchar(35) CHARACTER SET latin2 NOT NULL DEFAULT '',
`email` varchar(60) CHARACTER SET latin2 NOT NULL DEFAULT '',
PRIMARY KEY (`a`),
UNIQUE KEY `email` USING BTREE (`email`)
UNIQUE KEY `email` (`email`) USING BTREE
) ENGINE=MEMORY DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
set @@sql_mode="ansi_quotes";
show variables like 'sql_mode';
......@@ -31,7 +31,7 @@ t1 CREATE TABLE "t1" (
"pseudo" varchar(35) CHARACTER SET latin2 NOT NULL DEFAULT '',
"email" varchar(60) CHARACTER SET latin2 NOT NULL DEFAULT '',
PRIMARY KEY ("a"),
UNIQUE KEY "email" USING BTREE ("email")
UNIQUE KEY "email" ("email") USING BTREE
) ENGINE=MEMORY DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
set @@sql_mode="no_table_options";
show variables like 'sql_mode';
......@@ -44,7 +44,7 @@ t1 CREATE TABLE `t1` (
`pseudo` varchar(35) CHARACTER SET latin2 NOT NULL DEFAULT '',
`email` varchar(60) CHARACTER SET latin2 NOT NULL DEFAULT '',
PRIMARY KEY (`a`),
UNIQUE KEY `email` USING BTREE (`email`)
UNIQUE KEY `email` (`email`) USING BTREE
)
set @@sql_mode="no_key_options";
show variables like 'sql_mode';
......
......@@ -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;
......@@ -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;
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment