~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/pbxt/innodb.result

  • Committer: Patrick Crews
  • Date: 2010-09-14 20:21:03 UTC
  • mto: (1771.1.1 pcrews)
  • mto: This revision was merged to the branch mainline in revision 1772.
  • Revision ID: gleebix@gmail.com-20100914202103-1db2n0bshzafep19
Moved transaction_log tests into updated non-publisher-based tree

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;
169
167
alter table t1 ENGINE=innodb;
170
168
show keys from t1;
171
169
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
 
170
t1      TRUE    PRIMARY 1       id
 
171
t1      FALSE   parent_id       1       parent_id
 
172
t1      FALSE   level   1       level
175
173
drop table t1;
176
174
CREATE TABLE t1 (
177
175
gesuchnr int DEFAULT '0' NOT NULL,
210
208
test.t1 analyze status  OK
211
209
show keys from t1;
212
210
Table   Unique  Key_name        Seq_in_index    Column_name
213
 
t1      NO      skr     1       a
 
211
t1      FALSE   skr     1       a
214
212
drop table t1;
215
213
create table t1 (a int,b varchar(20),key(a)) engine=innodb;
216
214
insert into t1 values (1,""), (2,"testing");
397
395
key(a),primary key(a,b), unique(c),key(a),unique(b));
398
396
show index from t1;
399
397
Table   Unique  Key_name        Seq_in_index    Column_name
400
 
t1      YES     PRIMARY 1       a
401
 
t1      YES     PRIMARY 2       b
402
 
t1      YES     c       1       c
403
 
t1      YES     b       1       b
404
 
t1      NO      a       1       a
405
 
t1      NO      a_2     1       a
 
398
t1      TRUE    PRIMARY 1       a
 
399
t1      TRUE    PRIMARY 2       b
 
400
t1      TRUE    c       1       c
 
401
t1      TRUE    b       1       b
 
402
t1      FALSE   a       1       a
 
403
t1      FALSE   a_2     1       a
406
404
drop table t1;
407
405
create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
408
406
alter table t1 engine=innodb;
735
733
alter table t1 engine=innodb;
736
734
show keys from t1;
737
735
Table   Unique  Key_name        Seq_in_index    Column_name
738
 
t1      YES     PRIMARY 1       a
 
736
t1      TRUE    PRIMARY 1       a
739
737
drop table t1;
740
738
create table t1 (i int, j int ) ENGINE=innodb;
741
739
insert into t1 values (1,2);
775
773
show create table t1;
776
774
Table   Create Table
777
775
t1      CREATE TABLE `t1` (
778
 
  `a` VARCHAR(20) COLLATE utf8_general_ci DEFAULT NULL,
 
776
  `a` varchar(20) DEFAULT NULL,
779
777
  KEY `a` (`a`(5))
780
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
778
) ENGINE=InnoDB
781
779
drop table t1;
782
780
create temporary table t1 (a int not null auto_increment, primary key(a)) engine=innodb;
783
781
insert into t1 values (NULL),(NULL),(NULL);
886
884
create table t1 (t int not null default 1, key (t)) engine=innodb;
887
885
desc t1;
888
886
Field   Type    Null    Default Default_is_NULL On_Update
889
 
t       INTEGER NO      1       NO      
 
887
t       INTEGER FALSE   1       FALSE   
890
888
drop table t1;
891
889
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;
892
890
BEGIN;
1152
1150
show create table t1;
1153
1151
Table   Create Table
1154
1152
t1      CREATE TABLE `t1` (
1155
 
  `id` INT NOT NULL,
1156
 
  `id2` INT NOT NULL,
 
1153
  `id` int NOT NULL,
 
1154
  `id2` int NOT NULL,
1157
1155
  UNIQUE KEY `id` (`id`,`id2`)
1158
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1156
) ENGINE=InnoDB
1159
1157
show create table t2;
1160
1158
Table   Create Table
1161
1159
t2      CREATE TABLE `t2` (
1162
 
  `id` INT NOT NULL,
 
1160
  `id` int NOT NULL,
1163
1161
  KEY `t1_id_fk` (`id`),
1164
1162
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1165
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1163
) ENGINE=InnoDB
1166
1164
create index id on t2 (id);
1167
1165
show create table t2;
1168
1166
Table   Create Table
1169
1167
t2      CREATE TABLE `t2` (
1170
 
  `id` INT NOT NULL,
 
1168
  `id` int NOT NULL,
1171
1169
  KEY `id` (`id`),
1172
1170
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1173
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1171
) ENGINE=InnoDB
1174
1172
create index id2 on t2 (id);
1175
1173
show create table t2;
1176
1174
Table   Create Table
1177
1175
t2      CREATE TABLE `t2` (
1178
 
  `id` INT NOT NULL,
 
1176
  `id` int NOT NULL,
1179
1177
  KEY `id` (`id`),
1180
1178
  KEY `id2` (`id`),
1181
1179
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1182
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1180
) ENGINE=InnoDB
1183
1181
drop index id2 on t2;
1184
1182
drop index id on t2;
1185
1183
Got one of the listed errors
1186
1184
show create table t2;
1187
1185
Table   Create Table
1188
1186
t2      CREATE TABLE `t2` (
1189
 
  `id` INT NOT NULL,
 
1187
  `id` int NOT NULL,
1190
1188
  KEY `id` (`id`),
1191
1189
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1192
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1190
) ENGINE=InnoDB
1193
1191
drop table t2;
1194
1192
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;
1195
1193
show create table t2;
1196
1194
Table   Create Table
1197
1195
t2      CREATE TABLE `t2` (
1198
 
  `id` INT NOT NULL,
1199
 
  `id2` INT NOT NULL,
 
1196
  `id` int NOT NULL,
 
1197
  `id2` int NOT NULL,
1200
1198
  KEY `t1_id_fk` (`id`,`id2`),
1201
1199
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`)
1202
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1200
) ENGINE=InnoDB
1203
1201
create unique index id on t2 (id,id2);
1204
1202
show create table t2;
1205
1203
Table   Create Table
1206
1204
t2      CREATE TABLE `t2` (
1207
 
  `id` INT NOT NULL,
1208
 
  `id2` INT NOT NULL,
 
1205
  `id` int NOT NULL,
 
1206
  `id2` int NOT NULL,
1209
1207
  UNIQUE KEY `id` (`id`,`id2`),
1210
1208
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`)
1211
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1209
) ENGINE=InnoDB
1212
1210
drop table t2;
1213
1211
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;
1214
1212
show create table t2;
1215
1213
Table   Create Table
1216
1214
t2      CREATE TABLE `t2` (
1217
 
  `id` INT NOT NULL,
1218
 
  `id2` INT NOT NULL,
 
1215
  `id` int NOT NULL,
 
1216
  `id2` int NOT NULL,
1219
1217
  UNIQUE KEY `id` (`id`,`id2`),
1220
1218
  KEY `t1_id_fk` (`id2`,`id`),
1221
1219
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`)
1222
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1220
) ENGINE=InnoDB
1223
1221
drop table t2;
1224
1222
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;
1225
1223
show create table t2;
1226
1224
Table   Create Table
1227
1225
t2      CREATE TABLE `t2` (
1228
 
  `id` INT NOT NULL,
1229
 
  `id2` INT NOT NULL,
 
1226
  `id` int NOT NULL,
 
1227
  `id2` int NOT NULL,
1230
1228
  UNIQUE KEY `id` (`id`,`id2`),
1231
1229
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1232
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1230
) ENGINE=InnoDB
1233
1231
drop table t2;
1234
1232
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;
1235
1233
show create table t2;
1236
1234
Table   Create Table
1237
1235
t2      CREATE TABLE `t2` (
1238
 
  `id` INT NOT NULL,
1239
 
  `id2` INT NOT NULL,
 
1236
  `id` int NOT NULL,
 
1237
  `id2` int NOT NULL,
1240
1238
  UNIQUE KEY `id` (`id`,`id2`),
1241
1239
  KEY `t1_id_fk` (`id2`,`id`),
1242
1240
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`)
1243
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1241
) ENGINE=InnoDB
1244
1242
drop table t2;
1245
1243
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;
1246
1244
show create table t2;
1247
1245
Table   Create Table
1248
1246
t2      CREATE TABLE `t2` (
1249
 
  `id` INT NOT NULL AUTO_INCREMENT,
1250
 
  `id2` INT NOT NULL,
 
1247
  `id` int NOT NULL AUTO_INCREMENT,
 
1248
  `id2` int NOT NULL,
1251
1249
  PRIMARY KEY (`id`),
1252
1250
  KEY `id` (`id`,`id2`),
1253
1251
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1254
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1252
) ENGINE=InnoDB
1255
1253
drop table t2;
1256
1254
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;
1257
1255
show create table t2;
1258
1256
Table   Create Table
1259
1257
t2      CREATE TABLE `t2` (
1260
 
  `id` INT NOT NULL AUTO_INCREMENT,
1261
 
  `id2` INT NOT NULL,
 
1258
  `id` int NOT NULL AUTO_INCREMENT,
 
1259
  `id2` int NOT NULL,
1262
1260
  KEY `t1_id_fk` (`id`),
1263
1261
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1264
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1262
) ENGINE=InnoDB
1265
1263
alter table t2 add index id_test (id), add index id_test2 (id,id2);
1266
1264
show create table t2;
1267
1265
Table   Create Table
1268
1266
t2      CREATE TABLE `t2` (
1269
 
  `id` INT NOT NULL AUTO_INCREMENT,
1270
 
  `id2` INT NOT NULL,
 
1267
  `id` int NOT NULL AUTO_INCREMENT,
 
1268
  `id2` int NOT NULL,
1271
1269
  KEY `id_test` (`id`),
1272
1270
  KEY `id_test2` (`id`,`id2`),
1273
1271
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1274
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1272
) ENGINE=InnoDB
1275
1273
drop table t2;
1276
1274
create table t2 (id int not null, id2 int not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
1277
1275
ERROR 42000: Incorrect foreign key definition for 't1_id_fk': Key reference and table reference don't match
1279
1277
show create table t2;
1280
1278
Table   Create Table
1281
1279
t2      CREATE TABLE `t2` (
1282
 
  `a` INT NOT NULL AUTO_INCREMENT,
1283
 
  `b` INT DEFAULT NULL,
 
1280
  `a` int NOT NULL AUTO_INCREMENT,
 
1281
  `b` int DEFAULT NULL,
1284
1282
  PRIMARY KEY (`a`),
1285
1283
  UNIQUE KEY `b_2` (`b`),
1286
1284
  KEY `b` (`b`),
1287
1285
  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
1288
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1286
) ENGINE=InnoDB
1289
1287
drop table t2;
1290
1288
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;
1291
1289
show create table t2;
1292
1290
Table   Create Table
1293
1291
t2      CREATE TABLE `t2` (
1294
 
  `a` INT NOT NULL AUTO_INCREMENT,
1295
 
  `b` INT DEFAULT NULL,
 
1292
  `a` int NOT NULL AUTO_INCREMENT,
 
1293
  `b` int DEFAULT NULL,
1296
1294
  PRIMARY KEY (`a`),
1297
1295
  UNIQUE KEY `b` (`b`),
1298
1296
  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`),
1299
1297
  CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
1300
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1298
) ENGINE=InnoDB
1301
1299
drop table t2, t1;
1302
1300
create table t1 (c char(10), index (c,c)) engine=innodb;
1303
1301
ERROR 42S21: Duplicate column name 'c'
1498
1496
insert into t1 values('+ ', '+ ', '+ ');
1499
1497
set @a=repeat(' ',20);
1500
1498
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
1501
 
ERROR 22001: Data too long for column 'v' at row 1
1502
 
set @a=repeat(' ',10);
1503
 
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
1504
 
ERROR 22001: Data too long for column 'v' at row 1
1505
 
set @a=repeat(' ',9);
1506
 
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
 
1499
Warnings:
 
1500
Note    1265    Data truncated for column 'v' at row 1
 
1501
Note    1265    Data truncated for column 'c' at row 1
1507
1502
select concat('*',v,'*',c,'*',t,'*') from t1;
1508
1503
concat('*',v,'*',c,'*',t,'*')
1509
1504
*+ *+ *+ *
1510
 
*+         *+         *+         *
 
1505
*+         *+         *+                    *
1511
1506
show create table t1;
1512
1507
Table   Create Table
1513
1508
t1      CREATE TABLE `t1` (
1514
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1515
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1516
 
  `t` TEXT COLLATE utf8_general_ci
1517
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1509
  `v` varchar(10) DEFAULT NULL,
 
1510
  `c` varchar(10) DEFAULT NULL,
 
1511
  `t` text
 
1512
) ENGINE=InnoDB
1518
1513
create  table t2 like t1;
1519
1514
show create table t2;
1520
1515
Table   Create Table
1521
1516
t2      CREATE TABLE `t2` (
1522
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1523
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1524
 
  `t` TEXT COLLATE utf8_general_ci
1525
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1517
  `v` varchar(10) DEFAULT NULL,
 
1518
  `c` varchar(10) DEFAULT NULL,
 
1519
  `t` text
 
1520
) ENGINE=InnoDB
1526
1521
create  table t3 select * from t1;
1527
1522
show create table t3;
1528
1523
Table   Create Table
1529
1524
t3      CREATE TABLE `t3` (
1530
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1531
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1532
 
  `t` TEXT COLLATE utf8_general_ci
1533
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1525
  `v` varchar(10) DEFAULT NULL,
 
1526
  `c` varchar(10) DEFAULT NULL,
 
1527
  `t` text
 
1528
) ENGINE=InnoDB
1534
1529
alter table t1 modify c varchar(10);
1535
1530
show create table t1;
1536
1531
Table   Create Table
1537
1532
t1      CREATE TABLE `t1` (
1538
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1539
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1540
 
  `t` TEXT COLLATE utf8_general_ci
1541
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1533
  `v` varchar(10) DEFAULT NULL,
 
1534
  `c` varchar(10) DEFAULT NULL,
 
1535
  `t` text
 
1536
) ENGINE=InnoDB
1542
1537
alter table t1 modify v char(10);
1543
1538
show create table t1;
1544
1539
Table   Create Table
1545
1540
t1      CREATE TABLE `t1` (
1546
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1547
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1548
 
  `t` TEXT COLLATE utf8_general_ci
1549
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1541
  `v` varchar(10) DEFAULT NULL,
 
1542
  `c` varchar(10) DEFAULT NULL,
 
1543
  `t` text
 
1544
) ENGINE=InnoDB
1550
1545
alter table t1 modify t varchar(10);
 
1546
Warnings:
 
1547
Note    1265    Data truncated for column 't' at row 2
1551
1548
show create table t1;
1552
1549
Table   Create Table
1553
1550
t1      CREATE TABLE `t1` (
1554
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1555
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1556
 
  `t` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
1557
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1551
  `v` varchar(10) DEFAULT NULL,
 
1552
  `c` varchar(10) DEFAULT NULL,
 
1553
  `t` varchar(10) DEFAULT NULL
 
1554
) ENGINE=InnoDB
1558
1555
select concat('*',v,'*',c,'*',t,'*') from t1;
1559
1556
concat('*',v,'*',c,'*',t,'*')
1560
1557
*+ *+ *+ *
1564
1561
show create table t1;
1565
1562
Table   Create Table
1566
1563
t1      CREATE TABLE `t1` (
1567
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1568
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1569
 
  `t` TEXT COLLATE utf8_general_ci,
 
1564
  `v` varchar(10) DEFAULT NULL,
 
1565
  `c` varchar(10) DEFAULT NULL,
 
1566
  `t` text,
1570
1567
  KEY `v` (`v`),
1571
1568
  KEY `c` (`c`),
1572
1569
  KEY `t` (`t`(10))
1573
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1570
) ENGINE=InnoDB
1574
1571
select count(*) from t1;
1575
1572
count(*)
1576
1573
270
1781
1778
i       10
1782
1779
alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
1783
1780
Warnings:
1784
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
1781
Warning 1071    Specified key was too long; max key length is 767 bytes
1785
1782
show create table t1;
1786
1783
Table   Create Table
1787
1784
t1      CREATE TABLE `t1` (
1788
 
  `v` VARCHAR(300) COLLATE utf8_general_ci DEFAULT NULL,
1789
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1790
 
  `t` TEXT COLLATE utf8_general_ci,
 
1785
  `v` varchar(300) DEFAULT NULL,
 
1786
  `c` varchar(10) DEFAULT NULL,
 
1787
  `t` text,
1791
1788
  KEY `c` (`c`),
1792
1789
  KEY `t` (`t`(10)),
1793
 
  KEY `v` (`v`(255))
1794
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1790
  KEY `v` (`v`(191))
 
1791
) ENGINE=InnoDB
1795
1792
select count(*) from t1 where v='a';
1796
1793
count(*)
1797
1794
10
1812
1809
9
1813
1810
explain select count(*) from t1 where v='a  ';
1814
1811
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1815
 
1       SIMPLE  t1      ref     v       v       1023    const   #       Using where
 
1812
1       SIMPLE  t1      ref     v       v       767     const   #       Using where
1816
1813
explain select count(*) from t1 where v like 'a%';
1817
1814
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1818
 
1       SIMPLE  t1      range   v       v       1023    NULL    #       Using where
 
1815
1       SIMPLE  t1      range   v       v       767     NULL    #       Using where
1819
1816
explain select count(*) from t1 where v between 'a' and 'a ';
1820
1817
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1821
 
1       SIMPLE  t1      ref     v       v       1023    const   #       Using where
 
1818
1       SIMPLE  t1      ref     v       v       767     const   #       Using where
1822
1819
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
1823
1820
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1824
 
1       SIMPLE  t1      ref     v       v       1023    const   #       Using where
 
1821
1       SIMPLE  t1      ref     v       v       767     const   #       Using where
1825
1822
explain select * from t1 where v='a';
1826
1823
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1827
 
1       SIMPLE  t1      ref     v       v       1023    const   #       Using where
 
1824
1       SIMPLE  t1      ref     v       v       767     const   #       Using where
1828
1825
select v,count(*) from t1 group by v limit 10;
1829
1826
v       count(*)
1830
1827
a      1
1865
1862
show create table t1;
1866
1863
Table   Create Table
1867
1864
t1      CREATE TABLE `t1` (
1868
 
  `v` VARCHAR(300) COLLATE utf8_general_ci DEFAULT NULL,
1869
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1870
 
  `t` TEXT COLLATE utf8_general_ci,
 
1865
  `v` varchar(300) DEFAULT NULL,
 
1866
  `c` varchar(10) DEFAULT NULL,
 
1867
  `t` text,
1871
1868
  KEY `c` (`c`),
1872
1869
  KEY `t` (`t`(10)),
1873
1870
  KEY `v` (`v`(30))
1874
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1871
) ENGINE=InnoDB
1875
1872
select count(*) from t1 where v='a';
1876
1873
count(*)
1877
1874
10
1943
1940
i       10
1944
1941
alter table t1 modify v varchar(600), drop key v, add key v (v);
1945
1942
Warnings:
1946
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
1943
Warning 1071    Specified key was too long; max key length is 767 bytes
1947
1944
show create table t1;
1948
1945
Table   Create Table
1949
1946
t1      CREATE TABLE `t1` (
1950
 
  `v` VARCHAR(600) COLLATE utf8_general_ci DEFAULT NULL,
1951
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1952
 
  `t` TEXT COLLATE utf8_general_ci,
 
1947
  `v` varchar(600) DEFAULT NULL,
 
1948
  `c` varchar(10) DEFAULT NULL,
 
1949
  `t` text,
1953
1950
  KEY `c` (`c`),
1954
1951
  KEY `t` (`t`(10)),
1955
 
  KEY `v` (`v`(255))
1956
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
1952
  KEY `v` (`v`(191))
 
1953
) ENGINE=InnoDB
1957
1954
select v,count(*) from t1 group by v limit 10;
1958
1955
v       count(*)
1959
1956
a      1
2001
1998
insert into t1 values ('a     ');
2002
1999
ERROR 23000: Duplicate entry 'a     ' for key 'a'
2003
2000
insert into t1 values ('a          ');
2004
 
ERROR 22001: Data too long for column 'a' at row 1
 
2001
ERROR 23000: Duplicate entry 'a         ' for key 'a'
2005
2002
insert into t1 values ('a ');
2006
2003
ERROR 23000: Duplicate entry 'a ' for key 'a'
2007
2004
update t1 set a='a  ' where a like 'a%';
2025
2022
show create table t1;
2026
2023
Table   Create Table
2027
2024
t1      CREATE TABLE `t1` (
2028
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
2029
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
2030
 
  `t` TEXT COLLATE utf8_general_ci,
 
2025
  `v` varchar(10) DEFAULT NULL,
 
2026
  `c` varchar(10) DEFAULT NULL,
 
2027
  `t` text,
2031
2028
  KEY `v` (`v`(5)),
2032
2029
  KEY `c` (`c`(5)),
2033
2030
  KEY `t` (`t`(5))
2034
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2031
) ENGINE=InnoDB
2035
2032
drop table t1;
2036
2033
create  table t1 (v char(10));
2037
2034
show create table t1;
2038
2035
Table   Create Table
2039
2036
t1      CREATE TABLE `t1` (
2040
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
2041
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2037
  `v` varchar(10) DEFAULT NULL
 
2038
) ENGINE=InnoDB
2042
2039
drop table t1;
2043
2040
create  table t1 (v varchar(10), c char(10));
2044
2041
show create table t1;
2045
2042
Table   Create Table
2046
2043
t1      CREATE TABLE `t1` (
2047
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
2048
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
2049
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2044
  `v` varchar(10) DEFAULT NULL,
 
2045
  `c` varchar(10) DEFAULT NULL
 
2046
) ENGINE=InnoDB
2050
2047
insert into t1 values('a','a'),('a ','a ');
2051
2048
select concat('*',v,'*',c,'*') from t1;
2052
2049
concat('*',v,'*',c,'*')
2064
2061
drop table t1;
2065
2062
create table t1 (v varchar(16383), key(v));
2066
2063
Warnings:
2067
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
2068
 
drop table t1;
2069
 
create table t1 (v varchar(16383));
2070
 
show create table t1;
2071
 
Table   Create Table
2072
 
t1      CREATE TABLE `t1` (
2073
 
  `v` VARCHAR(16383) COLLATE utf8_general_ci DEFAULT NULL
2074
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
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
 
2064
Warning 1071    Specified key was too long; max key length is 767 bytes
 
2065
drop table t1;
 
2066
create table t1 (v varchar(16383));
 
2067
show create table t1;
 
2068
Table   Create Table
 
2069
t1      CREATE TABLE `t1` (
 
2070
  `v` varchar(16383) DEFAULT NULL
 
2071
) ENGINE=InnoDB
 
2072
drop table t1;
 
2073
create table t1 (v varchar(16383));
 
2074
show create table t1;
 
2075
Table   Create Table
 
2076
t1      CREATE TABLE `t1` (
 
2077
  `v` varchar(16383) DEFAULT NULL
 
2078
) ENGINE=InnoDB
2082
2079
drop table t1;
2083
2080
set storage_engine=PBXT;
2084
2081
create table t1 (v varchar(16383)) engine=innodb;
2122
2119
3       1
2123
2120
4       2
2124
2121
drop table t1;
 
2122
create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
 
2123
insert into t1 (val) values (1);
 
2124
update t1 set a=2 where a=1;
 
2125
insert into t1 (val) values (1);
 
2126
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
 
2127
select * from t1;
 
2128
a       val
 
2129
2       1
 
2130
drop table t1;
2125
2131
CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
2126
2132
INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
2127
2133
SELECT GRADE  FROM t1 WHERE GRADE > 160 AND GRADE < 300;
2169
2175
create table t1 (col1 varchar(2000), index (col1(767)))
2170
2176
engine = innodb;
2171
2177
Warnings:
2172
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
2178
Warning 1071    Specified key was too long; max key length is 767 bytes
2173
2179
create table t2 (col1 char(255), index (col1))
2174
2180
engine = innodb;
 
2181
Warnings:
 
2182
Warning 1071    Specified key was too long; max key length is 767 bytes
2175
2183
create table t4 (col1 varchar(767), index (col1))
2176
2184
engine = innodb;
2177
2185
Warnings:
2178
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
2186
Warning 1071    Specified key was too long; max key length is 767 bytes
2179
2187
create table t5 (col1 varchar(190) primary key)
2180
2188
engine = innodb;
2181
2189
create table t6 (col1 varbinary(254) primary key)
2183
2191
create table t7 (col1 text, index(col1(767)))
2184
2192
engine = innodb;
2185
2193
Warnings:
2186
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
2194
Warning 1071    Specified key was too long; max key length is 767 bytes
2187
2195
create table t8 (col1 blob, index(col1(767)))
2188
2196
engine = innodb;
2189
2197
create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2))
2190
2198
engine = innodb;
2191
2199
Warnings:
2192
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
2193
 
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 767 bytes
 
2201
Warning 1071    Specified key was too long; max key length is 767 bytes
2194
2202
show create table t9;
2195
2203
Table   Create Table
2196
2204
t9      CREATE TABLE `t9` (
2197
 
  `col1` VARCHAR(512) COLLATE utf8_general_ci DEFAULT NULL,
2198
 
  `col2` VARCHAR(512) COLLATE utf8_general_ci DEFAULT NULL,
2199
 
  KEY `col1` (`col1`(255),`col2`(255))
2200
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2205
  `col1` varchar(512) DEFAULT NULL,
 
2206
  `col2` varchar(512) DEFAULT NULL,
 
2207
  KEY `col1` (`col1`(191),`col2`(191))
 
2208
) ENGINE=InnoDB
2201
2209
drop table t1, t2, t4, t5, t6, t7, t8, t9;
2202
2210
create table t1 (col1 varchar(768), index(col1))
2203
2211
engine = innodb;
2204
2212
Warnings:
2205
 
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
2206
2214
create table t2 (col1 varbinary(768), index(col1))
2207
2215
engine = innodb;
 
2216
Warnings:
 
2217
Warning 1071    Specified key was too long; max key length is 767 bytes
2208
2218
create table t3 (col1 text, index(col1(768)))
2209
2219
engine = innodb;
2210
2220
Warnings:
2211
 
Warning 1071    Specified key was too long; max key length is 1023 bytes
 
2221
Warning 1071    Specified key was too long; max key length is 767 bytes
2212
2222
create table t4 (col1 blob, index(col1(768)))
2213
2223
engine = innodb;
 
2224
Warnings:
 
2225
Warning 1071    Specified key was too long; max key length is 767 bytes
2214
2226
show create table t1;
2215
2227
Table   Create Table
2216
2228
t1      CREATE TABLE `t1` (
2217
 
  `col1` VARCHAR(768) COLLATE utf8_general_ci DEFAULT NULL,
2218
 
  KEY `col1` (`col1`(255))
2219
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2229
  `col1` varchar(768) DEFAULT NULL,
 
2230
  KEY `col1` (`col1`(191))
 
2231
) ENGINE=InnoDB
2220
2232
drop table t1, t2, t3, t4;
2221
2233
create table t1 (col1 varchar(768) primary key)
2222
2234
engine = innodb;
2223
 
ERROR 42000: Specified key was too long; max key length is 1023 bytes
2224
 
create table t2 (col1 varbinary(1024) primary key)
 
2235
ERROR 42000: Specified key was too long; max key length is 767 bytes
 
2236
create table t2 (col1 varbinary(768) primary key)
2225
2237
engine = innodb;
2226
 
ERROR 42000: Specified key was too long; max key length is 1023 bytes
 
2238
ERROR 42000: Specified key was too long; max key length is 767 bytes
2227
2239
create table t3 (col1 text, primary key(col1(768)))
2228
2240
engine = innodb;
2229
 
ERROR 42000: Specified key was too long; max key length is 1023 bytes
2230
 
create table t4 (col1 blob, primary key(col1(1024)))
 
2241
ERROR 42000: Specified key was too long; max key length is 767 bytes
 
2242
create table t4 (col1 blob, primary key(col1(768)))
2231
2243
engine = innodb;
2232
 
ERROR 42000: Specified key was too long; max key length is 1023 bytes
 
2244
ERROR 42000: Specified key was too long; max key length is 767 bytes
2233
2245
CREATE TABLE t1
2234
2246
(
2235
2247
id INT PRIMARY KEY
2299
2311
b varchar(255),
2300
2312
c varchar(255),
2301
2313
d varchar(255),
2302
 
key (a(200),b(200),c(200),d(200))) engine=innodb;
 
2314
key (a,b,c,d)) engine=innodb;
 
2315
Warnings:
 
2316
Warning 1071    Specified key was too long; max key length is 767 bytes
 
2317
Warning 1071    Specified key was too long; max key length is 767 bytes
 
2318
Warning 1071    Specified key was too long; max key length is 767 bytes
 
2319
Warning 1071    Specified key was too long; max key length is 767 bytes
2303
2320
drop table t1;
2304
2321
create table t1 (a varchar(255),
2305
2322
b varchar(255),
2413
2430
SHOW CREATE TABLE t2;
2414
2431
Table   Create Table
2415
2432
t2      CREATE TABLE `t2` (
2416
 
  `a` INT DEFAULT NULL,
 
2433
  `a` int DEFAULT NULL,
2417
2434
  KEY `t2_ibfk_0` (`a`)
2418
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2435
) ENGINE=InnoDB
2419
2436
DROP TABLE t2,t1;
2420
2437
CREATE TABLE t1 (
2421
2438
field1 varchar(8) NOT NULL DEFAULT '',
2450
2467
show create table t1;
2451
2468
Table   Create Table
2452
2469
t1      CREATE TABLE `t1` (
2453
 
  `c1` BIGINT NOT NULL,
2454
 
  `c2` BIGINT NOT NULL,
 
2470
  `c1` bigint NOT NULL,
 
2471
  `c2` bigint NOT NULL,
2455
2472
  PRIMARY KEY (`c1`),
2456
2473
  UNIQUE KEY `c2` (`c2`),
2457
2474
  CONSTRAINT `c2_fk` FOREIGN KEY (`c2`) REFERENCES `t2` (`c1`) ON DELETE CASCADE
2458
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2475
) ENGINE=InnoDB
2459
2476
alter table t1 drop foreign key c2_fk;
2460
2477
show create table t1;
2461
2478
Table   Create Table
2462
2479
t1      CREATE TABLE `t1` (
2463
 
  `c1` BIGINT NOT NULL,
2464
 
  `c2` BIGINT NOT NULL,
 
2480
  `c1` bigint NOT NULL,
 
2481
  `c2` bigint NOT NULL,
2465
2482
  PRIMARY KEY (`c1`),
2466
2483
  UNIQUE KEY `c2` (`c2`)
2467
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2484
) ENGINE=InnoDB
2468
2485
drop table t1, t2;
2469
2486
create table t1(a date) engine=innodb;
2470
2487
create table t2(a date, key(a)) engine=innodb;
2615
2632
CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a) 
2616
2633
ON DELETE CASCADE
2617
2634
) ENGINE=INNODB;
 
2635
Warnings:
 
2636
Warning 1071    Specified key was too long; max key length is 767 bytes
2618
2637
INSERT INTO t1 VALUES (1);
2619
2638
INSERT INTO t2 VALUES (1, 'bar', 'vbar');
2620
2639
INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR');
2651
2670
SHOW CREATE TABLE t2;
2652
2671
Table   Create Table
2653
2672
t2      CREATE TABLE `t2` (
2654
 
  `id` INT NOT NULL,
2655
 
  `f` INT NOT NULL,
 
2673
  `id` int NOT NULL,
 
2674
  `f` int NOT NULL,
2656
2675
  PRIMARY KEY (`id`),
2657
2676
  KEY `f` (`f`),
2658
 
  CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,
2659
 
  CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`f`) REFERENCES `t1` (`f`) ON UPDATE CASCADE ON DELETE CASCADE
2660
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2677
  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f`) REFERENCES `t1` (`f`) ON DELETE CASCADE ON UPDATE CASCADE,
 
2678
  CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
 
2679
) ENGINE=InnoDB
2661
2680
DROP TABLE t2, t1;
2662
2681
CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB;
2663
2682
CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB;
2688
2707
SHOW CREATE TABLE t1;
2689
2708
Table   Create Table
2690
2709
t1      CREATE TABLE `t1` (
2691
 
  `id` INT NOT NULL AUTO_INCREMENT,
 
2710
  `id` int NOT NULL AUTO_INCREMENT,
2692
2711
  PRIMARY KEY (`id`)
2693
 
) ENGINE=InnoDB COLLATE = utf8_general_ci AUTO_INCREMENT=42
 
2712
) ENGINE=InnoDB
2694
2713
CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB;
2695
2714
INSERT INTO t2 VALUES(42),(347),(348);
2696
2715
ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id);
2697
2716
SHOW CREATE TABLE t1;
2698
2717
Table   Create Table
2699
2718
t1      CREATE TABLE `t1` (
2700
 
  `id` INT NOT NULL AUTO_INCREMENT,
 
2719
  `id` int NOT NULL AUTO_INCREMENT,
2701
2720
  PRIMARY KEY (`id`),
2702
2721
  CONSTRAINT `t1_t2` FOREIGN KEY (`id`) REFERENCES `t2` (`id`)
2703
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
2722
) ENGINE=InnoDB
2704
2723
DROP TABLE t1,t2;
2705
2724
DROP TABLE IF EXISTS t1;
2706
2725
Warnings:
2718
2737
-10
2719
2738
1
2720
2739
DROP TABLE t1;
2721
 
SET GLOBAL innodb_lock_wait_timeout=@orig_lock_wait_timeout ;