~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/include/common-tests.inc

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
--enable_warnings
15
15
 
16
16
CREATE TABLE t1 (
17
 
  Period int DEFAULT '0000' NOT NULL,
18
 
  Varor_period int DEFAULT '0' NOT NULL
 
17
  Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
 
18
  Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
19
19
);
20
20
 
21
21
INSERT INTO t1 VALUES (9410,9412);
30
30
 
31
31
CREATE TABLE t2 (
32
32
  auto int not null auto_increment,
33
 
  fld1 int DEFAULT '000000' NOT NULL,
34
 
  companynr int DEFAULT '00' NOT NULL,
 
33
  fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL,
 
34
  companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL,
35
35
  fld3 char(30) DEFAULT '' NOT NULL,
36
36
  fld4 char(35) DEFAULT '' NOT NULL,
37
37
  fld5 char(35) DEFAULT '' NOT NULL,
39
39
  UNIQUE fld1 (fld1),
40
40
  KEY fld3 (fld3),
41
41
  PRIMARY KEY (auto)
42
 
);
 
42
);  
43
43
 
44
44
#
45
45
# Populate table
46
46
#
47
47
 
48
48
--disable_query_log
49
 
begin;
50
49
INSERT INTO t2 VALUES (1,000001,00,'Omaha','teethe','neat','');
51
50
INSERT INTO t2 VALUES (2,011401,37,'breaking','dreaded','Steinberg','W');
52
51
INSERT INTO t2 VALUES (3,011402,37,'Romans','scholastics','jarring','');
1246
1245
INSERT INTO t2 VALUES (1191,068504,00,'bonfire','corresponds','positively','');
1247
1246
INSERT INTO t2 VALUES (1192,068305,00,'Colombo','hardware','colicky','');
1248
1247
INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly','');
1249
 
commit;
1250
1248
--enable_query_log
1251
1249
 
1252
1250
#
1285
1283
# Test using INDEX and IGNORE INDEX
1286
1284
#
1287
1285
 
1288
 
--replace_column 9 #
1289
1286
explain select t2.fld3 from t2 where fld3 = 'honeysuckle';
1290
1287
 
1291
 
--replace_column 9 #
1292
1288
explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle';
1293
 
--replace_column 9 #
1294
1289
explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle';
1295
1290
 
1296
 
--replace_column 9 #
1297
1291
explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle';
1298
 
--replace_column 9 #
1299
1292
explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
1300
1293
 
1301
1294
#
1303
1296
# The next should give an error
1304
1297
#
1305
1298
 
1306
 
--error ER_KEY_DOES_NOT_EXITS
 
1299
-- error 1176
1307
1300
explain select fld3 from t2 ignore index (fld3,not_used);
1308
 
--error ER_KEY_DOES_NOT_EXITS
 
1301
-- error 1176
1309
1302
explain select fld3 from t2 use index (not_used);
1310
1303
 
1311
1304
#
1313
1306
#
1314
1307
 
1315
1308
select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
1316
 
--replace_column 9 #
1317
1309
explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
1318
1310
select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
1319
1311
 
1332
1324
#
1333
1325
 
1334
1326
select fld1 from t2 where fld1=250501 or fld1="250502";
1335
 
--replace_column 9 #
1336
1327
explain select fld1 from t2 where fld1=250501 or fld1="250502"; 
1337
1328
select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
1338
 
--replace_column 9 #
1339
1329
explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
1340
1330
 
1341
1331
#
1359
1349
select distinct companynr from t2;
1360
1350
select distinct companynr from t2 order by companynr;
1361
1351
select distinct companynr from t2 order by companynr desc;
1362
 
select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%" ORDER BY t2.fld3,period;
 
1352
select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
1363
1353
 
1364
1354
select distinct fld3 from t2 where companynr = 34 order by fld3;
1365
 
select distinct fld3 from t2 ORDER BY fld3 limit 10;
 
1355
select distinct fld3 from t2 limit 10;
1366
1356
select distinct fld3 from t2 having fld3 like "A%" limit 10;
1367
1357
select distinct substring(fld3,1,3) from t2 where fld3 like "A%";
1368
 
select distinct lower(substring(fld3,1,3)) as a from t2 having a like "A%" order by a limit 10;
 
1358
select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10;
1369
1359
select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10;
 
1360
select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10;
1370
1361
 
1371
1362
# make a big table.
1372
1363
 
1381
1372
);
1382
1373
 
1383
1374
--disable_query_log
1384
 
BEGIN;
1385
1375
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1001,"Iranizes",37,5987435,234724);
1386
1376
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1002,"violinist",37,28357832,8723648);
1387
1377
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1003,"extramarital",37,39654943,235872);
1392
1382
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1008,"tucked",311,234298,3275892);
1393
1383
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1009,"gems",447,2374834,9872392);
1394
1384
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1010,"clinker",512,786542,76234234);
1395
 
COMMIT;
1396
1385
--enable_query_log
1397
1386
 
1398
1387
create temporary table tmp engine = myisam select * from t3;
1423
1412
 
1424
1413
# big table done
1425
1414
 
 
1415
SET SQL_BIG_TABLES=1;
1426
1416
select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10;
 
1417
SET SQL_BIG_TABLES=0;
1427
1418
select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10;
1428
1419
select distinct fld5 from t2 limit 10;
1429
1420
 
1432
1423
#
1433
1424
 
1434
1425
select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10;
 
1426
SET SQL_BIG_TABLES=1; # Force use of MyISAM
1435
1427
select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10;
 
1428
SET SQL_BIG_TABLES=0;
1436
1429
select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10;
1437
1430
 
1438
1431
#
1451
1444
# Here the last fld3 is optimized away from the order by
1452
1445
#
1453
1446
 
1454
 
--replace_column 9 #
1455
1447
explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
1456
1448
 
1457
1449
#
1458
1450
# Some test with ORDER BY and limit
1459
1451
#
1460
1452
 
1461
 
--replace_column 9 #
1462
1453
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
1463
 
--replace_column 9 #
1464
1454
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
1465
 
--replace_column 9 #
1466
1455
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
1467
1456
 
1468
1457
#
1480
1469
 
1481
1470
select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
1482
1471
 
1483
 
--replace_column 9 #
1484
1472
explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
1485
1473
 
1486
1474
#
1487
1475
# Search with a constant table and several rows from another table
1488
1476
#
1489
1477
 
1490
 
--sorted_result
1491
1478
select fld3,period from t2,t1 where companynr*10 = 37*10;
1492
1479
 
1493
1480
#
1509
1496
# We need another table for join stuff..
1510
1497
#
1511
1498
 
1512
 
create temporary table t4 (
1513
 
  companynr int NOT NULL default '00',
 
1499
create table t4 (
 
1500
  companynr tinyint(2) unsigned zerofill NOT NULL default '00',
1514
1501
  companyname char(30) NOT NULL default '',
1515
1502
  PRIMARY KEY (companynr),
1516
1503
  UNIQUE KEY companyname(companyname)
1517
 
) ENGINE=MyISAM COMMENT='companynames';
 
1504
) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
1518
1505
 
1519
1506
--disable_query_log
1520
1507
INSERT INTO t4 (companynr, companyname) VALUES (29,'company 1');
1553
1540
 
1554
1541
select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
1555
1542
select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null;
1556
 
--replace_column 9 #
1557
1543
explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
1558
 
--replace_column 9 #
1559
1544
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
1560
1545
 
1561
1546
select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
1562
1547
select count(*) from t2 left join t4 using (companynr) where companynr is not null;
1563
 
--replace_column 9 #
1564
1548
explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
1565
 
--replace_column 9 #
1566
1549
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null;
1567
1550
delete from t2 where fld1=999999;
1568
1551
 
1569
1552
#
1570
1553
# Test left join optimization
1571
1554
 
1572
 
--replace_column 9 #
1573
1555
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
1574
 
--replace_column 9 #
1575
1556
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
1576
 
--replace_column 9 #
1577
1557
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
1578
1558
 
1579
 
--replace_column 9 #
1580
1559
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
1581
 
--replace_column 9 #
1582
1560
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
1583
 
--replace_column 9 #
1584
1561
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
1585
1562
# Following can't be optimized
1586
 
--replace_column 9 #
1587
1563
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
1588
 
--replace_column 9 #
1589
1564
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
1590
 
--replace_column 9 #
1591
1565
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
1592
1566
 
1593
 
--replace_column 9 #
1594
1567
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
1595
 
--replace_column 9 #
1596
1568
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
1597
 
--replace_column 9 #
1598
1569
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
1599
1570
 
1600
1571
#
1602
1573
#
1603
1574
 
1604
1575
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
1605
 
--replace_column 9 #
1606
1576
explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
1607
1577
 
1608
1578
#
1642
1612
select companynr,count(*),sum(fld1) from t2 group by companynr;
1643
1613
select companynr,count(*) from t2 group by companynr order by companynr desc limit 5;
1644
1614
select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
1645
 
--replace_column 9 #
1646
1615
explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
1647
1616
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
1648
1617
select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
1674
1643
# Group with extra not group fields.
1675
1644
#
1676
1645
 
1677
 
select companynr,companyname from t4 group by 1;
 
1646
select companynr|0,companyname from t4 group by 1;
1678
1647
select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname;
1679
1648
select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
1680
1649
 
1732
1701
 
1733
1702
select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1;
1734
1703
 
1735
 
--replace_column 9 #
1736
1704
explain select fld3 from t2 where 1>2 or 2>3;
1737
 
--replace_column 9 #
1738
1705
explain select fld3 from t2 where fld1=fld1;
1739
1706
 
1740
1707
#
1760
1727
select max(fld1) from t2 where fld1>= 098024;
1761
1728
select count(*) from t3 where price2=76234234;
1762
1729
select count(*) from t3 where companynr=512 and price2=76234234;
1763
 
--replace_column 9 #
1764
1730
explain select min(fld1),max(fld1),count(*) from t2;
1765
1731
# PS does correct pre-zero here. MySQL can't do it as it returns a number.
1766
1732
--disable_ps_protocol
1797
1763
show full columns from t2 from test like 'f%';
1798
1764
--replace_column 8 #
1799
1765
show full columns from t2 from test like 's%';
1800
 
--replace_column 7 #
1801
1766
show keys from t2;
1802
1767
 
1803
1768
drop table t4, t3, t2, t1;
1804
1769
 
1805
1770
 
1806
 
CREATE TEMPORARY TABLE t1 (
1807
 
  cont_nr int NOT NULL auto_increment,
1808
 
  ver_nr int NOT NULL default '0',
1809
 
  aufnr int NOT NULL default '0',
 
1771
CREATE TABLE t1 (
 
1772
  cont_nr int(11) NOT NULL auto_increment,
 
1773
  ver_nr int(11) NOT NULL default '0',
 
1774
  aufnr int(11) NOT NULL default '0',
1810
1775
  username varchar(50) NOT NULL default '',
1811
 
  hdl_nr int NOT NULL default '0',
1812
 
  eintrag date NULL,
 
1776
  hdl_nr int(11) NOT NULL default '0',
 
1777
  eintrag date NOT NULL default '0000-00-00',
1813
1778
  st_klasse varchar(40) NOT NULL default '',
1814
1779
  st_wert varchar(40) NOT NULL default '',
1815
1780
  st_zusatz varchar(40) NOT NULL default '',
1816
1781
  st_bemerkung varchar(255) NOT NULL default '',
1817
1782
  kunden_art varchar(40) NOT NULL default '',
1818
 
  mcbs_knr int default NULL,
1819
 
  mcbs_aufnr int NOT NULL default '0',
 
1783
  mcbs_knr int(11) default NULL,
 
1784
  mcbs_aufnr int(11) NOT NULL default '0',
1820
1785
  schufa_status char(1) default '?',
1821
1786
  bemerkung text,
1822
1787
  wirknetz text,
1823
 
  wf_igz int NOT NULL default '0',
 
1788
  wf_igz int(11) NOT NULL default '0',
1824
1789
  tarifcode varchar(80) default NULL,
1825
1790
  recycle char(1) default NULL,
1826
1791
  sim varchar(30) default NULL,
1827
1792
  mcbs_tpl varchar(30) default NULL,
1828
 
  emp_nr int NOT NULL default '0',
1829
 
  laufzeit int default NULL,
 
1793
  emp_nr int(11) NOT NULL default '0',
 
1794
  laufzeit int(11) default NULL,
1830
1795
  hdl_name varchar(30) default NULL,
1831
 
  prov_hdl_nr int NOT NULL default '0',
 
1796
  prov_hdl_nr int(11) NOT NULL default '0',
1832
1797
  auto_wirknetz varchar(50) default NULL,
1833
1798
  auto_billing varchar(50) default NULL,
1834
1799
  touch timestamp NOT NULL,