~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Replace MAX_(DATE|TIME).*_WIDTH defines in definitions.h with real (and correct) static const members to Temporal types.

This fixes the buffer overflow in https://bugs.launchpad.net/drizzle/+bug/373468

It also removes a handwritten snprintf in field/datetime.cc
However... this caused us to have to change Temporal to have a way to not
"convert" the int64_t value (so 20090101 becomes 20090101000000 etc) as it
has already been converted and we just want the Temporal type to do the
to_string conversion.

This still causes a failure in 'metadata' test due to size of timestamp type. I need feedback from Jay on when the usecond code comes into play to know the correct fix for this.

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