Commit 11d37efa authored by evgen@moonbone.local's avatar evgen@moonbone.local

Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt

into  moonbone.local:/mnt/gentoo64/work/bk-trees/mysql-5.1-opt
parents eca8b1a6 f3e56b5a
...@@ -64,7 +64,7 @@ explain extended select * from v1 where f2=1; ...@@ -64,7 +64,7 @@ explain extended select * from v1 where f2=1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings: Warnings:
Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` where 1 Note 1003 select '1' AS `f1`,'1' AS `f2` from `test`.`t1` where 1
explain extended select * from t1 where 0; explain extended select * from t1 where 0;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
...@@ -74,7 +74,7 @@ explain extended select * from t1 where 1; ...@@ -74,7 +74,7 @@ explain extended select * from t1 where 1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings: Warnings:
Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` where 1 Note 1003 select '1' AS `f1`,'1' AS `f2` from `test`.`t1` where 1
explain extended select * from t1 having 0; explain extended select * from t1 having 0;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
...@@ -84,6 +84,6 @@ explain extended select * from t1 having 1; ...@@ -84,6 +84,6 @@ explain extended select * from t1 having 1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings: Warnings:
Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` having 1 Note 1003 select '1' AS `f1`,'1' AS `f2` from `test`.`t1` having 1
drop view v1; drop view v1;
drop table t1; drop table t1;
...@@ -8,7 +8,7 @@ explain extended select default(str), default(strnull), default(intg), default(r ...@@ -8,7 +8,7 @@ explain extended select default(str), default(strnull), default(intg), default(r
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings: Warnings:
Note 1003 select default(`test`.`t1`.`str`) AS `default(str)`,default(`test`.`t1`.`strnull`) AS `default(strnull)`,default(`test`.`t1`.`intg`) AS `default(intg)`,default(`test`.`t1`.`rel`) AS `default(rel)` from `test`.`t1` Note 1003 select default('') AS `default(str)`,default('') AS `default(strnull)`,default('0') AS `default(intg)`,default('0') AS `default(rel)` from `test`.`t1`
select * from t1 where str <> default(str); select * from t1 where str <> default(str);
str strnull intg rel str strnull intg rel
0 0 0 0
......
...@@ -40,7 +40,7 @@ explain extended select * from t1 where xxx regexp('is a test of some long text ...@@ -40,7 +40,7 @@ explain extended select * from t1 where xxx regexp('is a test of some long text
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings: Warnings:
Note 1003 select `test`.`t1`.`xxx` AS `xxx` from `test`.`t1` where (`test`.`t1`.`xxx` regexp _latin1'is a test of some long text to') Note 1003 select 'this is a test of some long text to see what happens' AS `xxx` from `test`.`t1` where ('this is a test of some long text to see what happens' regexp _latin1'is a test of some long text to')
select * from t1 where xxx regexp('is a test of some long text to '); select * from t1 where xxx regexp('is a test of some long text to ');
xxx xxx
this is a test of some long text to see what happens this is a test of some long text to see what happens
......
...@@ -1309,12 +1309,12 @@ explain extended select encode(f1,'zxcv') as 'enc' from t1; ...@@ -1309,12 +1309,12 @@ explain extended select encode(f1,'zxcv') as 'enc' from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found 1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings: Warnings:
Note 1003 select encode(`test`.`t1`.`f1`,_latin1'zxcv') AS `enc` from `test`.`t1` Note 1003 select encode('',_latin1'zxcv') AS `enc` from `test`.`t1`
explain extended select decode(f1,'zxcv') as 'enc' from t1; explain extended select decode(f1,'zxcv') as 'enc' from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found 1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings: Warnings:
Note 1003 select decode(`test`.`t1`.`f1`,_latin1'zxcv') AS `enc` from `test`.`t1` Note 1003 select decode('',_latin1'zxcv') AS `enc` from `test`.`t1`
drop table t1; drop table t1;
End of 4.1 tests End of 4.1 tests
create table t1 (d decimal default null); create table t1 (d decimal default null);
...@@ -1378,7 +1378,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1378,7 +1378,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 const PRIMARY PRIMARY 12 const 1 100.00 Using index 1 SIMPLE t2 const PRIMARY PRIMARY 12 const 1 100.00 Using index
1 SIMPLE t1 ref code code 13 const 3 100.00 Using where; Using index 1 SIMPLE t1 ref code code 13 const 3 100.00 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`code` AS `code`,`test`.`t2`.`id` AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = _latin1'a12') and (length(`test`.`t1`.`code`) = 5)) Note 1003 select `test`.`t1`.`code` AS `code`,'a12' AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = _latin1'a12') and (length(`test`.`t1`.`code`) = 5))
DROP TABLE t1,t2; DROP TABLE t1,t2;
select encode(NULL, NULL); select encode(NULL, NULL);
encode(NULL, NULL) encode(NULL, NULL)
...@@ -2273,6 +2273,17 @@ abcxx ...@@ -2273,6 +2273,17 @@ abcxx
select lpad('abc', cast(5 as unsigned integer), 'x'); select lpad('abc', cast(5 as unsigned integer), 'x');
lpad('abc', cast(5 as unsigned integer), 'x') lpad('abc', cast(5 as unsigned integer), 'x')
xxabc xxabc
create table t1(f1 longtext);
insert into t1 values ("123"),("456");
select substring(f1,1,1) from t1 group by 1;
substring(f1,1,1)
1
4
create table t2(f1 varchar(3));
insert into t1 values ("123"),("456");
select substring(f1,4,1), substring(f1,-4,1) from t2;
substring(f1,4,1) substring(f1,-4,1)
drop table t1,t2;
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`id` varchar(20) NOT NULL, `id` varchar(20) NOT NULL,
...@@ -2293,4 +2304,16 @@ NULL ...@@ -2293,4 +2304,16 @@ NULL
SELECT UNHEX('G') IS NULL; SELECT UNHEX('G') IS NULL;
UNHEX('G') IS NULL UNHEX('G') IS NULL
1 1
SELECT INSERT('abc', 3, 3, '1234');
INSERT('abc', 3, 3, '1234')
ab1234
SELECT INSERT('abc', 4, 3, '1234');
INSERT('abc', 4, 3, '1234')
abc1234
SELECT INSERT('abc', 5, 3, '1234');
INSERT('abc', 5, 3, '1234')
abc
SELECT INSERT('abc', 6, 3, '1234');
INSERT('abc', 6, 3, '1234')
abc
End of 5.0 tests End of 5.0 tests
...@@ -87,7 +87,7 @@ explain extended select - a from t1; ...@@ -87,7 +87,7 @@ explain extended select - a from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings: Warnings:
Note 1003 select -(`test`.`t1`.`a`) AS `- a` from `test`.`t1` Note 1003 select -('1') AS `- a` from `test`.`t1`
drop table t1; drop table t1;
select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1; select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1;
5 between 0 and 10 between 0 and 1 (5 between 0 and 10) between 0 and 1 5 between 0 and 10 between 0 and 1 (5 between 0 and 10) between 0 and 1
......
...@@ -12,7 +12,7 @@ explain extended select count(a) as b from t1 where a=0 having b >=0; ...@@ -12,7 +12,7 @@ explain extended select count(a) as b from t1 where a=0 having b >=0;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Note 1003 select count(`test`.`t1`.`a`) AS `b` from `test`.`t1` where 0 having (`b` >= 0) Note 1003 select count('0') AS `b` from `test`.`t1` where 0 having (`b` >= 0)
drop table t1; drop table t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
raw_id int(10) NOT NULL default '0', raw_id int(10) NOT NULL default '0',
......
...@@ -645,3 +645,12 @@ a LENGTH(a) COUNT(*) ...@@ -645,3 +645,12 @@ a LENGTH(a) COUNT(*)
NULL NULL 2 NULL NULL 2
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a int, KEY (a));
INSERT INTO t1 VALUES (3), (1), (4), (1), (3), (1), (1);
SELECT * FROM (SELECT a, SUM(a) FROM t1 GROUP BY a WITH ROLLUP) as t;
a SUM(a)
1 4
3 6
4 4
NULL 14
DROP TABLE t1;
...@@ -50,7 +50,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -50,7 +50,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings: Warnings:
Note 1276 Field or reference 'a' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'a' of SELECT #3 was resolved in SELECT #1
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having ((select `b`.`a` AS `a`) = 1) Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having ((select '1' AS `a`) = 1)
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
1 1
1 1
...@@ -204,7 +204,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -204,7 +204,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using where 3 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using filesort 2 SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using filesort
Warnings: Warnings:
Note 1003 select (select `test`.`t3`.`a` AS `a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,`tt`.`a` AS `a` from (select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 1)) `tt` Note 1003 select (select `test`.`t3`.`a` AS `a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,'2' AS `a` from (select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 1)) `tt`
select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1); select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1);
a a
2 2
...@@ -315,7 +315,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL ...@@ -315,7 +315,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings: Warnings:
Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1
Note 1003 select (select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`a`) union select `test`.`t5`.`a` AS `a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` Note 1003 select (select '2' AS `a` from `test`.`t1` where ('2' = `test`.`t2`.`a`) union select `test`.`t5`.`a` AS `a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2`
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
...@@ -368,7 +368,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -368,7 +368,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00
3 SUBQUERY t8 const PRIMARY PRIMARY 37 1 100.00 Using index 3 SUBQUERY t8 const PRIMARY PRIMARY 37 1 100.00 Using index
Warnings: Warnings:
Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` AS `email` from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1 Note 1003 select 'joce' AS `pseudo`,(select 'test' AS `email` from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce'); t8 WHERE pseudo='joce');
ERROR 21000: Operand should contain 1 column(s) ERROR 21000: Operand should contain 1 column(s)
...@@ -547,7 +547,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -547,7 +547,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index 1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings: Warnings:
Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = _latin1'1')) Note 1003 select '3' AS `numreponse` from `test`.`t1` where (('1' = _latin1'1'))
drop table t1; drop table t1;
CREATE TABLE t1 (a int(1)); CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
...@@ -1430,7 +1430,7 @@ explain extended (select * from t1); ...@@ -1430,7 +1430,7 @@ explain extended (select * from t1);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings: Warnings:
Note 1003 (select `test`.`t1`.`s1` AS `s1` from `test`.`t1`) Note 1003 (select 'tttt' AS `s1` from `test`.`t1`)
(select * from t1); (select * from t1);
s1 s1
tttt tttt
...@@ -1497,7 +1497,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1497,7 +1497,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings: Warnings:
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < (select max(`test`.`t2`.`b`) from `test`.`t2`))) Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < (select max('0') from `test`.`t2`)))
select * from t3 where a >= some (select b from t2); select * from t3 where a >= some (select b from t2);
a a
explain extended select * from t3 where a >= some (select b from t2); explain extended select * from t3 where a >= some (select b from t2);
...@@ -1505,7 +1505,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1505,7 +1505,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings: Warnings:
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= (select min(`test`.`t2`.`b`) from `test`.`t2`))) Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= (select min('0') from `test`.`t2`)))
select * from t3 where a >= all (select b from t2 group by 1); select * from t3 where a >= all (select b from t2 group by 1);
a a
6 6
...@@ -1516,7 +1516,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1516,7 +1516,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings: Warnings:
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < <max>(select `test`.`t2`.`b` AS `b` from `test`.`t2` group by 1))) Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < <max>(select '0' AS `b` from `test`.`t2` group by 1)))
select * from t3 where a >= some (select b from t2 group by 1); select * from t3 where a >= some (select b from t2 group by 1);
a a
explain extended select * from t3 where a >= some (select b from t2 group by 1); explain extended select * from t3 where a >= some (select b from t2 group by 1);
...@@ -1524,7 +1524,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1524,7 +1524,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings: Warnings:
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= <min>(select `test`.`t2`.`b` AS `b` from `test`.`t2` group by 1))) Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= <min>(select '0' AS `b` from `test`.`t2` group by 1)))
select * from t3 where NULL >= any (select b from t2); select * from t3 where NULL >= any (select b from t2);
a a
explain extended select * from t3 where NULL >= any (select b from t2); explain extended select * from t3 where NULL >= any (select b from t2);
...@@ -1618,7 +1618,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1618,7 +1618,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 UNION t1 system NULL NULL NULL NULL 1 100.00 3 UNION t1 system NULL NULL NULL NULL 1 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings: Warnings:
Note 1003 select `test`.`t1`.`s1` AS `s1` from `test`.`t1` where 1 Note 1003 select 'e' AS `s1` from `test`.`t1` where 1
drop table t1; drop table t1;
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1; CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874'); INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
......
...@@ -480,7 +480,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -480,7 +480,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 UNION t2 const PRIMARY PRIMARY 4 const 1 100.00 2 UNION t2 const PRIMARY PRIMARY 4 const 1 100.00
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
Warnings: Warnings:
Note 1003 (select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 1)) union (select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` = 1)) Note 1003 (select '1' AS `a`,'1' AS `b` from `test`.`t1` where ('1' = 1)) union (select '1' AS `a`,'10' AS `b` from `test`.`t2` where ('1' = 1))
(select * from t1 where a=5) union (select * from t2 where a=1); (select * from t1 where a=5) union (select * from t2 where a=1);
a b a b
1 10 1 10
......
...@@ -15,7 +15,7 @@ explain extended select * from t1 where UNIQ=0x38afba1d73e6a18a; ...@@ -15,7 +15,7 @@ explain extended select * from t1 where UNIQ=0x38afba1d73e6a18a;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 const UNIQ UNIQ 8 const 1 100.00 1 SIMPLE t1 const UNIQ UNIQ 8 const 1 100.00
Warnings: Warnings:
Note 1003 select `test`.`t1`.`ID` AS `ID`,`test`.`t1`.`UNIQ` AS `UNIQ` from `test`.`t1` where 1 Note 1003 select '00000001' AS `ID`,'004084688022709641610' AS `UNIQ` from `test`.`t1` where 1
drop table t1; drop table t1;
select x'hello'; select x'hello';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'x'hello'' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'x'hello'' at line 1
......
...@@ -1115,6 +1115,17 @@ select repeat('a', cast(2 as unsigned int)); ...@@ -1115,6 +1115,17 @@ select repeat('a', cast(2 as unsigned int));
select rpad('abc', cast(5 as unsigned integer), 'x'); select rpad('abc', cast(5 as unsigned integer), 'x');
select lpad('abc', cast(5 as unsigned integer), 'x'); select lpad('abc', cast(5 as unsigned integer), 'x');
#
# Bug#15757: Wrong SUBSTRING() result when a tmp table was employed.
#
create table t1(f1 longtext);
insert into t1 values ("123"),("456");
select substring(f1,1,1) from t1 group by 1;
create table t2(f1 varchar(3));
insert into t1 values ("123"),("456");
select substring(f1,4,1), substring(f1,-4,1) from t2;
drop table t1,t2;
# #
# Bug #25197 :repeat function returns null when using table field directly as count # Bug #25197 :repeat function returns null when using table field directly as count
# #
...@@ -1142,4 +1153,12 @@ DROP TABLE t1; ...@@ -1142,4 +1153,12 @@ DROP TABLE t1;
SELECT UNHEX('G'); SELECT UNHEX('G');
SELECT UNHEX('G') IS NULL; SELECT UNHEX('G') IS NULL;
#
# Bug #26281: INSERT() function mishandles NUL on boundary condition
#
SELECT INSERT('abc', 3, 3, '1234');
SELECT INSERT('abc', 4, 3, '1234');
SELECT INSERT('abc', 5, 3, '1234');
SELECT INSERT('abc', 6, 3, '1234');
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -327,3 +327,18 @@ SELECT * FROM v1; ...@@ -327,3 +327,18 @@ SELECT * FROM v1;
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #26830: derived table with ROLLUP
#
CREATE TABLE t1 (a int, KEY (a));
INSERT INTO t1 VALUES (3), (1), (4), (1), (3), (1), (1);
SELECT * FROM (SELECT a, SUM(a) FROM t1 GROUP BY a WITH ROLLUP) as t;
DROP TABLE t1;
...@@ -1791,9 +1791,10 @@ void Item_ident::print(String *str) ...@@ -1791,9 +1791,10 @@ void Item_ident::print(String *str)
} }
} }
if (!table_name || !field_name) if (!table_name || !field_name || !field_name[0])
{ {
const char *nm= field_name ? field_name : name ? name : "tmp_field"; const char *nm= (field_name && field_name[0]) ?
field_name : name ? name : "tmp_field";
append_identifier(thd, str, nm, (uint) strlen(nm)); append_identifier(thd, str, nm, (uint) strlen(nm));
return; return;
} }
...@@ -5002,6 +5003,22 @@ Item *Item_field::update_value_transformer(byte *select_arg) ...@@ -5002,6 +5003,22 @@ Item *Item_field::update_value_transformer(byte *select_arg)
} }
void Item_field::print(String *str)
{
if (field && field->table->const_table)
{
char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff),str->charset());
field->val_str(&tmp);
str->append('\'');
str->append(tmp);
str->append('\'');
return;
}
Item_ident::print(str);
}
Item_ref::Item_ref(Name_resolution_context *context_arg, Item_ref::Item_ref(Name_resolution_context *context_arg,
Item **item, const char *table_name_arg, Item **item, const char *table_name_arg,
const char *field_name_arg, const char *field_name_arg,
......
...@@ -1398,6 +1398,7 @@ public: ...@@ -1398,6 +1398,7 @@ public:
Item *safe_charset_converter(CHARSET_INFO *tocs); Item *safe_charset_converter(CHARSET_INFO *tocs);
int fix_outer_field(THD *thd, Field **field, Item **reference); int fix_outer_field(THD *thd, Field **field, Item **reference);
virtual Item *update_value_transformer(byte *select_arg); virtual Item *update_value_transformer(byte *select_arg);
void print(String *str);
friend class Item_default_value; friend class Item_default_value;
friend class Item_insert_value; friend class Item_insert_value;
friend class st_select_lex_unit; friend class st_select_lex_unit;
......
...@@ -964,18 +964,18 @@ String *Item_func_insert::val_str(String *str) ...@@ -964,18 +964,18 @@ String *Item_func_insert::val_str(String *str)
args[3]->null_value) args[3]->null_value)
goto null; /* purecov: inspected */ goto null; /* purecov: inspected */
if ((start < 0) || (start > res->length() + 1)) if ((start < 0) || (start > res->length()))
return res; // Wrong param; skip insert return res; // Wrong param; skip insert
if ((length < 0) || (length > res->length() + 1)) if ((length < 0) || (length > res->length()))
length= res->length() + 1; length= res->length();
/* start and length are now sufficiently valid to pass to charpos function */ /* start and length are now sufficiently valid to pass to charpos function */
start= res->charpos((int) start); start= res->charpos((int) start);
length= res->charpos((int) length, (uint32) start); length= res->charpos((int) length, (uint32) start);
/* Re-testing with corrected params */ /* Re-testing with corrected params */
if (start > res->length() + 1) if (start > res->length())
return res; // Wrong param; skip insert return res; /* purecov: inspected */ // Wrong param; skip insert
if (length > res->length() - start) if (length > res->length() - start)
length= res->length() - start; length= res->length() - start;
...@@ -1181,11 +1181,10 @@ void Item_func_substr::fix_length_and_dec() ...@@ -1181,11 +1181,10 @@ void Item_func_substr::fix_length_and_dec()
if (args[1]->const_item()) if (args[1]->const_item())
{ {
int32 start= (int32) args[1]->val_int(); int32 start= (int32) args[1]->val_int();
start= (int32)((start < 0) ? max_length + start : start - 1); if (start < 0)
if (start < 0 || start >= (int32) max_length) max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
max_length=0; /* purecov: inspected */
else else
max_length-= (uint) start; max_length-= min((uint)(start - 1), max_length);
} }
if (arg_count == 3 && args[2]->const_item()) if (arg_count == 3 && args[2]->const_item())
{ {
......
...@@ -8924,7 +8924,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree) ...@@ -8924,7 +8924,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
if ((join->tables != 1) || /* The query must reference one table. */ if ((join->tables != 1) || /* The query must reference one table. */
((!join->group_list) && /* Neither GROUP BY nor a DISTINCT query. */ ((!join->group_list) && /* Neither GROUP BY nor a DISTINCT query. */
(!join->select_distinct)) || (!join->select_distinct)) ||
(thd->lex->select_lex.olap == ROLLUP_TYPE)) /* Check (B3) for ROLLUP */ (join->select_lex->olap == ROLLUP_TYPE)) /* Check (B3) for ROLLUP */
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
if (table->s->keys == 0) /* There are no indexes to use. */ if (table->s->keys == 0) /* There are no indexes to use. */
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
......
...@@ -623,6 +623,12 @@ bool st_select_lex_unit::cleanup() ...@@ -623,6 +623,12 @@ bool st_select_lex_unit::cleanup()
join->tables= 0; join->tables= 0;
} }
error|= fake_select_lex->cleanup(); error|= fake_select_lex->cleanup();
if (fake_select_lex->order_list.elements)
{
ORDER *ord;
for (ord= (ORDER*)fake_select_lex->order_list.first; ord; ord= ord->next)
(*ord->item)->cleanup();
}
} }
DBUG_RETURN(error); DBUG_RETURN(error);
......
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