~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/csv.test

  • Committer: Brian Aker
  • Date: 2009-01-09 22:07:54 UTC
  • Revision ID: brian@tangent.org-20090109220754-1y50h7lqi9i1ifcs
Dead test/wrong test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
 
2
# Test for the CSV engine
 
3
#
 
4
 
 
5
--source include/have_csv.inc
 
6
 
 
7
#
2
8
# Simple select test
3
9
#
4
10
 
6
12
drop table if exists t1,t2,t3,t4;
7
13
--enable_warnings
8
14
 
9
 
CREATE TEMPORARY TABLE t1 (
 
15
CREATE TABLE t1 (
10
16
  Period int DEFAULT 0 NOT NULL,
11
17
  Varor_period int DEFAULT 0 NOT NULL
12
18
) ENGINE = CSV;
21
27
# Create test table
22
28
#
23
29
 
24
 
CREATE TEMPORARY TABLE t2 (
 
30
CREATE TABLE t2 (
25
31
  auto int not null,
26
32
  fld1 int DEFAULT 0 NOT NULL,
27
33
  companynr int DEFAULT 0 NOT NULL,
36
42
#
37
43
 
38
44
--disable_query_log
39
 
begin;
40
45
INSERT INTO t2 VALUES (1,000001,00,'Omaha','teethe','neat','');
41
46
INSERT INTO t2 VALUES (2,011401,37,'breaking','dreaded','Steinberg','W');
42
47
INSERT INTO t2 VALUES (3,011402,37,'Romans','scholastics','jarring','');
1236
1241
INSERT INTO t2 VALUES (1191,068504,00,'bonfire','corresponds','positively','');
1237
1242
INSERT INTO t2 VALUES (1192,068305,00,'Colombo','hardware','colicky','');
1238
1243
INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly','');
1239
 
commit;
1240
1244
--enable_query_log
1241
1245
 
1242
1246
#
1299
1303
 
1300
1304
 
1301
1305
DROP TABLE t1;
1302
 
CREATE TEMPORARY TABLE t1 (
 
1306
CREATE TABLE t1 (
1303
1307
  Period int DEFAULT 0 NOT NULL,
1304
1308
  Varor_period int DEFAULT 0 NOT NULL
1305
1309
) ENGINE = CSV;
1318
1322
DROP TABLE IF EXISTS bug13894;
1319
1323
--enable_warnings
1320
1324
 
1321
 
CREATE TEMPORARY TABLE bug13894 ( val integer not null ) ENGINE = CSV;
 
1325
CREATE TABLE bug13894 ( val integer not null ) ENGINE = CSV;
1322
1326
INSERT INTO bug13894 VALUES (5);
1323
1327
INSERT INTO bug13894 VALUES (10);
1324
1328
INSERT INTO bug13894 VALUES (11);
1336
1340
DROP TABLE IF EXISTS bug14672;
1337
1341
--enable_warnings
1338
1342
 
1339
 
CREATE TEMPORARY TABLE bug14672 (c1 integer not null) engine = CSV;   
 
1343
CREATE TABLE bug14672 (c1 integer not null) engine = CSV;   
1340
1344
INSERT INTO bug14672 VALUES (1), (2), (3);
1341
1345
SELECT * FROM bug14672;  
1342
1346
DELETE FROM bug14672 WHERE c1 = 2;   
1350
1354
# End of 4.1 tests
1351
1355
 
1352
1356
#
 
1357
# Test CONCURRENT INSERT (5.1)
 
1358
#
 
1359
 
 
1360
CREATE TABLE test_concurrent_insert ( val integer not null ) ENGINE = CSV;
 
1361
 
 
1362
connect (con1,localhost,root,,);
 
1363
connect (con2,localhost,root,,);
 
1364
 
 
1365
connection con1;
 
1366
# obtain TL_READ lock on the table
 
1367
LOCK TABLES test_concurrent_insert READ LOCAL;
 
1368
 
 
1369
connection con2;
 
1370
# should pass despite of the lock
 
1371
INSERT INTO test_concurrent_insert VALUES (1);
 
1372
SELECT * FROM test_concurrent_insert;
 
1373
 
 
1374
connection con1;
 
1375
# first connection should not notice the changes
 
1376
SELECT * FROM test_concurrent_insert;
 
1377
 
 
1378
UNLOCK TABLES;
 
1379
 
 
1380
# Now check that we see our own changes
 
1381
 
 
1382
LOCK TABLES test_concurrent_insert WRITE;
 
1383
INSERT INTO test_concurrent_insert VALUES (2);
 
1384
SELECT * FROM test_concurrent_insert;
 
1385
UNLOCK TABLES;
 
1386
 
 
1387
# cleanup
 
1388
DROP TABLE test_concurrent_insert;
 
1389
 
 
1390
#
 
1391
# Test REPAIR/CHECK TABLE (5.1)
 
1392
#
 
1393
 
 
1394
# Check that repair on the newly created table works fine
 
1395
 
 
1396
CREATE TABLE test_repair_table ( val integer not null ) ENGINE = CSV;
 
1397
 
 
1398
CHECK TABLE test_repair_table;
 
1399
REPAIR TABLE test_repair_table;
 
1400
 
 
1401
DROP TABLE test_repair_table;
 
1402
 
 
1403
#
 
1404
# Check autorepair. Here we also check that we can work w/o metafile
 
1405
# restore the meta-file
 
1406
#
 
1407
 
 
1408
CREATE TABLE test_repair_table2 ( val integer not null ) ENGINE = CSV;
 
1409
--remove_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table2.CSM
 
1410
 
 
1411
# Should give a warning and perform autorepair. We also disable ps-protocol
 
1412
# here, as mysql-test eats up warnings in ps-protocol mode
 
1413
 
 
1414
--disable_ps_protocol
 
1415
SELECT * from test_repair_table2;
 
1416
--enable_ps_protocol
 
1417
# this should work ok, as the table is already repaired
 
1418
SELECT * from test_repair_table2;
 
1419
# check that the metafile appeared again.
 
1420
--file_exists $MYSQLTEST_VARDIR/master-data/test/test_repair_table2.CSM
 
1421
CHECK TABLE test_repair_table2;
 
1422
DROP TABLE test_repair_table2;
 
1423
 
 
1424
 
 
1425
# Corrupt csv file and see if we can repair it
 
1426
CREATE TABLE test_repair_table3 ( val integer not null ) ENGINE = CSV;
 
1427
--remove_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table3.CSV
 
1428
--write_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table3.CSV
 
1429
"1"
 
1430
"4"
 
1431
"3
 
1432
EOF
 
1433
CHECK TABLE test_repair_table3;
 
1434
REPAIR TABLE test_repair_table3;
 
1435
SELECT * FROM test_repair_table3;
 
1436
DROP TABLE test_repair_table3;
 
1437
 
 
1438
# Test with more sophisticated table
 
1439
 
 
1440
CREATE TABLE test_repair_table4 (
 
1441
  num int not null,
 
1442
  magic_no int DEFAULT 0 NOT NULL,
 
1443
  company_name char(30) DEFAULT '' NOT NULL,
 
1444
  founded char(4) DEFAULT '' NOT NULL
 
1445
) ENGINE = CSV;
 
1446
 
 
1447
--remove_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table4.CSM
 
1448
--disable_ps_protocol
 
1449
SELECT * FROM test_repair_table4;
 
1450
--enable_ps_protocol
 
1451
SELECT * FROM test_repair_table4;
 
1452
CHECK TABLE test_repair_table4;
 
1453
 
 
1454
INSERT INTO test_repair_table4 VALUES (2,101,'SAP','1972');
 
1455
INSERT INTO test_repair_table4 VALUES (1,101,'Microsoft','1978');
 
1456
INSERT INTO test_repair_table4 VALUES (2,101,'MySQL','1995');
 
1457
 
 
1458
# list table content
 
1459
SELECT * FROM test_repair_table4;
 
1460
CHECK TABLE test_repair_table4;
 
1461
REPAIR TABLE test_repair_table4;
 
1462
# check that nothing changed
 
1463
SELECT * FROM test_repair_table4;
 
1464
# verify that check/repair did non corrupt the table itself
 
1465
CHECK TABLE test_repair_table4;
 
1466
REPAIR TABLE test_repair_table4;
 
1467
SELECT * FROM test_repair_table4;
 
1468
DROP TABLE test_repair_table4;
 
1469
 
 
1470
# Run CHECK/REPAIR on the CSV file with a single row, which misses a column.
 
1471
 
 
1472
CREATE TABLE test_repair_table5 (
 
1473
  num int not null,
 
1474
  magic_no int DEFAULT 0 NOT NULL,
 
1475
  company_name char(30) DEFAULT '' NOT NULL,
 
1476
  founded char(4) DEFAULT '' NOT NULL
 
1477
) ENGINE = CSV;
 
1478
 
 
1479
# Corrupt a table -- put a file with wrong # of columns
 
1480
--remove_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table5.CSV
 
1481
--write_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table5.CSV
 
1482
"1","101","IBM"
 
1483
EOF
 
1484
 
 
1485
CHECK TABLE test_repair_table5;
 
1486
REPAIR TABLE test_repair_table5;
 
1487
SELECT * FROM test_repair_table5;
 
1488
INSERT INTO test_repair_table5 VALUES (1, 102, "CORRECT", 1876);
 
1489
SELECT * FROM test_repair_table5;
 
1490
 
 
1491
# Corrupt a table -- put a row with wrong # of columns at end of file
 
1492
--append_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table5.CSV
 
1493
"1","101","IBM"
 
1494
EOF
 
1495
 
 
1496
FLUSH TABLES;
 
1497
CHECK TABLE test_repair_table5;
 
1498
REPAIR TABLE test_repair_table5;
 
1499
# The correct record inserted should still be in the file
 
1500
SELECT * FROM test_repair_table5;
 
1501
INSERT INTO test_repair_table5 VALUES (1, 102, "CORRECT2", 1876);
 
1502
SELECT * FROM test_repair_table5;
 
1503
 
 
1504
# Corrupt table again -- put a row with wrong # of columns at end of file
 
1505
--append_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table5.CSV
 
1506
"1","101","IBM"
 
1507
EOF
 
1508
 
 
1509
FLUSH TABLES;
 
1510
CHECK TABLE test_repair_table5;
 
1511
REPAIR TABLE test_repair_table5;
 
1512
# The two correct records inserted should still be in the file
 
1513
SELECT * FROM test_repair_table5;
 
1514
DROP TABLE test_repair_table5;
 
1515
 
 
1516
#
1353
1517
# BUG#13406 - incorrect amount of "records deleted"
1354
1518
#
1355
1519
 
1356
 
create temporary table t1 (a int not null) engine=csv;
 
1520
create table t1 (a int not null) engine=csv;
1357
1521
insert t1 values (1);
1358
1522
--enable_info
1359
1523
delete from t1;                 # delete_row
1381
1545
drop table t1;
1382
1546
 
1383
1547
#
 
1548
# Some additional tests for new, faster alter table.  Note that most of the
 
1549
# whole alter table code is being tested all around the test suite already.
 
1550
#
 
1551
 
 
1552
create table t1 (v varchar(32) not null);
 
1553
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
 
1554
select * from t1;
 
1555
# Fast alter, no copy performed
 
1556
alter table t1 change v v2 varchar(32);
 
1557
select * from t1;
 
1558
# Fast alter, no copy performed
 
1559
alter table t1 change v2 v varchar(64);
 
1560
select * from t1;
 
1561
update t1 set v = 'lmn' where v = 'hij';
 
1562
select * from t1;
 
1563
# Regular alter table
 
1564
alter table t1 add i int auto_increment not null primary key first;
 
1565
select * from t1;
 
1566
update t1 set i=5 where i=3;
 
1567
select * from t1;
 
1568
alter table t1 change i i bigint;
 
1569
select * from t1;
 
1570
alter table t1 add unique key (i, v);
 
1571
select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
 
1572
drop table t1;
 
1573
 
 
1574
#
1384
1575
# Bug #15205   Select from CSV table without the datafile causes crash
1385
1576
#
1386
1577
# NOTE: the bug is not deterministic
1408
1599
#drop table bug15205;
1409
1600
#drop table bug15205_2;
1410
1601
 
 
1602
 
 
1603
#
 
1604
# Bug#22080 "CHECK fails to identify some corruption"
 
1605
#
 
1606
 
 
1607
create table bug22080_1 (id int not null,string varchar(64) not null) Engine=CSV;
 
1608
create table bug22080_2 (id int not null,string varchar(64) not null) Engine=CSV;
 
1609
create table bug22080_3 (id int not null,string varchar(64) not null) Engine=CSV;
 
1610
insert into bug22080_1 values(1,'string');
 
1611
insert into bug22080_1 values(2,'string');
 
1612
insert into bug22080_1 values(3,'string');
 
1613
 
 
1614
# Create first corrupt file as described in bug report
 
1615
--remove_file $MYSQLTEST_VARDIR/master-data/test/bug22080_2.CSV
 
1616
--write_file $MYSQLTEST_VARDIR/master-data/test/bug22080_2.CSV
 
1617
1,"string"
 
1618
2","string"
 
1619
3,"string"
 
1620
EOF
 
1621
 
 
1622
# Create second corrupt file as described in bug report
 
1623
--remove_file $MYSQLTEST_VARDIR/master-data/test/bug22080_3.CSV
 
1624
--write_file $MYSQLTEST_VARDIR/master-data/test/bug22080_3.CSV
 
1625
1,"string"
 
1626
"2",string"
 
1627
3,"string"
 
1628
EOF
 
1629
 
 
1630
check table bug22080_2;
 
1631
 
 
1632
check table bug22080_3;
 
1633
 
 
1634
drop tables bug22080_1,bug22080_2,bug22080_3;
 
1635
 
1411
1636
#
1412
1637
# Testing float type
1413
1638
#
1414
 
create temporary table float_test (id float not null,string varchar(64) not null) Engine=CSV;
 
1639
create table float_test (id float not null,string varchar(64) not null) Engine=CSV;
1415
1640
insert into float_test values(1.0,'string');
1416
1641
insert into float_test values(2.23,'serg.g');
1417
1642
insert into float_test values(0.03,'string');
1425
1650
# Bug #21328 mysqld issues warnings on ALTER CSV table to MyISAM
1426
1651
#
1427
1652
 
1428
 
CREATE TEMPORARY TABLE `bug21328` (
 
1653
CREATE TABLE `bug21328` (
1429
1654
  `col1` int NOT NULL,
1430
1655
  `col2` int NOT NULL,
1431
1656
  `col3` int NOT NULL
1439
1664
# BUG#28971 - ALTER TABLE followed by UPDATE for a CSV table make server
1440
1665
# crash
1441
1666
#
1442
 
create temporary table t1(a blob not null, b int not null) engine=csv;
 
1667
create table t1(a blob not null, b int not null) engine=csv;
1443
1668
insert into t1 values('a', 1);
1444
1669
flush tables;
1445
1670
update t1 set b=2;
1449
1674
#
1450
1675
# Bug #29353: negative values
1451
1676
#
1452
 
create temporary table t1(a int not null) engine=csv;
 
1677
create table t1(a int not null) engine=csv;
1453
1678
insert into t1 values(-1), (-123.34), (2), (-23);
1454
1679
select * from t1;
1455
1680
check table t1;
1456
1681
drop table t1;
1457
1682
 
 
1683
create table t1(a int not null, b int not null) engine=csv;
 
1684
--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.CSV
 
1685
--write_file $MYSQLTEST_VARDIR/master-data/test/t1.CSV
 
1686
1, 1E-2
 
1687
-2E2, .9
 
1688
-10E-1, -.9
 
1689
-1, -100.1
 
1690
1a, -2b
 
1691
EOF
 
1692
repair table t1;
 
1693
check table t1;
 
1694
select * from t1;
 
1695
check table t1;
 
1696
drop table t1;
 
1697
 
1458
1698
#
1459
1699
# Bug #29411: deleting from a csv table leads to the table corruption
1460
1700
#
1461
 
create temporary table t1(a int not null) engine=csv;
 
1701
create table t1(a int not null) engine=csv;
1462
1702
insert into t1 values (0), (1), (2);
1463
1703
delete from t1 limit 2;
1464
1704
check table t1;
1471
1711
#
1472
1712
# Bug #31473: does not work with NULL value in datetime field
1473
1713
#
1474
 
create temporary table t1(a datetime not null) engine=csv;
1475
 
--error ER_NO_DEFAULT_FOR_FIELD
1476
 
insert into t1 values();
1477
 
select * from t1;
1478
 
drop table t1;
1479
 
create temporary table t1(a varchar(32) not null) engine=csv;
1480
 
--error ER_NO_DEFAULT_FOR_FIELD
1481
 
insert into t1 values();
1482
 
select * from t1;
1483
 
drop table t1;
1484
 
create temporary table t1(a int not null) engine=csv;
1485
 
--error ER_NO_DEFAULT_FOR_FIELD
1486
 
insert into t1 values();
1487
 
select * from t1;
1488
 
drop table t1;
1489
 
create temporary table t1(a blob not null) engine=csv;
1490
 
--error ER_NO_DEFAULT_FOR_FIELD
 
1714
create table t1(a datetime not null) engine=csv;
 
1715
--error 1364
 
1716
insert into t1 values();
 
1717
select * from t1;
 
1718
drop table t1;
 
1719
create table t1(a varchar(32) not null) engine=csv;
 
1720
--error 1364
 
1721
insert into t1 values();
 
1722
select * from t1;
 
1723
drop table t1;
 
1724
create table t1(a int not null) engine=csv;
 
1725
--error 1364
 
1726
insert into t1 values();
 
1727
select * from t1;
 
1728
drop table t1;
 
1729
create table t1(a blob not null) engine=csv;
 
1730
--error 1364
1491
1731
insert into t1 values();
1492
1732
select * from t1;
1493
1733
drop table t1;
1494
1734
# We prevent creation of table with nullable ENUM
1495
1735
--error ER_CHECK_NOT_IMPLEMENTED
1496
 
create temporary table t1(a enum('foo','bar') default null) engine=csv;
 
1736
create table t1(a enum('foo','bar') default null) engine=csv;
1497
1737
--error ER_CHECK_NOT_IMPLEMENTED
1498
 
create temporary table t1(a enum('foo','bar') default 'foo') engine=csv;
 
1738
create table t1(a enum('foo','bar') default 'foo') engine=csv;
1499
1739
# Enum columns must be specified as NOT NULL
1500
 
create temporary table t1(a enum('foo','bar') default 'foo' not null) engine=csv;
 
1740
create table t1(a enum('foo','bar') default 'foo' not null) engine=csv;
1501
1741
insert into t1 values();
1502
1742
select * from t1;
1503
1743
drop table t1;
1507
1747
#             with error 1005.
1508
1748
#
1509
1749
--error ER_CHECK_NOT_IMPLEMENTED
1510
 
CREATE TEMPORARY TABLE t1(a INT) ENGINE=CSV;
 
1750
CREATE TABLE t1(a INT) ENGINE=CSV;
1511
1751
SHOW WARNINGS;
1512
1752
 
1513
1753
#
1514
1754
# BUG#33067 - .
1515
1755
#
1516
 
create temporary table t1 (c1 blob not null) engine=csv;
 
1756
create table t1 (c1 blob not null) engine=csv;
1517
1757
insert into t1 values("This");
1518
1758
--enable_info            
1519
1759
update t1 set c1="That" where c1="This";
1521
1761
select * from t1;
1522
1762
drop table t1;
1523
1763
 
1524
 
#
1525
 
# Bug#311104
1526
 
# CSV engine reports "out of memory" when you select
1527
 
# from a missing file
1528
 
#
1529
 
--disable_warnings
1530
 
drop table if exists t1;
1531
 
--enable_warnings
1532
 
 
1533
1764
--echo End of 5.1 tests