~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-07-12 00:49:18 UTC
  • mfrom: (1063.9.51 brian-tmp-fix)
  • Revision ID: brian@gaz-20090712004918-chprmyj387ex6l8a
Merge Stewart

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
CREATE TABLE t1 (
17
17
  Period int DEFAULT '0000' NOT NULL,
18
18
  Varor_period int DEFAULT '0' NOT NULL
19
 
) ENGINE=myisam;
 
19
);
20
20
 
21
21
INSERT INTO t1 VALUES (9410,9412);
22
22
  
39
39
  UNIQUE fld1 (fld1),
40
40
  KEY fld3 (fld3),
41
41
  PRIMARY KEY (auto)
42
 
) ENGINE=myisam;  
 
42
);
43
43
 
44
44
#
45
45
# Populate table
1285
1285
# Test using INDEX and IGNORE INDEX
1286
1286
#
1287
1287
 
 
1288
--replace_column 9 #
1288
1289
explain select t2.fld3 from t2 where fld3 = 'honeysuckle';
1289
1290
 
 
1291
--replace_column 9 #
1290
1292
explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle';
 
1293
--replace_column 9 #
1291
1294
explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle';
1292
1295
 
 
1296
--replace_column 9 #
1293
1297
explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle';
 
1298
--replace_column 9 #
1294
1299
explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
1295
1300
 
1296
1301
#
1308
1313
#
1309
1314
 
1310
1315
select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
 
1316
--replace_column 9 #
1311
1317
explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
1312
1318
select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
1313
1319
 
1326
1332
#
1327
1333
 
1328
1334
select fld1 from t2 where fld1=250501 or fld1="250502";
 
1335
--replace_column 9 #
1329
1336
explain select fld1 from t2 where fld1=250501 or fld1="250502"; 
1330
1337
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 #
1331
1339
explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
1332
1340
 
1333
1341
#
1351
1359
select distinct companynr from t2;
1352
1360
select distinct companynr from t2 order by companynr;
1353
1361
select distinct companynr from t2 order by companynr desc;
1354
 
select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
 
1362
select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%" ORDER BY t2.fld3,period;
1355
1363
 
1356
1364
select distinct fld3 from t2 where companynr = 34 order by fld3;
1357
 
select distinct fld3 from t2 limit 10;
 
1365
select distinct fld3 from t2 ORDER BY fld3 limit 10;
1358
1366
select distinct fld3 from t2 having fld3 like "A%" limit 10;
1359
1367
select distinct substring(fld3,1,3) from t2 where fld3 like "A%";
1360
 
select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10;
 
1368
select distinct lower(substring(fld3,1,3)) as a from t2 having a like "A%" order by a limit 10;
1361
1369
select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10;
1362
 
select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10;
1363
1370
 
1364
1371
# make a big table.
1365
1372
 
1371
1378
 price2     double(11,0),
1372
1379
 key (period),
1373
1380
 key (name)
1374
 
) engine=myisam;
 
1381
);
1375
1382
 
1376
1383
--disable_query_log
 
1384
BEGIN;
1377
1385
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1001,"Iranizes",37,5987435,234724);
1378
1386
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1002,"violinist",37,28357832,8723648);
1379
1387
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1003,"extramarital",37,39654943,235872);
1384
1392
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1008,"tucked",311,234298,3275892);
1385
1393
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1009,"gems",447,2374834,9872392);
1386
1394
INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1010,"clinker",512,786542,76234234);
 
1395
COMMIT;
1387
1396
--enable_query_log
1388
1397
 
1389
1398
create temporary table tmp engine = myisam select * from t3;
1442
1451
# Here the last fld3 is optimized away from the order by
1443
1452
#
1444
1453
 
 
1454
--replace_column 9 #
1445
1455
explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
1446
1456
 
1447
1457
#
1448
1458
# Some test with ORDER BY and limit
1449
1459
#
1450
1460
 
 
1461
--replace_column 9 #
1451
1462
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
 
1463
--replace_column 9 #
1452
1464
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
 
1465
--replace_column 9 #
1453
1466
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
1454
1467
 
1455
1468
#
1467
1480
 
1468
1481
select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
1469
1482
 
 
1483
--replace_column 9 #
1470
1484
explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
1471
1485
 
1472
1486
#
1473
1487
# Search with a constant table and several rows from another table
1474
1488
#
1475
1489
 
 
1490
--sorted_result
1476
1491
select fld3,period from t2,t1 where companynr*10 = 37*10;
1477
1492
 
1478
1493
#
1494
1509
# We need another table for join stuff..
1495
1510
#
1496
1511
 
1497
 
create table t4 (
 
1512
create temporary table t4 (
1498
1513
  companynr int NOT NULL default '00',
1499
1514
  companyname char(30) NOT NULL default '',
1500
1515
  PRIMARY KEY (companynr),
1538
1553
 
1539
1554
select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
1540
1555
select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null;
 
1556
--replace_column 9 #
1541
1557
explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
 
1558
--replace_column 9 #
1542
1559
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
1543
1560
 
1544
1561
select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
1545
1562
select count(*) from t2 left join t4 using (companynr) where companynr is not null;
 
1563
--replace_column 9 #
1546
1564
explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
 
1565
--replace_column 9 #
1547
1566
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null;
1548
1567
delete from t2 where fld1=999999;
1549
1568
 
1550
1569
#
1551
1570
# Test left join optimization
1552
1571
 
 
1572
--replace_column 9 #
1553
1573
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
 
1574
--replace_column 9 #
1554
1575
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
 
1576
--replace_column 9 #
1555
1577
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
1556
1578
 
 
1579
--replace_column 9 #
1557
1580
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
 
1581
--replace_column 9 #
1558
1582
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
 
1583
--replace_column 9 #
1559
1584
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
1560
1585
# Following can't be optimized
 
1586
--replace_column 9 #
1561
1587
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 #
1562
1589
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 #
1563
1591
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
1564
1592
 
 
1593
--replace_column 9 #
1565
1594
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
 
1595
--replace_column 9 #
1566
1596
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
 
1597
--replace_column 9 #
1567
1598
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
1568
1599
 
1569
1600
#
1571
1602
#
1572
1603
 
1573
1604
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
 
1605
--replace_column 9 #
1574
1606
explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
1575
1607
 
1576
1608
#
1610
1642
select companynr,count(*),sum(fld1) from t2 group by companynr;
1611
1643
select companynr,count(*) from t2 group by companynr order by companynr desc limit 5;
1612
1644
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 #
1613
1646
explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
1614
1647
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
1615
1648
select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
1699
1732
 
1700
1733
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;
1701
1734
 
 
1735
--replace_column 9 #
1702
1736
explain select fld3 from t2 where 1>2 or 2>3;
 
1737
--replace_column 9 #
1703
1738
explain select fld3 from t2 where fld1=fld1;
1704
1739
 
1705
1740
#
1725
1760
select max(fld1) from t2 where fld1>= 098024;
1726
1761
select count(*) from t3 where price2=76234234;
1727
1762
select count(*) from t3 where companynr=512 and price2=76234234;
 
1763
--replace_column 9 #
1728
1764
explain select min(fld1),max(fld1),count(*) from t2;
1729
1765
# PS does correct pre-zero here. MySQL can't do it as it returns a number.
1730
1766
--disable_ps_protocol
1761
1797
show full columns from t2 from test like 'f%';
1762
1798
--replace_column 8 #
1763
1799
show full columns from t2 from test like 's%';
 
1800
--replace_column 7 #
1764
1801
show keys from t2;
1765
1802
 
1766
1803
drop table t4, t3, t2, t1;
1767
1804
 
1768
1805
 
1769
 
CREATE TABLE t1 (
 
1806
CREATE TEMPORARY TABLE t1 (
1770
1807
  cont_nr int NOT NULL auto_increment,
1771
1808
  ver_nr int NOT NULL default '0',
1772
1809
  aufnr int NOT NULL default '0',