1284
1282
# Test using INDEX and IGNORE INDEX
1287
#explain select t2.fld3 from t2 where fld3 = 'honeysuckle';
1289
#explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle';
1290
#explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle';
1292
#explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle';
1293
#explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
1285
explain select t2.fld3 from t2 where fld3 = 'honeysuckle';
1287
explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle';
1288
explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle';
1290
explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle';
1291
explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
1296
1294
# NOTE NOTE NOTE
1297
1295
# The next should give an error
1301
#explain select fld3 from t2 ignore index (fld3,not_used);
1303
#explain select fld3 from t2 use index (not_used);
1299
explain select fld3 from t2 ignore index (fld3,not_used);
1301
explain select fld3 from t2 use index (not_used);
1306
1304
# Test sorting with a used key (there is no need for sorting)
1309
1307
select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
1310
#explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
1308
explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
1311
1309
select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
1546
1540
select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
1547
1541
select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null;
1548
#explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
1549
#explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
1542
explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
1543
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
1551
1545
select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
1552
1546
select count(*) from t2 left join t4 using (companynr) where companynr is not null;
1553
#explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
1554
#explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null;
1547
explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
1548
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null;
1555
1549
delete from t2 where fld1=999999;
1558
1552
# Test left join optimization
1560
#explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
1561
#explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
1562
#explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
1564
#explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
1565
#explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
1566
#explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
1567
## Following can't be optimized
1568
#explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
1569
#explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
1570
#explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
1572
#explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
1573
#explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
1574
#explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
1554
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
1555
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
1556
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
1558
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
1559
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
1560
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
1561
# Following can't be optimized
1562
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
1563
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
1564
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
1566
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
1567
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
1568
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
1577
1571
# Joins with forms.
1580
1574
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
1581
#explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
1575
explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
1584
1578
# Search using 'or' with the same referens group.
1617
1611
select companynr,count(*),sum(fld1) from t2 group by companynr;
1618
1612
select companynr,count(*) from t2 group by companynr order by companynr desc limit 5;
1619
1613
select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
1620
#explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
1614
explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
1621
1615
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
1622
1616
select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
1623
1617
select /*! SQL_SMALL_RESULT */ companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
1791
1785
# Test of bug with SUM(CASE...)
1794
CREATE TEMPORARY TABLE t1 (gvid int default NULL, hmid int default NULL, volid int default NULL, mmid int default NULL, hdid int default NULL, fsid int default NULL, ctid int default NULL, dtid int default NULL, cost int default NULL, performance int default NULL, serialnumber bigint default NULL, monitored int default '1', removed int default '0', target int default '0', dt_modified timestamp NOT NULL, name varchar(255) default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=MyISAM;
1788
CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=MyISAM;
1795
1789
INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL);
1796
CREATE TEMPORARY TABLE t2 ( hmid int default NULL, volid int default NULL, sampletid int default NULL, sampletime datetime default NULL, samplevalue bigint default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=MyISAM;
1790
CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=MyISAM;
1797
1791
INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35);
1798
--error ER_INVALID_DATETIME_VALUE # bad datetime
1792
# Disable PS becasue we get more warnings from PS than from normal execution
1793
--disable_ps_protocol
1799
1794
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
1795
--enable_ps_protocol
1800
1796
# Testing the same select with NULL's instead of invalid datetime values
1801
1797
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
1802
1798
DROP TABLE t1,t2;
1865
1859
select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1;
1868
CREATE TEMPORARY TABLE t1 ( aa char(2), id int NOT NULL auto_increment, t2_id int NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)) ENGINE=MyISAM;
1862
CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)) ENGINE=MyISAM;
1869
1863
INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522);
1870
CREATE TEMPORARY TABLE t2 ( id int NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=MyISAM;
1864
CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=MyISAM;
1871
1865
INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522);
1872
1866
select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5;
1873
1867
drop table t1,t2;
1976
# Bug#7425 inconsistent sort order on columns result of substraction
1971
# Bug#7425 inconsistent sort order on unsigned columns result of substraction
1979
create table t1 (a int, b int);
1974
create table t1 (a int(11) unsigned, b int(11) unsigned);
1980
1975
insert into t1 values (1,0), (1,1), (1,2);
1981
1976
select a-b from t1 order by 1;
1982
1977
select a-b , (a-b < 0) from t1 order by 1;
1983
1978
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
1984
select a - b from t1 order by 1;
1979
select cast((a - b) as unsigned) from t1 order by 1;
1989
1984
# Bug#8733 server accepts malformed query (multiply mentioned distinct)
1991
create table t1 (a int);
1986
create table t1 (a int(11));
1992
1987
select all all * from t1;
1993
1988
select distinct distinct * from t1;
1994
--error ER_WRONG_USAGE
1995
1990
select all distinct * from t1;
1996
--error ER_WRONG_USAGE
1997
1992
select distinct all * from t1;
2062
# Test for Bug#8009, SELECT failed on bigint when using HEX
2057
# Test for Bug#8009, SELECT failed on bigint unsigned when using HEX
2065
CREATE TABLE t1 (b BIGINT NOT NULL, PRIMARY KEY (b));
2066
INSERT INTO t1 VALUES (0x4000000000000000);
2067
SELECT b FROM t1 WHERE b=0x4000000000000000;
2060
CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b));
2061
INSERT INTO t1 VALUES (0x8000000000000000);
2062
SELECT b FROM t1 WHERE b=0x8000000000000000;
2071
2066
# IN with outer join condition (BUG#9393)
2073
CREATE TABLE `t1` ( `gid` int default NULL, `uid` int default NULL);
2068
CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL);
2075
CREATE TABLE `t2` ( `ident` int default NULL, `level` char(16) default NULL);
2070
CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL);
2076
2071
INSERT INTO `t2` VALUES (0,'READ');
2078
CREATE TABLE `t3` ( `id` int default NULL, `name` char(16) default NULL);
2073
CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL);
2079
2074
INSERT INTO `t3` VALUES (1,'fs');
2081
2076
select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0);
2085
2080
# Test for BUG#11700
2086
2081
CREATE TABLE t1 (
2087
acct_id int NOT NULL default '0',
2088
profile_id int default NULL,
2082
acct_id int(11) NOT NULL default '0',
2083
profile_id smallint(6) default NULL,
2089
2084
UNIQUE KEY t1$acct_id (acct_id),
2090
2085
KEY t1$profile_id (profile_id)
2092
2087
INSERT INTO t1 VALUES (132,17),(133,18);
2094
2089
CREATE TABLE t2 (
2095
profile_id int default NULL,
2096
queue_id int default NULL,
2097
seq int default NULL,
2090
profile_id smallint(6) default NULL,
2091
queue_id int(11) default NULL,
2092
seq int(11) default NULL,
2098
2093
KEY t2$queue_id (queue_id)
2100
2095
INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1);
2102
2097
CREATE TABLE t3 (
2103
id int NOT NULL default '0',
2104
qtype int default NULL,
2105
seq int default NULL,
2106
warn_lvl int default NULL,
2107
crit_lvl int default NULL,
2108
rr1 int NOT NULL default '0',
2109
rr2 int default NULL,
2110
default_queue int NOT NULL default '0',
2098
id int(11) NOT NULL default '0',
2099
qtype int(11) default NULL,
2100
seq int(11) default NULL,
2101
warn_lvl int(11) default NULL,
2102
crit_lvl int(11) default NULL,
2103
rr1 tinyint(4) NOT NULL default '0',
2104
rr2 int(11) default NULL,
2105
default_queue tinyint(4) NOT NULL default '0',
2111
2106
KEY t3$qtype (qtype),
2271
2268
INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941);
2272
2269
INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941);
2274
#explain select max(key1) from t1 where key1 <= 0.6158;
2275
#explain select max(key2) from t2 where key2 <= 1.6158;
2276
#explain select min(key1) from t1 where key1 >= 0.3762;
2277
#explain select min(key2) from t2 where key2 >= 1.3762;
2278
#explain select max(key1), min(key2) from t1, t2 where key1 <= 0.6158 and key2 >= 1.3762;
2279
#explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
2280
#explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
2271
explain select max(key1) from t1 where key1 <= 0.6158;
2272
explain select max(key2) from t2 where key2 <= 1.6158;
2273
explain select min(key1) from t1 where key1 >= 0.3762;
2274
explain select min(key2) from t2 where key2 >= 1.3762;
2275
explain select max(key1), min(key2) from t1, t2
2276
where key1 <= 0.6158 and key2 >= 1.3762;
2277
explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
2278
explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
2282
2280
select max(key1) from t1 where key1 <= 0.6158;
2283
2281
select max(key2) from t2 where key2 <= 1.6158;
2589
2587
insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'),
2590
2588
(4,'2005-10-01'),(5,'2005-12-30');
2591
2589
# should return all records
2592
--error ER_INVALID_DATETIME_VALUE # Bad date
2593
2590
select * from t1 where f2 >= 0 order by f2;
2594
--error ER_INVALID_DATETIME_VALUE # Bad date
2595
2591
select * from t1 where f2 >= '0000-00-00' order by f2;
2596
2592
# should return 4,5
2597
--error ER_INVALID_DATETIME_VALUE # Bad date
2598
2593
select * from t1 where f2 >= '2005-09-31' order by f2;
2599
--error ER_INVALID_DATETIME_VALUE # Bad date
2600
2594
select * from t1 where f2 >= '2005-09-3a' order by f2;
2601
--error ER_INVALID_DATETIME_VALUE # Bad date
2595
# should return 1,2,3
2602
2596
select * from t1 where f2 <= '2005-09-31' order by f2;
2603
--error ER_INVALID_DATETIME_VALUE # Bad date
2604
2597
select * from t1 where f2 <= '2005-09-3a' order by f2;
3303
3308
# Bug#31800: Date comparison fails with timezone and slashes for greater
3304
3309
# than comparison
3307
# @TODO Commenting all str_to_date out for now...should move to a plugin.
3309
3312
# On DATETIME-like literals with trailing garbage, BETWEEN fudged in a
3310
3313
# DATETIME comparator, while greater/less-than used bin-string comparisons.
3311
3314
# Should correctly be compared as DATE or DATETIME, but throw a warning:
3313
#select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT'
3314
# and '2007/10/20 00:00:00 GMT';
3315
#select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6';
3316
#select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6';
3316
select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT'
3317
and '2007/10/20 00:00:00 GMT';
3318
select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6';
3319
select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6';
3318
3321
# We have all we need -- and trailing garbage:
3319
3322
# (leaving out a leading zero in first example to prove it's a
3320
3323
# value-comparison, not a string-comparison!)
3321
#select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6';
3322
#select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6';
3323
#select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6';
3324
#select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6';
3324
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6';
3325
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6';
3326
select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6';
3327
select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6';
3325
3328
# no time at all:
3326
#select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6';
3329
select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6';
3327
3330
# partial time:
3328
#select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6';
3331
select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6';
3329
3332
# fail, different second part:
3330
#select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6';
3333
select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6';
3331
3334
# correct syntax, no trailing nonsense -- this one must throw no warning:
3332
#select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56';
3335
select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56';
3333
3336
# no warning, but failure (different hour parts):
3334
#select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00';
3337
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00';
3336
#select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00';
3339
select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00';
3337
3340
# succeed, but warn for "trailing garbage" (":34"):
3338
#select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00';
3341
select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00';
3339
3342
# invalid date (Feb 30) succeeds
3340
#select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34';
3343
select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34';
3341
3344
# 0-day for both, just works in default SQL mode.
3342
#select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
3345
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
3343
3346
# 0-day, succeed
3344
#select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00'
3345
# and '2007/10/20 00:00:00';
3346
#select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
3347
#select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20';
3348
#select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34';
3349
#select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34';
3350
#select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '';
3347
select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00'
3348
and '2007/10/20 00:00:00';
3349
select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
3350
select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20';
3351
select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34';
3352
select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34';
3353
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '';
3352
#select str_to_date('1','%Y-%m-%d') = '1';
3353
#select str_to_date('1','%Y-%m-%d') = '1';
3354
#select str_to_date('','%Y-%m-%d') = '';
3355
select str_to_date('1','%Y-%m-%d') = '1';
3356
select str_to_date('1','%Y-%m-%d') = '1';
3357
select str_to_date('','%Y-%m-%d') = '';
3356
3359
# these three should work!
3357
#select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL;
3358
#select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00';
3359
#select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL;
3360
select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL;
3361
select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00';
3362
select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL;
3360
3363
###########################################################################
3456
3459
SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296;
3457
3460
SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297;
3461
# MySQL Bug#33546: Slowdown on re-evaluation of constant expressions.
3463
CREATE TABLE t1 (a INT);
3464
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
3465
CREATE TABLE t2 (b INT);
3466
INSERT INTO t2 VALUES (2);
3467
SELECT * FROM t1 WHERE a = 1 + 1;
3468
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a = 1 + 1;
3469
SELECT * FROM t1 HAVING a = 1 + 1;
3470
EXPLAIN EXTENDED SELECT * FROM t1 HAVING a = 1 + 1;
3471
SELECT * FROM t1, t2 WHERE a = b + (1 + 1);
3472
EXPLAIN EXTENDED SELECT * FROM t1, t2 WHERE a = b + (1 + 1);
3473
SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1;
3474
EXPLAIN EXTENDED SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1;
3475
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00');