~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/innodb.test

  • Committer: Brian Aker
  • Date: 2010-08-17 01:34:55 UTC
  • mto: (1711.1.23 build)
  • mto: This revision was merged to the branch mainline in revision 1714.
  • Revision ID: brian@tangent.org-20100817013455-zx3nm7qilxvpwrgb
Style on structure cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
#                                                                     #
12
12
#######################################################################
13
13
 
14
 
SET @orig_lock_wait_timeout= @@innodb_lock_wait_timeout; 
15
 
SET GLOBAL innodb_lock_wait_timeout=2;
16
 
 
 
14
-- source include/have_innodb.inc
17
15
 
18
16
#
19
17
# Small basic test with ignore
54
52
update t1 set parent_id=parent_id+100;
55
53
select * from t1 where parent_id=102;
56
54
update t1 set id=id+1000;
57
 
--error ER_DUP_ENTRY, ER_DUP_KEY
 
55
-- error ER_DUP_ENTRY,1022
58
56
update t1 set id=1024 where id=1009; 
59
57
select * from t1;
60
58
update ignore t1 set id=id+1; # This will change all rows
135
133
select n, "after commit" from t1;
136
134
commit;
137
135
insert into t1 values (5);
138
 
--error ER_DUP_ENTRY
 
136
-- error ER_DUP_ENTRY
139
137
insert into t1 values (4);
140
138
commit;
141
139
select n, "after commit" from t1;
142
140
set autocommit=1;
143
141
insert into t1 values (6);
144
 
--error ER_DUP_ENTRY
 
142
-- error ER_DUP_ENTRY
145
143
insert into t1 values (4);
146
144
select n from t1;
147
145
set autocommit=0;
156
154
select n from t1;
157
155
savepoint savept3;
158
156
rollback to savepoint savept2;
159
 
--error ER_SP_DOES_NOT_EXIST
 
157
--error 1305
160
158
rollback to savepoint savept3;
161
159
rollback to savepoint savept2;
162
160
release savepoint `my_savepoint`;
163
161
select n from t1;
164
 
--error ER_SP_DOES_NOT_EXIST
 
162
-- error 1305
165
163
rollback to savepoint `my_savepoint`;
166
164
rollback to savepoint savept2;
167
165
insert into t1 values (8);
183
181
flush tables with read lock;
184
182
#
185
183
# Current code can't handle a read lock in middle of transaction
186
 
#--error ER_CANT_UPDATE_WITH_READLOCK
 
184
#--error 1223;
187
185
commit;
188
186
unlock tables;
189
187
commit;
214
212
 
215
213
CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb;
216
214
insert into t1 values ('pippo', 12);
217
 
--error ER_DUP_ENTRY
 
215
-- error ER_DUP_ENTRY
218
216
insert into t1 values ('pippo', 12); # Gives error
219
217
delete from t1;
220
218
delete from t1 where id = 'pippo';
228
226
delete from t1;
229
227
commit;
230
228
select * from t1;
231
 
commit;
232
229
drop table t1;
233
230
 
234
231
#
236
233
#
237
234
 
238
235
create table t1 (a integer) engine=innodb;
 
236
start transaction;
239
237
rename table t1 to t2;
240
238
create table t1 (b integer) engine=innodb;
241
 
start transaction;
242
239
insert into t1 values (1);
243
240
rollback;
244
241
drop table t1;
261
258
COMMIT;
262
259
SELECT * FROM t1;
263
260
SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk';
264
 
COMMIT;
265
261
drop table t1;
266
262
set autocommit=1;
267
263
 
306
302
select * from t1;
307
303
update t1 set col2='7' where col1='4';
308
304
select * from t1;
309
 
ALTER TABLE t1 ADD co3 INT DEFAULT 42 NOT NULL;
 
305
alter table t1 add co3 int not null;
310
306
select * from t1;
311
307
update t1 set col2='9' where col1='2';
312
308
select * from t1;
541
537
commit;
542
538
drop database mysqltest;
543
539
# Don't check error message
544
 
--error ER_BAD_DB_ERROR
 
540
--error 1049
545
541
show tables from mysqltest;
546
542
 
547
543
#
551
547
set autocommit=0;
552
548
create table t1 (a int not null) engine= innodb;
553
549
insert into t1 values(1),(2);
554
 
commit;
555
550
truncate table t1;
556
551
commit;
557
552
truncate table t1;
782
777
        foreign key(pid) references t1(id) on delete cascade) engine=innodb;
783
778
insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
784
779
        (8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
785
 
--error ER_ROW_IS_REFERENCED_2
 
780
-- error 1451
786
781
delete from t1 where id=0;
787
782
delete from t1 where id=15;
788
783
delete from t1 where id=0;
871
866
create index id2 on t2 (id);
872
867
show create table t2;
873
868
drop index id2 on t2;
874
 
--error ER_ERROR_ON_RENAME, ER_ERROR_ON_RENAME
 
869
--error 1025,1025
875
870
drop index id on t2;
876
871
show create table t2;
877
872
drop table t2;
908
903
# Test error handling
909
904
 
910
905
# Embedded server doesn't chdir to data directory
911
 
--replace_result $DRIZZLETEST_VARDIR . master-data/ ''
 
906
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
912
907
--error ER_WRONG_FK_DEF
913
908
create table t2 (id int not null, id2 int not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
914
909
 
925
920
#
926
921
# Bug #6126: Duplicate columns in keys gives misleading error message
927
922
#
928
 
--error ER_DUP_FIELDNAME
 
923
--error 1060
929
924
create table t1 (c char(10), index (c,c)) engine=innodb;
930
 
--error ER_DUP_FIELDNAME
 
925
--error 1060
931
926
create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
932
 
--error ER_DUP_FIELDNAME
 
927
--error 1060
933
928
create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb;
934
 
--error ER_DUP_FIELDNAME
 
929
--error 1060
935
930
create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb;
936
931
create table t1 (c1 char(10), c2 char(10)) engine=innodb;
937
 
--error ER_DUP_FIELDNAME
 
932
--error 1060
938
933
alter table t1 add key (c1,c1);
939
 
--error ER_DUP_FIELDNAME
 
934
--error 1060
940
935
alter table t1 add key (c2,c1,c1);
941
 
--error ER_DUP_FIELDNAME
 
936
--error 1060
942
937
alter table t1 add key (c1,c2,c1);
943
 
--error ER_DUP_FIELDNAME
 
938
--error 1060
944
939
alter table t1 add key (c1,c1,c2);
945
940
drop table t1;
946
941
 
1054
1049
show status like "Innodb_row_lock_time_avg";
1055
1050
 
1056
1051
# Test for innodb_sync_spin_loops variable
1057
 
set @my_innodb_sync_spin_loops = @@global.innodb_sync_spin_loops;
1058
1052
show variables like "innodb_sync_spin_loops";
1059
1053
set global innodb_sync_spin_loops=1000;
1060
1054
show variables like "innodb_sync_spin_loops";
1062
1056
show variables like "innodb_sync_spin_loops";
1063
1057
set global innodb_sync_spin_loops=20;
1064
1058
show variables like "innodb_sync_spin_loops";
1065
 
set @@global.innodb_sync_spin_loops = @my_innodb_sync_spin_loops;
1066
1059
 
1067
1060
# Test for innodb_thread_concurrency variable
1068
 
set @my_innodb_thread_concurrency = @@global.innodb_thread_concurrency;
1069
1061
show variables like "innodb_thread_concurrency";
1070
1062
set global innodb_thread_concurrency=1001;
1071
1063
show variables like "innodb_thread_concurrency";
1073
1065
show variables like "innodb_thread_concurrency";
1074
1066
set global innodb_thread_concurrency=16;
1075
1067
show variables like "innodb_thread_concurrency";
1076
 
set @@global.innodb_thread_concurrency = @my_innodb_thread_concurrency;
1077
1068
 
1078
1069
# Test for innodb_concurrency_tickets variable
1079
1070
show variables like "innodb_concurrency_tickets";
1106
1097
#
1107
1098
 
1108
1099
# Embedded server doesn't chdir to data directory
1109
 
--replace_result $DRIZZLETEST_VARDIR . master-data/ ''
 
1100
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
1110
1101
create table t1 (v varchar(16383), key(v));
1111
1102
drop table t1;
1112
1103
create table t1 (v varchar(16383));
1203
1194
 id INT PRIMARY KEY
1204
1195
) ENGINE=InnoDB;
1205
1196
 
1206
 
--error ER_CANT_CREATE_TABLE, ER_CANT_CREATE_TABLE
 
1197
--error 1005,1005
1207
1198
CREATE TEMPORARY TABLE t2
1208
1199
(
1209
1200
 id INT NOT NULL PRIMARY KEY,
1257
1248
drop table t1, t2, t3, t4;
1258
1249
 
1259
1250
# these should be refused
1260
 
--error ER_TOO_LONG_KEY
 
1251
--error 1071
1261
1252
create table t1 (col1 varchar(768) primary key)
1262
1253
 engine = innodb;
1263
 
--error ER_TOO_LONG_KEY
 
1254
--error 1071
1264
1255
create table t2 (col1 varbinary(1024) primary key)
1265
1256
 engine = innodb;
1266
 
--error ER_TOO_LONG_KEY
 
1257
--error 1071
1267
1258
create table t3 (col1 text, primary key(col1(768)))
1268
1259
 engine = innodb;
1269
 
--error ER_TOO_LONG_KEY
 
1260
--error 1071
1270
1261
create table t4 (col1 blob, primary key(col1(1024)))
1271
1262
 engine = innodb;
1272
1263
 
1285
1276
 CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
1286
1277
) ENGINE=InnoDB;
1287
1278
 
1288
 
--error ER_NO_REFERENCED_ROW_2
 
1279
--error 1452
1289
1280
INSERT INTO t2 VALUES(2);
1290
1281
 
1291
1282
INSERT INTO t1 VALUES(1);
1292
1283
INSERT INTO t2 VALUES(1);
1293
1284
 
1294
 
--error ER_ROW_IS_REFERENCED_2
 
1285
--error 1451
1295
1286
DELETE FROM t1 WHERE id = 1;
1296
1287
 
1297
 
--error ER_ROW_IS_REFERENCED
 
1288
--error 1217
1298
1289
DROP TABLE t1;
1299
1290
 
1300
1291
SET FOREIGN_KEY_CHECKS=0;
1301
1292
DROP TABLE t1;
1302
1293
SET FOREIGN_KEY_CHECKS=1;
1303
1294
 
1304
 
--error ER_NO_REFERENCED_ROW_2
 
1295
--error 1452
1305
1296
INSERT INTO t2 VALUES(3);
1306
1297
 
1307
1298
DROP TABLE t2;
1313
1304
set foreign_key_checks=0;
1314
1305
create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
1315
1306
# Embedded server doesn't chdir to data directory
1316
 
--replace_result $DRIZZLETEST_VARDIR . master-data/ ''
1317
 
--error ER_CANT_CREATE_TABLE
 
1307
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
 
1308
-- error 1005
1318
1309
create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
1319
1310
set foreign_key_checks=1;
1320
1311
drop table t2;
1324
1315
set foreign_key_checks=0;
1325
1316
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
1326
1317
create table t1(a varchar(10) primary key) engine = innodb;
1327
 
--error ER_ERROR_ON_RENAME, ER_ERROR_ON_RENAME
 
1318
-- error 1025,1025
1328
1319
alter table t1 modify column a int;
1329
1320
set foreign_key_checks=1;
1330
1321
drop table t2,t1;
1338
1329
 
1339
1330
insert into t1 values(1);
1340
1331
insert into t3 values(1);
1341
 
--error ER_NO_REFERENCED_ROW_2
 
1332
-- error 1452
1342
1333
insert into t2 values(2);
1343
 
--error ER_NO_REFERENCED_ROW_2
 
1334
-- error 1452
1344
1335
insert into t4 values(2);
1345
1336
insert into t2 values(1);
1346
1337
insert into t4 values(1);
1347
 
--error ER_ROW_IS_REFERENCED_2
 
1338
-- error 1451
1348
1339
update t1 set a=2;
1349
 
--error ER_NO_REFERENCED_ROW_2
 
1340
-- error 1452
1350
1341
update t2 set a=2;
1351
 
--error ER_ROW_IS_REFERENCED_2
 
1342
-- error 1451
1352
1343
update t3 set a=2;
1353
 
--error ER_NO_REFERENCED_ROW_2
 
1344
-- error 1452
1354
1345
update t4 set a=2;
1355
 
--error ER_ROW_IS_REFERENCED_2
 
1346
-- error 1451
1356
1347
truncate t1;
1357
 
--error ER_ROW_IS_REFERENCED_2
 
1348
-- error 1451
1358
1349
truncate t3;
1359
1350
truncate t2;
1360
1351
truncate t4;
1389
1380
create table t4 (s1 char(2) ,primary key (s1)) engine=innodb;
1390
1381
 
1391
1382
insert into t1 values (0x41),(0x4120),(0x4100);
1392
 
--error ER_DUP_ENTRY
 
1383
-- error ER_DUP_ENTRY
1393
1384
insert into t3 values (0x41),(0x4120),(0x4100);
1394
1385
insert into t3 values (0x41),(0x4100);
1395
 
--error ER_DUP_ENTRY
 
1386
-- error ER_DUP_ENTRY
1396
1387
insert into t4 values (0x41),(0x4120),(0x4100);
1397
1388
insert into t4 values (0x41),(0x4100);
1398
1389
select hex(s1) from t1;
1407
1398
insert into t2 values(0x42);
1408
1399
insert into t2 values(0x41);
1409
1400
select hex(s1) from t2;
1410
 
--error ER_ROW_IS_REFERENCED_2
 
1401
-- error 1451
1411
1402
update t1 set s1=0x123456 where a=2;
1412
1403
select hex(s1) from t2;
1413
1404
update t1 set s1=0x12 where a=1;
1414
 
--error ER_DATA_TOO_LONG
 
1405
-- error 1406
1415
1406
update t1 set s1=0x12345678 where a=1;
1416
1407
update t1 set s1=0x123457 where a=1;
1417
1408
update t1 set s1=0x1220 where a=1;
1422
1413
select hex(s1) from t2;
1423
1414
delete from t1 where a=1;
1424
1415
update t2 set s1=0x4120;
1425
 
--error ER_ROW_IS_REFERENCED_2
 
1416
-- error 1451
1426
1417
delete from t1;
1427
1418
delete from t1 where a!=3;
1428
1419
select a,hex(s1) from t1;
1441
1432
update t1 set s1=0x12 where a=2;
1442
1433
select hex(s1) from t2;
1443
1434
delete from t1 where a=1;
1444
 
--error ER_ROW_IS_REFERENCED_2
 
1435
-- error 1451
1445
1436
delete from t1 where a=2;
1446
1437
select a,hex(s1) from t1;
1447
1438
select hex(s1) from t2;
1586
1577
#
1587
1578
# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update
1588
1579
#
1589
 
--error ER_LOCK_WAIT_TIMEOUT
 
1580
--error 1205
1590
1581
select * from t1 where a = 2 and b = 2 for update;
1591
1582
#
1592
1583
# X-lock to record (1,1),(3,1),(5,1) should not be released in a update
1593
1584
#
1594
 
--error ER_LOCK_WAIT_TIMEOUT
 
1585
--error 1205
1595
1586
connection a;
1596
1587
commit;
1597
1588
connection b;
1623
1614
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
1624
1615
insert into t1 select * from t2;
1625
1616
update t1 set b = (select e from t2 where a = d);
1626
 
commit;
1627
1617
create table t3(d int not null, e int, primary key(d)) engine=innodb
1628
1618
select * from t2;
1629
1619
commit;
1722
1712
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
1723
1713
 
1724
1714
connection b;
1725
 
--error ER_LOCK_WAIT_TIMEOUT
 
1715
--error 1205
1726
1716
reap;
1727
1717
 
1728
1718
connection c;
1729
 
--error ER_LOCK_WAIT_TIMEOUT
 
1719
--error 1205
1730
1720
reap;
1731
1721
 
1732
1722
connection d;
1733
 
--error ER_LOCK_WAIT_TIMEOUT
 
1723
--error 1205
1734
1724
reap;
1735
1725
 
1736
1726
connection e;
1737
 
--error ER_LOCK_WAIT_TIMEOUT
 
1727
--error 1205
1738
1728
reap;
1739
1729
 
1740
1730
connection f;
1741
 
--error ER_LOCK_WAIT_TIMEOUT
 
1731
--error 1205
1742
1732
reap;
1743
1733
 
1744
1734
connection g;
1745
 
--error ER_LOCK_WAIT_TIMEOUT
 
1735
--error 1205
1746
1736
reap;
1747
1737
 
1748
1738
connection h;
1749
 
--error ER_LOCK_WAIT_TIMEOUT
 
1739
--error 1205
1750
1740
reap;
1751
1741
 
1752
1742
connection i;
1753
 
--error ER_LOCK_WAIT_TIMEOUT
 
1743
--error 1205
1754
1744
reap;
1755
1745
 
1756
1746
connection j;
1757
 
--error ER_LOCK_WAIT_TIMEOUT
 
1747
--error 1205
1758
1748
reap;
1759
1749
 
1760
1750
connection a;
1774
1764
drop table t1, t2, t3, t5, t6, t8, t9;
1775
1765
 
1776
1766
# bug 18934, "InnoDB crashes when table uses column names like DB_ROW_ID"
1777
 
--error ER_CANT_CREATE_TABLE, ER_WRONG_COLUMN_NAME
 
1767
--error 1005
1778
1768
CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
1779
1769
 
1780
1770
#
1818
1808
CREATE TABLE t1 ( a int ) ENGINE=innodb;
1819
1809
BEGIN;
1820
1810
INSERT INTO t1 VALUES (1);
1821
 
COMMIT;
1822
1811
ALTER TABLE t1 ENGINE=innodb;
1823
1812
DROP TABLE t1;
1824
1813
 
1851
1840
# mysqltest first does replace_regex, then replace_result
1852
1841
--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
1853
1842
# Embedded server doesn't chdir to data directory
1854
 
--replace_result $DRIZZLETEST_VARDIR . master-data/ ''
1855
 
--error ER_ERROR_ON_RENAME
 
1843
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
 
1844
--error 1025
1856
1845
ALTER TABLE t2 MODIFY a INT NOT NULL;
1857
1846
DELETE FROM t1;
1858
1847
DROP TABLE t2,t1;
1908
1897
SELECT * FROM t1;
1909
1898
DROP TABLE t1;
1910
1899
 
1911
 
SET GLOBAL innodb_lock_wait_timeout=@orig_lock_wait_timeout ;
1912
 
 
1913
 
 
1914
1900
#######################################################################
1915
1901
#                                                                     #
1916
1902
# Please, DO NOT TOUCH this file as well as the innodb.result file.   #