1350
1354
# End of 4.1 tests
1357
# Test CONCURRENT INSERT (5.1)
1360
CREATE TABLE test_concurrent_insert ( val integer not null ) ENGINE = CSV;
1362
connect (con1,localhost,root,,);
1363
connect (con2,localhost,root,,);
1366
# obtain TL_READ lock on the table
1367
LOCK TABLES test_concurrent_insert READ LOCAL;
1370
# should pass despite of the lock
1371
INSERT INTO test_concurrent_insert VALUES (1);
1372
SELECT * FROM test_concurrent_insert;
1375
# first connection should not notice the changes
1376
SELECT * FROM test_concurrent_insert;
1380
# Now check that we see our own changes
1382
LOCK TABLES test_concurrent_insert WRITE;
1383
INSERT INTO test_concurrent_insert VALUES (2);
1384
SELECT * FROM test_concurrent_insert;
1388
DROP TABLE test_concurrent_insert;
1391
# Test REPAIR/CHECK TABLE (5.1)
1394
# Check that repair on the newly created table works fine
1396
CREATE TABLE test_repair_table ( val integer not null ) ENGINE = CSV;
1398
CHECK TABLE test_repair_table;
1399
REPAIR TABLE test_repair_table;
1401
DROP TABLE test_repair_table;
1404
# Check autorepair. Here we also check that we can work w/o metafile
1405
# restore the meta-file
1408
CREATE TABLE test_repair_table2 ( val integer not null ) ENGINE = CSV;
1409
--remove_file $MYSQLTEST_VARDIR/master-data/test/test_repair_table2.CSM
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
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;
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
1433
CHECK TABLE test_repair_table3;
1434
REPAIR TABLE test_repair_table3;
1435
SELECT * FROM test_repair_table3;
1436
DROP TABLE test_repair_table3;
1438
# Test with more sophisticated table
1440
CREATE TABLE test_repair_table4 (
1442
magic_no int(4) unsigned zerofill DEFAULT '0000' NOT NULL,
1443
company_name char(30) DEFAULT '' NOT NULL,
1444
founded char(4) DEFAULT '' NOT NULL
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;
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');
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;
1470
# Run CHECK/REPAIR on the CSV file with a single row, which misses a column.
1472
CREATE TABLE test_repair_table5 (
1474
magic_no int(4) unsigned zerofill DEFAULT '0000' NOT NULL,
1475
company_name char(30) DEFAULT '' NOT NULL,
1476
founded char(4) DEFAULT '' NOT NULL
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
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;
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
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;
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
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;
1353
1517
# BUG#13406 - incorrect amount of "records deleted"
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);
1359
1523
delete from t1; # delete_row
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.
1552
create table t1 (v varchar(32) not null);
1553
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
1555
# Fast alter, no copy performed
1556
alter table t1 change v v2 varchar(32);
1558
# Fast alter, no copy performed
1559
alter table t1 change v2 v varchar(64);
1561
update t1 set v = 'lmn' where v = 'hij';
1563
# Regular alter table
1564
alter table t1 add i int auto_increment not null primary key first;
1566
update t1 set i=5 where i=3;
1568
alter table t1 change i i bigint;
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');
1384
1575
# Bug #15205 Select from CSV table without the datafile causes crash
1386
1577
# NOTE: the bug is not deterministic
1392
1583
# resulted in scanning through deleted memory and we were geting a crash.
1393
1584
# that's why we need two tables in the bugtest
1395
# TODO: Bug lp:311104
1396
#create table bug15205 (val int not null) engine=csv;
1397
#create table bug15205_2 (val int not null) engine=csv;
1398
#--remove_file $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV
1399
## system error (can't open the datafile)
1400
#--replace_result $MYSQLTEST_VARDIR . master-data/ ''
1402
#select * from bug15205;
1403
#select * from bug15205_2;
1404
## Create empty file
1405
#--write_file $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV
1407
#select * from bug15205;
1408
#drop table bug15205;
1409
#drop table bug15205_2;
1586
create table bug15205 (val int(11) not null) engine=csv;
1587
create table bug15205_2 (val int(11) not null) engine=csv;
1588
--remove_file $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV
1589
# system error (can't open the datafile)
1590
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
1592
select * from bug15205;
1593
select * from bug15205_2;
1595
--write_file $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV
1597
select * from bug15205;
1598
drop table bug15205;
1599
drop table bug15205_2;
1603
# Bug#28862 "Extended Latin1 characters get lost in CVS engine"
1607
c varchar(1) not null,
1608
name varchar(64) not null
1609
) character set latin1 engine=csv;
1610
insert into t1 values (0xC0,'LATIN CAPITAL LETTER A WITH GRAVE');
1611
insert into t1 values (0xE0,'LATIN SMALL LETTER A WITH GRAVE');
1612
insert into t1 values (0xEE,'LATIN SMALL LETTER I WITH CIRCUMFLEX');
1613
insert into t1 values (0xFE,'LATIN SMALL LETTER THORN');
1614
insert into t1 values (0xF7,'DIVISION SIGN');
1615
insert into t1 values (0xFF,'LATIN SMALL LETTER Y WITH DIAERESIS');
1616
select hex(c), c, name from t1 order by 1;
1619
--echo End of 5.0 tests
1623
# Bug#22080 "CHECK fails to identify some corruption"
1626
create table bug22080_1 (id int not null,string varchar(64) not null) Engine=CSV;
1627
create table bug22080_2 (id int not null,string varchar(64) not null) Engine=CSV;
1628
create table bug22080_3 (id int not null,string varchar(64) not null) Engine=CSV;
1629
insert into bug22080_1 values(1,'string');
1630
insert into bug22080_1 values(2,'string');
1631
insert into bug22080_1 values(3,'string');
1633
# Create first corrupt file as described in bug report
1634
--remove_file $MYSQLTEST_VARDIR/master-data/test/bug22080_2.CSV
1635
--write_file $MYSQLTEST_VARDIR/master-data/test/bug22080_2.CSV
1641
# Create second corrupt file as described in bug report
1642
--remove_file $MYSQLTEST_VARDIR/master-data/test/bug22080_3.CSV
1643
--write_file $MYSQLTEST_VARDIR/master-data/test/bug22080_3.CSV
1649
check table bug22080_2;
1651
check table bug22080_3;
1653
drop tables bug22080_1,bug22080_2,bug22080_3;
1412
1656
# Testing float type
1414
create temporary table float_test (id float not null,string varchar(64) not null) Engine=CSV;
1658
create table float_test (id float not null,string varchar(64) not null) Engine=CSV;
1415
1659
insert into float_test values(1.0,'string');
1416
1660
insert into float_test values(2.23,'serg.g');
1417
1661
insert into float_test values(0.03,'string');
1472
1731
# Bug #31473: does not work with NULL value in datetime field
1474
create temporary table t1(a datetime not null) engine=csv;
1475
--error ER_NO_DEFAULT_FOR_FIELD
1476
insert into t1 values();
1479
create temporary table t1(a varchar(32) not null) engine=csv;
1480
--error ER_NO_DEFAULT_FOR_FIELD
1481
insert into t1 values();
1484
create temporary table t1(a int not null) engine=csv;
1485
--error ER_NO_DEFAULT_FOR_FIELD
1486
insert into t1 values();
1489
create temporary table t1(a blob not null) engine=csv;
1490
--error ER_NO_DEFAULT_FOR_FIELD
1491
insert into t1 values();
1733
create table t1(a datetime not null) engine=csv;
1734
insert into t1 values();
1737
create table t1(a set('foo','bar') not null) engine=csv;
1738
insert into t1 values();
1741
create table t1(a varchar(32) not null) engine=csv;
1742
insert into t1 values();
1745
create table t1(a int not null) engine=csv;
1746
insert into t1 values();
1749
create table t1(a blob not null) engine=csv;
1750
insert into t1 values();
1753
create table t1(a bit(1) not null) engine=csv;
1754
insert into t1 values();
1755
select BIN(a) from t1;
1494
1757
# We prevent creation of table with nullable ENUM
1495
1758
--error ER_CHECK_NOT_IMPLEMENTED
1496
create temporary table t1(a enum('foo','bar') default null) engine=csv;
1759
create table t1(a enum('foo','bar') default null) engine=csv;
1497
1760
--error ER_CHECK_NOT_IMPLEMENTED
1498
create temporary table t1(a enum('foo','bar') default 'foo') engine=csv;
1761
create table t1(a enum('foo','bar') default 'foo') engine=csv;
1499
1762
# Enum columns must be specified as NOT NULL
1500
create temporary table t1(a enum('foo','bar') default 'foo' not null) engine=csv;
1763
create table t1(a enum('foo','bar') default 'foo' not null) engine=csv;
1501
1764
insert into t1 values();
1502
1765
select * from t1;