~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/innodb.test

  • Committer: Padraig O'Sullivan
  • Date: 2010-02-10 16:26:01 UTC
  • mto: This revision was merged to the branch mainline in revision 1294.
  • Revision ID: osullivan.padraig@gmail.com-20100210162601-itx2ndl397pc1wr6
Corrected an order of initialization in a few optimizer classes

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
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 1305
 
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;
304
302
select * from t1;
305
303
update t1 set col2='7' where col1='4';
306
304
select * from t1;
307
 
ALTER TABLE t1 ADD co3 INT DEFAULT 42 NOT NULL;
 
305
alter table t1 add co3 int not null;
308
306
select * from t1;
309
307
update t1 set col2='9' where col1='2';
310
308
select * from t1;
539
537
commit;
540
538
drop database mysqltest;
541
539
# Don't check error message
542
 
--error ER_BAD_DB_ERROR
 
540
--error 1049
543
541
show tables from mysqltest;
544
542
 
545
543
#
836
834
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
837
835
insert t2 select * from t1;
838
836
insert t3 select * from t1;
839
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
 
837
checksum table t1, t2, t3, t4;
 
838
checksum table t1, t2, t3, t4;
 
839
checksum table t1, t2, t3, t4;
 
840
#show table status;
840
841
drop table t1,t2,t3;
841
842
 
842
843
#
868
869
create index id2 on t2 (id);
869
870
show create table t2;
870
871
drop index id2 on t2;
871
 
--error ER_ERROR_ON_RENAME, ER_ERROR_ON_RENAME
 
872
--error 1025,1025
872
873
drop index id on t2;
873
874
show create table t2;
874
875
drop table t2;
905
906
# Test error handling
906
907
 
907
908
# Embedded server doesn't chdir to data directory
908
 
--replace_result $DRIZZLETEST_VARDIR . master-data/ ''
 
909
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
909
910
--error ER_WRONG_FK_DEF
910
911
create table t2 (id int not null, id2 int not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
911
912
 
922
923
#
923
924
# Bug #6126: Duplicate columns in keys gives misleading error message
924
925
#
925
 
--error ER_DUP_FIELDNAME
 
926
--error 1060
926
927
create table t1 (c char(10), index (c,c)) engine=innodb;
927
 
--error ER_DUP_FIELDNAME
 
928
--error 1060
928
929
create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
929
 
--error ER_DUP_FIELDNAME
 
930
--error 1060
930
931
create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb;
931
 
--error ER_DUP_FIELDNAME
 
932
--error 1060
932
933
create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb;
933
934
create table t1 (c1 char(10), c2 char(10)) engine=innodb;
934
 
--error ER_DUP_FIELDNAME
 
935
--error 1060
935
936
alter table t1 add key (c1,c1);
936
 
--error ER_DUP_FIELDNAME
 
937
--error 1060
937
938
alter table t1 add key (c2,c1,c1);
938
 
--error ER_DUP_FIELDNAME
 
939
--error 1060
939
940
alter table t1 add key (c1,c2,c1);
940
 
--error ER_DUP_FIELDNAME
 
941
--error 1060
941
942
alter table t1 add key (c1,c1,c2);
942
943
drop table t1;
943
944
 
1027
1028
## Not deterministic.
1028
1029
# Test for testable InnoDB status variables. This test
1029
1030
# uses previous ones(pages_created, rows_deleted, ...).
1030
 
--replace_column 2 #
1031
 
show status like "Innodb_buffer_pool_pages_total";
1032
 
--replace_column 2 #
1033
 
show status like "Innodb_page_size";
1034
 
--replace_column 2 #
1035
 
show status like "Innodb_rows_deleted";
1036
 
--replace_column 2 #
1037
 
show status like "Innodb_rows_inserted";
1038
 
--replace_column 2 #
1039
 
show status like "Innodb_rows_updated";
 
1031
#show status like "Innodb_buffer_pool_pages_total";
 
1032
#show status like "Innodb_page_size";
 
1033
#show status like "Innodb_rows_deleted";
 
1034
#show status like "Innodb_rows_inserted";
 
1035
#show status like "Innodb_rows_updated";
1040
1036
 
1041
1037
## Test for row locks InnoDB status variables.
1042
 
--replace_column 2 #
1043
 
show status like "Innodb_row_lock_waits";
1044
 
--replace_column 2 #
1045
 
show status like "Innodb_row_lock_current_waits";
1046
 
--replace_column 2 #
1047
 
show status like "Innodb_row_lock_time";
1048
 
--replace_column 2 #
1049
 
show status like "Innodb_row_lock_time_max";
1050
 
--replace_column 2 #
1051
 
show status like "Innodb_row_lock_time_avg";
 
1038
#show status like "Innodb_row_lock_waits";
 
1039
#show status like "Innodb_row_lock_current_waits";
 
1040
#show status like "Innodb_row_lock_time";
 
1041
#show status like "Innodb_row_lock_time_max";
 
1042
#show status like "Innodb_row_lock_time_avg";
1052
1043
 
1053
1044
# Test for innodb_sync_spin_loops variable
1054
1045
show variables like "innodb_sync_spin_loops";
1099
1090
#
1100
1091
 
1101
1092
# Embedded server doesn't chdir to data directory
1102
 
--replace_result $DRIZZLETEST_VARDIR . master-data/ ''
 
1093
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
1103
1094
create table t1 (v varchar(16383), key(v));
1104
1095
drop table t1;
1105
1096
create table t1 (v varchar(16383));
1151
1142
drop table t1;
1152
1143
 
1153
1144
#
 
1145
# Test that update does not change internal auto-increment value
 
1146
#
 
1147
 
 
1148
create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
 
1149
insert into t1 (val) values (1);
 
1150
update t1 set a=2 where a=1;
 
1151
# We should get the following error because InnoDB does not update the counter
 
1152
--error ER_DUP_ENTRY
 
1153
insert into t1 (val) values (1);
 
1154
select * from t1;
 
1155
drop table t1;
 
1156
#
1154
1157
# Bug #10465
1155
1158
#
1156
1159
 
1196
1199
 id INT PRIMARY KEY
1197
1200
) ENGINE=InnoDB;
1198
1201
 
1199
 
--error ER_CANT_CREATE_TABLE, ER_CANT_CREATE_TABLE
 
1202
--error 1005,1005
1200
1203
CREATE TEMPORARY TABLE t2
1201
1204
(
1202
1205
 id INT NOT NULL PRIMARY KEY,
1250
1253
drop table t1, t2, t3, t4;
1251
1254
 
1252
1255
# these should be refused
1253
 
--error ER_TOO_LONG_KEY
 
1256
--error 1071
1254
1257
create table t1 (col1 varchar(768) primary key)
1255
1258
 engine = innodb;
1256
 
--error ER_TOO_LONG_KEY
1257
 
create table t2 (col1 varbinary(1024) primary key)
 
1259
--error 1071
 
1260
create table t2 (col1 varbinary(768) primary key)
1258
1261
 engine = innodb;
1259
 
--error ER_TOO_LONG_KEY
 
1262
--error 1071
1260
1263
create table t3 (col1 text, primary key(col1(768)))
1261
1264
 engine = innodb;
1262
 
--error ER_TOO_LONG_KEY
1263
 
create table t4 (col1 blob, primary key(col1(1024)))
 
1265
--error 1071
 
1266
create table t4 (col1 blob, primary key(col1(768)))
1264
1267
 engine = innodb;
1265
1268
 
1266
1269
#
1278
1281
 CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
1279
1282
) ENGINE=InnoDB;
1280
1283
 
1281
 
--error ER_NO_REFERENCED_ROW_2
 
1284
--error 1452
1282
1285
INSERT INTO t2 VALUES(2);
1283
1286
 
1284
1287
INSERT INTO t1 VALUES(1);
1285
1288
INSERT INTO t2 VALUES(1);
1286
1289
 
1287
 
--error ER_ROW_IS_REFERENCED_2
 
1290
--error 1451
1288
1291
DELETE FROM t1 WHERE id = 1;
1289
1292
 
1290
 
--error ER_ROW_IS_REFERENCED
 
1293
--error 1217
1291
1294
DROP TABLE t1;
1292
1295
 
1293
1296
SET FOREIGN_KEY_CHECKS=0;
1294
1297
DROP TABLE t1;
1295
1298
SET FOREIGN_KEY_CHECKS=1;
1296
1299
 
1297
 
--error ER_NO_REFERENCED_ROW_2
 
1300
--error 1452
1298
1301
INSERT INTO t2 VALUES(3);
1299
1302
 
1300
1303
DROP TABLE t2;
 
1304
#
 
1305
# Test that checksum table uses a consistent read Bug #12669
 
1306
#
 
1307
connect (a,localhost,root,,);
 
1308
connect (b,localhost,root,,);
 
1309
connection a;
 
1310
create table t1(a int not null) engine=innodb;
 
1311
insert into t1 values (1),(2);
 
1312
set autocommit=0;
 
1313
checksum table t1;
 
1314
connection b;
 
1315
insert into t1 values(3);
 
1316
connection a;
 
1317
#
 
1318
# Here checksum should not see insert
 
1319
#
 
1320
checksum table t1;
 
1321
connection a;
 
1322
commit;
 
1323
checksum table t1;
 
1324
commit;
 
1325
drop table t1;
 
1326
#
 
1327
# autocommit = 1
 
1328
#
 
1329
connection a;
 
1330
create table t1(a int not null) engine=innodb;
 
1331
insert into t1 values (1),(2);
 
1332
set autocommit=1;
 
1333
checksum table t1;
 
1334
connection b;
 
1335
set autocommit=1;
 
1336
insert into t1 values(3);
 
1337
connection a;
 
1338
#
 
1339
# Here checksum sees insert
 
1340
#
 
1341
checksum table t1;
 
1342
drop table t1;
 
1343
 
 
1344
connection default;
 
1345
disconnect a;
 
1346
disconnect b;
1301
1347
 
1302
1348
# tests for bugs #9802 and #13778
1303
1349
 
1306
1352
set foreign_key_checks=0;
1307
1353
create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
1308
1354
# Embedded server doesn't chdir to data directory
1309
 
--replace_result $DRIZZLETEST_VARDIR . master-data/ ''
 
1355
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
1310
1356
-- error 1005
1311
1357
create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
1312
1358
set foreign_key_checks=1;
1364
1410
                 b varchar(255),
1365
1411
                 c varchar(255),
1366
1412
                 d varchar(255),
1367
 
                 key (a(200),b(200),c(200),d(200))) engine=innodb;
 
1413
                 key (a,b,c,d)) engine=innodb;
1368
1414
drop table t1;
1369
1415
--error ER_TOO_LONG_KEY
1370
1416
create table t1 (a varchar(255),
1579
1625
#
1580
1626
# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update
1581
1627
#
1582
 
--error ER_LOCK_WAIT_TIMEOUT
 
1628
--error 1205
1583
1629
select * from t1 where a = 2 and b = 2 for update;
1584
1630
#
1585
1631
# X-lock to record (1,1),(3,1),(5,1) should not be released in a update
1586
1632
#
1587
 
--error ER_LOCK_WAIT_TIMEOUT
 
1633
--error 1205
1588
1634
connection a;
1589
1635
commit;
1590
1636
connection b;
1714
1760
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
1715
1761
 
1716
1762
connection b;
1717
 
--error ER_LOCK_WAIT_TIMEOUT
 
1763
--error 1205
1718
1764
reap;
1719
1765
 
1720
1766
connection c;
1721
 
--error ER_LOCK_WAIT_TIMEOUT
 
1767
--error 1205
1722
1768
reap;
1723
1769
 
1724
1770
connection d;
1725
 
--error ER_LOCK_WAIT_TIMEOUT
 
1771
--error 1205
1726
1772
reap;
1727
1773
 
1728
1774
connection e;
1729
 
--error ER_LOCK_WAIT_TIMEOUT
 
1775
--error 1205
1730
1776
reap;
1731
1777
 
1732
1778
connection f;
1733
 
--error ER_LOCK_WAIT_TIMEOUT
 
1779
--error 1205
1734
1780
reap;
1735
1781
 
1736
1782
connection g;
1737
 
--error ER_LOCK_WAIT_TIMEOUT
 
1783
--error 1205
1738
1784
reap;
1739
1785
 
1740
1786
connection h;
1741
 
--error ER_LOCK_WAIT_TIMEOUT
 
1787
--error 1205
1742
1788
reap;
1743
1789
 
1744
1790
connection i;
1745
 
--error ER_LOCK_WAIT_TIMEOUT
 
1791
--error 1205
1746
1792
reap;
1747
1793
 
1748
1794
connection j;
1749
 
--error ER_LOCK_WAIT_TIMEOUT
 
1795
--error 1205
1750
1796
reap;
1751
1797
 
1752
1798
connection a;
1766
1812
drop table t1, t2, t3, t5, t6, t8, t9;
1767
1813
 
1768
1814
# bug 18934, "InnoDB crashes when table uses column names like DB_ROW_ID"
1769
 
--error ER_CANT_CREATE_TABLE,1166
 
1815
--error 1005
1770
1816
CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
1771
1817
 
1772
1818
#
1842
1888
# mysqltest first does replace_regex, then replace_result
1843
1889
--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
1844
1890
# Embedded server doesn't chdir to data directory
1845
 
--replace_result $DRIZZLETEST_VARDIR . master-data/ ''
1846
 
--error ER_ERROR_ON_RENAME
 
1891
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
 
1892
--error 1025
1847
1893
ALTER TABLE t2 MODIFY a INT NOT NULL;
1848
1894
DELETE FROM t1;
1849
1895
DROP TABLE t2,t1;
1899
1945
SELECT * FROM t1;
1900
1946
DROP TABLE t1;
1901
1947
 
1902
 
SET GLOBAL innodb_lock_wait_timeout=@orig_lock_wait_timeout ;
1903
 
 
1904
 
 
1905
1948
#######################################################################
1906
1949
#                                                                     #
1907
1950
# Please, DO NOT TOUCH this file as well as the innodb.result file.   #