~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/innodb.result

  • Committer: Brian Aker
  • Date: 2009-08-04 06:21:17 UTC
  • mfrom: (1108.2.2 merge)
  • Revision ID: brian@gaz-20090804062117-fef8x6y3ydzrvab3
Merge Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
SET @orig_lock_wait_timeout= @@innodb_lock_wait_timeout;
2
 
SET GLOBAL innodb_lock_wait_timeout=2;
3
1
drop table if exists t1,t2,t3,t4;
4
2
drop database if exists mysqltest;
5
3
create table t1 (id int not null auto_increment, code int not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
166
164
1       1005    101
167
165
1       1006    101
168
166
1       1007    101
169
 
alter table t1 ENGINE=innodb;
 
167
optimize table t1;
 
168
Table   Op      Msg_type        Msg_text
 
169
test.t1 optimize        status  OK
170
170
show keys from t1;
171
 
Table   Unique  Key_name        Seq_in_index    Column_name
172
 
t1      YES     PRIMARY 1       id
173
 
t1      NO      parent_id       1       parent_id
174
 
t1      NO      level   1       level
 
171
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
172
t1      0       PRIMARY 1       id      A       #       NULL    NULL            BTREE           
 
173
t1      1       parent_id       1       parent_id       A       #       NULL    NULL            BTREE           
 
174
t1      1       level   1       level   A       #       NULL    NULL            BTREE           
175
175
drop table t1;
176
176
CREATE TABLE t1 (
177
177
gesuchnr int DEFAULT '0' NOT NULL,
188
188
drop table t1;
189
189
create table t1 (a int) engine=innodb;
190
190
insert into t1 values (1), (2);
191
 
alter table t1 engine=innodb;
 
191
optimize table t1;
 
192
Table   Op      Msg_type        Msg_text
 
193
test.t1 optimize        status  OK
192
194
delete from t1 where a = 1;
193
195
select * from t1;
194
196
a
209
211
Table   Op      Msg_type        Msg_text
210
212
test.t1 analyze status  OK
211
213
show keys from t1;
212
 
Table   Unique  Key_name        Seq_in_index    Column_name
213
 
t1      NO      skr     1       a
 
214
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
215
t1      1       skr     1       a       A       #       NULL    NULL    YES     BTREE           
214
216
drop table t1;
215
217
create table t1 (a int,b varchar(20),key(a)) engine=innodb;
216
218
insert into t1 values (1,""), (2,"testing");
275
277
rollback to savepoint `my_savepoint`;
276
278
ERROR 42000: SAVEPOINT my_savepoint does not exist
277
279
rollback to savepoint savept2;
 
280
ERROR 42000: SAVEPOINT savept2 does not exist
278
281
insert into t1 values (8);
279
282
savepoint sv;
280
283
commit;
331
334
commit;
332
335
select * from t1;
333
336
id      val
334
 
commit;
335
337
drop table t1;
336
338
create table t1 (a integer) engine=innodb;
 
339
start transaction;
337
340
rename table t1 to t2;
338
341
create table t1 (b integer) engine=innodb;
339
 
start transaction;
340
342
insert into t1 values (1);
341
343
rollback;
342
344
drop table t1;
359
361
SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk';
360
362
_userid
361
363
marc@anyware.co.uk
362
 
COMMIT;
363
364
drop table t1;
364
365
set autocommit=1;
365
366
CREATE TABLE t1 (
398
399
CREATE TABLE t1 (a int not null, b int not null,c int not null,
399
400
key(a),primary key(a,b), unique(c),key(a),unique(b));
400
401
show index from t1;
401
 
Table   Unique  Key_name        Seq_in_index    Column_name
402
 
t1      YES     PRIMARY 1       a
403
 
t1      YES     PRIMARY 2       b
404
 
t1      YES     c       1       c
405
 
t1      YES     b       1       b
406
 
t1      NO      a       1       a
407
 
t1      NO      a_2     1       a
 
402
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
403
t1      0       PRIMARY 1       a       A       #       NULL    NULL            BTREE           
 
404
t1      0       PRIMARY 2       b       A       #       NULL    NULL            BTREE           
 
405
t1      0       c       1       c       A       #       NULL    NULL            BTREE           
 
406
t1      0       b       1       b       A       #       NULL    NULL            BTREE           
 
407
t1      1       a       1       a       A       #       NULL    NULL            BTREE           
 
408
t1      1       a_2     1       a       A       #       NULL    NULL            BTREE           
408
409
drop table t1;
409
410
create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
410
411
alter table t1 engine=innodb;
424
425
3       4
425
426
4       7
426
427
5       2
427
 
ALTER TABLE t1 ADD co3 INT DEFAULT 42 NOT NULL;
 
428
alter table t1 add co3 int not null;
428
429
select * from t1;
429
430
col1    col2    co3
430
 
1       1       42
431
 
2       3       42
432
 
3       4       42
433
 
4       7       42
434
 
5       2       42
 
431
1       1       0
 
432
2       3       0
 
433
3       4       0
 
434
4       7       0
 
435
5       2       0
435
436
update t1 set col2='9' where col1='2';
436
437
select * from t1;
437
438
col1    col2    co3
438
 
1       1       42
439
 
2       9       42
440
 
3       4       42
441
 
4       7       42
442
 
5       2       42
 
439
1       1       0
 
440
2       9       0
 
441
3       4       0
 
442
4       7       0
 
443
5       2       0
443
444
drop table t1;
444
445
create table t1 (a int not null , b int, primary key (a)) engine = innodb;
445
446
create TEMPORARY table t2 (a int not null , b int, primary key (a)) engine = myisam;
734
735
a       b
735
736
world   2
736
737
hello   1
737
 
alter table t1 engine=innodb;
 
738
optimize table t1;
 
739
Table   Op      Msg_type        Msg_text
 
740
test.t1 optimize        status  OK
738
741
show keys from t1;
739
 
Table   Unique  Key_name        Seq_in_index    Column_name
740
 
t1      YES     PRIMARY 1       a
 
742
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
743
t1      0       PRIMARY 1       a       A       #       NULL    NULL            BTREE           
741
744
drop table t1;
742
745
create table t1 (i int, j int ) ENGINE=innodb;
743
746
insert into t1 values (1,2);
777
780
show create table t1;
778
781
Table   Create Table
779
782
t1      CREATE TABLE `t1` (
780
 
  `a` VARCHAR(20) COLLATE utf8_general_ci DEFAULT NULL,
 
783
  `a` varchar(20) DEFAULT NULL,
781
784
  KEY `a` (`a`(5))
782
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
785
) ENGINE=InnoDB
783
786
drop table t1;
784
787
create temporary table t1 (a int not null auto_increment, primary key(a)) engine=innodb;
785
788
insert into t1 values (NULL),(NULL),(NULL);
822
825
insert into mysqltest.t1 values(1);
823
826
create TEMPORARY table mysqltest.t2 (a int not null) engine= myisam;
824
827
insert into mysqltest.t2 values(1);
825
 
create temporary table mysqltest.t3 (a int not null) engine= MEMORY;
 
828
create temporary table mysqltest.t3 (a int not null) engine= heap;
826
829
insert into mysqltest.t3 values(1);
827
830
commit;
828
831
drop database mysqltest;
829
832
show tables from mysqltest;
830
 
ERROR 42000: Unknown schema 'mysqltest'
 
833
ERROR 42000: Unknown database 'mysqltest'
831
834
set autocommit=0;
832
835
create table t1 (a int not null) engine= innodb;
833
836
insert into t1 values(1),(2);
834
 
commit;
835
837
truncate table t1;
836
838
commit;
837
839
truncate table t1;
888
890
drop table t1;
889
891
create table t1 (t int not null default 1, key (t)) engine=innodb;
890
892
desc t1;
891
 
Field   Type    Null    Default Default_is_NULL On_Update
892
 
t       INTEGER NO      1       NO      
 
893
Field   Type    Null    Key     Default Extra
 
894
t       int     NO      MUL     1       
893
895
drop table t1;
894
896
create table t1 (id int not null auto_increment, code int not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
895
897
BEGIN;
1126
1128
3524    Societe Test
1127
1129
3525    Fournisseur Test
1128
1130
drop table t1,t2;
1129
 
create TEMPORARY table t1 (a int, b varchar(200), c text not null)  engine=myisam;
1130
 
create table t2 (a int, b varchar(200), c text not null) engine=innodb;
1131
 
create table t3 (a int, b varchar(200), c text not null) engine=innodb;
 
1131
create TEMPORARY table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam;
 
1132
create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb;
 
1133
create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb;
1132
1134
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
1133
1135
insert t2 select * from t1;
1134
1136
insert t3 select * from t1;
 
1137
checksum table t1, t2, t3, t4 quick;
 
1138
Table   Checksum
 
1139
test.t1 2948697075
 
1140
test.t2 NULL
 
1141
test.t3 NULL
 
1142
test.t4 NULL
 
1143
Warnings:
 
1144
Error   1146    Table 'test.t4' doesn't exist
 
1145
checksum table t1, t2, t3, t4;
 
1146
Table   Checksum
 
1147
test.t1 2948697075
 
1148
test.t2 2948697075
 
1149
test.t3 2948697075
 
1150
test.t4 NULL
 
1151
Warnings:
 
1152
Error   1146    Table 'test.t4' doesn't exist
 
1153
checksum table t1, t2, t3, t4 extended;
 
1154
Table   Checksum
 
1155
test.t1 2948697075
 
1156
test.t2 2948697075
 
1157
test.t3 2948697075
 
1158
test.t4 NULL
 
1159
Warnings:
 
1160
Error   1146    Table 'test.t4' doesn't exist
1135
1161
drop table t1,t2,t3;
1136
1162
create table t1 (id int,  name char(10) not null,  name2 char(10) not null) engine=innodb;
1137
1163
insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
1155
1181
show create table t1;
1156
1182
Table   Create Table
1157
1183
t1      CREATE TABLE `t1` (
1158
 
  `id` INT NOT NULL,
1159
 
  `id2` INT NOT NULL,
 
1184
  `id` int NOT NULL,
 
1185
  `id2` int NOT NULL,
1160
1186
  UNIQUE KEY `id` (`id`,`id2`)
1161
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1187
) ENGINE=InnoDB
1162
1188
show create table t2;
1163
1189
Table   Create Table
1164
1190
t2      CREATE TABLE `t2` (
1165
 
  `id` INT NOT NULL,
 
1191
  `id` int NOT NULL,
1166
1192
  KEY `t1_id_fk` (`id`),
1167
1193
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1168
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1194
) ENGINE=InnoDB
1169
1195
create index id on t2 (id);
1170
1196
show create table t2;
1171
1197
Table   Create Table
1172
1198
t2      CREATE TABLE `t2` (
1173
 
  `id` INT NOT NULL,
 
1199
  `id` int NOT NULL,
1174
1200
  KEY `id` (`id`),
1175
1201
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1176
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1202
) ENGINE=InnoDB
1177
1203
create index id2 on t2 (id);
1178
1204
show create table t2;
1179
1205
Table   Create Table
1180
1206
t2      CREATE TABLE `t2` (
1181
 
  `id` INT NOT NULL,
 
1207
  `id` int NOT NULL,
1182
1208
  KEY `id` (`id`),
1183
1209
  KEY `id2` (`id`),
1184
1210
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1185
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1211
) ENGINE=InnoDB
1186
1212
drop index id2 on t2;
1187
1213
drop index id on t2;
1188
1214
Got one of the listed errors
1189
1215
show create table t2;
1190
1216
Table   Create Table
1191
1217
t2      CREATE TABLE `t2` (
1192
 
  `id` INT NOT NULL,
 
1218
  `id` int NOT NULL,
1193
1219
  KEY `id` (`id`),
1194
1220
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1195
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1221
) ENGINE=InnoDB
1196
1222
drop table t2;
1197
1223
create table t2 (id int not null, id2 int not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb;
1198
1224
show create table t2;
1199
1225
Table   Create Table
1200
1226
t2      CREATE TABLE `t2` (
1201
 
  `id` INT NOT NULL,
1202
 
  `id2` INT NOT NULL,
 
1227
  `id` int NOT NULL,
 
1228
  `id2` int NOT NULL,
1203
1229
  KEY `t1_id_fk` (`id`,`id2`),
1204
1230
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`)
1205
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1231
) ENGINE=InnoDB
1206
1232
create unique index id on t2 (id,id2);
1207
1233
show create table t2;
1208
1234
Table   Create Table
1209
1235
t2      CREATE TABLE `t2` (
1210
 
  `id` INT NOT NULL,
1211
 
  `id2` INT NOT NULL,
 
1236
  `id` int NOT NULL,
 
1237
  `id2` int NOT NULL,
1212
1238
  UNIQUE KEY `id` (`id`,`id2`),
1213
1239
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`)
1214
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1240
) ENGINE=InnoDB
1215
1241
drop table t2;
1216
1242
create table t2 (id int not null, id2 int not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
1217
1243
show create table t2;
1218
1244
Table   Create Table
1219
1245
t2      CREATE TABLE `t2` (
1220
 
  `id` INT NOT NULL,
1221
 
  `id2` INT NOT NULL,
 
1246
  `id` int NOT NULL,
 
1247
  `id2` int NOT NULL,
1222
1248
  UNIQUE KEY `id` (`id`,`id2`),
1223
1249
  KEY `t1_id_fk` (`id2`,`id`),
1224
1250
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`)
1225
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1251
) ENGINE=InnoDB
1226
1252
drop table t2;
1227
1253
create table t2 (id int not null, id2 int not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb;
1228
1254
show create table t2;
1229
1255
Table   Create Table
1230
1256
t2      CREATE TABLE `t2` (
1231
 
  `id` INT NOT NULL,
1232
 
  `id2` INT NOT NULL,
 
1257
  `id` int NOT NULL,
 
1258
  `id2` int NOT NULL,
1233
1259
  UNIQUE KEY `id` (`id`,`id2`),
1234
1260
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1235
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1261
) ENGINE=InnoDB
1236
1262
drop table t2;
1237
1263
create table t2 (id int not null, id2 int not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
1238
1264
show create table t2;
1239
1265
Table   Create Table
1240
1266
t2      CREATE TABLE `t2` (
1241
 
  `id` INT NOT NULL,
1242
 
  `id2` INT NOT NULL,
 
1267
  `id` int NOT NULL,
 
1268
  `id2` int NOT NULL,
1243
1269
  UNIQUE KEY `id` (`id`,`id2`),
1244
1270
  KEY `t1_id_fk` (`id2`,`id`),
1245
1271
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`)
1246
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1272
) ENGINE=InnoDB
1247
1273
drop table t2;
1248
1274
create table t2 (id int not null auto_increment, id2 int not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = innodb;
1249
1275
show create table t2;
1250
1276
Table   Create Table
1251
1277
t2      CREATE TABLE `t2` (
1252
 
  `id` INT NOT NULL AUTO_INCREMENT,
1253
 
  `id2` INT NOT NULL,
 
1278
  `id` int NOT NULL AUTO_INCREMENT,
 
1279
  `id2` int NOT NULL,
1254
1280
  PRIMARY KEY (`id`),
1255
1281
  KEY `id` (`id`,`id2`),
1256
1282
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1257
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1283
) ENGINE=InnoDB
1258
1284
drop table t2;
1259
1285
create table t2 (id int not null auto_increment, id2 int not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb;
1260
1286
show create table t2;
1261
1287
Table   Create Table
1262
1288
t2      CREATE TABLE `t2` (
1263
 
  `id` INT NOT NULL AUTO_INCREMENT,
1264
 
  `id2` INT NOT NULL,
 
1289
  `id` int NOT NULL AUTO_INCREMENT,
 
1290
  `id2` int NOT NULL,
1265
1291
  KEY `t1_id_fk` (`id`),
1266
1292
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1267
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1293
) ENGINE=InnoDB
1268
1294
alter table t2 add index id_test (id), add index id_test2 (id,id2);
1269
1295
show create table t2;
1270
1296
Table   Create Table
1271
1297
t2      CREATE TABLE `t2` (
1272
 
  `id` INT NOT NULL AUTO_INCREMENT,
1273
 
  `id2` INT NOT NULL,
 
1298
  `id` int NOT NULL AUTO_INCREMENT,
 
1299
  `id2` int NOT NULL,
1274
1300
  KEY `id_test` (`id`),
1275
1301
  KEY `id_test2` (`id`,`id2`),
1276
1302
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1277
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1303
) ENGINE=InnoDB
1278
1304
drop table t2;
1279
1305
create table t2 (id int not null, id2 int not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
1280
1306
ERROR 42000: Incorrect foreign key definition for 't1_id_fk': Key reference and table reference don't match
1282
1308
show create table t2;
1283
1309
Table   Create Table
1284
1310
t2      CREATE TABLE `t2` (
1285
 
  `a` INT NOT NULL AUTO_INCREMENT,
1286
 
  `b` INT DEFAULT NULL,
 
1311
  `a` int NOT NULL AUTO_INCREMENT,
 
1312
  `b` int DEFAULT NULL,
1287
1313
  PRIMARY KEY (`a`),
1288
1314
  UNIQUE KEY `b_2` (`b`),
1289
1315
  KEY `b` (`b`),
1290
1316
  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
1291
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1317
) ENGINE=InnoDB
1292
1318
drop table t2;
1293
1319
create table t2 (a int auto_increment primary key, b int, foreign key (b) references t1(id), foreign key (b) references t1(id), unique(b)) engine=innodb;
1294
1320
show create table t2;
1295
1321
Table   Create Table
1296
1322
t2      CREATE TABLE `t2` (
1297
 
  `a` INT NOT NULL AUTO_INCREMENT,
1298
 
  `b` INT DEFAULT NULL,
 
1323
  `a` int NOT NULL AUTO_INCREMENT,
 
1324
  `b` int DEFAULT NULL,
1299
1325
  PRIMARY KEY (`a`),
1300
1326
  UNIQUE KEY `b` (`b`),
1301
1327
  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`),
1302
1328
  CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
1303
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1329
) ENGINE=InnoDB
1304
1330
drop table t2, t1;
1305
1331
create table t1 (c char(10), index (c,c)) engine=innodb;
1306
1332
ERROR 42S21: Duplicate column name 'c'
1397
1423
0
1398
1424
explain select count(*) from t1 where x > -16;
1399
1425
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1400
 
1       SIMPLE  t1      index   PRIMARY PRIMARY 8       NULL    2       Using where; Using index
 
1426
1       SIMPLE  t1      range   PRIMARY PRIMARY 8       NULL    1       Using where; Using index
1401
1427
select count(*) from t1 where x > -16;
1402
1428
count(*)
1403
1429
2
1409
1435
count(*)
1410
1436
1
1411
1437
drop table t1;
1412
 
show status like "Innodb_buffer_pool_pages_total";
1413
 
Variable_name   Value
1414
 
show status like "Innodb_page_size";
1415
 
Variable_name   Value
1416
 
show status like "Innodb_rows_deleted";
1417
 
Variable_name   Value
1418
 
show status like "Innodb_rows_inserted";
1419
 
Variable_name   Value
1420
 
show status like "Innodb_rows_updated";
1421
 
Variable_name   Value
1422
 
show status like "Innodb_row_lock_waits";
1423
 
Variable_name   Value
1424
 
show status like "Innodb_row_lock_current_waits";
1425
 
Variable_name   Value
1426
 
show status like "Innodb_row_lock_time";
1427
 
Variable_name   Value
1428
 
show status like "Innodb_row_lock_time_max";
1429
 
Variable_name   Value
1430
 
show status like "Innodb_row_lock_time_avg";
1431
 
Variable_name   Value
1432
 
set @my_innodb_sync_spin_loops = @@global.innodb_sync_spin_loops;
1433
1438
show variables like "innodb_sync_spin_loops";
1434
1439
Variable_name   Value
1435
 
innodb_sync_spin_loops  30
 
1440
innodb_sync_spin_loops  20
1436
1441
set global innodb_sync_spin_loops=1000;
1437
1442
show variables like "innodb_sync_spin_loops";
1438
1443
Variable_name   Value
1445
1450
show variables like "innodb_sync_spin_loops";
1446
1451
Variable_name   Value
1447
1452
innodb_sync_spin_loops  20
1448
 
set @@global.innodb_sync_spin_loops = @my_innodb_sync_spin_loops;
1449
 
set @my_innodb_thread_concurrency = @@global.innodb_thread_concurrency;
1450
1453
show variables like "innodb_thread_concurrency";
1451
1454
Variable_name   Value
1452
1455
innodb_thread_concurrency       0
1453
1456
set global innodb_thread_concurrency=1001;
1454
1457
Warnings:
1455
 
Error   1524    Error setting innodb_thread_concurrency. Given value 1001 (> 1000)
 
1458
Error   1292    Truncated incorrect thread_concurrency value: '1001'
1456
1459
show variables like "innodb_thread_concurrency";
1457
1460
Variable_name   Value
1458
 
innodb_thread_concurrency       0
 
1461
innodb_thread_concurrency       1000
1459
1462
set global innodb_thread_concurrency=0;
1460
1463
show variables like "innodb_thread_concurrency";
1461
1464
Variable_name   Value
1464
1467
show variables like "innodb_thread_concurrency";
1465
1468
Variable_name   Value
1466
1469
innodb_thread_concurrency       16
1467
 
set @@global.innodb_thread_concurrency = @my_innodb_thread_concurrency;
1468
1470
show variables like "innodb_concurrency_tickets";
1469
1471
Variable_name   Value
1470
1472
innodb_concurrency_tickets      500
1474
1476
innodb_concurrency_tickets      1000
1475
1477
set global innodb_concurrency_tickets=0;
1476
1478
Warnings:
1477
 
Error   1524    Error setting innodb_concurrency_tickets. Given value 0 (< 1)
 
1479
Error   1292    Truncated incorrect concurrency_tickets value: '0'
1478
1480
show variables like "innodb_concurrency_tickets";
1479
1481
Variable_name   Value
1480
 
innodb_concurrency_tickets      1000
 
1482
innodb_concurrency_tickets      1
1481
1483
set global innodb_concurrency_tickets=500;
1482
1484
show variables like "innodb_concurrency_tickets";
1483
1485
Variable_name   Value
1505
1507
insert into t1 values('+ ', '+ ', '+ ');
1506
1508
set @a=repeat(' ',20);
1507
1509
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
1508
 
ERROR 22001: Data too long for column 'v' at row 1
1509
 
set @a=repeat(' ',10);
1510
 
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
1511
 
ERROR 22001: Data too long for column 'v' at row 1
1512
 
set @a=repeat(' ',9);
1513
 
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
 
1510
Warnings:
 
1511
Note    1265    Data truncated for column 'v' at row 1
 
1512
Note    1265    Data truncated for column 'c' at row 1
1514
1513
select concat('*',v,'*',c,'*',t,'*') from t1;
1515
1514
concat('*',v,'*',c,'*',t,'*')
1516
1515
*+ *+ *+ *
1517
 
*+         *+         *+         *
 
1516
*+         *+         *+                    *
1518
1517
show create table t1;
1519
1518
Table   Create Table
1520
1519
t1      CREATE TABLE `t1` (
1521
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1522
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1523
 
  `t` TEXT COLLATE utf8_general_ci
1524
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1520
  `v` varchar(10) DEFAULT NULL,
 
1521
  `c` varchar(10) DEFAULT NULL,
 
1522
  `t` text
 
1523
) ENGINE=InnoDB
1525
1524
create  table t2 like t1;
1526
1525
show create table t2;
1527
1526
Table   Create Table
1528
1527
t2      CREATE TABLE `t2` (
1529
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1530
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1531
 
  `t` TEXT COLLATE utf8_general_ci
1532
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1528
  `v` varchar(10) DEFAULT NULL,
 
1529
  `c` varchar(10) DEFAULT NULL,
 
1530
  `t` text
 
1531
) ENGINE=InnoDB
1533
1532
create  table t3 select * from t1;
1534
1533
show create table t3;
1535
1534
Table   Create Table
1536
1535
t3      CREATE TABLE `t3` (
1537
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1538
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1539
 
  `t` TEXT COLLATE utf8_general_ci
1540
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1536
  `v` varchar(10) DEFAULT NULL,
 
1537
  `c` varchar(10) DEFAULT NULL,
 
1538
  `t` text
 
1539
) ENGINE=InnoDB
1541
1540
alter table t1 modify c varchar(10);
1542
1541
show create table t1;
1543
1542
Table   Create Table
1544
1543
t1      CREATE TABLE `t1` (
1545
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1546
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1547
 
  `t` TEXT COLLATE utf8_general_ci
1548
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1544
  `v` varchar(10) DEFAULT NULL,
 
1545
  `c` varchar(10) DEFAULT NULL,
 
1546
  `t` text
 
1547
) ENGINE=InnoDB
1549
1548
alter table t1 modify v char(10);
1550
1549
show create table t1;
1551
1550
Table   Create Table
1552
1551
t1      CREATE TABLE `t1` (
1553
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1554
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1555
 
  `t` TEXT COLLATE utf8_general_ci
1556
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1552
  `v` varchar(10) DEFAULT NULL,
 
1553
  `c` varchar(10) DEFAULT NULL,
 
1554
  `t` text
 
1555
) ENGINE=InnoDB
1557
1556
alter table t1 modify t varchar(10);
 
1557
Warnings:
 
1558
Note    1265    Data truncated for column 't' at row 2
1558
1559
show create table t1;
1559
1560
Table   Create Table
1560
1561
t1      CREATE TABLE `t1` (
1561
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1562
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1563
 
  `t` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
1564
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1562
  `v` varchar(10) DEFAULT NULL,
 
1563
  `c` varchar(10) DEFAULT NULL,
 
1564
  `t` varchar(10) DEFAULT NULL
 
1565
) ENGINE=InnoDB
1565
1566
select concat('*',v,'*',c,'*',t,'*') from t1;
1566
1567
concat('*',v,'*',c,'*',t,'*')
1567
1568
*+ *+ *+ *
1571
1572
show create table t1;
1572
1573
Table   Create Table
1573
1574
t1      CREATE TABLE `t1` (
1574
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1575
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1576
 
  `t` TEXT COLLATE utf8_general_ci,
 
1575
  `v` varchar(10) DEFAULT NULL,
 
1576
  `c` varchar(10) DEFAULT NULL,
 
1577
  `t` text,
1577
1578
  KEY `v` (`v`),
1578
1579
  KEY `c` (`c`),
1579
1580
  KEY `t` (`t`(10))
1580
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1581
) ENGINE=InnoDB
1581
1582
select count(*) from t1;
1582
1583
count(*)
1583
1584
270
1788
1789
i       10
1789
1790
alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
1790
1791
Warnings:
1791
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
1792
Warning 1071    Specified key was too long; max key length is 767 bytes
1792
1793
show create table t1;
1793
1794
Table   Create Table
1794
1795
t1      CREATE TABLE `t1` (
1795
 
  `v` VARCHAR(300) COLLATE utf8_general_ci DEFAULT NULL,
1796
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1797
 
  `t` TEXT COLLATE utf8_general_ci,
 
1796
  `v` varchar(300) DEFAULT NULL,
 
1797
  `c` varchar(10) DEFAULT NULL,
 
1798
  `t` text,
1798
1799
  KEY `c` (`c`),
1799
1800
  KEY `t` (`t`(10)),
1800
 
  KEY `v` (`v`(255))
1801
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1801
  KEY `v` (`v`(191))
 
1802
) ENGINE=InnoDB
1802
1803
select count(*) from t1 where v='a';
1803
1804
count(*)
1804
1805
10
1819
1820
9
1820
1821
explain select count(*) from t1 where v='a  ';
1821
1822
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1822
 
1       SIMPLE  t1      ref     v       v       1023    const   #       Using where
 
1823
1       SIMPLE  t1      ref     v       v       767     const   #       Using where
1823
1824
explain select count(*) from t1 where v like 'a%';
1824
1825
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1825
 
1       SIMPLE  t1      range   v       v       1023    NULL    #       Using where
 
1826
1       SIMPLE  t1      range   v       v       767     NULL    #       Using where
1826
1827
explain select count(*) from t1 where v between 'a' and 'a ';
1827
1828
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1828
 
1       SIMPLE  t1      ref     v       v       1023    const   #       Using where
 
1829
1       SIMPLE  t1      ref     v       v       767     const   #       Using where
1829
1830
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
1830
1831
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1831
 
1       SIMPLE  t1      ref     v       v       1023    const   #       Using where
 
1832
1       SIMPLE  t1      ref     v       v       767     const   #       Using where
1832
1833
explain select * from t1 where v='a';
1833
1834
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1834
 
1       SIMPLE  t1      ref     v       v       1023    const   #       Using where
 
1835
1       SIMPLE  t1      ref     v       v       767     const   #       Using where
1835
1836
select v,count(*) from t1 group by v limit 10;
1836
1837
v       count(*)
1837
1838
a      1
1872
1873
show create table t1;
1873
1874
Table   Create Table
1874
1875
t1      CREATE TABLE `t1` (
1875
 
  `v` VARCHAR(300) COLLATE utf8_general_ci DEFAULT NULL,
1876
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1877
 
  `t` TEXT COLLATE utf8_general_ci,
 
1876
  `v` varchar(300) DEFAULT NULL,
 
1877
  `c` varchar(10) DEFAULT NULL,
 
1878
  `t` text,
1878
1879
  KEY `c` (`c`),
1879
1880
  KEY `t` (`t`(10)),
1880
1881
  KEY `v` (`v`(30))
1881
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1882
) ENGINE=InnoDB
1882
1883
select count(*) from t1 where v='a';
1883
1884
count(*)
1884
1885
10
1950
1951
i       10
1951
1952
alter table t1 modify v varchar(600), drop key v, add key v (v);
1952
1953
Warnings:
1953
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
1954
Warning 1071    Specified key was too long; max key length is 767 bytes
1954
1955
show create table t1;
1955
1956
Table   Create Table
1956
1957
t1      CREATE TABLE `t1` (
1957
 
  `v` VARCHAR(600) COLLATE utf8_general_ci DEFAULT NULL,
1958
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1959
 
  `t` TEXT COLLATE utf8_general_ci,
 
1958
  `v` varchar(600) DEFAULT NULL,
 
1959
  `c` varchar(10) DEFAULT NULL,
 
1960
  `t` text,
1960
1961
  KEY `c` (`c`),
1961
1962
  KEY `t` (`t`(10)),
1962
 
  KEY `v` (`v`(255))
1963
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1963
  KEY `v` (`v`(191))
 
1964
) ENGINE=InnoDB
1964
1965
select v,count(*) from t1 group by v limit 10;
1965
1966
v       count(*)
1966
1967
a      1
2008
2009
insert into t1 values ('a     ');
2009
2010
ERROR 23000: Duplicate entry 'a     ' for key 'a'
2010
2011
insert into t1 values ('a          ');
2011
 
ERROR 22001: Data too long for column 'a' at row 1
 
2012
ERROR 23000: Duplicate entry 'a         ' for key 'a'
2012
2013
insert into t1 values ('a ');
2013
2014
ERROR 23000: Duplicate entry 'a ' for key 'a'
2014
2015
update t1 set a='a  ' where a like 'a%';
2032
2033
show create table t1;
2033
2034
Table   Create Table
2034
2035
t1      CREATE TABLE `t1` (
2035
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
2036
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
2037
 
  `t` TEXT COLLATE utf8_general_ci,
 
2036
  `v` varchar(10) DEFAULT NULL,
 
2037
  `c` varchar(10) DEFAULT NULL,
 
2038
  `t` text,
2038
2039
  KEY `v` (`v`(5)),
2039
2040
  KEY `c` (`c`(5)),
2040
2041
  KEY `t` (`t`(5))
2041
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2042
) ENGINE=InnoDB
2042
2043
drop table t1;
2043
2044
create  table t1 (v char(10));
2044
2045
show create table t1;
2045
2046
Table   Create Table
2046
2047
t1      CREATE TABLE `t1` (
2047
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
2048
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2048
  `v` varchar(10) DEFAULT NULL
 
2049
) ENGINE=InnoDB
2049
2050
drop table t1;
2050
 
create  table t1 (v varchar(10), c char(10));
 
2051
create  table t1 (v varchar(10), c char(10)) row_format=fixed;
 
2052
Warnings:
 
2053
Warning 1478    InnoDB: assuming ROW_FORMAT=COMPACT.
2051
2054
show create table t1;
2052
2055
Table   Create Table
2053
2056
t1      CREATE TABLE `t1` (
2054
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
2055
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
2056
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2057
  `v` varchar(10) DEFAULT NULL,
 
2058
  `c` varchar(10) DEFAULT NULL
 
2059
) ENGINE=InnoDB ROW_FORMAT=FIXED
2057
2060
insert into t1 values('a','a'),('a ','a ');
2058
2061
select concat('*',v,'*',c,'*') from t1;
2059
2062
concat('*',v,'*',c,'*')
2071
2074
drop table t1;
2072
2075
create table t1 (v varchar(16383), key(v));
2073
2076
Warnings:
2074
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
2075
 
drop table t1;
2076
 
create table t1 (v varchar(16383));
2077
 
show create table t1;
2078
 
Table   Create Table
2079
 
t1      CREATE TABLE `t1` (
2080
 
  `v` VARCHAR(16383) COLLATE utf8_general_ci DEFAULT NULL
2081
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
2082
 
drop table t1;
2083
 
create table t1 (v varchar(16383));
2084
 
show create table t1;
2085
 
Table   Create Table
2086
 
t1      CREATE TABLE `t1` (
2087
 
  `v` VARCHAR(16383) COLLATE utf8_general_ci DEFAULT NULL
2088
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2077
Warning 1071    Specified key was too long; max key length is 767 bytes
 
2078
drop table t1;
 
2079
create table t1 (v varchar(16383));
 
2080
show create table t1;
 
2081
Table   Create Table
 
2082
t1      CREATE TABLE `t1` (
 
2083
  `v` varchar(16383) DEFAULT NULL
 
2084
) ENGINE=InnoDB
 
2085
drop table t1;
 
2086
create table t1 (v varchar(16383));
 
2087
show create table t1;
 
2088
Table   Create Table
 
2089
t1      CREATE TABLE `t1` (
 
2090
  `v` varchar(16383) DEFAULT NULL
 
2091
) ENGINE=InnoDB
2089
2092
drop table t1;
2090
2093
set storage_engine=InnoDB;
2091
2094
create table t1 (v varchar(16383)) engine=innodb;
2129
2132
3       1
2130
2133
4       2
2131
2134
drop table t1;
 
2135
create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
 
2136
insert into t1 (val) values (1);
 
2137
update t1 set a=2 where a=1;
 
2138
insert into t1 (val) values (1);
 
2139
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
 
2140
select * from t1;
 
2141
a       val
 
2142
2       1
 
2143
drop table t1;
2132
2144
CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
2133
2145
INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
2134
2146
SELECT GRADE  FROM t1 WHERE GRADE > 160 AND GRADE < 300;
2176
2188
create table t1 (col1 varchar(2000), index (col1(767)))
2177
2189
engine = innodb;
2178
2190
Warnings:
2179
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
2191
Warning 1071    Specified key was too long; max key length is 767 bytes
2180
2192
create table t2 (col1 char(255), index (col1))
2181
2193
engine = innodb;
 
2194
Warnings:
 
2195
Warning 1071    Specified key was too long; max key length is 767 bytes
2182
2196
create table t4 (col1 varchar(767), index (col1))
2183
2197
engine = innodb;
2184
2198
Warnings:
2185
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
2199
Warning 1071    Specified key was too long; max key length is 767 bytes
2186
2200
create table t5 (col1 varchar(190) primary key)
2187
2201
engine = innodb;
2188
2202
create table t6 (col1 varbinary(254) primary key)
2190
2204
create table t7 (col1 text, index(col1(767)))
2191
2205
engine = innodb;
2192
2206
Warnings:
2193
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
2207
Warning 1071    Specified key was too long; max key length is 767 bytes
2194
2208
create table t8 (col1 blob, index(col1(767)))
2195
2209
engine = innodb;
2196
2210
create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2))
2197
2211
engine = innodb;
2198
2212
Warnings:
2199
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
2200
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
2213
Warning 1071    Specified key was too long; max key length is 767 bytes
 
2214
Warning 1071    Specified key was too long; max key length is 767 bytes
2201
2215
show create table t9;
2202
2216
Table   Create Table
2203
2217
t9      CREATE TABLE `t9` (
2204
 
  `col1` VARCHAR(512) COLLATE utf8_general_ci DEFAULT NULL,
2205
 
  `col2` VARCHAR(512) COLLATE utf8_general_ci DEFAULT NULL,
2206
 
  KEY `col1` (`col1`(255),`col2`(255))
2207
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2218
  `col1` varchar(512) DEFAULT NULL,
 
2219
  `col2` varchar(512) DEFAULT NULL,
 
2220
  KEY `col1` (`col1`(191),`col2`(191))
 
2221
) ENGINE=InnoDB
2208
2222
drop table t1, t2, t4, t5, t6, t7, t8, t9;
2209
2223
create table t1 (col1 varchar(768), index(col1))
2210
2224
engine = innodb;
2211
2225
Warnings:
2212
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
2226
Warning 1071    Specified key was too long; max key length is 767 bytes
2213
2227
create table t2 (col1 varbinary(768), index(col1))
2214
2228
engine = innodb;
 
2229
Warnings:
 
2230
Warning 1071    Specified key was too long; max key length is 767 bytes
2215
2231
create table t3 (col1 text, index(col1(768)))
2216
2232
engine = innodb;
2217
2233
Warnings:
2218
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
2234
Warning 1071    Specified key was too long; max key length is 767 bytes
2219
2235
create table t4 (col1 blob, index(col1(768)))
2220
2236
engine = innodb;
 
2237
Warnings:
 
2238
Warning 1071    Specified key was too long; max key length is 767 bytes
2221
2239
show create table t1;
2222
2240
Table   Create Table
2223
2241
t1      CREATE TABLE `t1` (
2224
 
  `col1` VARCHAR(768) COLLATE utf8_general_ci DEFAULT NULL,
2225
 
  KEY `col1` (`col1`(255))
2226
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2242
  `col1` varchar(768) DEFAULT NULL,
 
2243
  KEY `col1` (`col1`(191))
 
2244
) ENGINE=InnoDB
2227
2245
drop table t1, t2, t3, t4;
2228
2246
create table t1 (col1 varchar(768) primary key)
2229
2247
engine = innodb;
2230
 
ERROR 42000: Specified key was too long; max key length is 1023 bytes
2231
 
create table t2 (col1 varbinary(1024) primary key)
 
2248
ERROR 42000: Specified key was too long; max key length is 767 bytes
 
2249
create table t2 (col1 varbinary(768) primary key)
2232
2250
engine = innodb;
2233
 
ERROR 42000: Specified key was too long; max key length is 1023 bytes
 
2251
ERROR 42000: Specified key was too long; max key length is 767 bytes
2234
2252
create table t3 (col1 text, primary key(col1(768)))
2235
2253
engine = innodb;
2236
 
ERROR 42000: Specified key was too long; max key length is 1023 bytes
2237
 
create table t4 (col1 blob, primary key(col1(1024)))
 
2254
ERROR 42000: Specified key was too long; max key length is 767 bytes
 
2255
create table t4 (col1 blob, primary key(col1(768)))
2238
2256
engine = innodb;
2239
 
ERROR 42000: Specified key was too long; max key length is 1023 bytes
 
2257
ERROR 42000: Specified key was too long; max key length is 767 bytes
2240
2258
CREATE TABLE t1
2241
2259
(
2242
2260
id INT PRIMARY KEY
2260
2278
INSERT INTO t2 VALUES(3);
2261
2279
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
2262
2280
DROP TABLE t2;
 
2281
create table t1(a int not null) engine=innodb;
 
2282
insert into t1 values (1),(2);
 
2283
set autocommit=0;
 
2284
checksum table t1;
 
2285
Table   Checksum
 
2286
test.t1 1531596814
 
2287
insert into t1 values(3);
 
2288
checksum table t1;
 
2289
Table   Checksum
 
2290
test.t1 1531596814
 
2291
commit;
 
2292
checksum table t1;
 
2293
Table   Checksum
 
2294
test.t1 2050879373
 
2295
commit;
 
2296
drop table t1;
 
2297
create table t1(a int not null) engine=innodb;
 
2298
insert into t1 values (1),(2);
 
2299
set autocommit=1;
 
2300
checksum table t1;
 
2301
Table   Checksum
 
2302
test.t1 1531596814
 
2303
set autocommit=1;
 
2304
insert into t1 values(3);
 
2305
checksum table t1;
 
2306
Table   Checksum
 
2307
test.t1 2050879373
 
2308
drop table t1;
2263
2309
set foreign_key_checks=0;
2264
2310
create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
2265
2311
create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
2306
2352
b varchar(255),
2307
2353
c varchar(255),
2308
2354
d varchar(255),
2309
 
key (a(200),b(200),c(200),d(200))) engine=innodb;
 
2355
key (a,b,c,d)) engine=innodb;
 
2356
Warnings:
 
2357
Warning 1071    Specified key was too long; max key length is 767 bytes
 
2358
Warning 1071    Specified key was too long; max key length is 767 bytes
 
2359
Warning 1071    Specified key was too long; max key length is 767 bytes
 
2360
Warning 1071    Specified key was too long; max key length is 767 bytes
2310
2361
drop table t1;
2311
2362
create table t1 (a varchar(255),
2312
2363
b varchar(255),
2316
2367
key (a,b,c,d,e)) engine=innodb;
2317
2368
ERROR 42000: Specified key was too long; max key length is 3500 bytes
2318
2369
create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb;
2319
 
create table t3 (s1 varchar(2) ,primary key (s1)) engine=innodb;
2320
 
create table t4 (s1 char(2) ,primary key (s1)) engine=innodb;
 
2370
create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb;
 
2371
create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb;
2321
2372
insert into t1 values (0x41),(0x4120),(0x4100);
2322
2373
insert into t3 values (0x41),(0x4120),(0x4100);
2323
2374
ERROR 23000: Duplicate entry 'A ' for key 'PRIMARY'
2386
2437
4120
2387
2438
4120
2388
2439
drop table t2,t1;
2389
 
create table t1 (a int primary key,s1 varchar(2) not null unique) engine=innodb;
2390
 
create table t2 (s1 char(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
 
2440
create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb;
 
2441
create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
2391
2442
insert into t1 values(1,0x4100),(2,0x41);
2392
2443
insert into t2 values(0x41);
2393
2444
select hex(s1) from t2;
2420
2471
SHOW CREATE TABLE t2;
2421
2472
Table   Create Table
2422
2473
t2      CREATE TABLE `t2` (
2423
 
  `a` INT DEFAULT NULL,
 
2474
  `a` int DEFAULT NULL,
2424
2475
  KEY `t2_ibfk_0` (`a`)
2425
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2476
) ENGINE=InnoDB
2426
2477
DROP TABLE t2,t1;
2427
2478
CREATE TABLE t1 (
2428
2479
field1 varchar(8) NOT NULL DEFAULT '',
2457
2508
show create table t1;
2458
2509
Table   Create Table
2459
2510
t1      CREATE TABLE `t1` (
2460
 
  `c1` BIGINT NOT NULL,
2461
 
  `c2` BIGINT NOT NULL,
 
2511
  `c1` bigint NOT NULL,
 
2512
  `c2` bigint NOT NULL,
2462
2513
  PRIMARY KEY (`c1`),
2463
2514
  UNIQUE KEY `c2` (`c2`),
2464
2515
  CONSTRAINT `c2_fk` FOREIGN KEY (`c2`) REFERENCES `t2` (`c1`) ON DELETE CASCADE
2465
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2516
) ENGINE=InnoDB
2466
2517
alter table t1 drop foreign key c2_fk;
2467
2518
show create table t1;
2468
2519
Table   Create Table
2469
2520
t1      CREATE TABLE `t1` (
2470
 
  `c1` BIGINT NOT NULL,
2471
 
  `c2` BIGINT NOT NULL,
 
2521
  `c1` bigint NOT NULL,
 
2522
  `c2` bigint NOT NULL,
2472
2523
  PRIMARY KEY (`c1`),
2473
2524
  UNIQUE KEY `c2` (`c2`)
2474
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2525
) ENGINE=InnoDB
2475
2526
drop table t1, t2;
2476
2527
create table t1(a date) engine=innodb;
2477
2528
create table t2(a date, key(a)) engine=innodb;
2543
2594
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2544
2595
insert into t1 select * from t2;
2545
2596
update t1 set b = (select e from t2 where a = d);
2546
 
commit;
2547
2597
create table t3(d int not null, e int, primary key(d)) engine=innodb
2548
2598
select * from t2;
2549
2599
commit;
2609
2659
commit;
2610
2660
drop table t1, t2, t3, t5, t6, t8, t9;
2611
2661
CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
2612
 
Got one of the listed errors
 
2662
ERROR HY000: Can't create table 'test.t1' (errno: -1)
2613
2663
CREATE TABLE t1 (
2614
2664
a BIGINT NOT NULL,
2615
2665
PRIMARY KEY  (a)
2623
2673
CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a) 
2624
2674
ON DELETE CASCADE
2625
2675
) ENGINE=INNODB;
 
2676
Warnings:
 
2677
Warning 1071    Specified key was too long; max key length is 767 bytes
2626
2678
INSERT INTO t1 VALUES (1);
2627
2679
INSERT INTO t2 VALUES (1, 'bar', 'vbar');
2628
2680
INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR');
2648
2700
CREATE TABLE t1 ( a int ) ENGINE=innodb;
2649
2701
BEGIN;
2650
2702
INSERT INTO t1 VALUES (1);
2651
 
COMMIT;
2652
 
ALTER TABLE t1 ENGINE=innodb;
 
2703
OPTIMIZE TABLE t1;
 
2704
Table   Op      Msg_type        Msg_text
 
2705
test.t1 optimize        status  OK
2653
2706
DROP TABLE t1;
2654
2707
CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB;
2655
2708
CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL,
2660
2713
SHOW CREATE TABLE t2;
2661
2714
Table   Create Table
2662
2715
t2      CREATE TABLE `t2` (
2663
 
  `id` INT NOT NULL,
2664
 
  `f` INT NOT NULL,
 
2716
  `id` int NOT NULL,
 
2717
  `f` int NOT NULL,
2665
2718
  PRIMARY KEY (`id`),
2666
2719
  KEY `f` (`f`),
2667
 
  CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,
2668
 
  CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`f`) REFERENCES `t1` (`f`) ON UPDATE CASCADE ON DELETE CASCADE
2669
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2720
  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f`) REFERENCES `t1` (`f`) ON DELETE CASCADE ON UPDATE CASCADE,
 
2721
  CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
 
2722
) ENGINE=InnoDB
2670
2723
DROP TABLE t2, t1;
2671
2724
CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB;
2672
2725
CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB;
2674
2727
INSERT INTO t2 VALUES (1);
2675
2728
ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL;
2676
2729
ALTER TABLE t2 MODIFY a INT NOT NULL;
2677
 
ERROR HY000: Error on rename of '#sql-temporary' to 'test.t2' (errno: 150)
 
2730
ERROR HY000: Error on rename of '#sql-temporary' to './test/t2' (errno: 150)
2678
2731
DELETE FROM t1;
2679
2732
DROP TABLE t2,t1;
2680
2733
CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY)
2697
2750
SHOW CREATE TABLE t1;
2698
2751
Table   Create Table
2699
2752
t1      CREATE TABLE `t1` (
2700
 
  `id` INT NOT NULL AUTO_INCREMENT,
 
2753
  `id` int NOT NULL AUTO_INCREMENT,
2701
2754
  PRIMARY KEY (`id`)
2702
 
) ENGINE=InnoDB COLLATE = utf8_general_ci AUTO_INCREMENT=42
 
2755
) ENGINE=InnoDB AUTO_INCREMENT=349
2703
2756
CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB;
2704
2757
INSERT INTO t2 VALUES(42),(347),(348);
2705
2758
ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id);
2706
2759
SHOW CREATE TABLE t1;
2707
2760
Table   Create Table
2708
2761
t1      CREATE TABLE `t1` (
2709
 
  `id` INT NOT NULL AUTO_INCREMENT,
 
2762
  `id` int NOT NULL AUTO_INCREMENT,
2710
2763
  PRIMARY KEY (`id`),
2711
2764
  CONSTRAINT `t1_t2` FOREIGN KEY (`id`) REFERENCES `t2` (`id`)
2712
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2765
) ENGINE=InnoDB AUTO_INCREMENT=349
2713
2766
DROP TABLE t1,t2;
2714
2767
DROP TABLE IF EXISTS t1;
2715
2768
Warnings:
2727
2780
-10
2728
2781
1
2729
2782
DROP TABLE t1;
2730
 
SET GLOBAL innodb_lock_wait_timeout=@orig_lock_wait_timeout ;