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
1298
explain select fld3 from t2 ignore index (fld3,not_used);
1299
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);
1302
1304
# Test sorting with a used key (there is no need for sorting)
1305
1307
select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
1306
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;
1307
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.
1335
1336
select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%';
1336
1337
select fld3 from t2 where fld3 like "L%" and fld3 = "ok";
1337
1338
select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly");
1348
1349
select distinct companynr from t2;
1349
1350
select distinct companynr from t2 order by companynr;
1350
1351
select distinct companynr from t2 order by companynr desc;
1351
1353
select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
1353
1355
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
1354
1359
select distinct fld3 from t2 limit 10;
1355
1360
select distinct fld3 from t2 having fld3 like "A%" limit 10;
1356
1361
select distinct substring(fld3,1,3) from t2 where fld3 like "A%";
1357
1362
select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10;
1358
1363
select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10;
1359
1365
select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10;
1361
1367
# make a big table.
1443
1449
# Here the last fld3 is optimized away from the order by
1446
explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
1452
#explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
1449
1455
# Some test with ORDER BY and limit
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;
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;
1457
1463
# Search with a constant table.
1540
1547
select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
1541
1548
select count(*) from t2 left join t4 using (companynr) where t4.companynr is not 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;
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;
1545
1552
select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
1546
1553
select count(*) from t2 left join t4 using (companynr) where companynr is not 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;
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;
1549
1556
delete from t2 where fld1=999999;
1552
1559
# Test left join optimization
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;
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;
1571
1578
# Joins with forms.
1574
1581
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;
1582
#explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
1578
1585
# Search using 'or' with the same referens group.
1611
1618
select companynr,count(*),sum(fld1) from t2 group by companynr;
1612
1619
select companynr,count(*) from t2 group by companynr order by companynr desc limit 5;
1613
1620
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
#explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
1615
1622
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
1616
1623
select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
1617
1624
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;
1785
1792
# Test of bug with SUM(CASE...)
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
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;
1789
1796
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);
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
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;
1791
1798
INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35);
1792
1799
# Disable PS becasue we get more warnings from PS than from normal execution
1793
1800
--disable_ps_protocol
1801
1808
# Test of bigint comparision
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');
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');
1805
1812
INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093);
1806
1813
select wss_type from t1 where wss_type ='102935229216544106';
1807
1814
select wss_type from t1 where wss_type ='102935229216544105';
1859
1867
select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1;
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;
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;
1863
1871
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);
1864
CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=MyISAM;
1872
CREATE TABLE t2 ( id int NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=MyISAM;
1865
1873
INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522);
1866
1874
select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5;
1867
1875
drop table t1,t2;
1910
1917
create table t2 (c integer, d integer, index(c), index(d));
1911
1918
insert into t1 values (1,2), (2,2), (3,2), (4,2);
1912
1919
insert into t2 values (1,3), (2,3), (3,4), (4,4);
1913
explain select * from t1 left join t2 on a=c where d in (4);
1920
#explain select * from t1 left join t2 on a=c where d in (4);
1914
1921
select * from t1 left join t2 on a=c where d in (4);
1915
explain select * from t1 left join t2 on a=c where d = 4;
1922
#explain select * from t1 left join t2 on a=c where d = 4;
1916
1923
select * from t1 left join t2 on a=c where d = 4;
1917
1924
drop table t1, t2;
1971
# Bug#7425 inconsistent sort order on unsigned columns result of substraction
1978
# Bug#7425 inconsistent sort order on columns result of substraction
1974
create table t1 (a int(11) unsigned, b int(11) unsigned);
1981
create table t1 (a int, b int);
1975
1982
insert into t1 values (1,0), (1,1), (1,2);
1976
1983
select a-b from t1 order by 1;
1977
1984
select a-b , (a-b < 0) from t1 order by 1;
1978
1985
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
1979
select cast((a - b) as unsigned) from t1 order by 1;
1986
select a - b from t1 order by 1;
1984
1991
# Bug#8733 server accepts malformed query (multiply mentioned distinct)
1986
create table t1 (a int(11));
1993
create table t1 (a int);
1987
1994
select all all * from t1;
1988
1995
select distinct distinct * from t1;
1996
2003
# Test for BUG#10095
1998
2005
CREATE TABLE t1 (
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',
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',
2002
2009
aktuell enum('Ja','Nein') NOT NULL default 'Ja',
2003
2010
vorname varchar(128) NOT NULL default '',
2004
2011
nachname varchar(128) NOT NULL default '',
2057
# Test for Bug#8009, SELECT failed on bigint unsigned when using HEX
2064
# Test for Bug#8009, SELECT failed on bigint when using HEX
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;
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;
2066
2073
# IN with outer join condition (BUG#9393)
2068
CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL);
2075
CREATE TABLE `t1` ( `gid` int default NULL, `uid` int default NULL);
2070
CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL);
2077
CREATE TABLE `t2` ( `ident` int default NULL, `level` char(16) default NULL);
2071
2078
INSERT INTO `t2` VALUES (0,'READ');
2073
CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL);
2080
CREATE TABLE `t3` ( `id` int default NULL, `name` char(16) default NULL);
2074
2081
INSERT INTO `t3` VALUES (1,'fs');
2076
2083
select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0);
2080
2087
# Test for BUG#11700
2081
2088
CREATE TABLE t1 (
2082
acct_id int(11) NOT NULL default '0',
2083
profile_id smallint(6) default NULL,
2089
acct_id int NOT NULL default '0',
2090
profile_id int default NULL,
2084
2091
UNIQUE KEY t1$acct_id (acct_id),
2085
2092
KEY t1$profile_id (profile_id)
2087
2094
INSERT INTO t1 VALUES (132,17),(133,18);
2089
2096
CREATE TABLE t2 (
2090
profile_id smallint(6) default NULL,
2091
queue_id int(11) default NULL,
2092
seq int(11) default NULL,
2097
profile_id int default NULL,
2098
queue_id int default NULL,
2099
seq int default NULL,
2093
2100
KEY t2$queue_id (queue_id)
2095
2102
INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1);
2097
2104
CREATE TABLE t3 (
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',
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',
2106
2113
KEY t3$qtype (qtype),
2223
2230
CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b));
2224
2231
insert into t3 values (1,1),(1,2);
2225
2232
# must have "range checked" for t2
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;
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;
2229
2234
DROP TABLE t1,t2,t3;
2268
2273
INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941);
2269
2274
INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941);
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;
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;
2280
2284
select max(key1) from t1 where key1 <= 0.6158;
2281
2285
select max(key2) from t2 where key2 <= 1.6158;
2450
2454
# incorrect transformation to join ... on.
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));
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);
2456
2460
insert into t1 values (1,1),(2,2);
2457
2461
insert into t2 values (1,1),(2,2),(3,3);
2458
2462
insert into t3 values (1,1),(2,1),(3,1),(4,1);
2500
2504
# Bug #13067 JOIN xxx USING is case sensitive
2503
create table t1 (a int(10),b int(10));
2504
create table t2 (a int(10),b int(10));
2507
create table t1 (a int,b int);
2508
create table t2 (a int,b int);
2505
2509
insert into t1 values (1,10),(2,20),(3,30);
2506
2510
insert into t2 values (1,10);
2507
2511
# both queries should produce the same result
2549
2553
# nested right join.
2552
create table t1 (id int(11) not null default '0');
2556
create table t1 (id int not null default '0');
2553
2557
insert into t1 values (123),(191),(192);
2554
create table t2 (id char(16) character set utf8 not null);
2558
create table t2 (id char(16) not null);
2555
2559
insert into t2 values ('58013'),('58014'),('58015'),('58016');
2556
create table t3 (a_id int(11) not null, b_id char(16) character set utf8);
2560
create table t3 (a_id int not null, b_id char(16));
2557
2561
insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013');
2559
2563
# both queries are equivalent
3039
3031
AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
3041
3033
DROP TABLE t1,t2;
3042
# Bug #22026: Warning when using IF statement and large unsigned bigint
3034
# Bug #22026: Warning when using IF statement and large bigint
3045
create table t1 (a bigint unsigned);
3037
create table t1 (a bigint);
3046
3038
insert into t1 values
3047
(if(1, 9223372036854775808, 1)),
3048
(case when 1 then 9223372036854775808 else 1 end),
3049
(coalesce(9223372036854775808, 1));
3039
(if(1, 92233720368547758, 1)),
3040
(case when 1 then 92233720368547758 else 1 end),
3041
(coalesce(92233720368547758, 1));
3050
3042
select * from t1;
3052
3044
create table t1 select
3058
3050
# Ensure we handle big values properly
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;
3052
if(1, 1111111111111111111, 1) i,
3053
case when 1 then 1111111111111111111 else 1 end c,
3054
coalesce(1111111111111111111, 1) co;
3065
3057
# Bug #22971: indexes on text columns are ignored for ref accesses
3272
3264
# Bug #30666: Incorrect order when using range conditions on 2 tables or more
3275
CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);
3276
CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL,
3267
CREATE TABLE t1 (c11 INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
3268
CREATE TABLE t2 (c21 INT NOT NULL,
3277
3269
c22 INT DEFAULT NULL,
3278
3270
KEY(c21, c22));
3279
CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0,
3271
CREATE TABLE t3 (c31 INT NOT NULL DEFAULT 0,
3280
3272
c32 INT DEFAULT NULL,
3281
3273
c33 INT NOT NULL,
3282
c34 INT UNSIGNED DEFAULT 0,
3283
3275
KEY (c33, c34, c32));
3285
3277
INSERT INTO t1 values (),(),(),(),();