mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
Merge moonbone.local:/work/15351-bug-4.1-mysql
into moonbone.local:/home/evgen/bk-trees/mysql-4.1-opt sql/item_strfunc.cc: Auto merged
This commit is contained in:
commit
99c320d7cf
26 changed files with 484 additions and 53 deletions
|
|
@ -192,7 +192,7 @@ cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
|
|||
1
|
||||
select cast("1:2:3" as TIME) = "1:02:03";
|
||||
cast("1:2:3" as TIME) = "1:02:03"
|
||||
0
|
||||
1
|
||||
select cast(NULL as DATE);
|
||||
cast(NULL as DATE)
|
||||
NULL
|
||||
|
|
|
|||
|
|
@ -64,3 +64,10 @@ select 'a' union select concat('a', -0.0);
|
|||
a
|
||||
a
|
||||
good
|
||||
select concat((select x from (select 'a' as x) as t1 ),
|
||||
(select y from (select 'b' as y) as t2 )) from (select 1 union select 2 )
|
||||
as t3;
|
||||
concat((select x from (select 'a' as x) as t1 ),
|
||||
(select y from (select 'b' as y) as t2 ))
|
||||
ab
|
||||
ab
|
||||
|
|
|
|||
|
|
@ -916,3 +916,27 @@ select count(*), min(7), max(7) from t2m, t1i;
|
|||
count(*) min(7) max(7)
|
||||
0 NULL NULL
|
||||
drop table t1m, t1i, t2m, t2i;
|
||||
CREATE TABLE t1 (id int PRIMARY KEY, b char(3), INDEX(b));
|
||||
INSERT INTO t1 VALUES (1,'xx'), (2,'aa');
|
||||
SELECT * FROM t1;
|
||||
id b
|
||||
1 xx
|
||||
2 aa
|
||||
SELECT MAX(b) FROM t1 WHERE b < 'ppppp';
|
||||
MAX(b)
|
||||
aa
|
||||
SHOW WARNINGS;
|
||||
Level Code Message
|
||||
SELECT MAX(b) FROM t1 WHERE b < 'pp';
|
||||
MAX(b)
|
||||
aa
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (id int PRIMARY KEY, b char(16), INDEX(b(4)));
|
||||
INSERT INTO t1 VALUES (1, 'xxxxbbbb'), (2, 'xxxxaaaa');
|
||||
SELECT MAX(b) FROM t1;
|
||||
MAX(b)
|
||||
xxxxbbbb
|
||||
EXPLAIN SELECT MAX(b) FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
|
||||
DROP TABLE t1;
|
||||
|
|
|
|||
|
|
@ -202,3 +202,24 @@ select count(*) from t1 where id not in (1,2);
|
|||
count(*)
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (f1 char(1), f2 int);
|
||||
insert into t1 values (1,0),('a',1),('z',2);
|
||||
select f1 from t1 where f1 in (1,'z');
|
||||
f1
|
||||
1
|
||||
z
|
||||
select f2 from t1 where f2 in (1,'z');
|
||||
f2
|
||||
0
|
||||
1
|
||||
select f1 from t1 where 'z' in (1,f1);
|
||||
f1
|
||||
z
|
||||
select * from t1 where 'z' in (f2,f1);
|
||||
f1 f2
|
||||
z 2
|
||||
select * from t1 where 1 in (f2,f1);
|
||||
f1 f2
|
||||
1 0
|
||||
a 1
|
||||
drop table t1;
|
||||
|
|
|
|||
|
|
@ -630,3 +630,44 @@ select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')),
|
|||
monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
|
||||
monthname(str_to_date(null, '%m')) monthname(str_to_date(null, '%m')) monthname(str_to_date(1, '%m')) monthname(str_to_date(0, '%m'))
|
||||
NULL NULL January NULL
|
||||
create table t1(f1 date, f2 time, f3 datetime);
|
||||
insert into t1 values ("2006-01-01", "12:01:01", "2006-01-01 12:01:01");
|
||||
insert into t1 values ("2006-01-02", "12:01:02", "2006-01-02 12:01:02");
|
||||
select f1 from t1 where f1 between "2006-1-1" and 20060101;
|
||||
f1
|
||||
2006-01-01
|
||||
select f1 from t1 where f1 between "2006-1-1" and "2006.1.1";
|
||||
f1
|
||||
2006-01-01
|
||||
select f1 from t1 where date(f1) between "2006-1-1" and "2006.1.1";
|
||||
f1
|
||||
2006-01-01
|
||||
select f2 from t1 where f2 between "12:1:2" and "12:2:2";
|
||||
f2
|
||||
12:01:02
|
||||
select f2 from t1 where time(f2) between "12:1:2" and "12:2:2";
|
||||
f2
|
||||
12:01:02
|
||||
select f3 from t1 where f3 between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
|
||||
f3
|
||||
2006-01-01 12:01:01
|
||||
select f3 from t1 where timestamp(f3) between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
|
||||
f3
|
||||
2006-01-01 12:01:01
|
||||
select f1 from t1 where "2006-1-1" between f1 and f3;
|
||||
f1
|
||||
2006-01-01
|
||||
select f1 from t1 where "2006-1-1" between date(f1) and date(f3);
|
||||
f1
|
||||
2006-01-01
|
||||
select f1 from t1 where "2006-1-1" between f1 and 'zzz';
|
||||
f1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect date value: 'zzz'
|
||||
select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
|
||||
f1
|
||||
2006-01-01
|
||||
select f1 from t1 where makedate(2006,2) between date(f1) and date(f3);
|
||||
f1
|
||||
2006-01-02
|
||||
drop table t1;
|
||||
|
|
|
|||
|
|
@ -475,3 +475,8 @@ aclid bigint, index idx_acl(aclid)
|
|||
insert into t2 values(1,null);
|
||||
delete t2, t1 from t2 left join t1 on (t2.aclid=t1.aclid) where t2.refid='1';
|
||||
drop table t1, t2;
|
||||
create table t1(a int);
|
||||
create table t2(a int);
|
||||
delete from t1,t2 using t1,t2 where t1.a=(select a from t1);
|
||||
ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
||||
drop table t1, t2;
|
||||
|
|
|
|||
|
|
@ -2714,3 +2714,17 @@ select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 fro
|
|||
f1 f2
|
||||
1 1
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c));
|
||||
insert into t1 values (1,0,0),(2,0,0);
|
||||
CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a));
|
||||
insert into t2 values (1,'',''), (2,'','');
|
||||
CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b));
|
||||
insert into t3 values (1,1),(1,2);
|
||||
explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2
|
||||
where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and
|
||||
t2.b like '%%' order by t2.b limit 0,1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref b,c b 5 const 1 Using where; Using temporary; Using filesort
|
||||
1 SIMPLE t3 index PRIMARY,a,b PRIMARY 8 NULL 2 Using index
|
||||
1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Range checked for each record (index map: 0x1)
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
|
|
|||
|
|
@ -50,4 +50,11 @@ select 'a' union select concat('a', -0);
|
|||
--replace_result 'a-0.0' good 'a0.0' good
|
||||
select 'a' union select concat('a', -0.0);
|
||||
|
||||
#
|
||||
# Bug#16716: subselect in concat() may lead to a wrong result
|
||||
#
|
||||
select concat((select x from (select 'a' as x) as t1 ),
|
||||
(select y from (select 'b' as y) as t2 )) from (select 1 union select 2 )
|
||||
as t3;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
|
|
|||
|
|
@ -598,4 +598,23 @@ select count(*), min(7), max(7) from t2m, t1i;
|
|||
|
||||
drop table t1m, t1i, t2m, t2i;
|
||||
|
||||
#
|
||||
# Bug #18206: min/max optimization cannot be applied to partial index
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (id int PRIMARY KEY, b char(3), INDEX(b));
|
||||
INSERT INTO t1 VALUES (1,'xx'), (2,'aa');
|
||||
SELECT * FROM t1;
|
||||
|
||||
SELECT MAX(b) FROM t1 WHERE b < 'ppppp';
|
||||
SHOW WARNINGS;
|
||||
SELECT MAX(b) FROM t1 WHERE b < 'pp';
|
||||
DROP TABLE t1;
|
||||
|
||||
CREATE TABLE t1 (id int PRIMARY KEY, b char(16), INDEX(b(4)));
|
||||
INSERT INTO t1 VALUES (1, 'xxxxbbbb'), (2, 'xxxxaaaa');
|
||||
SELECT MAX(b) FROM t1;
|
||||
EXPLAIN SELECT MAX(b) FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
|
|
|||
|
|
@ -109,4 +109,16 @@ select count(*) from t1 where id not in (1);
|
|||
select count(*) from t1 where id not in (1,2);
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug#18360 Incorrect type coercion in IN() results in false comparison
|
||||
#
|
||||
create table t1 (f1 char(1), f2 int);
|
||||
insert into t1 values (1,0),('a',1),('z',2);
|
||||
select f1 from t1 where f1 in (1,'z');
|
||||
select f2 from t1 where f2 in (1,'z');
|
||||
select f1 from t1 where 'z' in (1,f1);
|
||||
select * from t1 where 'z' in (f2,f1);
|
||||
select * from t1 where 1 in (f2,f1);
|
||||
drop table t1;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
|
|
|||
|
|
@ -322,4 +322,24 @@ select last_day('2005-01-00');
|
|||
select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')),
|
||||
monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
|
||||
|
||||
#
|
||||
# Bug#16377 result of DATE/TIME functions were compared as strings which
|
||||
# can lead to a wrong result.
|
||||
#
|
||||
create table t1(f1 date, f2 time, f3 datetime);
|
||||
insert into t1 values ("2006-01-01", "12:01:01", "2006-01-01 12:01:01");
|
||||
insert into t1 values ("2006-01-02", "12:01:02", "2006-01-02 12:01:02");
|
||||
select f1 from t1 where f1 between "2006-1-1" and 20060101;
|
||||
select f1 from t1 where f1 between "2006-1-1" and "2006.1.1";
|
||||
select f1 from t1 where date(f1) between "2006-1-1" and "2006.1.1";
|
||||
select f2 from t1 where f2 between "12:1:2" and "12:2:2";
|
||||
select f2 from t1 where time(f2) between "12:1:2" and "12:2:2";
|
||||
select f3 from t1 where f3 between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
|
||||
select f3 from t1 where timestamp(f3) between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
|
||||
select f1 from t1 where "2006-1-1" between f1 and f3;
|
||||
select f1 from t1 where "2006-1-1" between date(f1) and date(f3);
|
||||
select f1 from t1 where "2006-1-1" between f1 and 'zzz';
|
||||
select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
|
||||
select f1 from t1 where makedate(2006,2) between date(f1) and date(f3);
|
||||
drop table t1;
|
||||
# End of 4.1 tests
|
||||
|
|
|
|||
|
|
@ -448,4 +448,12 @@ insert into t2 values(1,null);
|
|||
delete t2, t1 from t2 left join t1 on (t2.aclid=t1.aclid) where t2.refid='1';
|
||||
drop table t1, t2;
|
||||
|
||||
#
|
||||
# Bug#19225: unchecked error leads to server crash
|
||||
#
|
||||
create table t1(a int);
|
||||
create table t2(a int);
|
||||
--error 1093
|
||||
delete from t1,t2 using t1,t2 where t1.a=(select a from t1);
|
||||
drop table t1, t2;
|
||||
# End of 4.1 tests
|
||||
|
|
|
|||
|
|
@ -2248,4 +2248,18 @@ insert into t2 values(1,1);
|
|||
select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2));
|
||||
drop table t1,t2;
|
||||
|
||||
#
|
||||
# Bug #4981: 4.x and 5.x produce non-optimal execution path, 3.23 regression test failure
|
||||
#
|
||||
CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c));
|
||||
insert into t1 values (1,0,0),(2,0,0);
|
||||
CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a));
|
||||
insert into t2 values (1,'',''), (2,'','');
|
||||
CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b));
|
||||
insert into t3 values (1,1),(1,2);
|
||||
# must have "range checked" for t2
|
||||
explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2
|
||||
where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and
|
||||
t2.b like '%%' order by t2.b limit 0,1;
|
||||
DROP TABLE t1,t2,t3;
|
||||
# End of 4.1 tests
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue