1282
1282
# Test using INDEX and IGNORE INDEX
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';
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';
1294
1294
# NOTE NOTE NOTE
1295
1295
# The next should give an error
1299
#explain select fld3 from t2 ignore index (fld3,not_used);
1301
#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);
1304
1304
# Test sorting with a used key (there is no need for sorting)
1307
1307
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;
1308
explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
1309
1309
select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
1325
1325
select fld1 from t2 where fld1=250501 or fld1="250502";
1326
#explain select fld1 from t2 where fld1=250501 or fld1="250502";
1326
explain select fld1 from t2 where fld1=250501 or fld1="250502";
1327
1327
select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
1328
#explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
1328
explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
1331
1331
# Search with a key with LIKE constant
1332
1332
# If the like starts with a certain letter key will be used.
1336
1335
select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%';
1337
1336
select fld3 from t2 where fld3 like "L%" and fld3 = "ok";
1338
1337
select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly");
1349
1348
select distinct companynr from t2;
1350
1349
select distinct companynr from t2 order by companynr;
1351
1350
select distinct companynr from t2 order by companynr desc;
1353
1351
select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
1355
1353
select distinct fld3 from t2 where companynr = 34 order by fld3;
1356
# PBXT: because there is no ORDER BY with a LIMIT, these
1357
# statements return different results to those from innodb
1359
1354
select distinct fld3 from t2 limit 10;
1360
1355
select distinct fld3 from t2 having fld3 like "A%" limit 10;
1361
1356
select distinct substring(fld3,1,3) from t2 where fld3 like "A%";
1362
1357
select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10;
1363
1358
select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10;
1365
1359
select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10;
1367
1361
# make a big table.
1449
1443
# Here the last fld3 is optimized away from the order by
1452
#explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
1446
explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
1455
1449
# Some test with ORDER BY and limit
1458
#explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
1459
#explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
1460
#explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
1452
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
1453
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
1454
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
1463
1457
# Search with a constant table.
1547
1540
select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
1548
1541
select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null;
1549
#explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
1550
#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;
1552
1545
select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
1553
1546
select count(*) from t2 left join t4 using (companynr) where companynr is not null;
1554
#explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
1555
#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;
1556
1549
delete from t2 where fld1=999999;
1559
1552
# Test left join optimization
1561
#explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
1562
#explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
1563
#explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
1565
#explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
1566
#explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
1567
#explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
1568
## Following can't be optimized
1569
#explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
1570
#explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
1571
#explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
1573
#explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
1574
#explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
1575
#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;
1578
1571
# Joins with forms.
1581
1574
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
1582
#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;
1585
1578
# Search using 'or' with the same referens group.
1618
1611
select companynr,count(*),sum(fld1) from t2 group by companynr;
1619
1612
select companynr,count(*) from t2 group by companynr order by companynr desc limit 5;
1620
1613
select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
1621
#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<>"";
1622
1615
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
1623
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;
1624
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;
1792
1785
# Test of bug with SUM(CASE...)
1795
CREATE 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) binary 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;
1796
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);
1797
CREATE 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;
1798
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);
1799
1792
# Disable PS becasue we get more warnings from PS than from normal execution
1800
1793
--disable_ps_protocol
1808
1801
# Test of bigint comparision
1811
create table t1 ( A_Id bigint NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint NOT NULL default '0', A_UpdateSerial int NOT NULL default '0', other_types bigint NOT NULL default '0', wss_type bigint NOT NULL default '0');
1804
create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0');
1812
1805
INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093);
1813
1806
select wss_type from t1 where wss_type ='102935229216544106';
1814
1807
select wss_type from t1 where wss_type ='102935229216544105';
1867
1859
select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1;
1870
CREATE 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;
1871
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);
1872
CREATE 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;
1873
1865
INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522);
1874
1866
select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5;
1875
1867
drop table t1,t2;
1917
1910
create table t2 (c integer, d integer, index(c), index(d));
1918
1911
insert into t1 values (1,2), (2,2), (3,2), (4,2);
1919
1912
insert into t2 values (1,3), (2,3), (3,4), (4,4);
1920
#explain select * from t1 left join t2 on a=c where d in (4);
1913
explain select * from t1 left join t2 on a=c where d in (4);
1921
1914
select * from t1 left join t2 on a=c where d in (4);
1922
#explain select * from t1 left join t2 on a=c where d = 4;
1915
explain select * from t1 left join t2 on a=c where d = 4;
1923
1916
select * from t1 left join t2 on a=c where d = 4;
1924
1917
drop table t1, t2;
1978
# Bug#7425 inconsistent sort order on columns result of substraction
1971
# Bug#7425 inconsistent sort order on unsigned columns result of substraction
1981
create table t1 (a int, b int);
1974
create table t1 (a int(11) unsigned, b int(11) unsigned);
1982
1975
insert into t1 values (1,0), (1,1), (1,2);
1983
1976
select a-b from t1 order by 1;
1984
1977
select a-b , (a-b < 0) from t1 order by 1;
1985
1978
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
1986
select a - b from t1 order by 1;
1979
select cast((a - b) as unsigned) from t1 order by 1;
1991
1984
# Bug#8733 server accepts malformed query (multiply mentioned distinct)
1993
create table t1 (a int);
1986
create table t1 (a int(11));
1994
1987
select all all * from t1;
1995
1988
select distinct distinct * from t1;
2003
1996
# Test for BUG#10095
2005
1998
CREATE TABLE t1 (
2006
kunde_intern_id int NOT NULL default '0',
2007
kunde_id int NOT NULL default '0',
2008
FK_firma_id int NOT NULL default '0',
1999
kunde_intern_id int(10) unsigned NOT NULL default '0',
2000
kunde_id int(10) unsigned NOT NULL default '0',
2001
FK_firma_id int(10) unsigned NOT NULL default '0',
2009
2002
aktuell enum('Ja','Nein') NOT NULL default 'Ja',
2010
2003
vorname varchar(128) NOT NULL default '',
2011
2004
nachname varchar(128) NOT NULL default '',
2064
# Test for Bug#8009, SELECT failed on bigint when using HEX
2057
# Test for Bug#8009, SELECT failed on bigint unsigned when using HEX
2067
CREATE TABLE t1 (b BIGINT NOT NULL, PRIMARY KEY (b));
2068
INSERT INTO t1 VALUES (0x4000000000000000);
2069
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;
2073
2066
# IN with outer join condition (BUG#9393)
2075
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);
2077
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);
2078
2071
INSERT INTO `t2` VALUES (0,'READ');
2080
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);
2081
2074
INSERT INTO `t3` VALUES (1,'fs');
2083
2076
select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0);
2087
2080
# Test for BUG#11700
2088
2081
CREATE TABLE t1 (
2089
acct_id int NOT NULL default '0',
2090
profile_id int default NULL,
2082
acct_id int(11) NOT NULL default '0',
2083
profile_id smallint(6) default NULL,
2091
2084
UNIQUE KEY t1$acct_id (acct_id),
2092
2085
KEY t1$profile_id (profile_id)
2094
2087
INSERT INTO t1 VALUES (132,17),(133,18);
2096
2089
CREATE TABLE t2 (
2097
profile_id int default NULL,
2098
queue_id int default NULL,
2099
seq int default NULL,
2090
profile_id smallint(6) default NULL,
2091
queue_id int(11) default NULL,
2092
seq int(11) default NULL,
2100
2093
KEY t2$queue_id (queue_id)
2102
2095
INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1);
2104
2097
CREATE TABLE t3 (
2105
id int NOT NULL default '0',
2106
qtype int default NULL,
2107
seq int default NULL,
2108
warn_lvl int default NULL,
2109
crit_lvl int default NULL,
2110
rr1 int NOT NULL default '0',
2111
rr2 int default NULL,
2112
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',
2113
2106
KEY t3$qtype (qtype),
2230
2223
CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b));
2231
2224
insert into t3 values (1,1),(1,2);
2232
2225
# must have "range checked" for t2
2233
#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;
2226
explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2
2227
where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and
2228
t2.b like '%%' order by t2.b limit 0,1;
2234
2229
DROP TABLE t1,t2,t3;
2273
2268
INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941);
2274
2269
INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941);
2276
#explain select max(key1) from t1 where key1 <= 0.6158;
2277
#explain select max(key2) from t2 where key2 <= 1.6158;
2278
#explain select min(key1) from t1 where key1 >= 0.3762;
2279
#explain select min(key2) from t2 where key2 >= 1.3762;
2280
#explain select max(key1), min(key2) from t1, t2 where key1 <= 0.6158 and key2 >= 1.3762;
2281
#explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
2282
#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;
2284
2280
select max(key1) from t1 where key1 <= 0.6158;
2285
2281
select max(key2) from t2 where key2 <= 1.6158;
2454
2450
# incorrect transformation to join ... on.
2457
create table t1 (a int, t1_val int);
2458
create table t2 (b int, t2_val int);
2459
create table t3 (a int, b int);
2453
create table t1 (a int(10), t1_val int(10));
2454
create table t2 (b int(10), t2_val int(10));
2455
create table t3 (a int(10), b int(10));
2460
2456
insert into t1 values (1,1),(2,2);
2461
2457
insert into t2 values (1,1),(2,2),(3,3);
2462
2458
insert into t3 values (1,1),(2,1),(3,1),(4,1);
2504
2500
# Bug #13067 JOIN xxx USING is case sensitive
2507
create table t1 (a int,b int);
2508
create table t2 (a int,b int);
2503
create table t1 (a int(10),b int(10));
2504
create table t2 (a int(10),b int(10));
2509
2505
insert into t1 values (1,10),(2,20),(3,30);
2510
2506
insert into t2 values (1,10);
2511
2507
# both queries should produce the same result
2553
2549
# nested right join.
2556
create table t1 (id int not null default '0');
2552
create table t1 (id int(11) not null default '0');
2557
2553
insert into t1 values (123),(191),(192);
2558
create table t2 (id char(16) not null);
2554
create table t2 (id char(16) character set utf8 not null);
2559
2555
insert into t2 values ('58013'),('58014'),('58015'),('58016');
2560
create table t3 (a_id int not null, b_id char(16));
2556
create table t3 (a_id int(11) not null, b_id char(16) character set utf8);
2561
2557
insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013');
2563
2559
# both queries are equivalent
3031
3039
AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
3033
3041
DROP TABLE t1,t2;
3034
# Bug #22026: Warning when using IF statement and large bigint
3042
# Bug #22026: Warning when using IF statement and large unsigned bigint
3037
create table t1 (a bigint);
3045
create table t1 (a bigint unsigned);
3038
3046
insert into t1 values
3039
(if(1, 92233720368547758, 1)),
3040
(case when 1 then 92233720368547758 else 1 end),
3041
(coalesce(92233720368547758, 1));
3047
(if(1, 9223372036854775808, 1)),
3048
(case when 1 then 9223372036854775808 else 1 end),
3049
(coalesce(9223372036854775808, 1));
3042
3050
select * from t1;
3044
3052
create table t1 select
3050
3058
# Ensure we handle big values properly
3052
if(1, 1111111111111111111, 1) i,
3053
case when 1 then 1111111111111111111 else 1 end c,
3054
coalesce(1111111111111111111, 1) co;
3060
if(1, cast(1111111111111111111 as unsigned), 1) i,
3061
case when 1 then cast(1111111111111111111 as unsigned) else 1 end c,
3062
coalesce(cast(1111111111111111111 as unsigned), 1) co;
3057
3065
# Bug #22971: indexes on text columns are ignored for ref accesses
3264
3272
# Bug #30666: Incorrect order when using range conditions on 2 tables or more
3267
CREATE TABLE t1 (c11 INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
3268
CREATE TABLE t2 (c21 INT NOT NULL,
3275
CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);
3276
CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL,
3269
3277
c22 INT DEFAULT NULL,
3270
3278
KEY(c21, c22));
3271
CREATE TABLE t3 (c31 INT NOT NULL DEFAULT 0,
3279
CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0,
3272
3280
c32 INT DEFAULT NULL,
3273
3281
c33 INT NOT NULL,
3282
c34 INT UNSIGNED DEFAULT 0,
3275
3283
KEY (c33, c34, c32));
3277
3285
INSERT INTO t1 values (),(),(),(),();