mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / suite / innodb_plugin / r / innodb.result
blob3d3eaae5e16dd70225901a44e7b67768ad0d2a12
1 drop table if exists t1,t2,t3,t4;
2 drop database if exists mysqltest;
3 CREATE TABLE bug58912 (a BLOB, b TEXT, PRIMARY KEY(a(1))) ENGINE=InnoDB;
4 INSERT INTO bug58912 VALUES(REPEAT('a',8000),REPEAT('b',8000));
5 UPDATE bug58912 SET a=REPEAT('a',7999);
6 create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
7 insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
8 select id, code, name from t1 order by id;
9 id      code    name
10 1       1       Tim
11 2       1       Monty
12 3       2       David
13 4       2       Erik
14 5       3       Sasha
15 6       3       Jeremy
16 7       4       Matt
17 update ignore t1 set id = 8, name = 'Sinisa' where id < 3;
18 select id, code, name from t1 order by id;
19 id      code    name
20 2       1       Monty
21 3       2       David
22 4       2       Erik
23 5       3       Sasha
24 6       3       Jeremy
25 7       4       Matt
26 8       1       Sinisa
27 update ignore t1 set id = id + 10, name = 'Ralph' where id < 4;
28 select id, code, name from t1 order by id;
29 id      code    name
30 3       2       David
31 4       2       Erik
32 5       3       Sasha
33 6       3       Jeremy
34 7       4       Matt
35 8       1       Sinisa
36 12      1       Ralph
37 drop table t1;
38 CREATE TABLE t1 (
39 id int(11) NOT NULL auto_increment,
40 parent_id int(11) DEFAULT '0' NOT NULL,
41 level tinyint(4) DEFAULT '0' NOT NULL,
42 PRIMARY KEY (id),
43 KEY parent_id (parent_id),
44 KEY level (level)
45 ) engine=innodb;
46 INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
47 update t1 set parent_id=parent_id+100;
48 select * from t1 where parent_id=102;
49 id      parent_id       level
50 8       102     2
51 9       102     2
52 15      102     2
53 update t1 set id=id+1000;
54 update t1 set id=1024 where id=1009;
55 Got one of the listed errors
56 select * from t1;
57 id      parent_id       level
58 1001    100     0
59 1002    101     1
60 1003    101     1
61 1004    101     1
62 1005    101     1
63 1006    101     1
64 1007    101     1
65 1008    102     2
66 1009    102     2
67 1015    102     2
68 1016    103     2
69 1017    103     2
70 1018    103     2
71 1019    103     2
72 1020    103     2
73 1021    104     2
74 1022    104     2
75 1024    104     2
76 1025    105     2
77 1026    105     2
78 1027    105     2
79 1028    105     2
80 1029    105     2
81 1030    105     2
82 1031    106     2
83 1032    106     2
84 1033    106     2
85 1034    106     2
86 1035    106     2
87 1036    107     2
88 1037    107     2
89 1038    107     2
90 1040    107     2
91 1157    100     0
92 1179    105     2
93 1183    104     2
94 1193    105     2
95 1202    107     2
96 1203    107     2
97 update ignore t1 set id=id+1;
98 select * from t1;
99 id      parent_id       level
100 1001    100     0
101 1002    101     1
102 1003    101     1
103 1004    101     1
104 1005    101     1
105 1006    101     1
106 1007    101     1
107 1008    102     2
108 1010    102     2
109 1015    102     2
110 1016    103     2
111 1017    103     2
112 1018    103     2
113 1019    103     2
114 1020    103     2
115 1021    104     2
116 1023    104     2
117 1024    104     2
118 1025    105     2
119 1026    105     2
120 1027    105     2
121 1028    105     2
122 1029    105     2
123 1030    105     2
124 1031    106     2
125 1032    106     2
126 1033    106     2
127 1034    106     2
128 1035    106     2
129 1036    107     2
130 1037    107     2
131 1039    107     2
132 1041    107     2
133 1158    100     0
134 1180    105     2
135 1184    104     2
136 1194    105     2
137 1202    107     2
138 1204    107     2
139 update ignore t1 set id=1023 where id=1010;
140 select * from t1 where parent_id=102;
141 id      parent_id       level
142 1008    102     2
143 1010    102     2
144 1015    102     2
145 explain select level from t1 where level=1;
146 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
147 1       SIMPLE  t1      ref     level   level   1       const   #       Using index
148 explain select level,id from t1 where level=1;
149 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
150 1       SIMPLE  t1      ref     level   level   1       const   #       Using index
151 explain select level,id,parent_id from t1 where level=1;
152 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
153 1       SIMPLE  t1      ref     level   level   1       const   #       
154 select level,id from t1 where level=1;
155 level   id
156 1       1002
157 1       1003
158 1       1004
159 1       1005
160 1       1006
161 1       1007
162 select level,id,parent_id from t1 where level=1;
163 level   id      parent_id
164 1       1002    101
165 1       1003    101
166 1       1004    101
167 1       1005    101
168 1       1006    101
169 1       1007    101
170 optimize table t1;
171 Table   Op      Msg_type        Msg_text
172 test.t1 optimize        note    Table does not support optimize, doing recreate + analyze instead
173 test.t1 optimize        status  OK
174 show keys from t1;
175 Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment
176 t1      0       PRIMARY 1       id      A       #       NULL    NULL            BTREE   
177 t1      1       parent_id       1       parent_id       A       #       NULL    NULL            BTREE   
178 t1      1       level   1       level   A       #       NULL    NULL            BTREE   
179 drop table t1;
180 CREATE TABLE t1 (
181 gesuchnr int(11) DEFAULT '0' NOT NULL,
182 benutzer_id int(11) DEFAULT '0' NOT NULL,
183 PRIMARY KEY (gesuchnr,benutzer_id)
184 ) engine=innodb;
185 replace into t1 (gesuchnr,benutzer_id) values (2,1);
186 replace into t1 (gesuchnr,benutzer_id) values (1,1);
187 replace into t1 (gesuchnr,benutzer_id) values (1,1);
188 select * from t1;
189 gesuchnr        benutzer_id
190 1       1
191 2       1
192 drop table t1;
193 create table t1 (a int) engine=innodb;
194 insert into t1 values (1), (2);
195 optimize table t1;
196 Table   Op      Msg_type        Msg_text
197 test.t1 optimize        note    Table does not support optimize, doing recreate + analyze instead
198 test.t1 optimize        status  OK
199 delete from t1 where a = 1;
200 select * from t1;
203 check table t1;
204 Table   Op      Msg_type        Msg_text
205 test.t1 check   status  OK
206 drop table t1;
207 create table t1 (a int,b varchar(20)) engine=innodb;
208 insert into t1 values (1,""), (2,"testing");
209 delete from t1 where a = 1;
210 select * from t1;
211 a       b
212 2       testing
213 create index skr on t1 (a);
214 insert into t1 values (3,""), (4,"testing");
215 analyze table t1;
216 Table   Op      Msg_type        Msg_text
217 test.t1 analyze status  OK
218 show keys from t1;
219 Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment
220 t1      1       skr     1       a       A       #       NULL    NULL    YES     BTREE   
221 drop table t1;
222 create table t1 (a int,b varchar(20),key(a)) engine=innodb;
223 insert into t1 values (1,""), (2,"testing");
224 select * from t1 where a = 1;
225 a       b
226 1       
227 drop table t1;
228 create table t1 (n int not null primary key) engine=innodb;
229 set autocommit=0;
230 insert into t1 values (4);
231 rollback;
232 select n, "after rollback" from t1;
233 n       after rollback
234 insert into t1 values (4);
235 commit;
236 select n, "after commit" from t1;
237 n       after commit
238 4       after commit
239 commit;
240 insert into t1 values (5);
241 insert into t1 values (4);
242 ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
243 commit;
244 select n, "after commit" from t1;
245 n       after commit
246 4       after commit
247 5       after commit
248 set autocommit=1;
249 insert into t1 values (6);
250 insert into t1 values (4);
251 ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
252 select n from t1;
257 set autocommit=0;
258 begin;
259 savepoint `my_savepoint`;
260 insert into t1 values (7);
261 savepoint `savept2`;
262 insert into t1 values (3);
263 select n from t1;
270 savepoint savept3;
271 rollback to savepoint savept2;
272 rollback to savepoint savept3;
273 ERROR 42000: SAVEPOINT savept3 does not exist
274 rollback to savepoint savept2;
275 release savepoint `my_savepoint`;
276 select n from t1;
282 rollback to savepoint `my_savepoint`;
283 ERROR 42000: SAVEPOINT my_savepoint does not exist
284 rollback to savepoint savept2;
285 ERROR 42000: SAVEPOINT savept2 does not exist
286 insert into t1 values (8);
287 savepoint sv;
288 commit;
289 savepoint sv;
290 set autocommit=1;
291 rollback;
292 drop table t1;
293 create table t1 (n int not null primary key) engine=innodb;
294 start transaction;
295 insert into t1 values (4);
296 flush tables with read lock;
297 commit;
298 unlock tables;
299 commit;
300 select * from t1;
303 drop table t1;
304 create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=innodb;
305 begin;
306 insert into t1 values(1,'hamdouni');
307 select id as afterbegin_id,nom as afterbegin_nom from t1;
308 afterbegin_id   afterbegin_nom
309 1       hamdouni
310 rollback;
311 select id as afterrollback_id,nom as afterrollback_nom from t1;
312 afterrollback_id        afterrollback_nom
313 set autocommit=0;
314 insert into t1 values(2,'mysql');
315 select id as afterautocommit0_id,nom as afterautocommit0_nom from t1;
316 afterautocommit0_id     afterautocommit0_nom
317 2       mysql
318 rollback;
319 select id as afterrollback_id,nom as afterrollback_nom from t1;
320 afterrollback_id        afterrollback_nom
321 set autocommit=1;
322 drop table t1;
323 CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb;
324 insert into t1 values ('pippo', 12);
325 insert into t1 values ('pippo', 12);
326 ERROR 23000: Duplicate entry 'pippo' for key 'PRIMARY'
327 delete from t1;
328 delete from t1 where id = 'pippo';
329 select * from t1;
330 id      val
331 insert into t1 values ('pippo', 12);
332 set autocommit=0;
333 delete from t1;
334 rollback;
335 select * from t1;
336 id      val
337 pippo   12
338 delete from t1;
339 commit;
340 select * from t1;
341 id      val
342 drop table t1;
343 create table t1 (a integer) engine=innodb;
344 start transaction;
345 rename table t1 to t2;
346 create table t1 (b integer) engine=innodb;
347 insert into t1 values (1);
348 rollback;
349 drop table t1;
350 rename table t2 to t1;
351 drop table t1;
352 set autocommit=1;
353 CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) ENGINE=innodb;
354 INSERT INTO t1 VALUES (1, 'Jochen');
355 select * from t1;
356 ID      NAME
357 1       Jochen
358 drop table t1;
359 CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) ENGINE=innodb;
360 set autocommit=0;
361 INSERT INTO t1  SET _userid='marc@anyware.co.uk';
362 COMMIT;
363 SELECT * FROM t1;
364 _userid
365 marc@anyware.co.uk
366 SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk';
367 _userid
368 marc@anyware.co.uk
369 drop table t1;
370 set autocommit=1;
371 CREATE TABLE t1 (
372 user_id int(10) DEFAULT '0' NOT NULL,
373 name varchar(100),
374 phone varchar(100),
375 ref_email varchar(100) DEFAULT '' NOT NULL,
376 detail varchar(200),
377 PRIMARY KEY (user_id,ref_email)
378 )engine=innodb;
379 INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10292,'shirish','2333604','shirish@yahoo.com','ddsds'),(10292,'sonali','323232','sonali@bolly.com','filmstar');
380 select * from t1 where user_id=10292;
381 user_id name    phone   ref_email       detail
382 10292   sanjeev 29153373        sansh777@hotmail.com    xxx
383 10292   shirish 2333604 shirish@yahoo.com       ddsds
384 10292   sonali  323232  sonali@bolly.com        filmstar
385 INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10293,'shirish','2333604','shirish@yahoo.com','ddsds');
386 select * from t1 where user_id=10292;
387 user_id name    phone   ref_email       detail
388 10292   sanjeev 29153373        sansh777@hotmail.com    xxx
389 10292   shirish 2333604 shirish@yahoo.com       ddsds
390 10292   sonali  323232  sonali@bolly.com        filmstar
391 select * from t1 where user_id>=10292;
392 user_id name    phone   ref_email       detail
393 10292   sanjeev 29153373        sansh777@hotmail.com    xxx
394 10292   shirish 2333604 shirish@yahoo.com       ddsds
395 10292   sonali  323232  sonali@bolly.com        filmstar
396 10293   shirish 2333604 shirish@yahoo.com       ddsds
397 select * from t1 where user_id>10292;
398 user_id name    phone   ref_email       detail
399 10293   shirish 2333604 shirish@yahoo.com       ddsds
400 select * from t1 where user_id<10292;
401 user_id name    phone   ref_email       detail
402 10291   sanjeev 29153373        sansh777@hotmail.com    xxx
403 drop table t1;
404 CREATE TABLE t1 (a int not null, b int not null,c int not null,
405 key(a),primary key(a,b), unique(c),key(a),unique(b));
406 show index from t1;
407 Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment
408 t1      0       PRIMARY 1       a       A       #       NULL    NULL            BTREE   
409 t1      0       PRIMARY 2       b       A       #       NULL    NULL            BTREE   
410 t1      0       c       1       c       A       #       NULL    NULL            BTREE   
411 t1      0       b       1       b       A       #       NULL    NULL            BTREE   
412 t1      1       a       1       a       A       #       NULL    NULL            BTREE   
413 t1      1       a_2     1       a       A       #       NULL    NULL            BTREE   
414 drop table t1;
415 create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
416 alter table t1 engine=innodb;
417 insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4');
418 select * from t1;
419 col1    col2
420 1       1
421 2       3
422 3       4
423 4       4
424 5       2
425 update t1 set col2='7' where col1='4';
426 select * from t1;
427 col1    col2
428 1       1
429 2       3
430 3       4
431 4       7
432 5       2
433 alter table t1 add co3 int not null;
434 select * from t1;
435 col1    col2    co3
436 1       1       0
437 2       3       0
438 3       4       0
439 4       7       0
440 5       2       0
441 update t1 set col2='9' where col1='2';
442 select * from t1;
443 col1    col2    co3
444 1       1       0
445 2       9       0
446 3       4       0
447 4       7       0
448 5       2       0
449 drop table t1;
450 create table t1 (a int not null , b int, primary key (a)) engine = innodb;
451 create table t2 (a int not null , b int, primary key (a)) engine = myisam;
452 insert into t1 VALUES (1,3) , (2,3), (3,3);
453 select * from t1;
454 a       b
455 1       3
456 2       3
457 3       3
458 insert into t2 select * from t1;
459 select * from t2;
460 a       b
461 1       3
462 2       3
463 3       3
464 delete from t1 where b = 3;
465 select * from t1;
466 a       b
467 insert into t1 select * from t2;
468 select * from t1;
469 a       b
470 1       3
471 2       3
472 3       3
473 select * from t2;
474 a       b
475 1       3
476 2       3
477 3       3
478 drop table t1,t2;
479 CREATE TABLE t1 (
480 user_name varchar(12),
481 password text,
482 subscribed char(1),
483 user_id int(11) DEFAULT '0' NOT NULL,
484 quota bigint(20),
485 weight double,
486 access_date date,
487 access_time time,
488 approved datetime,
489 dummy_primary_key int(11) NOT NULL auto_increment,
490 PRIMARY KEY (dummy_primary_key)
491 ) ENGINE=innodb;
492 INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1);
493 INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2);
494 INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3);
495 INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4);
496 INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5);
497 select  user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name;
498 user_name       password        subscribed      user_id quota   weight  access_date     access_time     approved        dummy_primary_key
499 user_0  somepassword    N       0       0       0       2000-09-07      23:06:59        2000-09-07 23:06:59     1
500 user_1  somepassword    Y       1       1       1       2000-09-07      23:06:59        2000-09-07 23:06:59     2
501 user_2  somepassword    N       2       2       1.4142135623731 2000-09-07      23:06:59        2000-09-07 23:06:59     3
502 user_3  somepassword    Y       3       3       1.7320508075689 2000-09-07      23:06:59        2000-09-07 23:06:59     4
503 user_4  somepassword    N       4       4       2       2000-09-07      23:06:59        2000-09-07 23:06:59     5
504 drop table t1;
505 CREATE TABLE t1 (
506 id int(11) NOT NULL auto_increment,
507 parent_id int(11) DEFAULT '0' NOT NULL,
508 level tinyint(4) DEFAULT '0' NOT NULL,
509 KEY (id),
510 KEY parent_id (parent_id),
511 KEY level (level)
512 ) engine=innodb;
513 INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1);
514 INSERT INTO t1 values (179,5,2);
515 update t1 set parent_id=parent_id+100;
516 select * from t1 where parent_id=102;
517 id      parent_id       level
518 8       102     2
519 9       102     2
520 15      102     2
521 update t1 set id=id+1000;
522 update t1 set id=1024 where id=1009;
523 select * from t1;
524 id      parent_id       level
525 1001    100     0
526 1003    101     1
527 1004    101     1
528 1008    102     2
529 1024    102     2
530 1017    103     2
531 1022    104     2
532 1024    104     2
533 1028    105     2
534 1029    105     2
535 1030    105     2
536 1031    106     2
537 1032    106     2
538 1033    106     2
539 1203    107     2
540 1202    107     2
541 1020    103     2
542 1157    100     0
543 1193    105     2
544 1040    107     2
545 1002    101     1
546 1015    102     2
547 1006    101     1
548 1034    106     2
549 1035    106     2
550 1016    103     2
551 1007    101     1
552 1036    107     2
553 1018    103     2
554 1026    105     2
555 1027    105     2
556 1183    104     2
557 1038    107     2
558 1025    105     2
559 1037    107     2
560 1021    104     2
561 1019    103     2
562 1005    101     1
563 1179    105     2
564 update ignore t1 set id=id+1;
565 select * from t1;
566 id      parent_id       level
567 1002    100     0
568 1004    101     1
569 1005    101     1
570 1009    102     2
571 1025    102     2
572 1018    103     2
573 1023    104     2
574 1025    104     2
575 1029    105     2
576 1030    105     2
577 1031    105     2
578 1032    106     2
579 1033    106     2
580 1034    106     2
581 1204    107     2
582 1203    107     2
583 1021    103     2
584 1158    100     0
585 1194    105     2
586 1041    107     2
587 1003    101     1
588 1016    102     2
589 1007    101     1
590 1035    106     2
591 1036    106     2
592 1017    103     2
593 1008    101     1
594 1037    107     2
595 1019    103     2
596 1027    105     2
597 1028    105     2
598 1184    104     2
599 1039    107     2
600 1026    105     2
601 1038    107     2
602 1022    104     2
603 1020    103     2
604 1006    101     1
605 1180    105     2
606 update ignore t1 set id=1023 where id=1010;
607 select * from t1 where parent_id=102;
608 id      parent_id       level
609 1009    102     2
610 1025    102     2
611 1016    102     2
612 explain select level from t1 where level=1;
613 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
614 1       SIMPLE  t1      ref     level   level   1       const   #       Using index
615 select level,id from t1 where level=1;
616 level   id
617 1       1004
618 1       1005
619 1       1003
620 1       1007
621 1       1008
622 1       1006
623 select level,id,parent_id from t1 where level=1;
624 level   id      parent_id
625 1       1004    101
626 1       1005    101
627 1       1003    101
628 1       1007    101
629 1       1008    101
630 1       1006    101
631 select level,id from t1 where level=1 order by id;
632 level   id
633 1       1003
634 1       1004
635 1       1005
636 1       1006
637 1       1007
638 1       1008
639 delete from t1 where level=1;
640 select * from t1;
641 id      parent_id       level
642 1002    100     0
643 1009    102     2
644 1025    102     2
645 1018    103     2
646 1023    104     2
647 1025    104     2
648 1029    105     2
649 1030    105     2
650 1031    105     2
651 1032    106     2
652 1033    106     2
653 1034    106     2
654 1204    107     2
655 1203    107     2
656 1021    103     2
657 1158    100     0
658 1194    105     2
659 1041    107     2
660 1016    102     2
661 1035    106     2
662 1036    106     2
663 1017    103     2
664 1037    107     2
665 1019    103     2
666 1027    105     2
667 1028    105     2
668 1184    104     2
669 1039    107     2
670 1026    105     2
671 1038    107     2
672 1022    104     2
673 1020    103     2
674 1180    105     2
675 drop table t1;
676 CREATE TABLE t1 (
677 sca_code char(6) NOT NULL,
678 cat_code char(6) NOT NULL,
679 sca_desc varchar(50),
680 lan_code char(2) NOT NULL,
681 sca_pic varchar(100),
682 sca_sdesc varchar(50),
683 sca_sch_desc varchar(16),
684 PRIMARY KEY (sca_code, cat_code, lan_code),
685 INDEX sca_pic (sca_pic)
686 ) engine = innodb ;
687 INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING');
688 select count(*) from t1 where sca_code = 'PD';
689 count(*)
691 select count(*) from t1 where sca_code <= 'PD';
692 count(*)
694 select count(*) from t1 where sca_pic is null;
695 count(*)
697 alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
698 alter table t1 drop index sca_pic;
699 alter table t1 add index sca_pic (cat_code, sca_pic);
700 select count(*) from t1 where sca_code='PD' and sca_pic is null;
701 count(*)
703 select count(*) from t1 where cat_code='E';
704 count(*)
706 alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
707 ERROR 42000: Incorrect index name 'sca_pic'
708 alter table t1 drop index sca_pic;
709 alter table t1 add index (sca_pic, cat_code);
710 select count(*) from t1 where sca_code='PD' and sca_pic is null;
711 count(*)
713 select count(*) from t1 where sca_pic >= 'n';
714 count(*)
716 select sca_pic from t1 where sca_pic is null;
717 sca_pic
718 NULL
719 NULL
720 update t1 set sca_pic="test" where sca_pic is null;
721 delete from t1 where sca_code='pd';
722 drop table t1;
723 set @a:=now();
724 CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=innodb;
725 insert into t1 (a) values(1),(2),(3);
726 select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
731 select a from t1 natural join t1 as t2 where b >= @a order by a;
736 update t1 set a=5 where a=1;
737 select a from t1;
742 drop table t1;
743 create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=innodb;
744 insert into t1 values("hello",1),("world",2);
745 select * from t1 order by b desc;
746 a       b
747 world   2
748 hello   1
749 optimize table t1;
750 Table   Op      Msg_type        Msg_text
751 test.t1 optimize        note    Table does not support optimize, doing recreate + analyze instead
752 test.t1 optimize        status  OK
753 show keys from t1;
754 Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment
755 t1      0       PRIMARY 1       a       A       #       NULL    NULL            BTREE   
756 drop table t1;
757 create table t1 (i int, j int ) ENGINE=innodb;
758 insert into t1 values (1,2);
759 select * from t1 where i=1 and j=2;
760 i       j
761 1       2
762 create index ax1 on t1 (i,j);
763 select * from t1 where i=1 and j=2;
764 i       j
765 1       2
766 drop table t1;
767 CREATE TABLE t1 (
768 a int3 unsigned NOT NULL,
769 b int1 unsigned NOT NULL,
770 UNIQUE (a, b)
771 ) ENGINE = innodb;
772 INSERT INTO t1 VALUES (1, 1);
773 SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1;
774 MIN(B)  MAX(b)
775 1       1
776 drop table t1;
777 CREATE TABLE t1 (a int unsigned NOT NULL) engine=innodb;
778 INSERT INTO t1 VALUES (1);
779 SELECT * FROM t1;
782 DROP TABLE t1;
783 create table t1 (a int  primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = innodb;
784 insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
785 explain select * from t1 where a > 0 and a < 50;
786 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
787 1       SIMPLE  t1      range   PRIMARY PRIMARY 4       NULL    #       Using where
788 drop table t1;
789 create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
790 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
791 LOCK TABLES t1 WRITE;
792 insert into t1 values (99,1,2,'D'),(1,1,2,'D');
793 ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
794 select id from t1;
799 select id from t1;
804 UNLOCK TABLES;
805 DROP TABLE t1;
806 create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
807 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
808 LOCK TABLES t1 WRITE;
809 begin;
810 insert into t1 values (99,1,2,'D'),(1,1,2,'D');
811 ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
812 select id from t1;
817 insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
818 commit;
819 select id,id3 from t1;
820 id      id3
821 0       0
822 1       1
823 2       2
824 100     2
825 UNLOCK TABLES;
826 DROP TABLE t1;
827 create table t1 (a char(20), unique (a(5))) engine=innodb;
828 drop table t1;
829 create table t1 (a char(20), index (a(5))) engine=innodb;
830 show create table t1;
831 Table   Create Table
832 t1      CREATE TABLE `t1` (
833   `a` char(20) DEFAULT NULL,
834   KEY `a` (`a`(5))
835 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
836 drop table t1;
837 create temporary table t1 (a int not null auto_increment, primary key(a)) engine=innodb;
838 insert into t1 values (NULL),(NULL),(NULL);
839 delete from t1 where a=3;
840 insert into t1 values (NULL);
841 select * from t1;
846 alter table t1 add b int;
847 select * from t1;
848 a       b
849 1       NULL
850 2       NULL
851 4       NULL
852 drop table t1;
853 create table t1
855 id int auto_increment primary key,
856 name varchar(32) not null,
857 value text not null,
858 uid int not null,
859 unique key(name,uid)
860 ) engine=innodb;
861 insert into t1 values (1,'one','one value',101),
862 (2,'two','two value',102),(3,'three','three value',103);
863 set insert_id=5;
864 replace into t1 (value,name,uid) values ('other value','two',102);
865 delete from t1 where uid=102;
866 set insert_id=5;
867 replace into t1 (value,name,uid) values ('other value','two',102);
868 set insert_id=6;
869 replace into t1 (value,name,uid) values ('other value','two',102);
870 select * from t1;
871 id      name    value   uid
872 1       one     one value       101
873 3       three   three value     103
874 6       two     other value     102
875 drop table t1;
876 create database mysqltest;
877 create table mysqltest.t1 (a int not null) engine= innodb;
878 insert into mysqltest.t1 values(1);
879 create table mysqltest.t2 (a int not null) engine= myisam;
880 insert into mysqltest.t2 values(1);
881 create table mysqltest.t3 (a int not null) engine= heap;
882 insert into mysqltest.t3 values(1);
883 commit;
884 drop database mysqltest;
885 show tables from mysqltest;
886 ERROR 42000: Unknown database 'mysqltest'
887 set autocommit=0;
888 create table t1 (a int not null) engine= innodb;
889 insert into t1 values(1),(2);
890 truncate table t1;
891 commit;
892 truncate table t1;
893 truncate table t1;
894 select * from t1;
896 insert into t1 values(1),(2);
897 delete from t1;
898 select * from t1;
900 commit;
901 drop table t1;
902 set autocommit=1;
903 create table t1 (a int not null) engine= innodb;
904 insert into t1 values(1),(2);
905 truncate table t1;
906 insert into t1 values(1),(2);
907 select * from t1;
911 truncate table t1;
912 insert into t1 values(1),(2);
913 delete from t1;
914 select * from t1;
916 drop table t1;
917 create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=innodb;
918 insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
919 explain select * from t1 order by a;
920 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
921 1       SIMPLE  t1      index   NULL    PRIMARY 4       NULL    #       
922 explain select * from t1 order by b;
923 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
924 1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    #       Using filesort
925 explain select * from t1 order by c;
926 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
927 1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    #       Using filesort
928 explain select a from t1 order by a;
929 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
930 1       SIMPLE  t1      index   NULL    PRIMARY 4       NULL    #       Using index
931 explain select b from t1 order by b;
932 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
933 1       SIMPLE  t1      index   NULL    b       4       NULL    #       Using index
934 explain select a,b from t1 order by b;
935 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
936 1       SIMPLE  t1      index   NULL    b       4       NULL    #       Using index
937 explain select a,b from t1;
938 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
939 1       SIMPLE  t1      index   NULL    b       4       NULL    #       Using index
940 explain select a,b,c from t1;
941 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
942 1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    #       
943 drop table t1;
944 create table t1 (t int not null default 1, key (t)) engine=innodb;
945 desc t1;
946 Field   Type    Null    Key     Default Extra
947 t       int(11) NO      MUL     1       
948 drop table t1;
949 CREATE TABLE t1 (
950 number bigint(20) NOT NULL default '0',
951 cname char(15) NOT NULL default '',
952 carrier_id smallint(6) NOT NULL default '0',
953 privacy tinyint(4) NOT NULL default '0',
954 last_mod_date timestamp NOT NULL,
955 last_mod_id smallint(6) NOT NULL default '0',
956 last_app_date timestamp NOT NULL,
957 last_app_id smallint(6) default '-1',
958 version smallint(6) NOT NULL default '0',
959 assigned_scps int(11) default '0',
960 status tinyint(4) default '0'
961 ) ENGINE=InnoDB;
962 INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1);
963 INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
964 INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1);
965 INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);
966 INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
967 INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
968 CREATE TABLE t2 (
969 number bigint(20) NOT NULL default '0',
970 cname char(15) NOT NULL default '',
971 carrier_id smallint(6) NOT NULL default '0',
972 privacy tinyint(4) NOT NULL default '0',
973 last_mod_date timestamp NOT NULL,
974 last_mod_id smallint(6) NOT NULL default '0',
975 last_app_date timestamp NOT NULL,
976 last_app_id smallint(6) default '-1',
977 version smallint(6) NOT NULL default '0',
978 assigned_scps int(11) default '0',
979 status tinyint(4) default '0'
980 ) ENGINE=InnoDB;
981 INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1);
982 INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
983 INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1);
984 INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
985 select * from t1;
986 number  cname   carrier_id      privacy last_mod_date   last_mod_id     last_app_date   last_app_id     version assigned_scps   status
987 4077711111      SeanWheeler     90      2       2002-01-11 11:28:46     500     0000-00-00 00:00:00     -1      2       3       1
988 9197722223      berry   90      3       2002-01-11 11:28:09     500     2002-01-02 11:45:32     501     4       10      0
989 650     San Francisco   0       0       2001-12-27 11:13:36     342     0000-00-00 00:00:00     -1      1       24      1
990 302467  Sue's Subshop   90      3       2002-01-09 11:32:41     500     2002-01-02 11:51:11     501     7       24      0
991 6014911113      SudzCarwash     520     1       2002-01-02 11:52:34     500     2002-01-02 11:52:59     501     33      32768   0
992 333     tubs    99      2       2002-01-09 11:34:40     501     2002-01-09 11:34:40     500     3       10      0
993 select * from t2;
994 number  cname   carrier_id      privacy last_mod_date   last_mod_id     last_app_date   last_app_id     version assigned_scps   status
995 4077711111      SeanWheeler     0       2       2002-01-11 11:28:53     500     0000-00-00 00:00:00     -1      2       3       1
996 9197722223      berry   90      3       2002-01-11 11:28:18     500     2002-01-02 11:45:32     501     4       10      0
997 650     San Francisco   90      0       2002-01-09 11:31:58     342     0000-00-00 00:00:00     -1      1       24      1
998 333     tubs    99      2       2002-01-09 11:34:53     501     2002-01-09 11:34:53     500     3       10      0
999 delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or  (t1.carrier_id=90 and t2.number is null);
1000 select * from t1;
1001 number  cname   carrier_id      privacy last_mod_date   last_mod_id     last_app_date   last_app_id     version assigned_scps   status
1002 6014911113      SudzCarwash     520     1       2002-01-02 11:52:34     500     2002-01-02 11:52:59     501     33      32768   0
1003 333     tubs    99      2       2002-01-09 11:34:40     501     2002-01-09 11:34:40     500     3       10      0
1004 select * from t2;
1005 number  cname   carrier_id      privacy last_mod_date   last_mod_id     last_app_date   last_app_id     version assigned_scps   status
1006 333     tubs    99      2       2002-01-09 11:34:53     501     2002-01-09 11:34:53     500     3       10      0
1007 select * from t2;
1008 number  cname   carrier_id      privacy last_mod_date   last_mod_id     last_app_date   last_app_id     version assigned_scps   status
1009 333     tubs    99      2       2002-01-09 11:34:53     501     2002-01-09 11:34:53     500     3       10      0
1010 drop table t1,t2;
1011 create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
1012 BEGIN;
1013 SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
1014 SELECT @@tx_isolation,@@global.tx_isolation;
1015 @@tx_isolation  @@global.tx_isolation
1016 SERIALIZABLE    REPEATABLE-READ
1017 insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David');
1018 select id, code, name from t1 order by id;
1019 id      code    name
1020 1       1       Tim
1021 2       1       Monty
1022 3       2       David
1023 COMMIT;
1024 BEGIN;
1025 SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
1026 insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha');
1027 select id, code, name from t1 order by id;
1028 id      code    name
1029 1       1       Tim
1030 2       1       Monty
1031 3       2       David
1032 4       2       Erik
1033 5       3       Sasha
1034 COMMIT;
1035 SET binlog_format='MIXED';
1036 BEGIN;
1037 SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
1038 insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt');
1039 select id, code, name from t1 order by id;
1040 id      code    name
1041 1       1       Tim
1042 2       1       Monty
1043 3       2       David
1044 4       2       Erik
1045 5       3       Sasha
1046 6       3       Jeremy
1047 7       4       Matt
1048 COMMIT;
1049 DROP TABLE t1;
1050 create table t1 (n int(10), d int(10)) engine=innodb;
1051 create table t2 (n int(10), d int(10)) engine=innodb;
1052 insert into t1 values(1,1),(1,2);
1053 insert into t2 values(1,10),(2,20);
1054 UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
1055 select * from t1;
1056 n       d
1057 1       10
1058 1       10
1059 select * from t2;
1060 n       d
1061 1       30
1062 2       20
1063 drop table t1,t2;
1064 drop table if exists t1, t2;
1065 CREATE TABLE t1 (a int, PRIMARY KEY (a));
1066 CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
1067 create trigger trg_del_t2 after  delete on t2 for each row
1068 insert into t1 values (1);
1069 insert into t1 values (1);
1070 insert into t2 values (1),(2);
1071 delete t2 from t2;
1072 ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
1073 select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
1074 count(*)
1076 drop table t1, t2;
1077 drop table if exists t1, t2;
1078 CREATE TABLE t1 (a int, PRIMARY KEY (a));
1079 CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
1080 create trigger trg_del_t2 after  delete on t2 for each row
1081 insert into t1 values (1);
1082 insert into t1 values (1);
1083 insert into t2 values (1),(2);
1084 delete t2 from t2;
1085 ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
1086 select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
1087 count(*)
1089 drop table t1, t2;
1090 create table t1 (a int, b int) engine=innodb;
1091 insert into t1 values(20,null);
1092 select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
1093 t2.b=t3.a;
1094 b       ifnull(t2.b,"this is null")
1095 NULL    this is null
1096 select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
1097 t2.b=t3.a order by 1;
1098 b       ifnull(t2.b,"this is null")
1099 NULL    this is null
1100 insert into t1 values(10,null);
1101 select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
1102 t2.b=t3.a order by 1;
1103 b       ifnull(t2.b,"this is null")
1104 NULL    this is null
1105 NULL    this is null
1106 drop table t1;
1107 create table t1 (a varchar(10) not null) engine=myisam;
1108 create table t2 (b varchar(10) not null unique) engine=innodb;
1109 select t1.a from t1,t2 where t1.a=t2.b;
1111 drop table t1,t2;
1112 create table t1 (a int not null, b int, primary key (a)) engine = innodb;
1113 create table t2 (a int not null, b int, primary key (a)) engine = innodb;
1114 insert into t1 values (10, 20);
1115 insert into t2 values (10, 20);
1116 update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10;
1117 drop table t1,t2;
1118 CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
1119 CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (t1_id) REFERENCES t1(id)  ON DELETE CASCADE ) ENGINE=INNODB;
1120 insert into t1 set id=1;
1121 insert into t2 set id=1, t1_id=1;
1122 delete t1,t2 from t1,t2 where t1.id=t2.t1_id;
1123 select * from t1;
1125 select * from t2;
1126 id      t1_id
1127 drop table t2,t1;
1128 CREATE TABLE t1(id INT NOT NULL,  PRIMARY KEY (id)) ENGINE=INNODB;
1129 CREATE TABLE t2(id  INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id)  ) ENGINE=INNODB;
1130 INSERT INTO t1 VALUES(1);
1131 INSERT INTO t2 VALUES(1, 1);
1132 SELECT * from t1;
1135 UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1;
1136 SELECT * from t1;
1139 UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id;
1140 SELECT * from t1;
1143 DROP TABLE t1,t2;
1144 set autocommit=0;
1145 CREATE TABLE t1 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
1146 CREATE TABLE t2 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
1147 CREATE TABLE t3 (id1 CHAR(15) NOT NULL, id2 CHAR(15) NOT NULL, PRIMARY KEY(id1, id2)) ENGINE=InnoDB;
1148 INSERT INTO t3 VALUES("my-test-1", "my-test-2");
1149 COMMIT;
1150 INSERT INTO t1 VALUES("this-key", "will disappear");
1151 INSERT INTO t2 VALUES("this-key", "will also disappear");
1152 DELETE FROM t3 WHERE id1="my-test-1";
1153 SELECT * FROM t1;
1154 id      value
1155 this-key        will disappear
1156 SELECT * FROM t2;
1157 id      value
1158 this-key        will also disappear
1159 SELECT * FROM t3;
1160 id1     id2
1161 ROLLBACK;
1162 SELECT * FROM t1;
1163 id      value
1164 SELECT * FROM t2;
1165 id      value
1166 SELECT * FROM t3;
1167 id1     id2
1168 my-test-1       my-test-2
1169 SELECT * FROM t3 WHERE id1="my-test-1" LOCK IN SHARE MODE;
1170 id1     id2
1171 my-test-1       my-test-2
1172 COMMIT;
1173 set autocommit=1;
1174 DROP TABLE t1,t2,t3;
1175 CREATE TABLE t1 (a int not null primary key, b int not null, unique (b)) engine=innodb;
1176 INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
1177 UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000;
1178 SELECT * from t1;
1179 a       b
1180 1       1
1181 102     2
1182 103     3
1183 4       4
1184 5       5
1185 6       6
1186 7       7
1187 8       8
1188 9       9
1189 drop table t1;
1190 CREATE TABLE t2 (   NEXT_T         BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM;
1191 CREATE TABLE t1 (  B_ID           INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB;
1192 SET AUTOCOMMIT=0;
1193 INSERT INTO t1 ( B_ID ) VALUES ( 1 );
1194 INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
1195 ROLLBACK;
1196 Warnings:
1197 Warning 1196    Some non-transactional changed tables couldn't be rolled back
1198 SELECT * FROM t1;
1199 B_ID
1200 drop table  t1,t2;
1201 create table t1  ( pk         int primary key,    parent     int not null,    child      int not null,       index (parent)  ) engine = innodb;
1202 insert into t1 values   (1,0,4),  (2,1,3),  (3,2,1),  (4,1,2);
1203 select distinct  parent,child   from t1   order by parent;
1204 parent  child
1205 0       4
1206 1       2
1207 1       3
1208 2       1
1209 drop table t1;
1210 create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=innodb;
1211 create table t2 (a int not null auto_increment primary key, b int);
1212 insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
1213 insert into t2 (a) select b from t1;
1214 insert into t1 (b) select b from t2;
1215 insert into t2 (a) select b from t1;
1216 insert into t1 (a) select b from t2;
1217 insert into t2 (a) select b from t1;
1218 insert into t1 (a) select b from t2;
1219 insert into t2 (a) select b from t1;
1220 insert into t1 (a) select b from t2;
1221 insert into t2 (a) select b from t1;
1222 insert into t1 (a) select b from t2;
1223 select count(*) from t1;
1224 count(*)
1226 explain select * from t1 where c between 1 and 2500;
1227 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1228 1       SIMPLE  t1      range   c       c       5       NULL    #       Using where
1229 update t1 set c=a;
1230 explain select * from t1 where c between 1 and 2500;
1231 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1232 1       SIMPLE  t1      ALL     c       NULL    NULL    NULL    #       Using where
1233 drop table t1,t2;
1234 create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=innodb;
1235 insert into t1 (id) values (null),(null),(null),(null),(null);
1236 update t1 set fk=69 where fk is null order by id limit 1;
1237 SELECT * from t1;
1238 id      fk
1239 2       NULL
1240 3       NULL
1241 4       NULL
1242 5       NULL
1243 1       69
1244 drop table t1;
1245 create table t1 (a int not null, b int not null, key (a));
1246 insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
1247 SET @tmp=0;
1248 update t1 set b=(@tmp:=@tmp+1) order by a;
1249 update t1 set b=99 where a=1 order by b asc limit 1;
1250 update t1 set b=100 where a=1 order by b desc limit 2;
1251 update t1 set a=a+10+b where a=1 order by b;
1252 select * from t1 order by a,b;
1253 a       b
1254 2       4
1255 2       5
1256 2       6
1257 3       7
1258 3       8
1259 3       9
1260 3       10
1261 3       11
1262 3       12
1263 13      2
1264 111     100
1265 111     100
1266 drop table t1;
1267 create table t1 ( c char(8) not null ) engine=innodb;
1268 insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
1269 insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
1270 alter table t1 add b char(8) not null;
1271 alter table t1 add a char(8) not null;
1272 alter table t1 add primary key (a,b,c);
1273 update t1 set a=c, b=c;
1274 create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb;
1275 insert into t2 select * from t1;
1276 delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
1277 drop table t1,t2;
1278 SET AUTOCOMMIT=1;
1279 create table t1 (a integer auto_increment primary key) engine=innodb;
1280 insert into t1 (a) values (NULL),(NULL);
1281 truncate table t1;
1282 insert into t1 (a) values (NULL),(NULL);
1283 SELECT * from t1;
1287 drop table t1;
1288 CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) ENGINE=INNODB;
1289 CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`)  ON DELETE CASCADE ) ENGINE=INNODB;
1290 drop table t2,t1;
1291 create table `t1` (`id` int( 11 ) not null  ,primary key ( `id` )) engine = innodb;
1292 insert into `t1`values ( 1 ) ;
1293 create table `t2` (`id` int( 11 ) not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = innodb;
1294 insert into `t2`values ( 1 ) ;
1295 create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb;
1296 insert into `t3`values ( 1 ) ;
1297 delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
1298 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
1299 update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
1300 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
1301 update t3 set  t3.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
1302 ERROR 42S22: Unknown column 't1.id' in 'where clause'
1303 drop table t3,t2,t1;
1304 CREATE TABLE t1 (
1305 c1 VARCHAR(8), c2 VARCHAR(8),
1306 PRIMARY KEY (c1, c2)
1307 ) ENGINE=InnoDB;
1308 CREATE TABLE t2 (
1309 c0 INT PRIMARY KEY,
1310 c1 VARCHAR(8) UNIQUE,
1311 FOREIGN KEY (c1) REFERENCES t1 (c1) ON UPDATE CASCADE
1312 ) ENGINE=InnoDB;
1313 INSERT INTO t1 VALUES ('old', 'somevalu'), ('other', 'anyvalue');
1314 INSERT INTO t2 VALUES (10, 'old'), (20, 'other');
1315 UPDATE t1 SET c1 = 'other' WHERE c1 = 'old';
1316 ERROR 23000: Upholding foreign key constraints for table 't1', entry 'other-somevalu', key 2 would lead to a duplicate entry
1317 DROP TABLE t2,t1;
1318 create table t1(
1319 id int primary key,
1320 pid int,
1321 index(pid),
1322 foreign key(pid) references t1(id) on delete cascade) engine=innodb;
1323 insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
1324 (8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
1325 delete from t1 where id=0;
1326 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `t1` (`id`) ON DELETE CASCADE)
1327 delete from t1 where id=15;
1328 delete from t1 where id=0;
1329 drop table t1;
1330 CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB;
1331 CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
1332 (stamp))ENGINE=InnoDB;
1333 insert into t1 values (1),(2),(3);
1334 insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
1335 Warnings:
1336 Warning 1265    Data truncated for column 'stamp' at row 3
1337 SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
1338 '20020204120000' GROUP BY col1;
1339 col1
1344 drop table t1,t2;
1345 CREATE TABLE t1 (
1346 `id` int(10) unsigned NOT NULL auto_increment,
1347 `id_object` int(10) unsigned default '0',
1348 `id_version` int(10) unsigned NOT NULL default '1',
1349 `label` varchar(100) NOT NULL default '',
1350 `description` text,
1351 PRIMARY KEY  (`id`),
1352 KEY `id_object` (`id_object`),
1353 KEY `id_version` (`id_version`)
1354 ) ENGINE=InnoDB;
1355 INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL);
1356 CREATE TABLE t2 (
1357 `id` int(10) unsigned NOT NULL auto_increment,
1358 `id_version` int(10) unsigned NOT NULL default '1',
1359 PRIMARY KEY  (`id`),
1360 KEY `id_version` (`id_version`)
1361 ) ENGINE=InnoDB;
1362 INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9");
1363 SELECT t2.id, t1.`label` FROM t2 INNER JOIN
1364 (SELECT t1.id_object as id_object FROM t1 WHERE t1.`label` LIKE '%test%') AS lbl 
1365 ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
1366 id      label
1367 3382    Test
1368 102     Le Pekin (Test)
1369 1794    Test de resto
1370 1822    Test 3
1371 3524    Societe Test
1372 3525    Fournisseur Test
1373 drop table t1,t2;
1374 create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam;
1375 create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb;
1376 create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb;
1377 insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
1378 insert t2 select * from t1;
1379 insert t3 select * from t1;
1380 checksum table t1, t2, t3, t4 quick;
1381 Table   Checksum
1382 test.t1 2948697075
1383 test.t2 NULL
1384 test.t3 NULL
1385 test.t4 NULL
1386 Warnings:
1387 Error   1146    Table 'test.t4' doesn't exist
1388 checksum table t1, t2, t3, t4;
1389 Table   Checksum
1390 test.t1 2948697075
1391 test.t2 2948697075
1392 test.t3 2948697075
1393 test.t4 NULL
1394 Warnings:
1395 Error   1146    Table 'test.t4' doesn't exist
1396 checksum table t1, t2, t3, t4 extended;
1397 Table   Checksum
1398 test.t1 2948697075
1399 test.t2 2948697075
1400 test.t3 2948697075
1401 test.t4 NULL
1402 Warnings:
1403 Error   1146    Table 'test.t4' doesn't exist
1404 drop table t1,t2,t3;
1405 create table t1 (id int,  name char(10) not null,  name2 char(10) not null) engine=innodb;
1406 insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
1407 select trim(name2) from t1  union all  select trim(name) from t1 union all select trim(id) from t1;
1408 trim(name2)
1412 first
1413 second
1414 third
1418 drop table t1;
1419 create table t1 (a int) engine=innodb;
1420 create table t2 like t1;
1421 drop table t1,t2;
1422 create table t1 (id int(11) not null, id2 int(11) not null, unique (id,id2)) engine=innodb;
1423 create table t2 (id int(11) not null, constraint t1_id_fk foreign key ( id ) references t1 (id)) engine = innodb;
1424 show create table t1;
1425 Table   Create Table
1426 t1      CREATE TABLE `t1` (
1427   `id` int(11) NOT NULL,
1428   `id2` int(11) NOT NULL,
1429   UNIQUE KEY `id` (`id`,`id2`)
1430 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1431 show create table t2;
1432 Table   Create Table
1433 t2      CREATE TABLE `t2` (
1434   `id` int(11) NOT NULL,
1435   KEY `t1_id_fk` (`id`),
1436   CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1437 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1438 create index id on t2 (id);
1439 show create table t2;
1440 Table   Create Table
1441 t2      CREATE TABLE `t2` (
1442   `id` int(11) NOT NULL,
1443   KEY `id` (`id`),
1444   CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1445 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1446 create index id2 on t2 (id);
1447 show create table t2;
1448 Table   Create Table
1449 t2      CREATE TABLE `t2` (
1450   `id` int(11) NOT NULL,
1451   KEY `id` (`id`),
1452   KEY `id2` (`id`),
1453   CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1454 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1455 drop index id2 on t2;
1456 drop index id on t2;
1457 ERROR HY000: Cannot drop index 'id': needed in a foreign key constraint
1458 show create table t2;
1459 Table   Create Table
1460 t2      CREATE TABLE `t2` (
1461   `id` int(11) NOT NULL,
1462   KEY `id` (`id`),
1463   CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1464 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1465 drop table t2;
1466 create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb;
1467 show create table t2;
1468 Table   Create Table
1469 t2      CREATE TABLE `t2` (
1470   `id` int(11) NOT NULL,
1471   `id2` int(11) NOT NULL,
1472   KEY `t1_id_fk` (`id`,`id2`),
1473   CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`)
1474 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1475 create unique index id on t2 (id,id2);
1476 show create table t2;
1477 Table   Create Table
1478 t2      CREATE TABLE `t2` (
1479   `id` int(11) NOT NULL,
1480   `id2` int(11) NOT NULL,
1481   UNIQUE KEY `id` (`id`,`id2`),
1482   CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`)
1483 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1484 drop table t2;
1485 create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
1486 show create table t2;
1487 Table   Create Table
1488 t2      CREATE TABLE `t2` (
1489   `id` int(11) NOT NULL,
1490   `id2` int(11) NOT NULL,
1491   UNIQUE KEY `id` (`id`,`id2`),
1492   KEY `t1_id_fk` (`id2`,`id`),
1493   CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`)
1494 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1495 drop table t2;
1496 create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb;
1497 show create table t2;
1498 Table   Create Table
1499 t2      CREATE TABLE `t2` (
1500   `id` int(11) NOT NULL,
1501   `id2` int(11) NOT NULL,
1502   UNIQUE KEY `id` (`id`,`id2`),
1503   CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1504 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1505 drop table t2;
1506 create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
1507 show create table t2;
1508 Table   Create Table
1509 t2      CREATE TABLE `t2` (
1510   `id` int(11) NOT NULL,
1511   `id2` int(11) NOT NULL,
1512   UNIQUE KEY `id` (`id`,`id2`),
1513   KEY `t1_id_fk` (`id2`,`id`),
1514   CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`)
1515 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1516 drop table t2;
1517 create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = innodb;
1518 show create table t2;
1519 Table   Create Table
1520 t2      CREATE TABLE `t2` (
1521   `id` int(11) NOT NULL AUTO_INCREMENT,
1522   `id2` int(11) NOT NULL,
1523   PRIMARY KEY (`id`),
1524   KEY `id` (`id`,`id2`),
1525   CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1526 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1527 drop table t2;
1528 create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb;
1529 show create table t2;
1530 Table   Create Table
1531 t2      CREATE TABLE `t2` (
1532   `id` int(11) NOT NULL AUTO_INCREMENT,
1533   `id2` int(11) NOT NULL,
1534   KEY `t1_id_fk` (`id`),
1535   CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1536 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1537 alter table t2 add index id_test (id), add index id_test2 (id,id2);
1538 show create table t2;
1539 Table   Create Table
1540 t2      CREATE TABLE `t2` (
1541   `id` int(11) NOT NULL AUTO_INCREMENT,
1542   `id2` int(11) NOT NULL,
1543   KEY `id_test` (`id`),
1544   KEY `id_test2` (`id`,`id2`),
1545   CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1546 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1547 drop table t2;
1548 create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
1549 ERROR 42000: Incorrect foreign key definition for 't1_id_fk': Key reference and table reference don't match
1550 create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb;
1551 show create table t2;
1552 Table   Create Table
1553 t2      CREATE TABLE `t2` (
1554   `a` int(11) NOT NULL AUTO_INCREMENT,
1555   `b` int(11) DEFAULT NULL,
1556   PRIMARY KEY (`a`),
1557   UNIQUE KEY `b_2` (`b`),
1558   KEY `b` (`b`),
1559   CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
1560 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1561 drop table t2;
1562 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;
1563 show create table t2;
1564 Table   Create Table
1565 t2      CREATE TABLE `t2` (
1566   `a` int(11) NOT NULL AUTO_INCREMENT,
1567   `b` int(11) DEFAULT NULL,
1568   PRIMARY KEY (`a`),
1569   UNIQUE KEY `b` (`b`),
1570   CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`),
1571   CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
1572 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1573 drop table t2, t1;
1574 create table t1 (c char(10), index (c,c)) engine=innodb;
1575 ERROR 42S21: Duplicate column name 'c'
1576 create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
1577 ERROR 42S21: Duplicate column name 'c1'
1578 create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb;
1579 ERROR 42S21: Duplicate column name 'c1'
1580 create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb;
1581 ERROR 42S21: Duplicate column name 'c1'
1582 create table t1 (c1 char(10), c2 char(10)) engine=innodb;
1583 alter table t1 add key (c1,c1);
1584 ERROR 42S21: Duplicate column name 'c1'
1585 alter table t1 add key (c2,c1,c1);
1586 ERROR 42S21: Duplicate column name 'c1'
1587 alter table t1 add key (c1,c2,c1);
1588 ERROR 42S21: Duplicate column name 'c1'
1589 alter table t1 add key (c1,c1,c2);
1590 ERROR 42S21: Duplicate column name 'c1'
1591 drop table t1;
1592 create table t1(a int(1) , b int(1)) engine=innodb;
1593 insert into t1 values ('1111', '3333');
1594 select distinct concat(a, b) from t1;
1595 concat(a, b)
1596 11113333
1597 drop table t1;
1598 CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
1599 SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
1600 ERROR HY000: The used table type doesn't support FULLTEXT indexes
1601 DROP TABLE t1;
1602 CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY  (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
1603 INSERT INTO t1 VALUES (1),(2),(3);
1604 CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY  (b_id), KEY  (b_a), 
1605 CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1;
1606 INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2);
1607 SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz;
1608 a_id    b_list
1609 1       1,2,3
1610 2       4,5
1611 3       NULL
1612 DROP TABLE t2;
1613 DROP TABLE t1;
1614 create temporary table t1 (a int) engine=innodb;
1615 insert into t1 values (4711);
1616 truncate t1;
1617 insert into t1 values (42);
1618 select * from t1;
1621 drop table t1;
1622 create table t1 (a int) engine=innodb;
1623 insert into t1 values (4711);
1624 truncate t1;
1625 insert into t1 values (42);
1626 select * from t1;
1629 drop table t1;
1630 create table t1 (a int not null, b int not null, c blob not null, d int not null, e int, primary key (a,b,c(255),d)) engine=innodb;
1631 insert into t1 values (2,2,"b",2,2),(1,1,"a",1,1),(3,3,"ab",3,3);
1632 select * from t1 order by a,b,c,d;
1633 a       b       c       d       e
1634 1       1       a       1       1
1635 2       2       b       2       2
1636 3       3       ab      3       3
1637 explain select * from t1 order by a,b,c,d;
1638 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1639 1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    3       Using filesort
1640 drop table t1;
1641 create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
1642 insert into t1 values ('8', '6'), ('4', '7');
1643 select min(a) from t1;
1644 min(a)
1646 select min(b) from t1 where a='8';
1647 min(b)
1649 drop table t1;
1650 create table t1 (x bigint unsigned not null primary key) engine=innodb;
1651 insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1);
1652 select * from t1;
1654 18446744073709551600
1655 18446744073709551601
1656 select count(*) from t1 where x>0;
1657 count(*)
1659 select count(*) from t1 where x=0;
1660 count(*)
1662 select count(*) from t1 where x<0;
1663 count(*)
1665 select count(*) from t1 where x < -16;
1666 count(*)
1668 select count(*) from t1 where x = -16;
1669 count(*)
1671 explain select count(*) from t1 where x > -16;
1672 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1673 1       SIMPLE  t1      index   PRIMARY PRIMARY 8       NULL    2       Using where; Using index
1674 select count(*) from t1 where x > -16;
1675 count(*)
1677 select * from t1 where x > -16;
1679 18446744073709551600
1680 18446744073709551601
1681 select count(*) from t1 where x = 18446744073709551601;
1682 count(*)
1684 drop table t1;
1685 SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total';
1686 variable_value
1687 8191
1688 SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size';
1689 variable_value
1690 16384
1691 SELECT variable_value - @innodb_rows_deleted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_deleted';
1692 variable_value - @innodb_rows_deleted_orig
1694 SELECT variable_value - @innodb_rows_inserted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_inserted';
1695 variable_value - @innodb_rows_inserted_orig
1696 1071
1697 SELECT variable_value - @innodb_rows_updated_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_updated';
1698 variable_value - @innodb_rows_updated_orig
1700 SELECT variable_value - @innodb_row_lock_waits_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_waits';
1701 variable_value - @innodb_row_lock_waits_orig
1703 SELECT variable_value - @innodb_row_lock_current_waits_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_current_waits';
1704 variable_value - @innodb_row_lock_current_waits_orig
1706 SELECT variable_value - @innodb_row_lock_time_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time';
1707 variable_value - @innodb_row_lock_time_orig
1709 SELECT variable_value - @innodb_row_lock_time_max_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_max';
1710 variable_value - @innodb_row_lock_time_max_orig
1712 SELECT variable_value - @innodb_row_lock_time_avg_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg';
1713 variable_value - @innodb_row_lock_time_avg_orig
1715 SET @innodb_sync_spin_loops_orig = @@innodb_sync_spin_loops;
1716 show variables like "innodb_sync_spin_loops";
1717 Variable_name   Value
1718 innodb_sync_spin_loops  30
1719 set global innodb_sync_spin_loops=1000;
1720 show variables like "innodb_sync_spin_loops";
1721 Variable_name   Value
1722 innodb_sync_spin_loops  1000
1723 set global innodb_sync_spin_loops=0;
1724 show variables like "innodb_sync_spin_loops";
1725 Variable_name   Value
1726 innodb_sync_spin_loops  0
1727 set global innodb_sync_spin_loops=20;
1728 show variables like "innodb_sync_spin_loops";
1729 Variable_name   Value
1730 innodb_sync_spin_loops  20
1731 set global innodb_sync_spin_loops=@innodb_sync_spin_loops_orig;
1732 show variables like "innodb_thread_concurrency";
1733 Variable_name   Value
1734 innodb_thread_concurrency       0
1735 set global innodb_thread_concurrency=1001;
1736 Warnings:
1737 Warning 1292    Truncated incorrect thread_concurrency value: '1001'
1738 show variables like "innodb_thread_concurrency";
1739 Variable_name   Value
1740 innodb_thread_concurrency       1000
1741 set global innodb_thread_concurrency=0;
1742 show variables like "innodb_thread_concurrency";
1743 Variable_name   Value
1744 innodb_thread_concurrency       0
1745 set global innodb_thread_concurrency=16;
1746 show variables like "innodb_thread_concurrency";
1747 Variable_name   Value
1748 innodb_thread_concurrency       16
1749 show variables like "innodb_concurrency_tickets";
1750 Variable_name   Value
1751 innodb_concurrency_tickets      500
1752 set global innodb_concurrency_tickets=1000;
1753 show variables like "innodb_concurrency_tickets";
1754 Variable_name   Value
1755 innodb_concurrency_tickets      1000
1756 set global innodb_concurrency_tickets=0;
1757 Warnings:
1758 Warning 1292    Truncated incorrect concurrency_tickets value: '0'
1759 show variables like "innodb_concurrency_tickets";
1760 Variable_name   Value
1761 innodb_concurrency_tickets      1
1762 set global innodb_concurrency_tickets=500;
1763 show variables like "innodb_concurrency_tickets";
1764 Variable_name   Value
1765 innodb_concurrency_tickets      500
1766 show variables like "innodb_thread_sleep_delay";
1767 Variable_name   Value
1768 innodb_thread_sleep_delay       10000
1769 set global innodb_thread_sleep_delay=100000;
1770 show variables like "innodb_thread_sleep_delay";
1771 Variable_name   Value
1772 innodb_thread_sleep_delay       100000
1773 set global innodb_thread_sleep_delay=0;
1774 show variables like "innodb_thread_sleep_delay";
1775 Variable_name   Value
1776 innodb_thread_sleep_delay       0
1777 set global innodb_thread_sleep_delay=10000;
1778 show variables like "innodb_thread_sleep_delay";
1779 Variable_name   Value
1780 innodb_thread_sleep_delay       10000
1781 set storage_engine=INNODB;
1782 set session old_alter_table=1;
1783 drop table if exists t1,t2,t3;
1784 --- Testing varchar ---
1785 --- Testing varchar ---
1786 create table t1 (v varchar(10), c char(10), t text);
1787 insert into t1 values('+ ', '+ ', '+ ');
1788 set @a=repeat(' ',20);
1789 insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
1790 Warnings:
1791 Note    1265    Data truncated for column 'v' at row 1
1792 select concat('*',v,'*',c,'*',t,'*') from t1;
1793 concat('*',v,'*',c,'*',t,'*')
1794 *+ *+*+ *
1795 *+         *+*+                    *
1796 show create table t1;
1797 Table   Create Table
1798 t1      CREATE TABLE `t1` (
1799   `v` varchar(10) DEFAULT NULL,
1800   `c` char(10) DEFAULT NULL,
1801   `t` text
1802 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1803 create table t2 like t1;
1804 show create table t2;
1805 Table   Create Table
1806 t2      CREATE TABLE `t2` (
1807   `v` varchar(10) DEFAULT NULL,
1808   `c` char(10) DEFAULT NULL,
1809   `t` text
1810 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1811 create table t3 select * from t1;
1812 show create table t3;
1813 Table   Create Table
1814 t3      CREATE TABLE `t3` (
1815   `v` varchar(10) DEFAULT NULL,
1816   `c` char(10) DEFAULT NULL,
1817   `t` text
1818 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1819 alter table t1 modify c varchar(10);
1820 show create table t1;
1821 Table   Create Table
1822 t1      CREATE TABLE `t1` (
1823   `v` varchar(10) DEFAULT NULL,
1824   `c` varchar(10) DEFAULT NULL,
1825   `t` text
1826 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1827 alter table t1 modify v char(10);
1828 show create table t1;
1829 Table   Create Table
1830 t1      CREATE TABLE `t1` (
1831   `v` char(10) DEFAULT NULL,
1832   `c` varchar(10) DEFAULT NULL,
1833   `t` text
1834 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1835 alter table t1 modify t varchar(10);
1836 Warnings:
1837 Note    1265    Data truncated for column 't' at row 2
1838 show create table t1;
1839 Table   Create Table
1840 t1      CREATE TABLE `t1` (
1841   `v` char(10) DEFAULT NULL,
1842   `c` varchar(10) DEFAULT NULL,
1843   `t` varchar(10) DEFAULT NULL
1844 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1845 select concat('*',v,'*',c,'*',t,'*') from t1;
1846 concat('*',v,'*',c,'*',t,'*')
1847 *+*+*+ *
1848 *+*+*+         *
1849 drop table t1,t2,t3;
1850 create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10)));
1851 show create table t1;
1852 Table   Create Table
1853 t1      CREATE TABLE `t1` (
1854   `v` varchar(10) DEFAULT NULL,
1855   `c` char(10) DEFAULT NULL,
1856   `t` text,
1857   KEY `v` (`v`),
1858   KEY `c` (`c`),
1859   KEY `t` (`t`(10))
1860 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
1861 select count(*) from t1;
1862 count(*)
1864 insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
1865 select count(*) from t1 where v='a';
1866 count(*)
1868 select count(*) from t1 where c='a';
1869 count(*)
1871 select count(*) from t1 where t='a';
1872 count(*)
1874 select count(*) from t1 where v='a  ';
1875 count(*)
1877 select count(*) from t1 where c='a  ';
1878 count(*)
1880 select count(*) from t1 where t='a  ';
1881 count(*)
1883 select count(*) from t1 where v between 'a' and 'a ';
1884 count(*)
1886 select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
1887 count(*)
1889 select count(*) from t1 where v like 'a%';
1890 count(*)
1892 select count(*) from t1 where c like 'a%';
1893 count(*)
1895 select count(*) from t1 where t like 'a%';
1896 count(*)
1898 select count(*) from t1 where v like 'a %';
1899 count(*)
1901 explain select count(*) from t1 where v='a  ';
1902 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1903 1       SIMPLE  t1      ref     v       v       13      const   #       Using where; Using index
1904 explain select count(*) from t1 where c='a  ';
1905 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1906 1       SIMPLE  t1      ref     c       c       11      const   #       Using where; Using index
1907 explain select count(*) from t1 where t='a  ';
1908 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1909 1       SIMPLE  t1      ref     t       t       13      const   #       Using where
1910 explain select count(*) from t1 where v like 'a%';
1911 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1912 1       SIMPLE  t1      range   v       v       13      NULL    #       Using where; Using index
1913 explain select count(*) from t1 where v between 'a' and 'a ';
1914 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1915 1       SIMPLE  t1      ref     v       v       13      const   #       Using where; Using index
1916 explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
1917 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1918 1       SIMPLE  t1      ref     v       v       13      const   #       Using where; Using index
1919 alter table t1 add unique(v);
1920 ERROR 23000: Duplicate entry '{ ' for key 'v_2'
1921 alter table t1 add key(v);
1922 select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
1924 *a*a*a*
1925 *a *a*a *
1926 *a  *a*a  *
1927 *a   *a*a   *
1928 *a    *a*a    *
1929 *a     *a*a     *
1930 *a      *a*a      *
1931 *a       *a*a       *
1932 *a        *a*a        *
1933 *a         *a*a         *
1934 explain select * from t1 where v='a';
1935 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1936 1       SIMPLE  t1      ref     v,v_2   #       13      const   #       Using where
1937 select v,count(*) from t1 group by v limit 10;
1938 v       count(*)
1939 a\x01      1
1940 a       10
1941 b       10
1942 c       10
1943 d       10
1944 e       10
1945 f       10
1946 g       10
1947 h       10
1948 i       10
1949 select v,count(t) from t1 group by v limit 10;
1950 v       count(t)
1951 a\x01      1
1952 a       10
1953 b       10
1954 c       10
1955 d       10
1956 e       10
1957 f       10
1958 g       10
1959 h       10
1960 i       10
1961 select v,count(c) from t1 group by v limit 10;
1962 v       count(c)
1963 a\x01      1
1964 a       10
1965 b       10
1966 c       10
1967 d       10
1968 e       10
1969 f       10
1970 g       10
1971 h       10
1972 i       10
1973 select sql_big_result v,count(t) from t1 group by v limit 10;
1974 v       count(t)
1975 a\x01      1
1976 a       10
1977 b       10
1978 c       10
1979 d       10
1980 e       10
1981 f       10
1982 g       10
1983 h       10
1984 i       10
1985 select sql_big_result v,count(c) from t1 group by v limit 10;
1986 v       count(c)
1987 a\x01      1
1988 a       10
1989 b       10
1990 c       10
1991 d       10
1992 e       10
1993 f       10
1994 g       10
1995 h       10
1996 i       10
1997 select c,count(*) from t1 group by c limit 10;
1998 c       count(*)
1999 a\x01      1
2000 a       10
2001 b       10
2002 c       10
2003 d       10
2004 e       10
2005 f       10
2006 g       10
2007 h       10
2008 i       10
2009 select c,count(t) from t1 group by c limit 10;
2010 c       count(t)
2011 a\x01      1
2012 a       10
2013 b       10
2014 c       10
2015 d       10
2016 e       10
2017 f       10
2018 g       10
2019 h       10
2020 i       10
2021 select sql_big_result c,count(t) from t1 group by c limit 10;
2022 c       count(t)
2023 a\x01      1
2024 a       10
2025 b       10
2026 c       10
2027 d       10
2028 e       10
2029 f       10
2030 g       10
2031 h       10
2032 i       10
2033 select t,count(*) from t1 group by t limit 10;
2034 t       count(*)
2035 a\x01      1
2036 a       10
2037 b       10
2038 c       10
2039 d       10
2040 e       10
2041 f       10
2042 g       10
2043 h       10
2044 i       10
2045 select t,count(t) from t1 group by t limit 10;
2046 t       count(t)
2047 a\x01      1
2048 a       10
2049 b       10
2050 c       10
2051 d       10
2052 e       10
2053 f       10
2054 g       10
2055 h       10
2056 i       10
2057 select sql_big_result t,count(t) from t1 group by t limit 10;
2058 t       count(t)
2059 a\x01      1
2060 a       10
2061 b       10
2062 c       10
2063 d       10
2064 e       10
2065 f       10
2066 g       10
2067 h       10
2068 i       10
2069 alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
2070 show create table t1;
2071 Table   Create Table
2072 t1      CREATE TABLE `t1` (
2073   `v` varchar(300) DEFAULT NULL,
2074   `c` char(10) DEFAULT NULL,
2075   `t` text,
2076   KEY `c` (`c`),
2077   KEY `t` (`t`(10)),
2078   KEY `v` (`v`)
2079 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
2080 select count(*) from t1 where v='a';
2081 count(*)
2083 select count(*) from t1 where v='a  ';
2084 count(*)
2086 select count(*) from t1 where v between 'a' and 'a ';
2087 count(*)
2089 select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
2090 count(*)
2092 select count(*) from t1 where v like 'a%';
2093 count(*)
2095 select count(*) from t1 where v like 'a %';
2096 count(*)
2098 explain select count(*) from t1 where v='a  ';
2099 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
2100 1       SIMPLE  t1      ref     v       v       303     const   #       Using where; Using index
2101 explain select count(*) from t1 where v like 'a%';
2102 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
2103 1       SIMPLE  t1      range   v       v       303     NULL    #       Using where; Using index
2104 explain select count(*) from t1 where v between 'a' and 'a ';
2105 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
2106 1       SIMPLE  t1      ref     v       v       303     const   #       Using where; Using index
2107 explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
2108 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
2109 1       SIMPLE  t1      ref     v       v       303     const   #       Using where; Using index
2110 explain select * from t1 where v='a';
2111 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
2112 1       SIMPLE  t1      ref     v       v       303     const   #       Using where
2113 select v,count(*) from t1 group by v limit 10;
2114 v       count(*)
2115 a\x01      1
2116 a       10
2117 b       10
2118 c       10
2119 d       10
2120 e       10
2121 f       10
2122 g       10
2123 h       10
2124 i       10
2125 select v,count(t) from t1 group by v limit 10;
2126 v       count(t)
2127 a\x01      1
2128 a       10
2129 b       10
2130 c       10
2131 d       10
2132 e       10
2133 f       10
2134 g       10
2135 h       10
2136 i       10
2137 select sql_big_result v,count(t) from t1 group by v limit 10;
2138 v       count(t)
2139 a\x01      1
2140 a       10
2141 b       10
2142 c       10
2143 d       10
2144 e       10
2145 f       10
2146 g       10
2147 h       10
2148 i       10
2149 alter table t1 drop key v, add key v (v(30));
2150 show create table t1;
2151 Table   Create Table
2152 t1      CREATE TABLE `t1` (
2153   `v` varchar(300) DEFAULT NULL,
2154   `c` char(10) DEFAULT NULL,
2155   `t` text,
2156   KEY `c` (`c`),
2157   KEY `t` (`t`(10)),
2158   KEY `v` (`v`(30))
2159 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
2160 select count(*) from t1 where v='a';
2161 count(*)
2163 select count(*) from t1 where v='a  ';
2164 count(*)
2166 select count(*) from t1 where v between 'a' and 'a ';
2167 count(*)
2169 select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
2170 count(*)
2172 select count(*) from t1 where v like 'a%';
2173 count(*)
2175 select count(*) from t1 where v like 'a %';
2176 count(*)
2178 explain select count(*) from t1 where v='a  ';
2179 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
2180 1       SIMPLE  t1      ref     v       v       33      const   #       Using where
2181 explain select count(*) from t1 where v like 'a%';
2182 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
2183 1       SIMPLE  t1      range   v       v       33      NULL    #       Using where
2184 explain select count(*) from t1 where v between 'a' and 'a ';
2185 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
2186 1       SIMPLE  t1      ref     v       v       33      const   #       Using where
2187 explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
2188 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
2189 1       SIMPLE  t1      ref     v       v       33      const   #       Using where
2190 explain select * from t1 where v='a';
2191 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
2192 1       SIMPLE  t1      ref     v       v       33      const   #       Using where
2193 select v,count(*) from t1 group by v limit 10;
2194 v       count(*)
2195 a\x01      1
2196 a       10
2197 b       10
2198 c       10
2199 d       10
2200 e       10
2201 f       10
2202 g       10
2203 h       10
2204 i       10
2205 select v,count(t) from t1 group by v limit 10;
2206 v       count(t)
2207 a\x01      1
2208 a       10
2209 b       10
2210 c       10
2211 d       10
2212 e       10
2213 f       10
2214 g       10
2215 h       10
2216 i       10
2217 select sql_big_result v,count(t) from t1 group by v limit 10;
2218 v       count(t)
2219 a\x01      1
2220 a       10
2221 b       10
2222 c       10
2223 d       10
2224 e       10
2225 f       10
2226 g       10
2227 h       10
2228 i       10
2229 alter table t1 modify v varchar(600), drop key v, add key v (v);
2230 show create table t1;
2231 Table   Create Table
2232 t1      CREATE TABLE `t1` (
2233   `v` varchar(600) DEFAULT NULL,
2234   `c` char(10) DEFAULT NULL,
2235   `t` text,
2236   KEY `c` (`c`),
2237   KEY `t` (`t`(10)),
2238   KEY `v` (`v`)
2239 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
2240 select v,count(*) from t1 group by v limit 10;
2241 v       count(*)
2242 a\x01      1
2243 a       10
2244 b       10
2245 c       10
2246 d       10
2247 e       10
2248 f       10
2249 g       10
2250 h       10
2251 i       10
2252 select v,count(t) from t1 group by v limit 10;
2253 v       count(t)
2254 a\x01      1
2255 a       10
2256 b       10
2257 c       10
2258 d       10
2259 e       10
2260 f       10
2261 g       10
2262 h       10
2263 i       10
2264 select sql_big_result v,count(t) from t1 group by v limit 10;
2265 v       count(t)
2266 a\x01      1
2267 a       10
2268 b       10
2269 c       10
2270 d       10
2271 e       10
2272 f       10
2273 g       10
2274 h       10
2275 i       10
2276 drop table t1;
2277 create table t1 (a char(10), unique (a));
2278 insert into t1 values ('a   ');
2279 insert into t1 values ('a ');
2280 ERROR 23000: Duplicate entry 'a' for key 'a'
2281 alter table t1 modify a varchar(10);
2282 insert into t1 values ('a '),('a  '),('a   '),('a         ');
2283 ERROR 23000: Duplicate entry 'a ' for key 'a'
2284 insert into t1 values ('a     ');
2285 ERROR 23000: Duplicate entry 'a     ' for key 'a'
2286 insert into t1 values ('a          ');
2287 ERROR 23000: Duplicate entry 'a         ' for key 'a'
2288 insert into t1 values ('a ');
2289 ERROR 23000: Duplicate entry 'a ' for key 'a'
2290 update t1 set a='a  ' where a like 'a%';
2291 select concat(a,'.') from t1;
2292 concat(a,'.')
2293 a  .
2294 update t1 set a='abc    ' where a like 'a ';
2295 select concat(a,'.') from t1;
2296 concat(a,'.')
2297 a  .
2298 update t1 set a='a      ' where a like 'a %';
2299 select concat(a,'.') from t1;
2300 concat(a,'.')
2301 a      .
2302 update t1 set a='a  ' where a like 'a      ';
2303 select concat(a,'.') from t1;
2304 concat(a,'.')
2305 a  .
2306 drop table t1;
2307 create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5)));
2308 show create table t1;
2309 Table   Create Table
2310 t1      CREATE TABLE `t1` (
2311   `v` varchar(10) DEFAULT NULL,
2312   `c` char(10) DEFAULT NULL,
2313   `t` text,
2314   KEY `v` (`v`(5)),
2315   KEY `c` (`c`(5)),
2316   KEY `t` (`t`(5))
2317 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
2318 drop table t1;
2319 create table t1 (v char(10) character set utf8);
2320 show create table t1;
2321 Table   Create Table
2322 t1      CREATE TABLE `t1` (
2323   `v` char(10) CHARACTER SET utf8 DEFAULT NULL
2324 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
2325 drop table t1;
2326 create table t1 (v varchar(10), c char(10)) row_format=fixed;
2327 Warnings:
2328 Warning 1478    InnoDB: assuming ROW_FORMAT=COMPACT.
2329 show create table t1;
2330 Table   Create Table
2331 t1      CREATE TABLE `t1` (
2332   `v` varchar(10) DEFAULT NULL,
2333   `c` char(10) DEFAULT NULL
2334 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
2335 insert into t1 values('a','a'),('a ','a ');
2336 select concat('*',v,'*',c,'*') from t1;
2337 concat('*',v,'*',c,'*')
2338 *a*a*
2339 *a *a*
2340 drop table t1;
2341 create table t1 (v varchar(65530), key(v(10)));
2342 insert into t1 values(repeat('a',65530));
2343 select length(v) from t1 where v=repeat('a',65530);
2344 length(v)
2345 65530
2346 drop table t1;
2347 create table t1(a int, b varchar(12), key ba(b, a));
2348 insert into t1 values (1, 'A'), (20, NULL);
2349 explain select * from t1 where a=20 and b is null;
2350 id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
2351 1       SIMPLE  t1      ref     ba      ba      20      const,const     1       Using where; Using index
2352 select * from t1 where a=20 and b is null;
2353 a       b
2354 20      NULL
2355 drop table t1;
2356 set session old_alter_table=0;
2357 create table t1 (v varchar(65530), key(v));
2358 Warnings:
2359 Warning 1071    Specified key was too long; max key length is 767 bytes
2360 drop table t1;
2361 create table t1 (v varchar(65536));
2362 Warnings:
2363 Note    1246    Converting column 'v' from VARCHAR to TEXT
2364 show create table t1;
2365 Table   Create Table
2366 t1      CREATE TABLE `t1` (
2367   `v` mediumtext
2368 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
2369 drop table t1;
2370 create table t1 (v varchar(65530) character set utf8);
2371 Warnings:
2372 Note    1246    Converting column 'v' from VARCHAR to TEXT
2373 show create table t1;
2374 Table   Create Table
2375 t1      CREATE TABLE `t1` (
2376   `v` mediumtext CHARACTER SET utf8
2377 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
2378 drop table t1;
2379 set storage_engine=MyISAM;
2380 create table t1 (v varchar(16384)) engine=innodb;
2381 drop table t1;
2382 create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
2383 insert into t1 values ('8', '6'), ('4', '7');
2384 select min(a) from t1;
2385 min(a)
2387 select min(b) from t1 where a='8';
2388 min(b)
2390 drop table t1;
2391 CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb;
2392 insert into t1 (b) values (1);
2393 replace into t1 (b) values (2), (1), (3);
2394 select * from t1;
2395 a       b
2396 3       1
2397 2       2
2398 4       3
2399 truncate table t1;
2400 insert into t1 (b) values (1);
2401 replace into t1 (b) values (2);
2402 replace into t1 (b) values (1);
2403 replace into t1 (b) values (3);
2404 select * from t1;
2405 a       b
2406 3       1
2407 2       2
2408 4       3
2409 drop table t1;
2410 create table t1 (rowid int not null auto_increment, val int not null,primary
2411 key (rowid), unique(val)) engine=innodb;
2412 replace into t1 (val) values ('1'),('2');
2413 replace into t1 (val) values ('1'),('2');
2414 insert into t1 (val) values ('1'),('2');
2415 ERROR 23000: Duplicate entry '1' for key 'val'
2416 select * from t1;
2417 rowid   val
2418 3       1
2419 4       2
2420 drop table t1;
2421 create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
2422 insert into t1 (val) values (1);
2423 update t1 set a=2 where a=1;
2424 insert into t1 (val) values (1);
2425 ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
2426 select * from t1;
2427 a       val
2428 2       1
2429 drop table t1;
2430 CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
2431 INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
2432 SELECT GRADE  FROM t1 WHERE GRADE > 160 AND GRADE < 300;
2433 GRADE
2435 SELECT GRADE  FROM t1 WHERE GRADE= 151;
2436 GRADE
2438 DROP TABLE t1;
2439 create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb;
2440 create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb;
2441 insert into t2 values ('aa','cc');
2442 insert into t1 values ('aa','bb'),('aa','cc');
2443 delete t1 from t1,t2 where f1=f3 and f4='cc';
2444 select * from t1;
2445 f1      f2
2446 drop table t1,t2;
2447 CREATE TABLE t1 (
2448 id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
2449 ) ENGINE=InnoDB;
2450 CREATE TABLE t2 (
2451 id INTEGER NOT NULL,
2452 FOREIGN KEY (id) REFERENCES t1 (id)
2453 ) ENGINE=InnoDB;
2454 INSERT INTO t1 (id) VALUES (NULL);
2455 SELECT * FROM t1;
2458 TRUNCATE t1;
2459 INSERT INTO t1 (id) VALUES (NULL);
2460 SELECT * FROM t1;
2463 DELETE FROM t1;
2464 TRUNCATE t1;
2465 INSERT INTO t1 (id) VALUES (NULL);
2466 SELECT * FROM t1;
2469 DROP TABLE t2, t1;
2470 CREATE TABLE t1
2472 id INT PRIMARY KEY
2473 ) ENGINE=InnoDB;
2474 CREATE TEMPORARY TABLE t2
2476 id INT NOT NULL PRIMARY KEY,
2477 b INT,
2478 FOREIGN KEY (b) REFERENCES test.t1(id)
2479 ) ENGINE=InnoDB;
2480 Got one of the listed errors
2481 DROP TABLE t1;
2482 create table t1 (col1 varchar(2000), index (col1(767)))
2483 character set = latin1 engine = innodb;
2484 create table t2 (col1 char(255), index (col1))
2485 character set = latin1 engine = innodb;
2486 create table t3 (col1 binary(255), index (col1))
2487 character set = latin1 engine = innodb;
2488 create table t4 (col1 varchar(767), index (col1))
2489 character set = latin1 engine = innodb;
2490 create table t5 (col1 varchar(767) primary key)
2491 character set = latin1 engine = innodb;
2492 create table t6 (col1 varbinary(767) primary key)
2493 character set = latin1 engine = innodb;
2494 create table t7 (col1 text, index(col1(767)))
2495 character set = latin1 engine = innodb;
2496 create table t8 (col1 blob, index(col1(767)))
2497 character set = latin1 engine = innodb;
2498 create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2))
2499 character set = latin1 engine = innodb;
2500 show create table t9;
2501 Table   Create Table
2502 t9      CREATE TABLE `t9` (
2503   `col1` varchar(512) DEFAULT NULL,
2504   `col2` varchar(512) DEFAULT NULL,
2505   KEY `col1` (`col1`,`col2`)
2506 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
2507 drop table t1, t2, t3, t4, t5, t6, t7, t8, t9;
2508 create table t1 (col1 varchar(768), index(col1))
2509 character set = latin1 engine = innodb;
2510 Warnings:
2511 Warning 1071    Specified key was too long; max key length is 767 bytes
2512 create table t2 (col1 varbinary(768), index(col1))
2513 character set = latin1 engine = innodb;
2514 Warnings:
2515 Warning 1071    Specified key was too long; max key length is 767 bytes
2516 create table t3 (col1 text, index(col1(768)))
2517 character set = latin1 engine = innodb;
2518 Warnings:
2519 Warning 1071    Specified key was too long; max key length is 767 bytes
2520 create table t4 (col1 blob, index(col1(768)))
2521 character set = latin1 engine = innodb;
2522 Warnings:
2523 Warning 1071    Specified key was too long; max key length is 767 bytes
2524 show create table t1;
2525 Table   Create Table
2526 t1      CREATE TABLE `t1` (
2527   `col1` varchar(768) DEFAULT NULL,
2528   KEY `col1` (`col1`(767))
2529 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
2530 drop table t1, t2, t3, t4;
2531 create table t1 (col1 varchar(768) primary key)
2532 character set = latin1 engine = innodb;
2533 ERROR 42000: Specified key was too long; max key length is 767 bytes
2534 create table t2 (col1 varbinary(768) primary key)
2535 character set = latin1 engine = innodb;
2536 ERROR 42000: Specified key was too long; max key length is 767 bytes
2537 create table t3 (col1 text, primary key(col1(768)))
2538 character set = latin1 engine = innodb;
2539 ERROR 42000: Specified key was too long; max key length is 767 bytes
2540 create table t4 (col1 blob, primary key(col1(768)))
2541 character set = latin1 engine = innodb;
2542 ERROR 42000: Specified key was too long; max key length is 767 bytes
2543 CREATE TABLE t1
2545 id INT PRIMARY KEY
2546 ) ENGINE=InnoDB;
2547 CREATE TABLE t2
2549 v INT,
2550 CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
2551 ) ENGINE=InnoDB;
2552 INSERT INTO t2 VALUES(2);
2553 ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
2554 INSERT INTO t1 VALUES(1);
2555 INSERT INTO t2 VALUES(1);
2556 DELETE FROM t1 WHERE id = 1;
2557 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
2558 DROP TABLE t1;
2559 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
2560 SET FOREIGN_KEY_CHECKS=0;
2561 DROP TABLE t1;
2562 SET FOREIGN_KEY_CHECKS=1;
2563 INSERT INTO t2 VALUES(3);
2564 ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
2565 DROP TABLE t2;
2566 create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
2567 insert into t1 values (1),(2);
2568 set autocommit=0;
2569 checksum table t1;
2570 Table   Checksum
2571 test.t1 1531596814
2572 insert into t1 values(3);
2573 checksum table t1;
2574 Table   Checksum
2575 test.t1 1531596814
2576 commit;
2577 checksum table t1;
2578 Table   Checksum
2579 test.t1 2050879373
2580 commit;
2581 drop table t1;
2582 create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
2583 insert into t1 values (1),(2);
2584 set autocommit=1;
2585 checksum table t1;
2586 Table   Checksum
2587 test.t1 1531596814
2588 set autocommit=1;
2589 insert into t1 values(3);
2590 checksum table t1;
2591 Table   Checksum
2592 test.t1 2050879373
2593 drop table t1;
2594 set foreign_key_checks=0;
2595 create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
2596 create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
2597 ERROR HY000: Can't create table 'test.t1' (errno: 150)
2598 set foreign_key_checks=1;
2599 drop table t2;
2600 set foreign_key_checks=0;
2601 create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
2602 create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
2603 ERROR HY000: Can't create table 'test.t2' (errno: 150)
2604 set foreign_key_checks=1;
2605 drop table t1;
2606 set foreign_key_checks=0;
2607 create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
2608 create table t1(a varchar(10) primary key) engine = innodb;
2609 alter table t1 modify column a int;
2610 Got one of the listed errors
2611 set foreign_key_checks=1;
2612 drop table t2,t1;
2613 set foreign_key_checks=0;
2614 create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
2615 create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
2616 alter table t1 convert to character set utf8;
2617 set foreign_key_checks=1;
2618 drop table t2,t1;
2619 set foreign_key_checks=0;
2620 create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
2621 create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8;
2622 rename table t3 to t1;
2623 ERROR HY000: Error on rename of './test/t3' to './test/t1' (errno: 150)
2624 set foreign_key_checks=1;
2625 drop table t2,t3;
2626 create table t1(a int primary key) row_format=redundant engine=innodb;
2627 create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb;
2628 create table t3(a int primary key) row_format=compact engine=innodb;
2629 create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb;
2630 insert into t1 values(1);
2631 insert into t3 values(1);
2632 insert into t2 values(2);
2633 ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
2634 insert into t4 values(2);
2635 ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
2636 insert into t2 values(1);
2637 insert into t4 values(1);
2638 update t1 set a=2;
2639 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
2640 update t2 set a=2;
2641 ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
2642 update t3 set a=2;
2643 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
2644 update t4 set a=2;
2645 ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
2646 truncate t1;
2647 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
2648 truncate t3;
2649 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
2650 truncate t2;
2651 truncate t4;
2652 truncate t1;
2653 truncate t3;
2654 drop table t4,t3,t2,t1;
2655 create table t1 (a varchar(255) character set utf8,
2656 b varchar(255) character set utf8,
2657 c varchar(255) character set utf8,
2658 d varchar(255) character set utf8,
2659 key (a,b,c,d)) engine=innodb;
2660 drop table t1;
2661 create table t1 (a varchar(255) character set utf8,
2662 b varchar(255) character set utf8,
2663 c varchar(255) character set utf8,
2664 d varchar(255) character set utf8,
2665 e varchar(255) character set utf8,
2666 key (a,b,c,d,e)) engine=innodb;
2667 ERROR 42000: Specified key was too long; max key length is 3072 bytes
2668 create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb;
2669 create table t2 (s1 binary(2),primary key (s1)) engine=innodb;
2670 create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb;
2671 create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb;
2672 insert into t1 values (0x41),(0x4120),(0x4100);
2673 insert into t2 values (0x41),(0x4120),(0x4100);
2674 ERROR 23000: Duplicate entry 'A' for key 'PRIMARY'
2675 insert into t2 values (0x41),(0x4120);
2676 insert into t3 values (0x41),(0x4120),(0x4100);
2677 ERROR 23000: Duplicate entry 'A ' for key 'PRIMARY'
2678 insert into t3 values (0x41),(0x4100);
2679 insert into t4 values (0x41),(0x4120),(0x4100);
2680 ERROR 23000: Duplicate entry 'A' for key 'PRIMARY'
2681 insert into t4 values (0x41),(0x4100);
2682 select hex(s1) from t1;
2683 hex(s1)
2685 4100
2686 4120
2687 select hex(s1) from t2;
2688 hex(s1)
2689 4100
2690 4120
2691 select hex(s1) from t3;
2692 hex(s1)
2693 4100
2695 select hex(s1) from t4;
2696 hex(s1)
2697 4100
2699 drop table t1,t2,t3,t4;
2700 create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb;
2701 create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
2702 insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
2703 insert into t2 values(0x42);
2704 ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
2705 insert into t2 values(0x41);
2706 select hex(s1) from t2;
2707 hex(s1)
2708 4100
2709 update t1 set s1=0x123456 where a=2;
2710 select hex(s1) from t2;
2711 hex(s1)
2712 4100
2713 update t1 set s1=0x12 where a=1;
2714 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
2715 update t1 set s1=0x12345678 where a=1;
2716 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
2717 update t1 set s1=0x123457 where a=1;
2718 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
2719 update t1 set s1=0x1220 where a=1;
2720 select hex(s1) from t2;
2721 hex(s1)
2722 1220
2723 update t1 set s1=0x1200 where a=1;
2724 select hex(s1) from t2;
2725 hex(s1)
2726 1200
2727 update t1 set s1=0x4200 where a=1;
2728 select hex(s1) from t2;
2729 hex(s1)
2730 4200
2731 delete from t1 where a=1;
2732 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
2733 delete from t1 where a=2;
2734 update t2 set s1=0x4120;
2735 delete from t1;
2736 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
2737 delete from t1 where a!=3;
2738 select a,hex(s1) from t1;
2739 a       hex(s1)
2740 3       4120
2741 select hex(s1) from t2;
2742 hex(s1)
2743 4120
2744 drop table t2,t1;
2745 create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb;
2746 create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
2747 insert into t1 values(1,0x4100),(2,0x41);
2748 insert into t2 values(0x41);
2749 select hex(s1) from t2;
2750 hex(s1)
2752 update t1 set s1=0x1234 where a=1;
2753 select hex(s1) from t2;
2754 hex(s1)
2756 update t1 set s1=0x12 where a=2;
2757 select hex(s1) from t2;
2758 hex(s1)
2760 delete from t1 where a=1;
2761 delete from t1 where a=2;
2762 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
2763 select a,hex(s1) from t1;
2764 a       hex(s1)
2765 2       12
2766 select hex(s1) from t2;
2767 hex(s1)
2769 drop table t2,t1;
2770 CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
2771 CREATE TABLE t2(a INT) ENGINE=InnoDB;
2772 ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
2773 ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
2774 ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
2775 ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
2776 SHOW CREATE TABLE t2;
2777 Table   Create Table
2778 t2      CREATE TABLE `t2` (
2779   `a` int(11) DEFAULT NULL,
2780   KEY `t2_ibfk_0` (`a`)
2781 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
2782 DROP TABLE t2,t1;
2783 create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
2784 insert into t1(a) values (1),(2),(3);
2785 commit;
2786 set autocommit = 0;
2787 update t1 set b = 5 where a = 2;
2788 create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
2789 set autocommit = 0;
2790 insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
2791 (11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
2792 (12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
2793 (13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
2794 (14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
2795 commit;
2796 commit;
2797 drop trigger t1t;
2798 drop table t1;
2799 create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
2800 create table t2(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
2801 create table t3(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
2802 create table t4(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
2803 create table t5(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
2804 insert into t1(a) values (1),(2),(3);
2805 insert into t2(a) values (1),(2),(3);
2806 insert into t3(a) values (1),(2),(3);
2807 insert into t4(a) values (1),(2),(3);
2808 insert into t3(a) values (5),(7),(8);
2809 insert into t4(a) values (5),(7),(8);
2810 insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
2811 create trigger t1t before insert on t1 for each row begin 
2812 INSERT INTO t2 SET a = NEW.a;
2813 end |
2814 create trigger t2t before insert on t2 for each row begin
2815 DELETE FROM t3 WHERE a = NEW.a;
2816 end |
2817 create trigger t3t before delete on t3 for each row begin  
2818 UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
2819 end |
2820 create trigger t4t before update on t4 for each row begin
2821 UPDATE t5 SET b = b + 1 where a = NEW.a;
2822 end |
2823 commit;
2824 set autocommit = 0;
2825 update t1 set b = b + 5 where a = 1;
2826 update t2 set b = b + 5 where a = 1;
2827 update t3 set b = b + 5 where a = 1;
2828 update t4 set b = b + 5 where a = 1;
2829 insert into t5(a) values(20);
2830 set autocommit = 0;
2831 insert into t1(a) values(7);
2832 insert into t2(a) values(8);
2833 delete from t2 where a = 3;
2834 update t4 set b = b + 1 where a = 3;
2835 commit;
2836 drop trigger t1t;
2837 drop trigger t2t;
2838 drop trigger t3t;
2839 drop trigger t4t;
2840 drop table t1, t2, t3, t4, t5;
2841 CREATE TABLE t1 (
2842 field1 varchar(8) NOT NULL DEFAULT '',
2843 field2 varchar(8) NOT NULL DEFAULT '',
2844 PRIMARY KEY  (field1, field2)
2845 ) ENGINE=InnoDB;
2846 CREATE TABLE t2 (
2847 field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
2848 FOREIGN KEY (field1) REFERENCES t1 (field1)
2849 ON DELETE CASCADE ON UPDATE CASCADE
2850 ) ENGINE=InnoDB;
2851 INSERT INTO t1 VALUES ('old', 'somevalu');
2852 INSERT INTO t1 VALUES ('other', 'anyvalue');
2853 INSERT INTO t2 VALUES ('old');
2854 INSERT INTO t2 VALUES ('other');
2855 UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';
2856 ERROR 23000: Upholding foreign key constraints for table 't1', entry 'other-somevalu', key 1 would lead to a duplicate entry
2857 DROP TABLE t2;
2858 DROP TABLE t1;
2859 create table t1 (
2860 c1 bigint not null,
2861 c2 bigint not null,
2862 primary key (c1),
2863 unique  key (c2)
2864 ) engine=innodb;
2865 create table t2 (
2866 c1 bigint not null,
2867 primary key (c1)
2868 ) engine=innodb;
2869 alter table t1 add constraint c2_fk foreign key (c2)
2870 references t2(c1) on delete cascade;
2871 show create table t1;
2872 Table   Create Table
2873 t1      CREATE TABLE `t1` (
2874   `c1` bigint(20) NOT NULL,
2875   `c2` bigint(20) NOT NULL,
2876   PRIMARY KEY (`c1`),
2877   UNIQUE KEY `c2` (`c2`),
2878   CONSTRAINT `c2_fk` FOREIGN KEY (`c2`) REFERENCES `t2` (`c1`) ON DELETE CASCADE
2879 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
2880 alter table t1 drop foreign key c2_fk;
2881 show create table t1;
2882 Table   Create Table
2883 t1      CREATE TABLE `t1` (
2884   `c1` bigint(20) NOT NULL,
2885   `c2` bigint(20) NOT NULL,
2886   PRIMARY KEY (`c1`),
2887   UNIQUE KEY `c2` (`c2`)
2888 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
2889 drop table t1, t2;
2890 create table t1(a date) engine=innodb;
2891 create table t2(a date, key(a)) engine=innodb;
2892 insert into t1 values('2005-10-01');
2893 insert into t2 values('2005-10-01');
2894 select * from t1, t2
2895 where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
2896 a       a
2897 2005-10-01      2005-10-01
2898 drop table t1, t2;
2899 create table t1 (id int not null, f_id int not null, f int not null,
2900 primary key(f_id, id)) engine=innodb;
2901 create table t2 (id int not null,s_id int not null,s varchar(200),
2902 primary key(id)) engine=innodb;
2903 INSERT INTO t1 VALUES (8, 1, 3);
2904 INSERT INTO t1 VALUES (1, 2, 1);
2905 INSERT INTO t2 VALUES (1, 0, '');
2906 INSERT INTO t2 VALUES (8, 1, '');
2907 commit;
2908 DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
2909 WHERE mm.id IS NULL;
2910 select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
2911 where mm.id is null lock in share mode;
2912 id      f_id    f
2913 drop table t1,t2;
2914 create table t1(a int not null, b int, primary key(a)) engine=innodb;
2915 insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
2916 commit;
2917 SET binlog_format='MIXED';
2918 set autocommit = 0;
2919 SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2920 update t1 set b = 5 where b = 1;
2921 SET binlog_format='MIXED';
2922 set autocommit = 0;
2923 SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2924 select * from t1 where a = 7 and b = 3 for update;
2925 a       b
2926 7       3
2927 commit;
2928 commit;
2929 drop table t1;
2930 create table t1(a int not null, b int, primary key(a)) engine=innodb;
2931 insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
2932 commit;
2933 set autocommit = 0;
2934 select * from t1 lock in share mode;
2935 a       b
2936 1       1
2937 2       2
2938 3       1
2939 4       2
2940 5       1
2941 6       2
2942 update t1 set b = 5 where b = 1;
2943 set autocommit = 0;
2944 select * from t1 where a = 2 and b = 2 for update;
2945 ERROR HY000: Lock wait timeout exceeded; try restarting transaction
2946 commit;
2947 commit;
2948 drop table t1;
2949 create table t1(a int not null, b int, primary key(a)) engine=innodb;
2950 insert into t1 values (1,2),(5,3),(4,2);
2951 create table t2(d int not null, e int, primary key(d)) engine=innodb;
2952 insert into t2 values (8,6),(12,1),(3,1);
2953 commit;
2954 set autocommit = 0;
2955 select * from t2 for update;
2956 d       e
2957 3       1
2958 8       6
2959 12      1
2960 SET binlog_format='MIXED';
2961 set autocommit = 0;
2962 SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2963 insert into t1 select * from t2;
2964 update t1 set b = (select e from t2 where a = d);
2965 create table t3(d int not null, e int, primary key(d)) engine=innodb
2966 select * from t2;
2967 commit;
2968 commit;
2969 drop table t1, t2, t3;
2970 create table t1(a int not null, b int, primary key(a)) engine=innodb;
2971 insert into t1 values (1,2),(5,3),(4,2);
2972 create table t2(a int not null, b int, primary key(a)) engine=innodb;
2973 insert into t2 values (8,6),(12,1),(3,1);
2974 create table t3(d int not null, b int, primary key(d)) engine=innodb;
2975 insert into t3 values (8,6),(12,1),(3,1);
2976 create table t5(a int not null, b int, primary key(a)) engine=innodb;
2977 insert into t5 values (1,2),(5,3),(4,2);
2978 create table t6(d int not null, e int, primary key(d)) engine=innodb;
2979 insert into t6 values (8,6),(12,1),(3,1);
2980 create table t8(a int not null, b int, primary key(a)) engine=innodb;
2981 insert into t8 values (1,2),(5,3),(4,2);
2982 create table t9(d int not null, e int, primary key(d)) engine=innodb;
2983 insert into t9 values (8,6),(12,1),(3,1);
2984 commit;
2985 set autocommit = 0;
2986 select * from t2 for update;
2987 a       b
2988 3       1
2989 8       6
2990 12      1
2991 SET binlog_format='MIXED';
2992 set autocommit = 0;
2993 SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
2994 insert into t1 select * from t2;
2995 SET binlog_format='MIXED';
2996 set autocommit = 0;
2997 SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
2998 update t3 set b = (select b from t2 where a = d);
2999 SET binlog_format='MIXED';
3000 set autocommit = 0;
3001 SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
3002 create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
3003 SET binlog_format='MIXED';
3004 set autocommit = 0;
3005 SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
3006 insert into t5 (select * from t2 lock in share mode);
3007 SET binlog_format='MIXED';
3008 set autocommit = 0;
3009 SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
3010 update t6 set e = (select b from t2 where a = d lock in share mode);
3011 SET binlog_format='MIXED';
3012 set autocommit = 0;
3013 SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
3014 create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
3015 SET binlog_format='MIXED';
3016 set autocommit = 0;
3017 SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
3018 insert into t8 (select * from t2 for update);
3019 SET binlog_format='MIXED';
3020 set autocommit = 0;
3021 SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
3022 update t9 set e = (select b from t2 where a = d for update);
3023 SET binlog_format='MIXED';
3024 set autocommit = 0;
3025 SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
3026 create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
3027 ERROR HY000: Lock wait timeout exceeded; try restarting transaction
3028 ERROR HY000: Lock wait timeout exceeded; try restarting transaction
3029 ERROR HY000: Lock wait timeout exceeded; try restarting transaction
3030 ERROR HY000: Lock wait timeout exceeded; try restarting transaction
3031 ERROR HY000: Lock wait timeout exceeded; try restarting transaction
3032 ERROR HY000: Lock wait timeout exceeded; try restarting transaction
3033 ERROR HY000: Lock wait timeout exceeded; try restarting transaction
3034 ERROR HY000: Lock wait timeout exceeded; try restarting transaction
3035 ERROR HY000: Lock wait timeout exceeded; try restarting transaction
3036 commit;
3037 drop table t1, t2, t3, t5, t6, t8, t9;
3038 CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
3039 ERROR 42000: Incorrect column name 'DB_ROW_ID'
3040 CREATE TABLE t1 (
3041 a BIGINT(20) NOT NULL,
3042 PRIMARY KEY  (a)
3043 ) ENGINE=INNODB DEFAULT CHARSET=UTF8;
3044 CREATE TABLE t2 (
3045 a BIGINT(20) NOT NULL,
3046 b VARCHAR(128) NOT NULL,
3047 c TEXT NOT NULL,
3048 PRIMARY KEY  (a,b),
3049 KEY idx_t2_b_c (b,c(200)),
3050 CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a) 
3051 ON DELETE CASCADE
3052 ) ENGINE=INNODB DEFAULT CHARSET=UTF8;
3053 INSERT INTO t1 VALUES (1);
3054 INSERT INTO t2 VALUES (1, 'bar', 'vbar');
3055 INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR');
3056 INSERT INTO t2 VALUES (1, 'bar_bar', 'bibi');
3057 INSERT INTO t2 VALUES (1, 'customer_over', '1');
3058 SELECT * FROM t2 WHERE b = 'customer_over';
3059 a       b       c
3060 1       customer_over   1
3061 SELECT * FROM t2 WHERE BINARY b = 'customer_over';
3062 a       b       c
3063 1       customer_over   1
3064 SELECT DISTINCT p0.a FROM t2 p0 WHERE p0.b = 'customer_over';
3067 /* Bang: Empty result set, above was expected: */
3068 SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
3071 SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
3074 drop table t2, t1;
3075 CREATE TABLE t1 ( a int ) ENGINE=innodb;
3076 BEGIN;
3077 INSERT INTO t1 VALUES (1);
3078 OPTIMIZE TABLE t1;
3079 Table   Op      Msg_type        Msg_text
3080 test.t1 optimize        note    Table does not support optimize, doing recreate + analyze instead
3081 test.t1 optimize        status  OK
3082 DROP TABLE t1;
3083 CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB;
3084 CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL,
3085 CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id)
3086 ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
3087 ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON
3088 DELETE CASCADE ON UPDATE CASCADE;
3089 SHOW CREATE TABLE t2;
3090 Table   Create Table
3091 t2      CREATE TABLE `t2` (
3092   `id` int(11) NOT NULL,
3093   `f` int(11) NOT NULL,
3094   PRIMARY KEY (`id`),
3095   KEY `f` (`f`),
3096   CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f`) REFERENCES `t1` (`f`) ON DELETE CASCADE ON UPDATE CASCADE,
3097   CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
3098 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
3099 DROP TABLE t2, t1;
3100 CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB;
3101 CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB;
3102 INSERT INTO t1 VALUES (1);
3103 INSERT INTO t2 VALUES (1);
3104 ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL;
3105 ALTER TABLE t2 MODIFY a INT NOT NULL;
3106 ERROR HY000: Error on rename of '#sql-temporary' to './test/t2' (errno: 150)
3107 DELETE FROM t1;
3108 DROP TABLE t2,t1;
3109 CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY)
3110 ENGINE=InnoDB;
3111 INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4);
3112 DELETE FROM t1;
3113 INSERT INTO t1 VALUES ('DDD');
3114 SELECT * FROM t1;
3117 DROP TABLE t1;
3118 CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB
3119 AUTO_INCREMENT=42;
3120 INSERT INTO t1 VALUES (0),(347),(0);
3121 SELECT * FROM t1;
3126 SHOW CREATE TABLE t1;
3127 Table   Create Table
3128 t1      CREATE TABLE `t1` (
3129   `id` int(11) NOT NULL AUTO_INCREMENT,
3130   PRIMARY KEY (`id`)
3131 ) ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=latin1
3132 CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB;
3133 INSERT INTO t2 VALUES(42),(347),(348);
3134 ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id);
3135 SHOW CREATE TABLE t1;
3136 Table   Create Table
3137 t1      CREATE TABLE `t1` (
3138   `id` int(11) NOT NULL AUTO_INCREMENT,
3139   PRIMARY KEY (`id`),
3140   CONSTRAINT `t1_t2` FOREIGN KEY (`id`) REFERENCES `t2` (`id`)
3141 ) ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=latin1
3142 DROP TABLE t1,t2;
3143 set innodb_strict_mode=on;
3144 CREATE TABLE t1 (
3145 c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255),
3146 c05 CHAR(255), c06 CHAR(255), c07 CHAR(255), c08 CHAR(255),
3147 c09 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255),
3148 c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255),
3149 c17 CHAR(255), c18 CHAR(255), c19 CHAR(255), c20 CHAR(255),
3150 c21 CHAR(255), c22 CHAR(255), c23 CHAR(255), c24 CHAR(255),
3151 c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255),
3152 c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
3153 ) ENGINE = InnoDB;
3154 ERROR 42000: Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
3155 DROP TABLE IF EXISTS t1;
3156 Warnings:
3157 Note    1051    Unknown table 't1'
3158 CREATE TABLE t1(
3159 id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
3160 ) ENGINE=InnoDB;
3161 INSERT INTO t1 VALUES(-10);
3162 SELECT * FROM t1;
3165 INSERT INTO t1 VALUES(NULL);
3166 SELECT * FROM t1;
3170 DROP TABLE t1;
3171 SET binlog_format='MIXED';
3172 SET TX_ISOLATION='read-committed';
3173 SET AUTOCOMMIT=0;
3174 DROP TABLE IF EXISTS t1, t2;
3175 Warnings:
3176 Note    1051    Unknown table 't1'
3177 Note    1051    Unknown table 't2'
3178 CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
3179 CREATE TABLE t2 LIKE t1;
3180 SELECT * FROM t2;
3182 SET binlog_format='MIXED';
3183 SET TX_ISOLATION='read-committed';
3184 SET AUTOCOMMIT=0;
3185 INSERT INTO t1 VALUES (1);
3186 COMMIT;
3187 SELECT * FROM t1 WHERE a=1;
3190 SET binlog_format='MIXED';
3191 SET TX_ISOLATION='read-committed';
3192 SET AUTOCOMMIT=0;
3193 SELECT * FROM t2;
3195 SET binlog_format='MIXED';
3196 SET TX_ISOLATION='read-committed';
3197 SET AUTOCOMMIT=0;
3198 INSERT INTO t1 VALUES (2);
3199 COMMIT;
3200 SELECT * FROM t1 WHERE a=2;
3203 SELECT * FROM t1 WHERE a=2;
3206 DROP TABLE t1;
3207 DROP TABLE t2;
3208 create table t1 (i int, j int) engine=innodb;
3209 insert into t1 (i, j) values (1, 1), (2, 2);
3210 update t1 set j = 2;
3211 affected rows: 1
3212 info: Rows matched: 2  Changed: 1  Warnings: 0
3213 drop table t1;
3214 create table t1 (id int) comment='this is a comment' engine=innodb;
3215 select table_comment, data_free > 0 as data_free_is_set
3216 from information_schema.tables
3217 where table_schema='test' and table_name = 't1';
3218 table_comment   data_free_is_set
3219 this is a comment       1
3220 drop table t1;
3221 CREATE TABLE t1 (
3222 c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
3223 c2 VARCHAR(128) NOT NULL,
3224 PRIMARY KEY(c1)
3225 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100;
3226 CREATE TABLE t2 (
3227 c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
3228 c2 INT(10) UNSIGNED DEFAULT NULL,
3229 PRIMARY KEY(c1)
3230 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200;
3231 SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
3232 AUTO_INCREMENT
3234 ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1);
3235 SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
3236 AUTO_INCREMENT
3238 DROP TABLE t2;
3239 DROP TABLE t1;
3240 CREATE TABLE t1 (c1 int default NULL,
3241 c2 int default NULL
3242 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
3243 TRUNCATE TABLE t1;
3244 affected rows: 0
3245 INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
3246 affected rows: 5
3247 info: Records: 5  Duplicates: 0  Warnings: 0
3248 TRUNCATE TABLE t1;
3249 affected rows: 0
3250 DROP TABLE t1;
3251 Variable_name   Value
3252 Handler_update  0
3253 Variable_name   Value
3254 Handler_delete  0
3255 Variable_name   Value
3256 Handler_update  1
3257 Variable_name   Value
3258 Handler_delete  1
3259 DROP TABLE bug58912;
3260 create table t1 (f1 integer primary key) engine=innodb;
3261 flush status;
3262 show status like "handler_read_key";
3263 Variable_name   Value
3264 Handler_read_key        0
3265 select f1 from t1;
3267 show status like "handler_read_key";
3268 Variable_name   Value
3269 Handler_read_key        1
3270 drop table t1;