14
13
(151,2),(234,2),(236,2),(243,2),(255,2),(259,2),(232,3),(235,3),(238,3),
15
14
(246,3),(253,3),(269,3),(285,3),(291,3),(293,3),(131,4),(230,4),(231,4);
17
slai_id int(11) not null default '0',
18
owner_tbl int(11) default null,
19
owner_id int(11) default null,
20
sla_id int(11) default null,
21
inc_web int(11) default null,
22
inc_email int(11) default null,
23
inc_chat int(11) default null,
24
inc_csr int(11) default null,
25
inc_total int(11) default null,
26
time_billed int(11) default null,
16
slai_id int not null default '0',
17
owner_tbl int default null,
18
owner_id int default null,
19
sla_id int default null,
20
inc_web int default null,
21
inc_email int default null,
22
inc_chat int default null,
23
inc_csr int default null,
24
inc_total int default null,
25
time_billed int default null,
27
26
activedate timestamp null default null,
28
27
expiredate timestamp null default null,
29
state int(11) default null,
30
sla_set int(11) default null,
28
state int default null,
29
sla_set int default null,
31
30
unique key t2$slai_id (slai_id),
32
31
key t2$owner_id (owner_id),
33
32
key t2$sla_id (sla_id)
71
70
INSERT INTO t3 VALUES (1,1,1),(2,1,2);
72
71
INSERT INTO t3 SELECT a + 2, a + 2, 3 FROM t3;
73
72
INSERT INTO t3 SELECT a + 4, a + 4, 3 FROM t3;
74
SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
73
SELECT STRAIGHT_JOIN t1.b, t1.a FROM t1, t3, t2 WHERE
75
74
t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
76
75
ORDER BY t1.b LIMIT 2;
80
SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
79
SELECT STRAIGHT_JOIN t1.b, t1.a FROM t1, t3, t2 WHERE
81
80
t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
82
81
ORDER BY t1.b LIMIT 5;
169
160
id select_type table type possible_keys key key_len ref rows Extra
170
161
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
172
create table t1m (a int) engine = MEMORY;
163
create temporary table t1m (a int) engine = MEMORY;
173
164
create table t1i (a int);
174
create table t2m (a int) engine = MEMORY;
165
create temporary table t2m (a int) engine = MEMORY;
175
166
create table t2i (a int);
176
167
insert into t2m values (5);
177
168
insert into t2i values (5);
178
select min(a) from t1i;
181
select min(7) from t1i;
184
select min(7) from DUAL;
187
explain select min(7) from t2i join t1i;
188
id select_type table type possible_keys key key_len ref rows Extra
189
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
190
1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer
191
select min(7) from t2i join t1i;
194
select max(a) from t1i;
197
select max(7) from t1i;
200
select max(7) from DUAL;
203
explain select max(7) from t2i join t1i;
204
id select_type table type possible_keys key key_len ref rows Extra
205
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
206
1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer
207
select max(7) from t2i join t1i;
210
169
select 1, min(a) from t1i where a=99;
340
299
alter table t1 drop primary key, add primary key (f2, f1);
341
300
explain select distinct f1 a, f1 b from t1;
342
301
id select_type table type possible_keys key key_len ref rows Extra
343
1 SIMPLE t1 index NULL PRIMARY 5 NULL 4 Using index; Using temporary
302
1 SIMPLE t1 index NULL PRIMARY 10 NULL 4 Using index; Using temporary
344
303
explain select distinct f1, f2 from t1;
345
304
id select_type table type possible_keys key key_len ref rows Extra
346
1 SIMPLE t1 range NULL PRIMARY 5 NULL 3 Using index for group-by; Using temporary
305
1 SIMPLE t1 range NULL PRIMARY 10 NULL 3 Using index for group-by; Using temporary
348
CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
307
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, name varchar(20),
350
CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11));
309
CREATE TABLE t2 (id int NOT NULL PRIMARY KEY, fkey int);
351
310
ALTER TABLE t2 ADD FOREIGN KEY (fkey) REFERENCES t2(id);
352
311
INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
353
312
INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
534
id int AUTO_INCREMENT PRIMARY KEY,
535
stat_id int NOT NULL,
536
acct_id int DEFAULT NULL,
537
INDEX idx1 (stat_id, acct_id),
541
id int AUTO_INCREMENT PRIMARY KEY,
542
stat_id int NOT NULL,
543
acct_id int DEFAULT NULL,
544
INDEX idx1 (stat_id, acct_id),
547
INSERT INTO t1(stat_id,acct_id) VALUES
548
(1,759), (2,831), (3,785), (4,854), (1,921),
549
(1,553), (2,589), (3,743), (2,827), (2,545),
550
(4,779), (4,783), (1,597), (1,785), (4,832),
551
(1,741), (1,833), (3,788), (2,973), (1,907);
552
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
553
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
554
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
555
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
556
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
557
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
558
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
559
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
560
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
561
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
562
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
563
UPDATE t1 SET acct_id=785
564
WHERE MOD(stat_id,2)=0 AND MOD(id,stat_id)=MOD(acct_id,stat_id);
566
Table Op Msg_type Msg_text
567
test.t1 optimize status OK
568
SELECT COUNT(*) FROM t1;
571
SELECT COUNT(*) FROM t1 WHERE acct_id=785;
574
EXPLAIN SELECT COUNT(*) FROM t1 WHERE stat_id IN (1,3) AND acct_id=785;
575
id select_type table type possible_keys key key_len ref rows Extra
576
1 SIMPLE t1 range idx1,idx2 idx1 9 NULL 2 Using where; Using index
577
INSERT INTO t2 SELECT * FROM t1;
579
Table Op Msg_type Msg_text
580
test.t2 optimize status OK
581
EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785;
582
id select_type table type possible_keys key key_len ref rows Extra
583
1 SIMPLE t2 range idx1,idx2 idx1 9 NULL 2 Using where; Using index
585
486
create table t1(a int) engine=innodb;
586
487
alter table t1 comment '123';
587
488
show create table t1;
588
489
Table Create Table
589
490
t1 CREATE TABLE `t1` (
590
`a` int(11) DEFAULT NULL
591
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='123'
492
) ENGINE=InnoDB COMMENT='123'
593
CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8;
494
CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB;
594
495
INSERT INTO t1 VALUES ('uk'),('bg');
595
496
SELECT * FROM t1 WHERE a = 'uk';
626
527
SELECT * FROM t3 WHERE a = 'uk';
628
529
DROP TABLE t1,t2,t3;
629
create table t1 (a int) engine=innodb;
630
select * from bug29807;
631
ERROR 42S02: Table 'test.bug29807' doesn't exist
634
ERROR 42S02: Unknown table 'bug29807'
635
create table bug29807 (a int);
637
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
638
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
639
switch to connection c1
641
INSERT INTO t2 VALUES (1);
642
switch to connection c2
644
LOCK TABLES t1 READ, t2 READ;
645
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
646
switch to connection c1
648
INSERT INTO t1 VALUES (1);
649
switch to connection default
650
SET AUTOCOMMIT=default;
652
530
CREATE TABLE t1 (
653
531
id int NOT NULL auto_increment PRIMARY KEY,
821
drop table if exists t1;
822
create table t1 (a int) engine=innodb;
823
alter table t1 alter a set default 1;
826
Bug#24918 drop table and lock / inconsistent between
829
Check transactional tables under LOCK TABLES
831
drop table if exists t24918, t24918_tmp, t24918_trans, t24918_trans_tmp,
833
create table t24918_access (id int);
834
create table t24918 (id int) engine=myisam;
835
create temporary table t24918_tmp (id int) engine=myisam;
836
create table t24918_trans (id int) engine=innodb;
837
create temporary table t24918_trans_tmp (id int) engine=innodb;
838
lock table t24918 write, t24918_tmp write, t24918_trans write, t24918_trans_tmp write;
840
select * from t24918_access;
841
ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES
842
drop table t24918_trans;
843
select * from t24918_access;
844
ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES
845
drop table t24918_trans_tmp;
846
select * from t24918_access;
847
ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES
848
drop table t24918_tmp;
849
select * from t24918_access;
850
ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES
852
drop table t24918_access;
853
698
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY bkey (b)) ENGINE=InnoDB;
854
699
INSERT INTO t1 VALUES (1,2),(3,2),(2,2),(4,2),(5,2),(6,2),(7,2),(8,2);
855
700
INSERT INTO t1 SELECT a + 8, 2 FROM t1;
1097
942
DROP TABLE t1,t2;
1098
CREATE TABLE t1 (a INT, PRIMARY KEY (a)) ENGINE=InnoDB;
1099
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
1100
INSERT INTO t1 SELECT a + 8 FROM t1;
1101
INSERT INTO t1 SELECT a + 16 FROM t1;
1102
CREATE PROCEDURE p1 ()
1104
DECLARE i INT DEFAULT 50;
1107
ALTER TABLE t1 ENGINE=InnoDB;
1112
SELECT COUNT(*) INTO cnt FROM t1 LOCK IN SHARE MODE;
1121
create table t1(a text) engine=innodb default charset=utf8;
943
create table t1(a text) engine=innodb;
1122
944
insert into t1 values('aaa');
1123
945
alter table t1 add index(a(1024));
1125
947
Warning 1071 Specified key was too long; max key length is 767 bytes
1126
Warning 1071 Specified key was too long; max key length is 767 bytes
1127
Warning 1071 Specified key was too long; max key length is 767 bytes
1128
948
show create table t1;
1129
949
Table Create Table
1130
950
t1 CREATE TABLE `t1` (
1132
952
KEY `a` (`a`(191))
1133
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1135
955
CREATE TABLE t1 (
1435
drop table if exists t1, t2;
1436
create table t1 (i int);
1437
alter table t1 modify i int default 1;
1438
alter table t1 modify i int default 2, rename t2;
1439
lock table t2 write;
1440
alter table t2 modify i int default 3;
1442
lock table t2 write;
1443
alter table t2 modify i int default 4, rename t1;
1446
drop table if exists t1;
1447
create table t1 (i int);
1448
insert into t1 values ();
1449
lock table t1 write;
1450
alter table t1 modify i int default 1;
1451
insert into t1 values ();
1456
alter table t1 change i c char(10) default "Two";
1457
insert into t1 values ();
1470
1255
create table t1(f1 varchar(5) unique, f2 timestamp NOT NULL DEFAULT
1471
1256
CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
1472
1257
insert into t1(f1) values(1);
1473
1258
select @a:=f2 from t1;
1476
1261
update t1 set f1=1;
1477
1262
select @b:=f2 from t1;
1480
1265
select if(@a=@b,"ok","wrong");
1481
1266
if(@a=@b,"ok","wrong")
1483
1268
insert into t1(f1) values (1) on duplicate key update f1="1";
1484
1269
select @b:=f2 from t1;
1487
1272
select if(@a=@b,"ok","wrong");
1488
1273
if(@a=@b,"ok","wrong")
1490
1275
insert into t1(f1) select f1 from t1 on duplicate key update f1="1";
1491
1276
select @b:=f2 from t1;
1494
1279
select if(@a=@b,"ok","wrong");
1495
1280
if(@a=@b,"ok","wrong")
1498
SET SESSION AUTOCOMMIT = 0;
1499
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
1500
# Switch to connection con1
1501
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256))
1503
INSERT INTO t1 VALUES (1,2);
1504
# 1. test for locking:
1506
UPDATE t1 SET b = 12 WHERE a = 1;
1508
info: Rows matched: 1 Changed: 1 Warnings: 0
1512
# Switch to connection con2
1513
UPDATE t1 SET b = 21 WHERE a = 1;
1514
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
1515
# Switch to connection con1
1520
# 2. test for serialized update:
1521
CREATE TABLE t2 (a INT);
1523
INSERT INTO t1 VALUES (1,'init');
1524
CREATE PROCEDURE p1()
1526
UPDATE t1 SET b = CONCAT(b, '+con2') WHERE a = 1;
1527
INSERT INTO t2 VALUES ();
1530
UPDATE t1 SET b = CONCAT(b, '+con1') WHERE a = 1;
1532
info: Rows matched: 1 Changed: 1 Warnings: 0
1536
# Switch to connection con2
1538
# Switch to connection con1
1546
# Switch to connection con2
1550
# Switch to connection con1
1551
# 3. test for updated key column:
1554
INSERT INTO t1 VALUES (1,'init');
1556
UPDATE t1 SET a = 2, b = CONCAT(b, '+con1') WHERE a = 1;
1558
info: Rows matched: 1 Changed: 1 Warnings: 0
1562
# Switch to connection con2
1564
# Switch to connection con1
1572
# Switch to connection con2
1578
1283
CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)) engine=innodb;
1579
1284
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
1580
1285
CONSTRAINT c2 FOREIGN KEY f2 (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb;