~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/suite/broken/t/csv.test

  • Committer: Stewart Smith
  • Date: 2009-06-16 06:55:11 UTC
  • mto: This revision was merged to the branch mainline in revision 1094.
  • Revision ID: stewart@flamingspork.com-20090616065511-ps3ewfxj7918lwy3
rollback.test for MyISAM temp only.
- rename to myisam_rollback to reflect what it's testing
- just use create temporary table

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,
1299
1305
 
1300
1306
 
1301
1307
DROP TABLE t1;
1302
 
CREATE TEMPORARY TABLE t1 (
 
1308
CREATE TABLE t1 (
1303
1309
  Period int DEFAULT 0 NOT NULL,
1304
1310
  Varor_period int DEFAULT 0 NOT NULL
1305
1311
) ENGINE = CSV;
1318
1324
DROP TABLE IF EXISTS bug13894;
1319
1325
--enable_warnings
1320
1326
 
1321
 
CREATE TEMPORARY TABLE bug13894 ( val integer not null ) ENGINE = CSV;
 
1327
CREATE TABLE bug13894 ( val integer not null ) ENGINE = CSV;
1322
1328
INSERT INTO bug13894 VALUES (5);
1323
1329
INSERT INTO bug13894 VALUES (10);
1324
1330
INSERT INTO bug13894 VALUES (11);
1336
1342
DROP TABLE IF EXISTS bug14672;
1337
1343
--enable_warnings
1338
1344
 
1339
 
CREATE TEMPORARY TABLE bug14672 (c1 integer not null) engine = CSV;   
 
1345
CREATE TABLE bug14672 (c1 integer not null) engine = CSV;   
1340
1346
INSERT INTO bug14672 VALUES (1), (2), (3);
1341
1347
SELECT * FROM bug14672;  
1342
1348
DELETE FROM bug14672 WHERE c1 = 2;   
1350
1356
# End of 4.1 tests
1351
1357
 
1352
1358
#
 
1359
# Test REPAIR/CHECK TABLE (5.1)
 
1360
#
 
1361
 
 
1362
# Check that repair on the newly created table works fine
 
1363
 
 
1364
CREATE TABLE test_repair_table ( val integer not null ) ENGINE = CSV;
 
1365
 
 
1366
CHECK TABLE test_repair_table;
 
1367
REPAIR TABLE test_repair_table;
 
1368
 
 
1369
DROP TABLE test_repair_table;
 
1370
 
 
1371
#
 
1372
# Check autorepair. Here we also check that we can work w/o metafile
 
1373
# restore the meta-file
 
1374
#
 
1375
 
 
1376
CREATE TABLE test_repair_table2 ( val integer not null ) ENGINE = CSV;
 
1377
--remove_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table2.CSM
 
1378
 
 
1379
# Should give a warning and perform autorepair. We also disable ps-protocol
 
1380
# here, as mysql-test eats up warnings in ps-protocol mode
 
1381
 
 
1382
--disable_ps_protocol
 
1383
SELECT * from test_repair_table2;
 
1384
--enable_ps_protocol
 
1385
# this should work ok, as the table is already repaired
 
1386
SELECT * from test_repair_table2;
 
1387
# check that the metafile appeared again.
 
1388
--file_exists $MYSQLTEST_VARDIR/master-data/test/test_repair_table2.CSM
 
1389
CHECK TABLE test_repair_table2;
 
1390
DROP TABLE test_repair_table2;
 
1391
 
 
1392
 
 
1393
# Corrupt csv file and see if we can repair it
 
1394
CREATE TABLE test_repair_table3 ( val integer not null ) ENGINE = CSV;
 
1395
--remove_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table3.CSV
 
1396
--write_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table3.CSV
 
1397
"1"
 
1398
"4"
 
1399
"3
 
1400
EOF
 
1401
CHECK TABLE test_repair_table3;
 
1402
REPAIR TABLE test_repair_table3;
 
1403
SELECT * FROM test_repair_table3;
 
1404
DROP TABLE test_repair_table3;
 
1405
 
 
1406
# Test with more sophisticated table
 
1407
 
 
1408
CREATE TABLE test_repair_table4 (
 
1409
  num int not null,
 
1410
  magic_no int DEFAULT 0 NOT NULL,
 
1411
  company_name char(30) DEFAULT '' NOT NULL,
 
1412
  founded char(4) DEFAULT '' NOT NULL
 
1413
) ENGINE = CSV;
 
1414
 
 
1415
--remove_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table4.CSM
 
1416
--disable_ps_protocol
 
1417
SELECT * FROM test_repair_table4;
 
1418
--enable_ps_protocol
 
1419
SELECT * FROM test_repair_table4;
 
1420
CHECK TABLE test_repair_table4;
 
1421
 
 
1422
INSERT INTO test_repair_table4 VALUES (2,101,'SAP','1972');
 
1423
INSERT INTO test_repair_table4 VALUES (1,101,'Microsoft','1978');
 
1424
INSERT INTO test_repair_table4 VALUES (2,101,'MySQL','1995');
 
1425
 
 
1426
# list table content
 
1427
SELECT * FROM test_repair_table4;
 
1428
CHECK TABLE test_repair_table4;
 
1429
REPAIR TABLE test_repair_table4;
 
1430
# check that nothing changed
 
1431
SELECT * FROM test_repair_table4;
 
1432
# verify that check/repair did non corrupt the table itself
 
1433
CHECK TABLE test_repair_table4;
 
1434
REPAIR TABLE test_repair_table4;
 
1435
SELECT * FROM test_repair_table4;
 
1436
DROP TABLE test_repair_table4;
 
1437
 
 
1438
# Run CHECK/REPAIR on the CSV file with a single row, which misses a column.
 
1439
 
 
1440
CREATE TABLE test_repair_table5 (
 
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
# Corrupt a table -- put a file with wrong # of columns
 
1448
--remove_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table5.CSV
 
1449
--write_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table5.CSV
 
1450
"1","101","IBM"
 
1451
EOF
 
1452
 
 
1453
CHECK TABLE test_repair_table5;
 
1454
REPAIR TABLE test_repair_table5;
 
1455
SELECT * FROM test_repair_table5;
 
1456
INSERT INTO test_repair_table5 VALUES (1, 102, "CORRECT", 1876);
 
1457
SELECT * FROM test_repair_table5;
 
1458
 
 
1459
# Corrupt a table -- put a row with wrong # of columns at end of file
 
1460
--append_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table5.CSV
 
1461
"1","101","IBM"
 
1462
EOF
 
1463
 
 
1464
FLUSH TABLES;
 
1465
CHECK TABLE test_repair_table5;
 
1466
REPAIR TABLE test_repair_table5;
 
1467
# The correct record inserted should still be in the file
 
1468
SELECT * FROM test_repair_table5;
 
1469
INSERT INTO test_repair_table5 VALUES (1, 102, "CORRECT2", 1876);
 
1470
SELECT * FROM test_repair_table5;
 
1471
 
 
1472
# Corrupt table again -- put a row with wrong # of columns at end of file
 
1473
--append_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table5.CSV
 
1474
"1","101","IBM"
 
1475
EOF
 
1476
 
 
1477
FLUSH TABLES;
 
1478
CHECK TABLE test_repair_table5;
 
1479
REPAIR TABLE test_repair_table5;
 
1480
# The two correct records inserted should still be in the file
 
1481
SELECT * FROM test_repair_table5;
 
1482
DROP TABLE test_repair_table5;
 
1483
 
 
1484
#
1353
1485
# BUG#13406 - incorrect amount of "records deleted"
1354
1486
#
1355
1487
 
1356
 
create temporary table t1 (a int not null) engine=csv;
 
1488
create table t1 (a int not null) engine=csv;
1357
1489
insert t1 values (1);
1358
1490
--enable_info
1359
1491
delete from t1;                 # delete_row
1381
1513
drop table t1;
1382
1514
 
1383
1515
#
 
1516
# Some additional tests for new, faster alter table.  Note that most of the
 
1517
# whole alter table code is being tested all around the test suite already.
 
1518
#
 
1519
 
 
1520
create table t1 (v varchar(32) not null);
 
1521
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
 
1522
select * from t1;
 
1523
# Fast alter, no copy performed
 
1524
alter table t1 change v v2 varchar(32);
 
1525
select * from t1;
 
1526
# Fast alter, no copy performed
 
1527
alter table t1 change v2 v varchar(64);
 
1528
select * from t1;
 
1529
update t1 set v = 'lmn' where v = 'hij';
 
1530
select * from t1;
 
1531
# Regular alter table
 
1532
alter table t1 add i int auto_increment not null primary key first;
 
1533
select * from t1;
 
1534
update t1 set i=5 where i=3;
 
1535
select * from t1;
 
1536
alter table t1 change i i bigint;
 
1537
select * from t1;
 
1538
alter table t1 add unique key (i, v);
 
1539
select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
 
1540
drop table t1;
 
1541
 
 
1542
#
1384
1543
# Bug #15205   Select from CSV table without the datafile causes crash
1385
1544
#
1386
1545
# NOTE: the bug is not deterministic
1408
1567
#drop table bug15205;
1409
1568
#drop table bug15205_2;
1410
1569
 
 
1570
 
 
1571
#
 
1572
# Bug#22080 "CHECK fails to identify some corruption"
 
1573
#
 
1574
 
 
1575
create table bug22080_1 (id int not null,string varchar(64) not null) Engine=CSV;
 
1576
create table bug22080_2 (id int not null,string varchar(64) not null) Engine=CSV;
 
1577
create table bug22080_3 (id int not null,string varchar(64) not null) Engine=CSV;
 
1578
insert into bug22080_1 values(1,'string');
 
1579
insert into bug22080_1 values(2,'string');
 
1580
insert into bug22080_1 values(3,'string');
 
1581
 
 
1582
# Create first corrupt file as described in bug report
 
1583
--remove_file $MYSQLTEST_VARDIR/master-data/test/bug22080_2.CSV
 
1584
--write_file $MYSQLTEST_VARDIR/master-data/test/bug22080_2.CSV
 
1585
1,"string"
 
1586
2","string"
 
1587
3,"string"
 
1588
EOF
 
1589
 
 
1590
# Create second corrupt file as described in bug report
 
1591
--remove_file $MYSQLTEST_VARDIR/master-data/test/bug22080_3.CSV
 
1592
--write_file $MYSQLTEST_VARDIR/master-data/test/bug22080_3.CSV
 
1593
1,"string"
 
1594
"2",string"
 
1595
3,"string"
 
1596
EOF
 
1597
 
 
1598
check table bug22080_2;
 
1599
 
 
1600
check table bug22080_3;
 
1601
 
 
1602
drop tables bug22080_1,bug22080_2,bug22080_3;
 
1603
 
1411
1604
#
1412
1605
# Testing float type
1413
1606
#
1414
 
create temporary table float_test (id float not null,string varchar(64) not null) Engine=CSV;
 
1607
create table float_test (id float not null,string varchar(64) not null) Engine=CSV;
1415
1608
insert into float_test values(1.0,'string');
1416
1609
insert into float_test values(2.23,'serg.g');
1417
1610
insert into float_test values(0.03,'string');
1425
1618
# Bug #21328 mysqld issues warnings on ALTER CSV table to MyISAM
1426
1619
#
1427
1620
 
1428
 
CREATE TEMPORARY TABLE `bug21328` (
 
1621
CREATE TABLE `bug21328` (
1429
1622
  `col1` int NOT NULL,
1430
1623
  `col2` int NOT NULL,
1431
1624
  `col3` int NOT NULL
1439
1632
# BUG#28971 - ALTER TABLE followed by UPDATE for a CSV table make server
1440
1633
# crash
1441
1634
#
1442
 
create temporary table t1(a blob not null, b int not null) engine=csv;
 
1635
create table t1(a blob not null, b int not null) engine=csv;
1443
1636
insert into t1 values('a', 1);
1444
1637
flush tables;
1445
1638
update t1 set b=2;
1449
1642
#
1450
1643
# Bug #29353: negative values
1451
1644
#
1452
 
create temporary table t1(a int not null) engine=csv;
 
1645
create table t1(a int not null) engine=csv;
1453
1646
insert into t1 values(-1), (-123.34), (2), (-23);
1454
1647
select * from t1;
1455
1648
check table t1;
1456
1649
drop table t1;
1457
1650
 
 
1651
create table t1(a int not null, b int not null) engine=csv;
 
1652
--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.CSV
 
1653
--write_file $MYSQLTEST_VARDIR/master-data/test/t1.CSV
 
1654
1, 1E-2
 
1655
-2E2, .9
 
1656
-10E-1, -.9
 
1657
-1, -100.1
 
1658
1a, -2b
 
1659
EOF
 
1660
repair table t1;
 
1661
check table t1;
 
1662
select * from t1;
 
1663
check table t1;
 
1664
drop table t1;
 
1665
 
1458
1666
#
1459
1667
# Bug #29411: deleting from a csv table leads to the table corruption
1460
1668
#
1461
 
create temporary table t1(a int not null) engine=csv;
 
1669
create table t1(a int not null) engine=csv;
1462
1670
insert into t1 values (0), (1), (2);
1463
1671
delete from t1 limit 2;
1464
1672
check table t1;
1471
1679
#
1472
1680
# Bug #31473: does not work with NULL value in datetime field
1473
1681
#
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
 
1682
create table t1(a datetime not null) engine=csv;
 
1683
--error 1364
 
1684
insert into t1 values();
 
1685
select * from t1;
 
1686
drop table t1;
 
1687
create table t1(a varchar(32) not null) engine=csv;
 
1688
--error 1364
 
1689
insert into t1 values();
 
1690
select * from t1;
 
1691
drop table t1;
 
1692
create table t1(a int not null) engine=csv;
 
1693
--error 1364
 
1694
insert into t1 values();
 
1695
select * from t1;
 
1696
drop table t1;
 
1697
create table t1(a blob not null) engine=csv;
 
1698
--error 1364
1491
1699
insert into t1 values();
1492
1700
select * from t1;
1493
1701
drop table t1;
1494
1702
# We prevent creation of table with nullable ENUM
1495
1703
--error ER_CHECK_NOT_IMPLEMENTED
1496
 
create temporary table t1(a enum('foo','bar') default null) engine=csv;
 
1704
create table t1(a enum('foo','bar') default null) engine=csv;
1497
1705
--error ER_CHECK_NOT_IMPLEMENTED
1498
 
create temporary table t1(a enum('foo','bar') default 'foo') engine=csv;
 
1706
create table t1(a enum('foo','bar') default 'foo') engine=csv;
1499
1707
# Enum columns must be specified as NOT NULL
1500
 
create temporary table t1(a enum('foo','bar') default 'foo' not null) engine=csv;
 
1708
create table t1(a enum('foo','bar') default 'foo' not null) engine=csv;
1501
1709
insert into t1 values();
1502
1710
select * from t1;
1503
1711
drop table t1;
1507
1715
#             with error 1005.
1508
1716
#
1509
1717
--error ER_CHECK_NOT_IMPLEMENTED
1510
 
CREATE TEMPORARY TABLE t1(a INT) ENGINE=CSV;
 
1718
CREATE TABLE t1(a INT) ENGINE=CSV;
1511
1719
SHOW WARNINGS;
1512
1720
 
1513
1721
#
1514
1722
# BUG#33067 - .
1515
1723
#
1516
 
create temporary table t1 (c1 blob not null) engine=csv;
 
1724
create table t1 (c1 blob not null) engine=csv;
1517
1725
insert into t1 values("This");
1518
1726
--enable_info            
1519
1727
update t1 set c1="That" where c1="This";
1530
1738
drop table if exists t1;
1531
1739
--enable_warnings
1532
1740
 
 
1741
create table t1 (val int not null) engine=csv;
 
1742
--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.CSV
 
1743
 
 
1744
--error 1017
 
1745
select * from t1;
 
1746
 
1533
1747
--echo End of 5.1 tests