2006-08-16 19:29:49 +02:00
|
|
|
# include/mix1.inc
|
2006-08-16 14:58:49 +02:00
|
|
|
#
|
|
|
|
# The variables
|
|
|
|
# $engine_type -- storage engine to be tested
|
|
|
|
# $other_engine_type -- storage engine <> $engine_type
|
2006-08-16 19:29:49 +02:00
|
|
|
# $other_engine_type must point to an all
|
|
|
|
# time available storage engine
|
|
|
|
# 2006-08 MySQL 5.1 MyISAM and MEMORY only
|
2006-09-18 16:55:56 +02:00
|
|
|
# $test_foreign_keys -- 0, skip foreign key tests
|
|
|
|
# -- 1, do not skip foreign key tests
|
2006-08-16 14:58:49 +02:00
|
|
|
# have to be set before sourcing this script.
|
2006-08-16 19:29:49 +02:00
|
|
|
#
|
2006-08-16 14:58:49 +02:00
|
|
|
# Note: The comments/expectations refer to InnoDB.
|
|
|
|
# They might be not valid for other storage engines.
|
|
|
|
#
|
|
|
|
# Last update:
|
|
|
|
# 2006-08-15 ML refactoring of t/innodb_mysql.test
|
|
|
|
# - shift main code of t/innodb_mysql.test to include/mix1.inc
|
|
|
|
# - replace hardcoded assignment of storage engine by
|
|
|
|
# use of $engine_type and $other_engine_type variables
|
2006-08-16 19:29:49 +02:00
|
|
|
# - remove redundant replay testcase of
|
2006-08-16 14:58:49 +02:00
|
|
|
# Bug#12882 min/max inconsistent on empty table
|
|
|
|
# - corrected analyze table t1; to analyze table t4;
|
|
|
|
# Much older versions of this test show that the table
|
|
|
|
# where just some indexes have been created must be used.
|
2006-08-16 19:29:49 +02:00
|
|
|
#
|
2006-08-16 14:58:49 +02:00
|
|
|
|
2013-07-21 16:39:19 +02:00
|
|
|
eval SET SESSION DEFAULT_STORAGE_ENGINE = $engine_type;
|
2006-08-16 14:58:49 +02:00
|
|
|
|
|
|
|
--disable_warnings
|
2007-07-04 11:58:56 +03:00
|
|
|
drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4;
|
2007-10-09 01:07:15 +05:00
|
|
|
drop procedure if exists p1;
|
2006-08-16 14:58:49 +02:00
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
|
|
|
|
# BUG#16798: Uninitialized row buffer reads in ref-or-null optimizer
|
|
|
|
# (repeatable only w/innodb).
|
|
|
|
create table t1 (
|
|
|
|
c_id int(11) not null default '0',
|
|
|
|
org_id int(11) default null,
|
|
|
|
unique key contacts$c_id (c_id),
|
|
|
|
key contacts$org_id (org_id)
|
|
|
|
);
|
2006-08-16 19:29:49 +02:00
|
|
|
insert into t1 values
|
2006-08-16 14:58:49 +02:00
|
|
|
(2,null),(120,null),(141,null),(218,7), (128,1),
|
|
|
|
(151,2),(234,2),(236,2),(243,2),(255,2),(259,2),(232,3),(235,3),(238,3),
|
|
|
|
(246,3),(253,3),(269,3),(285,3),(291,3),(293,3),(131,4),(230,4),(231,4);
|
|
|
|
|
|
|
|
create table t2 (
|
|
|
|
slai_id int(11) not null default '0',
|
|
|
|
owner_tbl int(11) default null,
|
|
|
|
owner_id int(11) default null,
|
|
|
|
sla_id int(11) default null,
|
|
|
|
inc_web int(11) default null,
|
|
|
|
inc_email int(11) default null,
|
|
|
|
inc_chat int(11) default null,
|
|
|
|
inc_csr int(11) default null,
|
|
|
|
inc_total int(11) default null,
|
|
|
|
time_billed int(11) default null,
|
|
|
|
activedate timestamp null default null,
|
|
|
|
expiredate timestamp null default null,
|
|
|
|
state int(11) default null,
|
|
|
|
sla_set int(11) default null,
|
|
|
|
unique key t2$slai_id (slai_id),
|
|
|
|
key t2$owner_id (owner_id),
|
|
|
|
key t2$sla_id (sla_id)
|
|
|
|
);
|
|
|
|
insert into t2(slai_id, owner_tbl, owner_id, sla_id) values
|
|
|
|
(1,3,1,1), (3,3,10,2), (4,3,3,6), (5,3,2,5), (6,3,8,3), (7,3,9,7),
|
|
|
|
(8,3,6,8), (9,3,4,9), (10,3,5,10), (11,3,11,11), (12,3,7,12);
|
|
|
|
|
|
|
|
flush tables;
|
|
|
|
select si.slai_id
|
|
|
|
from t1 c join t2 si on
|
2006-08-16 19:29:49 +02:00
|
|
|
((si.owner_tbl = 3 and si.owner_id = c.org_id) or
|
|
|
|
( si.owner_tbl = 2 and si.owner_id = c.c_id))
|
|
|
|
where
|
2006-08-16 14:58:49 +02:00
|
|
|
c.c_id = 218 and expiredate is null;
|
2006-08-16 19:29:49 +02:00
|
|
|
|
2006-08-16 14:58:49 +02:00
|
|
|
select * from t1 where org_id is null;
|
|
|
|
select si.slai_id
|
|
|
|
from t1 c join t2 si on
|
2006-08-16 19:29:49 +02:00
|
|
|
((si.owner_tbl = 3 and si.owner_id = c.org_id) or
|
|
|
|
( si.owner_tbl = 2 and si.owner_id = c.c_id))
|
|
|
|
where
|
2006-08-16 14:58:49 +02:00
|
|
|
c.c_id = 218 and expiredate is null;
|
|
|
|
|
|
|
|
drop table t1, t2;
|
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#17212: results not sorted correctly by ORDER BY when using index
|
|
|
|
# (repeatable only w/innodb because of index props)
|
|
|
|
#
|
2006-08-16 19:29:49 +02:00
|
|
|
CREATE TABLE t1 (a int, b int, KEY b (b));
|
|
|
|
CREATE TABLE t2 (a int, b int, PRIMARY KEY (a,b));
|
|
|
|
CREATE TABLE t3 (a int, b int, c int, PRIMARY KEY (a),
|
|
|
|
UNIQUE KEY b (b,c), KEY a (a,b,c));
|
2006-08-16 14:58:49 +02:00
|
|
|
|
|
|
|
INSERT INTO t1 VALUES (1, 1);
|
2006-08-16 19:29:49 +02:00
|
|
|
INSERT INTO t1 SELECT a + 1, b + 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 2, b + 2 FROM t1;
|
2006-08-16 14:58:49 +02:00
|
|
|
|
|
|
|
INSERT INTO t2 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8);
|
|
|
|
INSERT INTO t2 SELECT a + 1, b FROM t2;
|
|
|
|
DELETE FROM t2 WHERE a = 1 AND b < 2;
|
|
|
|
|
|
|
|
INSERT INTO t3 VALUES (1,1,1),(2,1,2);
|
|
|
|
INSERT INTO t3 SELECT a + 2, a + 2, 3 FROM t3;
|
|
|
|
INSERT INTO t3 SELECT a + 4, a + 4, 3 FROM t3;
|
|
|
|
|
|
|
|
# demonstrate a problem when a must-use-sort table flag
|
|
|
|
# (sort_by_table=1) is being neglected.
|
2006-08-16 19:29:49 +02:00
|
|
|
SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
|
|
|
|
t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
|
2006-08-16 14:58:49 +02:00
|
|
|
ORDER BY t1.b LIMIT 2;
|
|
|
|
|
|
|
|
# demonstrate the problem described in the bug report
|
2006-08-16 19:29:49 +02:00
|
|
|
SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
|
|
|
|
t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
|
2006-08-16 14:58:49 +02:00
|
|
|
ORDER BY t1.b LIMIT 5;
|
|
|
|
DROP TABLE t1, t2, t3;
|
|
|
|
|
2006-09-14 21:44:17 +02:00
|
|
|
|
|
|
|
# BUG#21077 (The testcase is not deterministic so correct execution doesn't
|
|
|
|
# prove anything) For proof one should track if sequence of ha_innodb::* func
|
|
|
|
# calls is correct.
|
|
|
|
CREATE TABLE `t1` (`id1` INT) ;
|
|
|
|
INSERT INTO `t1` (`id1`) VALUES (1),(5),(2);
|
|
|
|
|
|
|
|
CREATE TABLE `t2` (
|
|
|
|
`id1` INT,
|
|
|
|
`id2` INT NOT NULL,
|
|
|
|
`id3` INT,
|
|
|
|
`id4` INT NOT NULL,
|
|
|
|
UNIQUE (`id2`,`id4`),
|
|
|
|
KEY (`id1`)
|
2006-09-18 16:55:56 +02:00
|
|
|
);
|
2006-09-14 21:44:17 +02:00
|
|
|
|
2006-09-18 16:55:56 +02:00
|
|
|
INSERT INTO `t2`(`id1`,`id2`,`id3`,`id4`) VALUES
|
2006-09-14 21:44:17 +02:00
|
|
|
(1,1,1,0),
|
|
|
|
(1,1,2,1),
|
|
|
|
(5,1,2,2),
|
|
|
|
(6,1,2,3),
|
|
|
|
(1,2,2,2),
|
|
|
|
(1,2,1,1);
|
|
|
|
|
|
|
|
SELECT `id1` FROM `t1` WHERE `id1` NOT IN (SELECT `id1` FROM `t2` WHERE `id2` = 1 AND `id3` = 2);
|
|
|
|
DROP TABLE t1, t2;
|
2006-09-18 16:55:56 +02:00
|
|
|
|
2006-10-17 12:00:36 -04:00
|
|
|
#
|
|
|
|
# Bug #22728 - Handler_rollback value is growing
|
|
|
|
#
|
2006-10-30 13:45:24 +01:00
|
|
|
|
|
|
|
let $before= `show /*!50002 GLOBAL */ status like 'Handler_rollback'`;
|
2006-10-17 12:00:36 -04:00
|
|
|
create table t1 (c1 int) engine=innodb;
|
|
|
|
connect (con1,localhost,root,,);
|
|
|
|
connect (con2,localhost,root,,);
|
|
|
|
connection con2;
|
|
|
|
handler t1 open;
|
|
|
|
handler t1 read first;
|
|
|
|
disconnect con2;
|
|
|
|
connection con1;
|
2006-10-30 13:45:24 +01:00
|
|
|
let $after= `show /*!50002 GLOBAL */ status like 'Handler_rollback'`;
|
|
|
|
# Compare the before and after value, it should be equal
|
|
|
|
--disable_query_log
|
|
|
|
eval select STRCMP("$before", "$after") as "Before and after comparison";
|
|
|
|
--enable_query_log
|
2006-10-17 12:00:36 -04:00
|
|
|
connection default;
|
|
|
|
drop table t1;
|
|
|
|
disconnect con1;
|
|
|
|
|
2007-04-29 13:19:32 +05:00
|
|
|
#
|
|
|
|
# Bug #13191: INSERT...ON DUPLICATE KEY UPDATE of UTF-8 string fields
|
|
|
|
# used in partial unique indices.
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1(c1 TEXT, UNIQUE (c1(1)), cnt INT DEFAULT 1)
|
|
|
|
ENGINE=INNODB CHARACTER SET UTF8;
|
|
|
|
INSERT INTO t1 (c1) VALUES ('1a');
|
|
|
|
SELECT * FROM t1;
|
|
|
|
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1(c1 VARCHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1)
|
|
|
|
ENGINE=INNODB CHARACTER SET UTF8;
|
|
|
|
INSERT INTO t1 (c1) VALUES ('1a');
|
|
|
|
SELECT * FROM t1;
|
|
|
|
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t1(c1 CHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1)
|
|
|
|
ENGINE=INNODB CHARACTER SET UTF8;
|
|
|
|
INSERT INTO t1 (c1) VALUES ('1a');
|
|
|
|
SELECT * FROM t1;
|
|
|
|
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2007-05-18 20:00:49 +05:00
|
|
|
#
|
|
|
|
# Bug #28272: EXPLAIN for SELECT from an empty InnoDB table
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
a1 decimal(10,0) DEFAULT NULL,
|
|
|
|
a2 blob,
|
|
|
|
a3 time DEFAULT NULL,
|
|
|
|
a4 blob,
|
|
|
|
a5 char(175) DEFAULT NULL,
|
|
|
|
a6 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
|
|
|
a7 tinyblob,
|
|
|
|
INDEX idx (a6,a7(239),a5)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
EXPLAIN SELECT a4 FROM t1 WHERE
|
|
|
|
a6=NULL AND
|
|
|
|
a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS';
|
|
|
|
|
|
|
|
EXPLAIN SELECT t1.a4 FROM t1, t1 t WHERE
|
|
|
|
t.a6=t.a6 AND t1.a6=NULL AND
|
|
|
|
t1.a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS';
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2006-08-16 14:58:49 +02:00
|
|
|
#
|
|
|
|
# Bug #12882 min/max inconsistent on empty table
|
|
|
|
#
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
eval create table t1m (a int) engine = $other_engine_type;
|
|
|
|
create table t1i (a int);
|
|
|
|
eval create table t2m (a int) engine = $other_engine_type;
|
|
|
|
create table t2i (a int);
|
|
|
|
--enable_warnings
|
|
|
|
insert into t2m values (5);
|
|
|
|
insert into t2i values (5);
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
analyze table t1i;
|
|
|
|
analyze table t1m;
|
|
|
|
analyze table t2i;
|
|
|
|
analyze table t2m;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2006-08-16 14:58:49 +02:00
|
|
|
# test with $engine_type
|
|
|
|
select min(a) from t1i;
|
|
|
|
select min(7) from t1i;
|
|
|
|
select min(7) from DUAL;
|
|
|
|
explain select min(7) from t2i join t1i;
|
|
|
|
select min(7) from t2i join t1i;
|
|
|
|
|
|
|
|
select max(a) from t1i;
|
|
|
|
select max(7) from t1i;
|
|
|
|
select max(7) from DUAL;
|
|
|
|
explain select max(7) from t2i join t1i;
|
|
|
|
select max(7) from t2i join t1i;
|
|
|
|
|
|
|
|
select 1, min(a) from t1i where a=99;
|
|
|
|
select 1, min(a) from t1i where 1=99;
|
|
|
|
select 1, min(1) from t1i where a=99;
|
|
|
|
select 1, min(1) from t1i where 1=99;
|
|
|
|
|
|
|
|
select 1, max(a) from t1i where a=99;
|
|
|
|
select 1, max(a) from t1i where 1=99;
|
|
|
|
select 1, max(1) from t1i where a=99;
|
|
|
|
select 1, max(1) from t1i where 1=99;
|
|
|
|
|
|
|
|
# mixed $engine_type/$other_engine_type test
|
|
|
|
explain select count(*), min(7), max(7) from t1m, t1i;
|
|
|
|
select count(*), min(7), max(7) from t1m, t1i;
|
|
|
|
|
|
|
|
explain select count(*), min(7), max(7) from t1m, t2i;
|
|
|
|
select count(*), min(7), max(7) from t1m, t2i;
|
|
|
|
|
|
|
|
explain select count(*), min(7), max(7) from t2m, t1i;
|
|
|
|
select count(*), min(7), max(7) from t2m, t1i;
|
|
|
|
|
|
|
|
drop table t1m, t1i, t2m, t2i;
|
|
|
|
|
|
|
|
#
|
2006-08-16 19:29:49 +02:00
|
|
|
# Bug #12882: primary key implcitly included in every innodb index
|
2006-08-16 14:58:49 +02:00
|
|
|
# (was part of group_min_max.test)
|
|
|
|
#
|
|
|
|
|
|
|
|
eval create table t1 (
|
|
|
|
a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
|
|
|
|
) ENGINE = $other_engine_type;
|
|
|
|
|
|
|
|
insert into t1 (a1, a2, b, c, d) values
|
|
|
|
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
|
|
|
|
('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
|
|
|
|
('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
|
|
|
|
('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
|
|
|
|
('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
|
|
|
|
('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
|
|
|
|
('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
|
|
|
|
('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
|
|
|
|
('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
|
|
|
|
('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
|
|
|
|
('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
|
|
|
|
('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
|
|
|
|
('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
|
|
|
|
('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
|
|
|
|
('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
|
|
|
|
('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'),
|
|
|
|
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
|
|
|
|
('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
|
|
|
|
('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
|
|
|
|
('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
|
|
|
|
('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
|
|
|
|
('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
|
|
|
|
('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
|
|
|
|
('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
|
|
|
|
('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
|
|
|
|
('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
|
|
|
|
('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
|
|
|
|
('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
|
|
|
|
('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
|
|
|
|
('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
|
|
|
|
('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
|
|
|
|
('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4');
|
|
|
|
--disable_warnings
|
|
|
|
create table t4 (
|
|
|
|
pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
|
|
|
|
);
|
|
|
|
--enable_warnings
|
|
|
|
insert into t4 (a1, a2, b, c, d, dummy) select * from t1;
|
|
|
|
|
|
|
|
create index idx12672_0 on t4 (a1);
|
|
|
|
create index idx12672_1 on t4 (a1,a2,b,c);
|
|
|
|
create index idx12672_2 on t4 (a1,a2,b);
|
|
|
|
analyze table t4;
|
|
|
|
|
|
|
|
select distinct a1 from t4 where pk_col not in (1,2,3,4);
|
|
|
|
|
|
|
|
drop table t1,t4;
|
|
|
|
|
2006-10-25 20:10:12 +04:00
|
|
|
|
|
|
|
#
|
|
|
|
# BUG#18819: DELETE IGNORE hangs on foreign key parent delete
|
|
|
|
#
|
|
|
|
# The bug itself does not relate to InnoDB, but we have to use foreign
|
|
|
|
# keys to reproduce it.
|
|
|
|
#
|
|
|
|
--disable_warnings
|
|
|
|
DROP TABLE IF EXISTS t2, t1;
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE= InnoDB;
|
|
|
|
CREATE TABLE t2 (
|
|
|
|
i INT NOT NULL,
|
|
|
|
FOREIGN KEY (i) REFERENCES t1 (i) ON DELETE NO ACTION
|
|
|
|
) ENGINE= InnoDB;
|
|
|
|
|
|
|
|
INSERT INTO t1 VALUES (1);
|
|
|
|
INSERT INTO t2 VALUES (1);
|
|
|
|
|
|
|
|
DELETE IGNORE FROM t1 WHERE i = 1;
|
|
|
|
|
|
|
|
SELECT * FROM t1, t2;
|
|
|
|
|
|
|
|
DROP TABLE t2, t1;
|
|
|
|
|
|
|
|
|
|
|
|
--echo End of 4.1 tests.
|
|
|
|
|
|
|
|
|
2006-08-16 14:58:49 +02:00
|
|
|
#
|
2006-08-16 19:29:49 +02:00
|
|
|
# Bug #6142: a problem with the empty innodb table
|
2006-08-16 14:58:49 +02:00
|
|
|
# (was part of group_min_max.test)
|
|
|
|
#
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
create table t1 (
|
|
|
|
a varchar(30), b varchar(30), primary key(a), key(b)
|
|
|
|
);
|
|
|
|
--enable_warnings
|
|
|
|
select distinct a from t1;
|
|
|
|
drop table t1;
|
|
|
|
|
|
|
|
#
|
2006-08-16 19:29:49 +02:00
|
|
|
# Bug #9798: group by with rollup
|
2006-08-16 14:58:49 +02:00
|
|
|
# (was part of group_min_max.test)
|
|
|
|
#
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
create table t1(a int, key(a));
|
|
|
|
--enable_warnings
|
|
|
|
insert into t1 values(1);
|
|
|
|
select a, count(a) from t1 group by a with rollup;
|
|
|
|
drop table t1;
|
|
|
|
|
|
|
|
#
|
2006-08-16 19:29:49 +02:00
|
|
|
# Bug #13293 Wrongly used index results in endless loop.
|
2006-08-16 14:58:49 +02:00
|
|
|
# (was part of group_min_max.test)
|
|
|
|
#
|
2013-07-21 16:39:19 +02:00
|
|
|
create table t1 (f1 int, f2 char(1), primary key(f1,f2)) stats_persistent=0;
|
2006-08-16 14:58:49 +02:00
|
|
|
insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d");
|
|
|
|
alter table t1 drop primary key, add primary key (f2, f1);
|
|
|
|
explain select distinct f1 a, f1 b from t1;
|
|
|
|
explain select distinct f1, f2 from t1;
|
|
|
|
drop table t1;
|
|
|
|
|
2006-09-14 21:44:17 +02:00
|
|
|
#
|
|
|
|
# Test for bug #17164: ORed FALSE blocked conversion of outer join into join
|
2006-09-18 16:55:56 +02:00
|
|
|
#
|
2006-09-14 21:44:17 +02:00
|
|
|
|
|
|
|
CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
|
2006-09-18 16:55:56 +02:00
|
|
|
INDEX (name));
|
|
|
|
CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11));
|
|
|
|
# CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11),
|
|
|
|
# FOREIGN KEY (fkey) REFERENCES t2(id));
|
|
|
|
if ($test_foreign_keys)
|
|
|
|
{
|
|
|
|
ALTER TABLE t2 ADD FOREIGN KEY (fkey) REFERENCES t2(id);
|
|
|
|
}
|
2006-09-14 21:44:17 +02:00
|
|
|
INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
|
|
|
|
INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
ANALYZE TABLE t2;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2006-09-14 21:44:17 +02:00
|
|
|
EXPLAIN
|
2006-09-18 16:55:56 +02:00
|
|
|
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
|
2006-09-14 21:44:17 +02:00
|
|
|
WHERE t1.name LIKE 'A%';
|
|
|
|
|
|
|
|
EXPLAIN
|
2006-09-18 16:55:56 +02:00
|
|
|
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
|
2006-09-14 21:44:17 +02:00
|
|
|
WHERE t1.name LIKE 'A%' OR FALSE;
|
|
|
|
|
|
|
|
DROP TABLE t1,t2;
|
2006-08-16 14:58:49 +02:00
|
|
|
|
2007-02-13 01:34:36 -08:00
|
|
|
#
|
|
|
|
# Bug#26159: crash for a loose scan of a table that has been emptied
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
id int NOT NULL,
|
|
|
|
name varchar(20) NOT NULL,
|
|
|
|
dept varchar(20) NOT NULL,
|
|
|
|
age tinyint(3) unsigned NOT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
INDEX (name,dept)
|
2013-07-21 16:39:19 +02:00
|
|
|
) ENGINE=InnoDB STATS_PERSISTENT=0;
|
2007-02-13 01:34:36 -08:00
|
|
|
INSERT INTO t1(id, dept, age, name) VALUES
|
|
|
|
(3987, 'cs1', 10, 'rs1'), (3988, 'cs2', 20, 'rs1'), (3995, 'cs3', 10, 'rs2'),
|
|
|
|
(3996, 'cs4', 20, 'rs2'), (4003, 'cs5', 10, 'rs3'), (4004, 'cs6', 20, 'rs3'),
|
|
|
|
(4011, 'cs7', 10, 'rs4'), (4012, 'cs8', 20, 'rs4'), (4019, 'cs9', 10, 'rs5'),
|
|
|
|
(4020, 'cs10', 20, 'rs5'),(4027, 'cs11', 10, 'rs6'),(4028, 'cs12', 20, 'rs6');
|
|
|
|
|
|
|
|
EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
|
|
|
SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
|
|
|
DELETE FROM t1;
|
2009-10-05 15:16:27 +02:00
|
|
|
--echo # Masking (#) number in "rows" column of the following EXPLAIN output, as it may vary (bug#47746).
|
|
|
|
--replace_column 9 #
|
2007-02-13 01:34:36 -08:00
|
|
|
EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
|
|
|
SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
--source include/innodb_rollback_on_timeout.inc
|
|
|
|
|
2007-04-19 22:53:19 +02:00
|
|
|
#
|
|
|
|
# Bug #27210: INNODB ON DUPLICATE KEY UPDATE
|
|
|
|
#
|
|
|
|
|
|
|
|
set @save_qcache_size=@@global.query_cache_size;
|
|
|
|
set @save_qcache_type=@@global.query_cache_type;
|
|
|
|
set global query_cache_size=10*1024*1024;
|
|
|
|
set global query_cache_type=1;
|
|
|
|
connect (con1,localhost,root,,);
|
|
|
|
connection con1;
|
|
|
|
drop table if exists `test`;
|
|
|
|
CREATE TABLE `test` (`test1` varchar(3) NOT NULL,
|
|
|
|
`test2` varchar(4) NOT NULL,PRIMARY KEY (`test1`))
|
|
|
|
ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
|
|
|
INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '5678');
|
|
|
|
disconnect con1;
|
|
|
|
connect (con2,localhost,root,,);
|
|
|
|
connection con2;
|
|
|
|
select * from test;
|
|
|
|
INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '1234')
|
|
|
|
ON DUPLICATE KEY UPDATE `test2` = '1234';
|
|
|
|
select * from test;
|
|
|
|
flush tables;
|
|
|
|
select * from test;
|
|
|
|
disconnect con2;
|
2007-04-29 19:04:05 +05:00
|
|
|
connection default;
|
|
|
|
drop table test;
|
|
|
|
set global query_cache_type=@save_qcache_type;
|
|
|
|
set global query_cache_size=@save_qcache_size;
|
|
|
|
|
|
|
|
--source include/innodb_rollback_on_timeout.inc
|
|
|
|
|
2007-04-29 13:19:32 +05:00
|
|
|
#
|
|
|
|
# Bug #27650: INSERT fails after multi-row INSERT of the form:
|
|
|
|
# INSERT INTO t (id...) VALUES (NULL...) ON DUPLICATE KEY UPDATE id=VALUES(id)
|
|
|
|
#
|
|
|
|
|
|
|
|
create table t1(
|
|
|
|
id int auto_increment,
|
|
|
|
c char(1) not null,
|
|
|
|
counter int not null default 1,
|
|
|
|
primary key (id),
|
|
|
|
unique key (c)
|
|
|
|
) engine=innodb;
|
|
|
|
|
|
|
|
insert into t1 (id, c) values
|
|
|
|
(NULL, 'a'),
|
|
|
|
(NULL, 'a')
|
|
|
|
on duplicate key update id = values(id), counter = counter + 1;
|
|
|
|
|
|
|
|
select * from t1;
|
|
|
|
|
|
|
|
insert into t1 (id, c) values
|
|
|
|
(NULL, 'b')
|
|
|
|
on duplicate key update id = values(id), counter = counter + 1;
|
|
|
|
|
|
|
|
select * from t1;
|
|
|
|
|
|
|
|
truncate table t1;
|
|
|
|
|
|
|
|
insert into t1 (id, c) values (NULL, 'a');
|
|
|
|
|
|
|
|
select * from t1;
|
|
|
|
|
|
|
|
insert into t1 (id, c) values (NULL, 'b'), (NULL, 'b')
|
|
|
|
on duplicate key update id = values(id), c = values(c), counter = counter + 1;
|
|
|
|
|
|
|
|
select * from t1;
|
|
|
|
|
|
|
|
insert into t1 (id, c) values (NULL, 'a')
|
|
|
|
on duplicate key update id = values(id), c = values(c), counter = counter + 1;
|
|
|
|
|
|
|
|
select * from t1;
|
|
|
|
|
|
|
|
drop table t1;
|
|
|
|
|
2007-05-11 17:48:20 +05:00
|
|
|
#
|
|
|
|
# Bug #28189: optimizer erroniously prefers ref access to range access
|
|
|
|
# for an InnoDB table
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1(
|
|
|
|
id int AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
stat_id int NOT NULL,
|
|
|
|
acct_id int DEFAULT NULL,
|
|
|
|
INDEX idx1 (stat_id, acct_id),
|
|
|
|
INDEX idx2 (acct_id)
|
|
|
|
) ENGINE=MyISAM;
|
|
|
|
|
|
|
|
CREATE TABLE t2(
|
|
|
|
id int AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
stat_id int NOT NULL,
|
|
|
|
acct_id int DEFAULT NULL,
|
|
|
|
INDEX idx1 (stat_id, acct_id),
|
|
|
|
INDEX idx2 (acct_id)
|
2013-07-21 16:39:19 +02:00
|
|
|
) ENGINE=InnoDB STATS_PERSISTENT=0;
|
2007-05-11 17:48:20 +05:00
|
|
|
|
|
|
|
INSERT INTO t1(stat_id,acct_id) VALUES
|
|
|
|
(1,759), (2,831), (3,785), (4,854), (1,921),
|
|
|
|
(1,553), (2,589), (3,743), (2,827), (2,545),
|
|
|
|
(4,779), (4,783), (1,597), (1,785), (4,832),
|
|
|
|
(1,741), (1,833), (3,788), (2,973), (1,907);
|
|
|
|
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
2017-02-08 15:28:00 -05:00
|
|
|
INSERT IGNORE INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT IGNORE INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT IGNORE INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT IGNORE INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT IGNORE INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT IGNORE INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT IGNORE INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT IGNORE INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
2007-05-11 17:48:20 +05:00
|
|
|
UPDATE t1 SET acct_id=785
|
|
|
|
WHERE MOD(stat_id,2)=0 AND MOD(id,stat_id)=MOD(acct_id,stat_id);
|
|
|
|
OPTIMIZE TABLE t1;
|
|
|
|
|
|
|
|
SELECT COUNT(*) FROM t1;
|
|
|
|
SELECT COUNT(*) FROM t1 WHERE acct_id=785;
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2007-05-11 17:48:20 +05:00
|
|
|
EXPLAIN SELECT COUNT(*) FROM t1 WHERE stat_id IN (1,3) AND acct_id=785;
|
|
|
|
|
|
|
|
INSERT INTO t2 SELECT * FROM t1;
|
|
|
|
OPTIMIZE TABLE t2;
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t2;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
2007-05-11 17:48:20 +05:00
|
|
|
|
|
|
|
DROP TABLE t1,t2;
|
|
|
|
|
2007-06-04 10:14:28 +05:00
|
|
|
#
|
|
|
|
# Bug #28652: assert when alter innodb table operation
|
|
|
|
#
|
|
|
|
create table t1(a int) engine=innodb;
|
|
|
|
alter table t1 comment '123';
|
|
|
|
show create table t1;
|
|
|
|
drop table t1;
|
|
|
|
|
2007-06-11 00:16:00 +04:00
|
|
|
#
|
|
|
|
# Bug #25866: Getting "#HY000 Can't find record in..." on and INSERT
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8;
|
|
|
|
INSERT INTO t1 VALUES ('uk'),('bg');
|
|
|
|
SELECT * FROM t1 WHERE a = 'uk';
|
|
|
|
DELETE FROM t1 WHERE a = 'uk';
|
|
|
|
SELECT * FROM t1 WHERE a = 'uk';
|
|
|
|
UPDATE t1 SET a = 'us' WHERE a = 'uk';
|
|
|
|
SELECT * FROM t1 WHERE a = 'uk';
|
|
|
|
|
|
|
|
CREATE TABLE t2 (a CHAR(2), KEY (a)) ENGINE = InnoDB;
|
|
|
|
INSERT INTO t2 VALUES ('uk'),('bg');
|
|
|
|
SELECT * FROM t2 WHERE a = 'uk';
|
|
|
|
DELETE FROM t2 WHERE a = 'uk';
|
|
|
|
SELECT * FROM t2 WHERE a = 'uk';
|
|
|
|
INSERT INTO t2 VALUES ('uk');
|
|
|
|
UPDATE t2 SET a = 'us' WHERE a = 'uk';
|
|
|
|
SELECT * FROM t2 WHERE a = 'uk';
|
|
|
|
|
|
|
|
CREATE TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM;
|
|
|
|
INSERT INTO t3 VALUES ('uk'),('bg');
|
|
|
|
SELECT * FROM t3 WHERE a = 'uk';
|
|
|
|
DELETE FROM t3 WHERE a = 'uk';
|
|
|
|
SELECT * FROM t3 WHERE a = 'uk';
|
|
|
|
INSERT INTO t3 VALUES ('uk');
|
|
|
|
UPDATE t3 SET a = 'us' WHERE a = 'uk';
|
|
|
|
SELECT * FROM t3 WHERE a = 'uk';
|
|
|
|
|
|
|
|
DROP TABLE t1,t2,t3;
|
|
|
|
|
2007-07-06 13:49:15 +03:00
|
|
|
#
|
|
|
|
# Test bug when trying to drop data file which no InnoDB directory entry
|
|
|
|
#
|
|
|
|
|
2016-09-06 09:43:16 +03:00
|
|
|
--disable_query_log
|
|
|
|
call mtr.add_suppression("InnoDB: Table .*bug29807.*");
|
|
|
|
call mtr.add_suppression("InnoDB: Cannot open table test/bug29807 from");
|
|
|
|
--enable_query_log
|
|
|
|
|
2007-07-06 13:49:15 +03:00
|
|
|
create table t1 (a int) engine=innodb;
|
2007-12-12 18:19:24 +01:00
|
|
|
let $MYSQLD_DATADIR= `select @@datadir`;
|
|
|
|
copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/bug29807.frm;
|
2013-04-09 15:34:17 +02:00
|
|
|
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
2007-07-16 15:09:46 +05:00
|
|
|
select * from bug29807;
|
2007-07-06 13:49:15 +03:00
|
|
|
drop table t1;
|
2007-07-16 15:09:46 +05:00
|
|
|
drop table bug29807;
|
2007-07-06 13:49:15 +03:00
|
|
|
|
2007-06-30 20:49:28 -07:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug #29154: LOCK TABLES is not atomic when >1 InnoDB tables are locked
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
|
|
|
|
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
CONNECT (c1,localhost,root,,);
|
|
|
|
CONNECT (c2,localhost,root,,);
|
|
|
|
|
|
|
|
CONNECTION c1;
|
|
|
|
SET AUTOCOMMIT=0;
|
|
|
|
INSERT INTO t2 VALUES (1);
|
|
|
|
|
|
|
|
CONNECTION c2;
|
|
|
|
SET AUTOCOMMIT=0;
|
2016-12-22 14:02:27 +04:00
|
|
|
SET @old_lock_wait_timeout= @@lock_wait_timeout;
|
|
|
|
SET lock_wait_timeout= 1;
|
2007-06-30 20:49:28 -07:00
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
|
|
LOCK TABLES t1 READ, t2 READ;
|
2016-12-22 14:02:27 +04:00
|
|
|
SET @@lock_wait_timeout= @old_lock_wait_timeout;
|
2007-06-30 20:49:28 -07:00
|
|
|
CONNECTION c1;
|
|
|
|
COMMIT;
|
|
|
|
INSERT INTO t1 VALUES (1);
|
|
|
|
|
|
|
|
CONNECTION default;
|
|
|
|
SET AUTOCOMMIT=default;
|
|
|
|
DISCONNECT c1;
|
|
|
|
DISCONNECT c2;
|
|
|
|
DROP TABLE t1,t2;
|
|
|
|
|
2007-07-04 11:46:45 +03:00
|
|
|
#
|
|
|
|
# Bug #25798: a query with forced index merge returns wrong result
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
id int NOT NULL auto_increment PRIMARY KEY,
|
|
|
|
b int NOT NULL,
|
|
|
|
c datetime NOT NULL,
|
|
|
|
INDEX idx_b(b),
|
|
|
|
INDEX idx_c(c)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
CREATE TABLE t2 (
|
|
|
|
b int NOT NULL auto_increment PRIMARY KEY,
|
|
|
|
c datetime NOT NULL
|
|
|
|
) ENGINE= MyISAM;
|
|
|
|
|
|
|
|
INSERT INTO t2(c) VALUES ('2007-01-01');
|
|
|
|
INSERT INTO t2(c) SELECT c FROM t2;
|
|
|
|
INSERT INTO t2(c) SELECT c FROM t2;
|
|
|
|
INSERT INTO t2(c) SELECT c FROM t2;
|
|
|
|
INSERT INTO t2(c) SELECT c FROM t2;
|
|
|
|
INSERT INTO t2(c) SELECT c FROM t2;
|
|
|
|
INSERT INTO t2(c) SELECT c FROM t2;
|
|
|
|
INSERT INTO t2(c) SELECT c FROM t2;
|
|
|
|
INSERT INTO t2(c) SELECT c FROM t2;
|
|
|
|
INSERT INTO t2(c) SELECT c FROM t2;
|
|
|
|
INSERT INTO t2(c) SELECT c FROM t2;
|
|
|
|
|
|
|
|
INSERT INTO t1(b,c) SELECT b,c FROM t2;
|
|
|
|
UPDATE t2 SET c='2007-01-02';
|
|
|
|
INSERT INTO t1(b,c) SELECT b,c FROM t2;
|
|
|
|
UPDATE t2 SET c='2007-01-03';
|
|
|
|
INSERT INTO t1(b,c) SELECT b,c FROM t2;
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
ANALYZE TABLE t2;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2007-07-04 11:46:45 +03:00
|
|
|
set @@sort_buffer_size=8192;
|
|
|
|
|
|
|
|
SELECT COUNT(*) FROM t1;
|
|
|
|
|
|
|
|
--replace_column 9 #
|
|
|
|
EXPLAIN
|
|
|
|
SELECT COUNT(*) FROM t1
|
|
|
|
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
|
|
|
|
SELECT COUNT(*) FROM t1
|
|
|
|
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
|
|
|
|
|
|
|
|
--replace_column 9 #
|
|
|
|
EXPLAIN
|
|
|
|
SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c)
|
|
|
|
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
|
|
|
|
SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c)
|
|
|
|
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
|
|
|
|
|
|
|
|
set @@sort_buffer_size=default;
|
|
|
|
|
|
|
|
DROP TABLE t1,t2;
|
|
|
|
|
2006-08-16 14:58:49 +02:00
|
|
|
# Test of behaviour with CREATE ... SELECT
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a int, b int);
|
|
|
|
insert into t1 values (1,1),(1,2);
|
2007-06-06 10:57:07 -07:00
|
|
|
--error ER_DUP_ENTRY
|
2006-08-16 14:58:49 +02:00
|
|
|
CREATE TABLE t2 (primary key (a)) select * from t1;
|
|
|
|
# This should give warning
|
|
|
|
drop table if exists t2;
|
2007-06-06 10:57:07 -07:00
|
|
|
--error ER_DUP_ENTRY
|
2006-08-16 14:58:49 +02:00
|
|
|
CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1;
|
|
|
|
# This should give warning
|
|
|
|
drop table if exists t2;
|
|
|
|
CREATE TABLE t2 (a int, b int, primary key (a));
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t2 values(100,100);
|
|
|
|
CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
|
|
|
|
SELECT * from t2;
|
|
|
|
ROLLBACK;
|
|
|
|
SELECT * from t2;
|
|
|
|
TRUNCATE table t2;
|
2007-06-06 10:57:07 -07:00
|
|
|
--error ER_DUP_ENTRY
|
2006-08-16 14:58:49 +02:00
|
|
|
INSERT INTO t2 select * from t1;
|
|
|
|
SELECT * from t2;
|
|
|
|
drop table t2;
|
|
|
|
|
|
|
|
CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a));
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t2 values(100,100);
|
|
|
|
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
|
|
|
|
SELECT * from t2;
|
|
|
|
COMMIT;
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t2 values(101,101);
|
|
|
|
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
|
|
|
|
SELECT * from t2;
|
|
|
|
ROLLBACK;
|
|
|
|
SELECT * from t2;
|
|
|
|
TRUNCATE table t2;
|
2007-06-06 10:57:07 -07:00
|
|
|
--error ER_DUP_ENTRY
|
2006-08-16 14:58:49 +02:00
|
|
|
INSERT INTO t2 select * from t1;
|
|
|
|
SELECT * from t2;
|
|
|
|
drop table t1,t2;
|
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#17530: Incorrect key truncation on table creation caused server crash.
|
|
|
|
#
|
2006-08-16 19:29:49 +02:00
|
|
|
create table t1(f1 varchar(800) binary not null, key(f1))
|
2006-08-16 14:58:49 +02:00
|
|
|
character set utf8 collate utf8_general_ci;
|
|
|
|
insert into t1 values('aaa');
|
|
|
|
drop table t1;
|
2006-09-14 21:44:17 +02:00
|
|
|
|
2006-10-25 17:14:32 -06:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#22781: SQL_BIG_RESULT fails to influence sort plan
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c FLOAT, KEY b(b)) ENGINE = INNODB;
|
|
|
|
|
|
|
|
INSERT INTO t1 VALUES ( 1 , 1 , 1);
|
|
|
|
INSERT INTO t1 SELECT a + 1 , MOD(a + 1 , 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 2 , MOD(a + 2 , 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 4 , MOD(a + 4 , 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 8 , MOD(a + 8 , 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20), 1 FROM t1;
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2006-10-25 17:14:32 -06:00
|
|
|
EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b;
|
|
|
|
EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2006-12-20 15:46:36 -07:00
|
|
|
--source include/innodb_rollback_on_timeout.inc
|
|
|
|
|
2007-07-16 23:31:36 +04:00
|
|
|
#
|
|
|
|
# Bug#27296 Assertion in ALTER TABLE SET DEFAULT in Linux Debug build
|
|
|
|
# (possible deadlock).
|
|
|
|
#
|
|
|
|
# The bug is applicable only to a transactoinal table.
|
|
|
|
# Cover with tests behavior that no longer causes an
|
|
|
|
# assertion.
|
|
|
|
#
|
|
|
|
--disable_warnings
|
|
|
|
drop table if exists t1;
|
|
|
|
--enable_warnings
|
|
|
|
create table t1 (a int) engine=innodb;
|
|
|
|
alter table t1 alter a set default 1;
|
|
|
|
drop table t1;
|
|
|
|
|
2007-07-31 20:00:05 +04:00
|
|
|
--echo
|
|
|
|
--echo Bug#24918 drop table and lock / inconsistent between
|
|
|
|
--echo perm and temp tables
|
|
|
|
--echo
|
|
|
|
--echo Check transactional tables under LOCK TABLES
|
|
|
|
--echo
|
|
|
|
--disable_warnings
|
|
|
|
drop table if exists t24918, t24918_tmp, t24918_trans, t24918_trans_tmp,
|
|
|
|
t24918_access;
|
|
|
|
--enable_warnings
|
|
|
|
create table t24918_access (id int);
|
|
|
|
create table t24918 (id int) engine=myisam;
|
|
|
|
create temporary table t24918_tmp (id int) engine=myisam;
|
|
|
|
create table t24918_trans (id int) engine=innodb;
|
|
|
|
create temporary table t24918_trans_tmp (id int) engine=innodb;
|
|
|
|
|
|
|
|
lock table t24918 write, t24918_tmp write, t24918_trans write, t24918_trans_tmp write;
|
|
|
|
drop table t24918;
|
|
|
|
--error ER_TABLE_NOT_LOCKED
|
|
|
|
select * from t24918_access;
|
|
|
|
drop table t24918_trans;
|
|
|
|
--error ER_TABLE_NOT_LOCKED
|
|
|
|
select * from t24918_access;
|
|
|
|
drop table t24918_trans_tmp;
|
|
|
|
--error ER_TABLE_NOT_LOCKED
|
|
|
|
select * from t24918_access;
|
|
|
|
drop table t24918_tmp;
|
|
|
|
--error ER_TABLE_NOT_LOCKED
|
|
|
|
select * from t24918_access;
|
|
|
|
unlock tables;
|
|
|
|
|
|
|
|
drop table t24918_access;
|
2007-07-26 01:23:39 +05:00
|
|
|
#
|
|
|
|
# Bug #28591: MySQL need not sort the records in case of ORDER BY
|
|
|
|
# primary_key on InnoDB table
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY bkey (b)) ENGINE=InnoDB;
|
|
|
|
INSERT INTO t1 VALUES (1,2),(3,2),(2,2),(4,2),(5,2),(6,2),(7,2),(8,2);
|
|
|
|
INSERT INTO t1 SELECT a + 8, 2 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 16, 1 FROM t1;
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
2007-07-26 01:23:39 +05:00
|
|
|
query_vertical EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a;
|
|
|
|
SELECT * FROM t1 WHERE b=2 ORDER BY a;
|
|
|
|
query_vertical EXPLAIN SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a;
|
|
|
|
SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a;
|
|
|
|
query_vertical EXPLAIN SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY b,a;
|
|
|
|
SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY b,a;
|
|
|
|
|
|
|
|
CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a), KEY bkey (b,c))
|
|
|
|
ENGINE=InnoDB;
|
|
|
|
INSERT INTO t2 VALUES (1,1,1),(3,1,1),(2,1,1),(4,1,1);
|
|
|
|
INSERT INTO t2 SELECT a + 4, 1, 1 FROM t2;
|
|
|
|
INSERT INTO t2 SELECT a + 8, 1, 1 FROM t2;
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t2;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2007-07-26 01:23:39 +05:00
|
|
|
query_vertical EXPLAIN SELECT * FROM t2 WHERE b=1 ORDER BY a;
|
|
|
|
SELECT * FROM t2 WHERE b=1 ORDER BY a;
|
|
|
|
query_vertical EXPLAIN SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY a;
|
|
|
|
SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY a;
|
|
|
|
query_vertical EXPLAIN SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY b,c,a;
|
|
|
|
SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY b,c,a;
|
|
|
|
query_vertical EXPLAIN SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY c,a;
|
|
|
|
SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY c,a;
|
|
|
|
|
|
|
|
DROP TABLE t1,t2;
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Bug #29644: alter table hangs if records locked in share mode by long
|
|
|
|
# running transaction
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a INT, PRIMARY KEY (a)) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
|
|
|
|
INSERT INTO t1 SELECT a + 8 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 16 FROM t1;
|
|
|
|
|
|
|
|
DELIMITER |;
|
|
|
|
CREATE PROCEDURE p1 ()
|
|
|
|
BEGIN
|
|
|
|
DECLARE i INT DEFAULT 50;
|
|
|
|
DECLARE cnt INT;
|
2009-12-08 10:39:49 +03:00
|
|
|
# Continue even in the presence of ER_LOCK_DEADLOCK.
|
|
|
|
DECLARE CONTINUE HANDLER FOR 1213 BEGIN END;
|
2007-07-26 01:23:39 +05:00
|
|
|
START TRANSACTION;
|
|
|
|
ALTER TABLE t1 ENGINE=InnoDB;
|
|
|
|
COMMIT;
|
|
|
|
START TRANSACTION;
|
|
|
|
WHILE (i > 0) DO
|
|
|
|
SET i = i - 1;
|
|
|
|
SELECT COUNT(*) INTO cnt FROM t1 LOCK IN SHARE MODE;
|
|
|
|
END WHILE;
|
|
|
|
COMMIT;
|
|
|
|
END;|
|
|
|
|
|
|
|
|
DELIMITER ;|
|
|
|
|
|
|
|
|
CONNECT (con1,localhost,root,,);
|
|
|
|
CONNECT (con2,localhost,root,,);
|
|
|
|
|
|
|
|
CONNECTION con1;
|
|
|
|
SEND CALL p1();
|
|
|
|
CONNECTION con2;
|
|
|
|
SEND CALL p1();
|
|
|
|
CONNECTION default;
|
|
|
|
CALL p1();
|
|
|
|
|
|
|
|
CONNECTION con1;
|
|
|
|
REAP;
|
|
|
|
CONNECTION con2;
|
|
|
|
REAP;
|
|
|
|
CONNECTION default;
|
|
|
|
DISCONNECT con1;
|
|
|
|
DISCONNECT con2;
|
|
|
|
|
|
|
|
DROP PROCEDURE p1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2007-07-20 10:30:40 +05:00
|
|
|
#
|
|
|
|
# Bug #28125: ERROR 2013 when adding index.
|
|
|
|
#
|
|
|
|
create table t1(a text) engine=innodb default charset=utf8;
|
|
|
|
insert into t1 values('aaa');
|
2017-02-08 15:28:00 -05:00
|
|
|
set statement sql_mode = 'NO_ENGINE_SUBSTITUTION' for
|
2007-07-20 10:30:40 +05:00
|
|
|
alter table t1 add index(a(1024));
|
|
|
|
show create table t1;
|
|
|
|
drop table t1;
|
2007-07-26 01:23:39 +05:00
|
|
|
|
2007-08-15 12:03:11 +02:00
|
|
|
#
|
|
|
|
# Bug #28570: handler::index_read() is called with different find_flag when
|
|
|
|
# ORDER BY is used
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
a INT,
|
|
|
|
b INT,
|
|
|
|
KEY (b)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
INSERT INTO t1 VALUES (1,10), (2,10), (2,20), (3,30);
|
|
|
|
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1 WHERE b=20 FOR UPDATE;
|
|
|
|
|
|
|
|
--connect (conn2, localhost, root,,test)
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
# This statement gives a "failed: 1205: Lock wait timeout exceeded; try
|
2007-08-15 12:03:11 +02:00
|
|
|
# restarting transaction" message when the bug is present.
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1 WHERE b=10 ORDER BY A FOR UPDATE;
|
|
|
|
ROLLBACK;
|
|
|
|
|
|
|
|
--disconnect conn2
|
|
|
|
--connection default
|
|
|
|
|
|
|
|
ROLLBACK;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2007-08-28 18:01:29 +02:00
|
|
|
#
|
|
|
|
# Bug#30596: GROUP BY optimization gives wrong result order
|
|
|
|
#
|
|
|
|
CREATE TABLE t1(
|
|
|
|
a INT,
|
|
|
|
b INT NOT NULL,
|
|
|
|
c INT NOT NULL,
|
|
|
|
d INT,
|
|
|
|
UNIQUE KEY (c,b)
|
|
|
|
) engine=innodb;
|
|
|
|
|
|
|
|
INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2007-08-28 18:01:29 +02:00
|
|
|
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d;
|
|
|
|
SELECT c,b,d FROM t1 GROUP BY c,b,d;
|
|
|
|
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
|
|
|
|
SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
|
|
|
|
EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d;
|
|
|
|
SELECT c,b,d FROM t1 ORDER BY c,b,d;
|
|
|
|
|
|
|
|
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b;
|
|
|
|
SELECT c,b,d FROM t1 GROUP BY c,b;
|
|
|
|
EXPLAIN SELECT c,b FROM t1 GROUP BY c,b;
|
|
|
|
SELECT c,b FROM t1 GROUP BY c,b;
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2007-09-14 19:03:14 +03:00
|
|
|
#
|
|
|
|
# Bug #31001: ORDER BY DESC in InnoDB not working
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), INDEX b (b)) ENGINE=InnoDB;
|
|
|
|
INSERT INTO t1(a,b) VALUES (1,1), (2,2), (3,2);
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2007-09-14 19:03:14 +03:00
|
|
|
#The two queries below should produce different results, but they don't.
|
|
|
|
query_vertical EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
|
|
|
|
SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
|
|
|
|
query_vertical EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a DESC;
|
|
|
|
SELECT * FROM t1 WHERE b=2 ORDER BY a DESC;
|
|
|
|
|
|
|
|
query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a ASC;
|
|
|
|
SELECT * FROM t1 ORDER BY b ASC, a ASC;
|
|
|
|
query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a DESC;
|
|
|
|
SELECT * FROM t1 ORDER BY b DESC, a DESC;
|
|
|
|
query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a DESC;
|
|
|
|
SELECT * FROM t1 ORDER BY b ASC, a DESC;
|
|
|
|
query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a ASC;
|
|
|
|
SELECT * FROM t1 ORDER BY b DESC, a ASC;
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2007-10-29 15:42:49 +03:00
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo #
|
|
|
|
--echo # Bug#27610: ALTER TABLE ROW_FORMAT=... does not rebuild the table.
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo # - prepare;
|
|
|
|
--echo
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
--echo
|
|
|
|
|
|
|
|
CREATE TABLE t1(c INT)
|
|
|
|
ENGINE = InnoDB
|
|
|
|
ROW_FORMAT = COMPACT;
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo # - initial check;
|
|
|
|
--echo
|
|
|
|
|
|
|
|
SELECT table_schema, table_name, row_format
|
|
|
|
FROM INFORMATION_SCHEMA.TABLES
|
|
|
|
WHERE table_schema = DATABASE() AND table_name = 't1';
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo # - change ROW_FORMAT and check;
|
|
|
|
--echo
|
|
|
|
|
|
|
|
ALTER TABLE t1 ROW_FORMAT = REDUNDANT;
|
|
|
|
|
|
|
|
--echo
|
|
|
|
|
|
|
|
SELECT table_schema, table_name, row_format
|
|
|
|
FROM INFORMATION_SCHEMA.TABLES
|
|
|
|
WHERE table_schema = DATABASE() AND table_name = 't1';
|
|
|
|
|
|
|
|
--echo
|
|
|
|
--echo # - that's it, cleanup.
|
|
|
|
--echo
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
|
2007-10-29 20:31:03 +04:00
|
|
|
#
|
|
|
|
# Bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0
|
|
|
|
#
|
|
|
|
create table t1(a char(10) not null, unique key aa(a(1)),
|
|
|
|
b char(4) not null, unique key bb(b(4))) engine=innodb;
|
|
|
|
desc t1;
|
|
|
|
show create table t1;
|
|
|
|
drop table t1;
|
|
|
|
|
2008-01-11 10:05:34 -08:00
|
|
|
#
|
|
|
|
# Bug #32815: query with ORDER BY and a possible ref_or_null access
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (id int, type char(6), d int, INDEX idx(id,d)) ENGINE=InnoDB;
|
|
|
|
INSERT INTO t1 VALUES
|
|
|
|
(191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), (201, 'member', 2);
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2008-01-11 10:05:34 -08:00
|
|
|
EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
|
|
|
|
SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2008-02-13 12:12:00 +03:00
|
|
|
#
|
|
|
|
# Bug #34223: Assertion failed: (optp->var_type & 127) == 8,
|
|
|
|
# file .\my_getopt.c, line 830
|
|
|
|
#
|
|
|
|
|
|
|
|
set @my_innodb_autoextend_increment=@@global.innodb_autoextend_increment;
|
|
|
|
set global innodb_autoextend_increment=8;
|
|
|
|
set global innodb_autoextend_increment=@my_innodb_autoextend_increment;
|
|
|
|
|
|
|
|
set @my_innodb_commit_concurrency=@@global.innodb_commit_concurrency;
|
|
|
|
set global innodb_commit_concurrency=0;
|
|
|
|
set global innodb_commit_concurrency=@my_innodb_commit_concurrency;
|
|
|
|
|
2008-07-17 18:51:24 +03:00
|
|
|
#
|
|
|
|
# Bug #37830: ORDER BY ASC/DESC - no difference
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY (a), KEY t1_b (b))
|
|
|
|
ENGINE=InnoDB;
|
|
|
|
|
|
|
|
INSERT INTO t1 (a,b,c) VALUES (1,1,1), (2,1,1), (3,1,1), (4,1,1);
|
|
|
|
INSERT INTO t1 (a,b,c) SELECT a+4,b,c FROM t1;
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
2011-07-18 23:04:24 +02:00
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
# should be range access
|
2008-07-17 18:51:24 +03:00
|
|
|
EXPLAIN SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5;
|
|
|
|
|
|
|
|
# should produce '8 7 6 5 4' for a
|
|
|
|
SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5;
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2009-03-27 13:34:24 +04:00
|
|
|
#
|
|
|
|
# Bug#37284 Crash in Field_string::type()
|
|
|
|
#
|
|
|
|
--disable_warnings
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
--enable_warnings
|
|
|
|
CREATE TABLE t1 (a char(50)) ENGINE=InnoDB;
|
|
|
|
CREATE INDEX i1 on t1 (a(3));
|
|
|
|
SELECT * FROM t1 WHERE a = 'abcde';
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # BUG #26288: savepoint are not deleted on comit, if the transaction
|
|
|
|
--echo # was otherwise empty
|
|
|
|
--echo #
|
|
|
|
BEGIN;
|
|
|
|
SAVEPOINT s1;
|
|
|
|
COMMIT;
|
|
|
|
--error 1305
|
|
|
|
RELEASE SAVEPOINT s1;
|
|
|
|
|
|
|
|
BEGIN;
|
|
|
|
SAVEPOINT s2;
|
|
|
|
COMMIT;
|
|
|
|
--error 1305
|
|
|
|
ROLLBACK TO SAVEPOINT s2;
|
|
|
|
|
|
|
|
BEGIN;
|
|
|
|
SAVEPOINT s3;
|
|
|
|
ROLLBACK;
|
|
|
|
--error 1305
|
|
|
|
RELEASE SAVEPOINT s3;
|
|
|
|
|
|
|
|
BEGIN;
|
|
|
|
SAVEPOINT s4;
|
|
|
|
ROLLBACK;
|
|
|
|
--error 1305
|
|
|
|
ROLLBACK TO SAVEPOINT s4;
|
|
|
|
|
2009-05-19 11:48:04 +05:00
|
|
|
#
|
|
|
|
# Bug#39793 Foreign keys not constructed when column has a '#' in a comment or default value
|
|
|
|
#
|
|
|
|
|
|
|
|
#This statement should be written on a single line for proper testing
|
|
|
|
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY COMMENT 'My ID#', f2 INTEGER DEFAULT NULL, f3 CHAR(10) DEFAULT 'My ID#', CONSTRAINT f2_ref FOREIGN KEY (f2) REFERENCES t1 (f1)) ENGINE=INNODB;
|
|
|
|
SHOW CREATE TABLE t1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2009-06-04 13:26:18 +03:00
|
|
|
--echo #
|
|
|
|
--echo # Bug #36995: valgrind error in remove_const during subquery executions
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
create table t1 (a bit(1) not null,b int) engine=myisam;
|
|
|
|
create table t2 (c int) engine=innodb;
|
2010-03-11 23:43:31 +02:00
|
|
|
set @save_optimizer_switch=@@optimizer_switch;
|
2011-12-19 23:05:44 +02:00
|
|
|
set @@optimizer_switch='in_to_exists=on,materialization=off';
|
2009-06-04 13:26:18 +03:00
|
|
|
explain
|
2011-12-19 23:05:44 +02:00
|
|
|
select b from t1 where a not in (select max(b) from t1,t2 group by a) group by a;
|
2010-03-11 23:43:31 +02:00
|
|
|
set optimizer_switch=@save_optimizer_switch;
|
2009-06-04 13:26:18 +03:00
|
|
|
DROP TABLE t1,t2;
|
|
|
|
|
2006-10-25 17:14:32 -06:00
|
|
|
--echo End of 5.0 tests
|
|
|
|
|
2006-09-14 21:44:17 +02:00
|
|
|
# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY
|
|
|
|
# UPDATE": if the row is updated, it's like a regular UPDATE:
|
|
|
|
# LAST_INSERT_ID() is not affected.
|
|
|
|
CREATE TABLE `t2` (
|
|
|
|
`k` int(11) NOT NULL auto_increment,
|
|
|
|
`a` int(11) default NULL,
|
|
|
|
`c` int(11) default NULL,
|
|
|
|
PRIMARY KEY (`k`),
|
|
|
|
UNIQUE KEY `idx_1` (`a`)
|
2006-09-18 16:55:56 +02:00
|
|
|
);
|
|
|
|
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
|
2006-09-14 21:44:17 +02:00
|
|
|
ifnull( c,
|
|
|
|
0 ) + 1;
|
|
|
|
insert into t2 ( a ) values ( 7 ) on duplicate key update c =
|
|
|
|
ifnull( c,
|
|
|
|
0 ) + 1;
|
|
|
|
select last_insert_id();
|
|
|
|
select * from t2;
|
|
|
|
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
|
|
|
|
ifnull( c,
|
|
|
|
0 ) + 1;
|
|
|
|
select last_insert_id();
|
|
|
|
# test again when last_insert_id() is 0 initially
|
|
|
|
select last_insert_id(0);
|
|
|
|
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
|
|
|
|
ifnull( c,
|
|
|
|
0 ) + 1;
|
|
|
|
select last_insert_id();
|
|
|
|
select * from t2;
|
|
|
|
|
|
|
|
# Test of LAST_INSERT_ID() when autogenerated will fail:
|
|
|
|
# last_insert_id() should not change
|
|
|
|
insert ignore into t2 values (null,6,1),(10,8,1);
|
|
|
|
select last_insert_id();
|
|
|
|
# First and second autogenerated will fail, last_insert_id() should
|
|
|
|
# point to third
|
|
|
|
insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
|
|
|
|
select last_insert_id();
|
|
|
|
select * from t2;
|
|
|
|
|
|
|
|
# Test of the workaround which enables people to know the id of the
|
|
|
|
# updated row in INSERT ON DUPLICATE KEY UPDATE, by using
|
|
|
|
# LAST_INSERT_ID(autoinc_col) in the UPDATE clause.
|
|
|
|
|
|
|
|
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
|
|
|
|
ifnull( c,
|
|
|
|
0 ) + 1, k=last_insert_id(k);
|
|
|
|
select last_insert_id();
|
|
|
|
select * from t2;
|
|
|
|
|
|
|
|
drop table t2;
|
2006-10-25 17:14:32 -06:00
|
|
|
|
2007-05-14 22:38:26 +04:00
|
|
|
|
|
|
|
#
|
|
|
|
# Tests for bug #28415 "Some ALTER TABLE statements no longer work
|
|
|
|
# under LOCK TABLES" and some aspects of fast ALTER TABLE behaviour
|
|
|
|
# for transactional tables.
|
|
|
|
#
|
|
|
|
--disable_warnings
|
|
|
|
drop table if exists t1, t2;
|
|
|
|
--enable_warnings
|
|
|
|
create table t1 (i int);
|
|
|
|
alter table t1 modify i int default 1;
|
|
|
|
alter table t1 modify i int default 2, rename t2;
|
|
|
|
lock table t2 write;
|
|
|
|
alter table t2 modify i int default 3;
|
|
|
|
unlock tables;
|
|
|
|
lock table t2 write;
|
|
|
|
alter table t2 modify i int default 4, rename t1;
|
|
|
|
unlock tables;
|
|
|
|
drop table t1;
|
|
|
|
|
2007-05-19 10:49:56 +04:00
|
|
|
|
|
|
|
#
|
|
|
|
# Some more tests for ALTER TABLE and LOCK TABLES for transactional tables.
|
|
|
|
#
|
|
|
|
# Table which is altered under LOCK TABLES should stay in list of locked
|
|
|
|
# tables and be available after alter takes place unless ALTER contains
|
|
|
|
# RENAME clause. We should see the new definition of table, of course.
|
|
|
|
# Before 5.1 this behavior was inconsistent across the platforms and
|
|
|
|
# different engines. See also tests in alter_table.test
|
|
|
|
#
|
|
|
|
--disable_warnings
|
|
|
|
drop table if exists t1;
|
|
|
|
--enable_warnings
|
|
|
|
create table t1 (i int);
|
|
|
|
insert into t1 values ();
|
|
|
|
lock table t1 write;
|
|
|
|
# Example of so-called 'fast' ALTER TABLE
|
|
|
|
alter table t1 modify i int default 1;
|
|
|
|
insert into t1 values ();
|
|
|
|
select * from t1;
|
|
|
|
# And now full-blown ALTER TABLE
|
|
|
|
alter table t1 change i c char(10) default "Two";
|
|
|
|
insert into t1 values ();
|
|
|
|
select * from t1;
|
|
|
|
unlock tables;
|
|
|
|
select * from t1;
|
|
|
|
drop tables t1;
|
|
|
|
|
2007-07-08 18:13:04 +04:00
|
|
|
#
|
|
|
|
# Bug#29310: An InnoDB table was updated when the data wasn't actually changed.
|
|
|
|
#
|
|
|
|
create table t1(f1 varchar(5) unique, f2 timestamp NOT NULL DEFAULT
|
|
|
|
CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
|
|
|
|
insert into t1(f1) values(1);
|
|
|
|
--replace_column 1 #
|
|
|
|
select @a:=f2 from t1;
|
|
|
|
--sleep 5
|
|
|
|
update t1 set f1=1;
|
|
|
|
--replace_column 1 #
|
|
|
|
select @b:=f2 from t1;
|
|
|
|
select if(@a=@b,"ok","wrong");
|
|
|
|
--sleep 5
|
|
|
|
insert into t1(f1) values (1) on duplicate key update f1="1";
|
|
|
|
--replace_column 1 #
|
|
|
|
select @b:=f2 from t1;
|
|
|
|
select if(@a=@b,"ok","wrong");
|
|
|
|
--sleep 5
|
|
|
|
insert into t1(f1) select f1 from t1 on duplicate key update f1="1";
|
|
|
|
--replace_column 1 #
|
|
|
|
select @b:=f2 from t1;
|
|
|
|
select if(@a=@b,"ok","wrong");
|
|
|
|
drop table t1;
|
2007-05-19 10:49:56 +04:00
|
|
|
|
2007-09-13 19:22:08 -03:00
|
|
|
#
|
2007-10-09 01:07:15 +05:00
|
|
|
# Bug #31310: Locked rows silently skipped in read-committed isolation level.
|
|
|
|
#
|
|
|
|
|
|
|
|
connect (con1,localhost,root,,);
|
|
|
|
connect (con2,localhost,root,,);
|
|
|
|
SET SESSION AUTOCOMMIT = 0;
|
|
|
|
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
2008-10-03 15:24:19 +03:00
|
|
|
set binlog_format=mixed;
|
2007-10-09 01:07:15 +05:00
|
|
|
connection con1;
|
|
|
|
|
|
|
|
eval
|
|
|
|
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256))
|
|
|
|
ENGINE = $engine_type;
|
|
|
|
INSERT INTO t1 VALUES (1,2);
|
|
|
|
|
2007-11-02 09:58:29 +01:00
|
|
|
--echo # 1. test for locking:
|
2007-10-09 01:07:15 +05:00
|
|
|
|
|
|
|
BEGIN;
|
|
|
|
--enable_info
|
|
|
|
UPDATE t1 SET b = 12 WHERE a = 1;
|
|
|
|
--disable_info
|
|
|
|
SELECT * FROM t1;
|
|
|
|
|
|
|
|
connection con2;
|
|
|
|
|
|
|
|
--enable_info
|
|
|
|
--disable_abort_on_error
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
|
|
UPDATE t1 SET b = 21 WHERE a = 1;
|
|
|
|
--disable_info
|
|
|
|
|
|
|
|
connection con1;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
ROLLBACK;
|
|
|
|
|
2010-05-25 17:01:38 -03:00
|
|
|
connection con2;
|
|
|
|
ROLLBACK;
|
|
|
|
|
|
|
|
connection con1;
|
|
|
|
|
2007-10-09 01:07:15 +05:00
|
|
|
--echo # 2. test for serialized update:
|
|
|
|
|
|
|
|
CREATE TABLE t2 (a INT);
|
|
|
|
|
|
|
|
TRUNCATE t1;
|
|
|
|
INSERT INTO t1 VALUES (1,'init');
|
|
|
|
|
|
|
|
DELIMITER |;
|
|
|
|
CREATE PROCEDURE p1()
|
|
|
|
BEGIN
|
2010-12-08 14:34:08 +01:00
|
|
|
# retry the UPDATE in case it times out the lock before con1 has time
|
|
|
|
# to COMMIT.
|
|
|
|
DECLARE do_retry INT DEFAULT 0;
|
|
|
|
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET do_retry = 1;
|
|
|
|
retry_loop:LOOP
|
|
|
|
UPDATE t1 SET b = CONCAT(b, '+con2') WHERE a = 1;
|
|
|
|
IF do_retry = 0 THEN
|
|
|
|
LEAVE retry_loop;
|
|
|
|
END IF;
|
|
|
|
SET do_retry = 0;
|
|
|
|
END LOOP;
|
2007-10-09 01:07:15 +05:00
|
|
|
INSERT INTO t2 VALUES ();
|
|
|
|
END|
|
|
|
|
DELIMITER ;|
|
|
|
|
|
|
|
|
BEGIN;
|
|
|
|
--enable_info
|
|
|
|
UPDATE t1 SET b = CONCAT(b, '+con1') WHERE a = 1;
|
|
|
|
--disable_info
|
|
|
|
SELECT * FROM t1;
|
|
|
|
|
|
|
|
connection con2;
|
|
|
|
|
|
|
|
--send CALL p1;
|
|
|
|
|
|
|
|
connection con1;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
COMMIT;
|
|
|
|
|
|
|
|
let $bug31310 = 1;
|
|
|
|
while ($bug31310)
|
|
|
|
{
|
|
|
|
let $bug31310= `SELECT 1 - COUNT(*) FROM t2`;
|
|
|
|
}
|
|
|
|
|
|
|
|
SELECT * FROM t1;
|
|
|
|
|
|
|
|
connection con2;
|
2008-04-29 00:03:19 -03:00
|
|
|
--reap
|
2007-10-09 01:07:15 +05:00
|
|
|
SELECT * FROM t1;
|
Backport of revno ## 2617.31.1, 2617.31.3, 2617.31.4, 2617.31.5,
2617.31.12, 2617.31.15, 2617.31.15, 2617.31.16, 2617.43.1
- initial changeset that introduced the fix for
Bug#989 and follow up fixes for all test suite failures
introduced in the initial changeset.
------------------------------------------------------------
revno: 2617.31.1
committer: Davi Arnaut <Davi.Arnaut@Sun.COM>
branch nick: 4284-6.0
timestamp: Fri 2009-03-06 19:17:00 -0300
message:
Bug#989: If DROP TABLE while there's an active transaction, wrong binlog order
WL#4284: Transactional DDL locking
Currently the MySQL server does not keep metadata locks on
schema objects for the duration of a transaction, thus failing
to guarantee the integrity of the schema objects being used
during the transaction and to protect then from concurrent
DDL operations. This also poses a problem for replication as
a DDL operation might be replicated even thought there are
active transactions using the object being modified.
The solution is to defer the release of metadata locks until
a active transaction is either committed or rolled back. This
prevents other statements from modifying the table for the
entire duration of the transaction. This provides commitment
ordering for guaranteeing serializability across multiple
transactions.
- Incompatible change:
If MySQL's metadata locking system encounters a lock conflict,
the usual schema is to use the try and back-off technique to
avoid deadlocks -- this schema consists in releasing all locks
and trying to acquire them all in one go.
But in a transactional context this algorithm can't be utilized
as its not possible to release locks acquired during the course
of the transaction without breaking the transaction commitments.
To avoid deadlocks in this case, the ER_LOCK_DEADLOCK will be
returned if a lock conflict is encountered during a transaction.
Let's consider an example:
A transaction has two statements that modify table t1, then table
t2, and then commits. The first statement of the transaction will
acquire a shared metadata lock on table t1, and it will be kept
utill COMMIT to ensure serializability.
At the moment when the second statement attempts to acquire a
shared metadata lock on t2, a concurrent ALTER or DROP statement
might have locked t2 exclusively. The prescription of the current
locking protocol is that the acquirer of the shared lock backs off
-- gives up all his current locks and retries. This implies that
the entire multi-statement transaction has to be rolled back.
- Incompatible change:
FLUSH commands such as FLUSH PRIVILEGES and FLUSH TABLES WITH READ
LOCK won't cause locked tables to be implicitly unlocked anymore.
mysql-test/extra/binlog_tests/drop_table.test:
Add test case for Bug#989.
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
mysql-test/include/mix1.inc:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
mysql-test/include/mix2.inc:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
mysql-test/r/flush_block_commit.result:
Update test case result (WL#4284).
mysql-test/r/flush_block_commit_notembedded.result:
Update test case result (WL#4284).
mysql-test/r/innodb.result:
Update test case result (WL#4284).
mysql-test/r/innodb_mysql.result:
Update test case result (WL#4284).
mysql-test/r/lock.result:
Add test case result for an effect of WL#4284/Bug#989
(all locks should be released when a connection terminates).
mysql-test/r/mix2_myisam.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/r/not_embedded_server.result:
Update test case result (effects of WL#4284/Bug#989).
Add a test case for interaction of WL#4284 and FLUSH PRIVILEGES.
mysql-test/r/partition_innodb_semi_consistent.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/r/partition_sync.result:
Temporarily disable the test case for Bug#43867,
which will be fixed by a subsequent backport.
mysql-test/r/ps.result:
Add a test case for effect of PREPARE on transactional
locks: we take a savepoint at beginning of PREAPRE
and release it at the end. Thus PREPARE does not
accumulate metadata locks (Bug#989/WL#4284).
mysql-test/r/read_only_innodb.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_row_drop_tbl.result:
Add a test case result (WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_stm_drop_tbl.result:
Add a test case result (WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
Update test case result (effects of WL#4284/Bug#989).
mysql-test/suite/binlog/r/binlog_unsafe.result:
A side effect of Bug#989 -- slightly different table map ids.
mysql-test/suite/binlog/t/binlog_row_drop_tbl.test:
Add a test case for WL#4284/Bug#989.
mysql-test/suite/binlog/t/binlog_stm_drop_tbl.test:
Add a test case for WL#4284/Bug#989.
mysql-test/suite/binlog/t/binlog_stm_row.test:
Update to the new state name. This
is actually a follow up to another patch for WL#4284,
that changes Locked thread state to Table lock.
mysql-test/suite/ndb/r/ndb_index_ordered.result:
Remove result for disabled part of the test case.
mysql-test/suite/ndb/t/disabled.def:
Temporarily disable a test case (Bug#45621).
mysql-test/suite/ndb/t/ndb_index_ordered.test:
Disable a part of a test case (needs update to
reflect semantics of Bug#989).
mysql-test/suite/rpl/t/disabled.def:
Disable tests made meaningless by transactional metadata
locking.
mysql-test/suite/sys_vars/r/autocommit_func.result:
Add a commit (Bug#989).
mysql-test/suite/sys_vars/t/autocommit_func.test:
Add a commit (Bug#989).
mysql-test/t/flush_block_commit.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
mysql-test/t/flush_block_commit_notembedded.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction.
Add a test case for transaction-scope locks and the global
read lock (Bug#989/WL#4284).
mysql-test/t/innodb.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction
(effects of Bug#989/WL#4284).
mysql-test/t/lock.test:
Add a test case for Bug#989/WL#4284.
mysql-test/t/not_embedded_server.test:
Add a test case for Bug#989/WL#4284.
mysql-test/t/partition_innodb_semi_consistent.test:
Replace TRUNCATE with DELETE, to not issue
an implicit commit of a transaction, and not depend
on metadata locks.
mysql-test/t/partition_sync.test:
Temporarily disable the test case for Bug#43867,
which needs a fix to be backported from 6.0.
mysql-test/t/ps.test:
Add a test case for semantics of PREPARE and transaction-scope
locks: metadata locks on tables used in PREPARE are enclosed into a
temporary savepoint, taken at the beginning of PREPARE,
and released at the end. Thus PREPARE does not effect
what locks a transaction owns.
mysql-test/t/read_only_innodb.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction
(Bug#989/WL#4284).
Wait for the read_only statement to actually flush tables before
sending other concurrent statements that depend on its state.
mysql-test/t/xa.test:
Fix test case to reflect the fact that transactions now hold
metadata locks for the duration of a transaction
(Bug#989/WL#4284).
sql/ha_ndbcluster_binlog.cc:
Backport bits of changes of ha_ndbcluster_binlog.cc
from 6.0, to fix the failing binlog test suite with
WL#4284. WL#4284 implementation does not work
with 5.1 implementation of ndbcluster binlog index.
sql/log_event.cc:
Release metadata locks after issuing a commit.
sql/mdl.cc:
Style changes (WL#4284).
sql/mysql_priv.h:
Rename parameter to match the name used in the definition (WL#4284).
sql/rpl_injector.cc:
Release metadata locks on commit (WL#4284).
sql/rpl_rli.cc:
Remove assert made meaningless, metadata locks are released
at the end of the transaction.
sql/set_var.cc:
Close tables and release locks if autocommit mode is set.
sql/slave.cc:
Release metadata locks after a rollback.
sql/sql_acl.cc:
Don't implicitly unlock locked tables. Issue a implicit commit
at the end and unlock tables.
sql/sql_base.cc:
Defer the release of metadata locks when closing tables
if not required to.
Issue a deadlock error if the locking protocol requires
that a transaction re-acquire its locks.
Release metadata locks when closing tables for reopen.
sql/sql_class.cc:
Release metadata locks if the thread is killed.
sql/sql_parse.cc:
Release metadata locks after implicitly committing a active
transaction, or after explicit commits or rollbacks.
sql/sql_plugin.cc:
Allocate MDL request on the stack as the use of the table
is contained within the function. It will be removed from
the context once close_thread_tables is called at the end
of the function.
sql/sql_prepare.cc:
The problem is that the prepare phase of the CREATE TABLE
statement takes a exclusive metadata lock lock and this can
cause a self-deadlock the thread already holds a shared lock
on the table being that should be created.
The solution is to make the prepare phase take a shared
metadata lock when preparing a CREATE TABLE statement. The
execution of the statement will still acquire a exclusive
lock, but won't cause any problem as it issues a implicit
commit.
After some discussions with stakeholders it has been decided that
metadata locks acquired during a PREPARE statement must be released
once the statement is prepared even if it is prepared within a multi
statement transaction.
sql/sql_servers.cc:
Don't implicitly unlock locked tables. Issue a implicit commit
at the end and unlock tables.
sql/sql_table.cc:
Close table and release metadata locks after a admin operation.
sql/table.h:
The problem is that the prepare phase of the CREATE TABLE
statement takes a exclusive metadata lock lock and this can
cause a self-deadlock the thread already holds a shared lock
on the table being that should be created.
The solution is to make the prepare phase take a shared
metadata lock when preparing a CREATE TABLE statement. The
execution of the statement will still acquire a exclusive
lock, but won't cause any problem as it issues a implicit
commit.
sql/transaction.cc:
Release metadata locks after the implicitly committed due
to a new transaction being started. Also, release metadata
locks acquired after a savepoint if the transaction is rolled
back to the save point.
The problem is that in some cases transaction-long metadata locks
could be released before the transaction was committed. This could
happen when a active transaction was ended by a "START TRANSACTION"
or "BEGIN" statement, in which case the metadata locks would be
released before the actual commit of the active transaction.
The solution is to defer the release of metadata locks to after the
transaction has been implicitly committed. No test case is provided
as the effort to provide one is too disproportional to the size of
the fix.
2009-12-05 02:02:48 +03:00
|
|
|
COMMIT;
|
2007-10-09 01:07:15 +05:00
|
|
|
|
|
|
|
connection con1;
|
|
|
|
|
|
|
|
--echo # 3. test for updated key column:
|
|
|
|
|
|
|
|
TRUNCATE t1;
|
|
|
|
TRUNCATE t2;
|
|
|
|
|
|
|
|
INSERT INTO t1 VALUES (1,'init');
|
|
|
|
|
|
|
|
BEGIN;
|
|
|
|
--enable_info
|
|
|
|
UPDATE t1 SET a = 2, b = CONCAT(b, '+con1') WHERE a = 1;
|
|
|
|
--disable_info
|
|
|
|
SELECT * FROM t1;
|
|
|
|
|
|
|
|
connection con2;
|
|
|
|
|
|
|
|
--send CALL p1;
|
|
|
|
|
|
|
|
connection con1;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
COMMIT;
|
|
|
|
|
|
|
|
let $bug31310 = 1;
|
|
|
|
while ($bug31310)
|
|
|
|
{
|
|
|
|
let $bug31310= `SELECT 1 - COUNT(*) FROM t2`;
|
|
|
|
}
|
|
|
|
|
|
|
|
SELECT * FROM t1;
|
|
|
|
|
|
|
|
connection con2;
|
2009-04-02 12:21:51 +04:00
|
|
|
--reap
|
2007-10-09 01:07:15 +05:00
|
|
|
SELECT * FROM t1;
|
|
|
|
|
2010-05-25 17:01:38 -03:00
|
|
|
--enable_abort_on_error
|
2007-10-09 01:07:15 +05:00
|
|
|
connection default;
|
|
|
|
disconnect con1;
|
|
|
|
disconnect con2;
|
|
|
|
DROP PROCEDURE p1;
|
|
|
|
DROP TABLE t1, t2;
|
2007-09-13 19:22:08 -03:00
|
|
|
# Bug#30747 Create table with identical constraint names behaves incorrectly
|
|
|
|
#
|
|
|
|
|
|
|
|
if ($test_foreign_keys)
|
|
|
|
{
|
|
|
|
CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)) engine=innodb;
|
|
|
|
--error ER_WRONG_FK_DEF
|
|
|
|
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
|
|
|
|
CONSTRAINT c2 FOREIGN KEY f2 (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb;
|
|
|
|
--error ER_WRONG_FK_DEF
|
|
|
|
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
|
|
|
|
CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb;
|
|
|
|
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
|
|
|
|
CONSTRAINT c1 FOREIGN KEY c2 (c) REFERENCES t1 (a) ON DELETE NO ACTION,
|
|
|
|
CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION) engine=innodb;
|
|
|
|
ALTER TABLE t2 DROP FOREIGN KEY c2;
|
|
|
|
DROP TABLE t2;
|
|
|
|
--error ER_WRONG_FK_DEF
|
|
|
|
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
|
|
|
|
FOREIGN KEY (c) REFERENCES t1 (a,k) ON UPDATE NO ACTION) engine=innodb;
|
|
|
|
--error ER_WRONG_FK_DEF
|
|
|
|
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
|
|
|
|
FOREIGN KEY f1 (c) REFERENCES t1 (a,k) ON UPDATE NO ACTION) engine=innodb;
|
|
|
|
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
|
|
|
|
CONSTRAINT c1 FOREIGN KEY f1 (c) REFERENCES t1 (a) ON DELETE NO ACTION,
|
|
|
|
CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION,
|
|
|
|
FOREIGN KEY f3 (c) REFERENCES t1 (a) ON UPDATE NO ACTION,
|
|
|
|
FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION) engine=innodb;
|
|
|
|
SHOW CREATE TABLE t2;
|
|
|
|
DROP TABLE t2;
|
|
|
|
DROP TABLE t1;
|
|
|
|
}
|
|
|
|
|
2007-11-07 19:59:58 +04:00
|
|
|
#
|
|
|
|
# Bug #26447: "ALTER TABLE .. ORDER" does not work with InnoDB and
|
|
|
|
# auto_increment keys
|
|
|
|
#
|
|
|
|
create table t1 (a int auto_increment primary key) engine=innodb;
|
2017-02-08 15:28:00 -05:00
|
|
|
set statement sql_mode = 'NO_ENGINE_SUBSTITUTION' for
|
2007-11-07 19:59:58 +04:00
|
|
|
alter table t1 order by a;
|
|
|
|
drop table t1;
|
|
|
|
|
2008-01-11 10:05:34 -08:00
|
|
|
#
|
|
|
|
# Bug #33697: ORDER BY primary key DESC vs. ref access + filesort
|
|
|
|
# (reproduced only with InnoDB tables)
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1
|
|
|
|
(vid integer NOT NULL,
|
|
|
|
tid integer NOT NULL,
|
|
|
|
idx integer NOT NULL,
|
|
|
|
name varchar(128) NOT NULL,
|
|
|
|
type varchar(128) NULL,
|
|
|
|
PRIMARY KEY(idx, vid, tid),
|
|
|
|
UNIQUE(vid, tid, name)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
INSERT INTO t1 VALUES
|
|
|
|
(1,1,1,'pk',NULL),(2,1,1,'pk',NULL),(3,1,1,'pk',NULL),(4,1,1,'c1',NULL),
|
|
|
|
(5,1,1,'pk',NULL),(1,1,2,'c1',NULL),(2,1,2,'c1',NULL),(3,1,2,'c1',NULL),
|
|
|
|
(4,1,2,'c2',NULL),(5,1,2,'c1',NULL),(2,1,3,'c2',NULL),(3,1,3,'c2',NULL),
|
|
|
|
(4,1,3,'pk',NULL),(5,1,3,'c2',NULL),
|
|
|
|
(2,1,4,'c_extra',NULL),(3,1,4,'c_extra',NULL);
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2009-07-07 15:52:34 +03:00
|
|
|
EXPLAIN SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC;
|
2008-01-11 10:05:34 -08:00
|
|
|
|
2009-07-07 15:52:34 +03:00
|
|
|
SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC;
|
2008-01-11 10:05:34 -08:00
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2009-05-12 22:42:31 +05:00
|
|
|
--echo #
|
|
|
|
--echo # Bug #44290: explain crashes for subquery with distinct in
|
|
|
|
--echo # SQL_SELECT::test_quick_select
|
|
|
|
--echo # (reproduced only with InnoDB tables)
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
eval
|
|
|
|
CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, KEY (c3), KEY (c2, c3))
|
|
|
|
ENGINE=$engine_type;
|
|
|
|
INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2);
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2009-05-12 22:42:31 +05:00
|
|
|
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
|
|
|
|
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
|
|
|
|
EXPLAIN
|
|
|
|
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
|
|
|
|
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2009-05-25 11:00:40 +03:00
|
|
|
eval
|
|
|
|
CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3))
|
|
|
|
ENGINE=$engine_type;
|
|
|
|
INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2);
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2009-05-25 11:00:40 +03:00
|
|
|
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
|
|
|
|
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
|
|
|
|
EXPLAIN
|
|
|
|
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
|
|
|
|
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
eval
|
|
|
|
CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2),
|
|
|
|
KEY (c3), KEY (c2, c3))
|
|
|
|
ENGINE=$engine_type;
|
|
|
|
INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2);
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2009-05-25 11:00:40 +03:00
|
|
|
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
|
|
|
|
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
|
|
|
|
EXPLAIN
|
|
|
|
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
|
|
|
|
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2006-10-25 17:14:32 -06:00
|
|
|
--echo End of 5.1 tests
|
2010-05-25 17:01:38 -03:00
|
|
|
|
2013-07-21 16:39:19 +02:00
|
|
|
--echo #
|
|
|
|
--echo # Bug#43600: Incorrect type conversion caused wrong result.
|
|
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
a int NOT NULL
|
|
|
|
) engine= innodb;
|
|
|
|
|
|
|
|
CREATE TABLE t2 (
|
|
|
|
a int NOT NULL,
|
|
|
|
b int NOT NULL,
|
|
|
|
filler char(100) DEFAULT NULL,
|
|
|
|
KEY a (a,b)
|
|
|
|
) engine= innodb;
|
|
|
|
|
|
|
|
insert into t1 values (0),(1),(2),(3),(4);
|
|
|
|
insert into t2 select A.a + 10 *B.a, 1, 'filler' from t1 A, t1 B;
|
|
|
|
|
2016-12-22 16:48:49 +02:00
|
|
|
-- disable_query_log
|
|
|
|
-- disable_result_log
|
|
|
|
analyze table t1;
|
|
|
|
analyze table t2;
|
|
|
|
-- enable_result_log
|
|
|
|
-- enable_query_log
|
|
|
|
|
2013-07-21 16:39:19 +02:00
|
|
|
explain select * from t1, t2 where t2.a=t1.a and t2.b + 1;
|
|
|
|
select * from t1, t2 where t2.a=t1.a and t2.b + 1;
|
|
|
|
|
|
|
|
drop table t1,t2;
|
|
|
|
--echo # End of test case for the bug#43600
|
|
|
|
|
2010-05-25 17:01:38 -03:00
|
|
|
--echo #
|
|
|
|
--echo # Bug#42643: InnoDB does not support replication of TRUNCATE TABLE
|
|
|
|
--echo #
|
|
|
|
--echo # Check that a TRUNCATE TABLE statement, needing an exclusive meta
|
|
|
|
--echo # data lock, waits for a shared metadata lock owned by a concurrent
|
|
|
|
--echo # transaction.
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
eval CREATE TABLE t1 (a INT) ENGINE=$engine_type;
|
|
|
|
INSERT INTO t1 VALUES (1),(2),(3);
|
|
|
|
BEGIN;
|
|
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
connect (con1, localhost, root,,);
|
|
|
|
--send TRUNCATE TABLE t1;
|
|
|
|
connection default;
|
|
|
|
let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist
|
Part of fix for bug#52044 "FLUSH TABLES WITH READ LOCK and
FLUSH TABLES <list> WITH READ LOCK are incompatible" to
be pushed as separate patch.
Replaced thread state name "Waiting for table", which was
used by threads waiting for a metadata lock or table flush,
with a set of names which better reflect types of resources
being waited for.
Also replaced "Table lock" thread state name, which was used
by threads waiting on thr_lock.c table level lock, with more
elaborate "Waiting for table level lock", to make it
more consistent with other thread state names.
Updated test cases and their results according to these
changes.
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script.
mysql-test/r/query_cache.result:
Added test coverage for query_cache_wlock_invalidate
behavior for implicitly locked tables.
mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result:
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script. Reverted
changes to test which introduced timeout and replaced waiting
condition with a more appropriate one.
Test coverage for query_cache_wlock_invalidate behavior for
implicitly locked tables was added to query_cache.test.
mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test:
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script. Reverted
changes to test which introduced timeout and replaced waiting
condition with a more appropriate one.
Test coverage for query_cache_wlock_invalidate behavior for
implicitly locked tables was added to query_cache.test.
mysql-test/t/query_cache.test:
Added test coverage for query_cache_wlock_invalidate
behavior for implicitly locked tables.
mysys/thr_lock.c:
Replaced "Table lock" thread state name, which was used by
threads waiting on thr_lock.c table level lock, with more
elaborate "Waiting for table level lock", to make it
consistent with thread state names which are used while
waiting for metadata locks and table flush.
sql/mdl.cc:
Replaced thread state name "Waiting for table", which was
used by threads waiting for a metadata lock or table flush,
with a set of names which better reflect types of resources
being waited for.
To implement this:
- Adjusted MDL_wait::timed_wait() to take thread state name
as parameter.
- Introduced method of MDL_key class which allows to get
thread state name to be used while waiting for resource
corresponding to the key and changed code to use it.
Added array translating namespaces to thread state names
as part of this change.
sql/mdl.h:
To implement this:
- Adjusted MDL_wait::timed_wait() to take thread state name
as parameter.
- Introduced method of MDL_key class which allows to get
thread state name to be used while waiting for resource
corresponding to the key and changed code to use it.
Added array translating namespaces to thread state names
as part of this change.
sql/sql_base.cc:
Replaced thread state name "Waiting for table", which was
used by threads waiting for table flush, with a more elaborate
"Waiting for table flush".
2010-08-06 15:29:37 +04:00
|
|
|
WHERE state='Waiting for table metadata lock' AND info='TRUNCATE TABLE t1';
|
2010-05-25 17:01:38 -03:00
|
|
|
--source include/wait_condition.inc
|
|
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
ROLLBACK;
|
|
|
|
connection con1;
|
|
|
|
--echo # Reaping TRUNCATE TABLE
|
|
|
|
--reap
|
|
|
|
SELECT * FROM t1;
|
|
|
|
disconnect con1;
|
|
|
|
connection default;
|
|
|
|
DROP TABLE t1;
|