1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Fixes for innodb suite, merging tests from 5.6.

Includes 5.6 changesets for:
*****
Fix for BUG#13489996 valgrind:conditional jump or move depends on uninitialised values-field_blob.
blob_ptr_size was not initialized properly: remove this variable.
*****
Bug#14021323 CRASH IN FIELD::SET_NULL WHEN INSERTING ROWS TO NEW TABLE
*****
This commit is contained in:
Sergei Golubchik
2013-07-15 18:01:22 +02:00
parent b427da7651
commit e1c76b80d9
31 changed files with 1060 additions and 1455 deletions

View File

@ -1,6 +1,7 @@
set global innodb_support_xa=default;
set session innodb_support_xa=default;
SET SESSION STORAGE_ENGINE = InnoDB;
SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB;
SET SESSION DEFAULT_TMP_STORAGE_ENGINE = InnoDB;
drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4;
drop procedure if exists p1;
create table t1 (
@ -186,8 +187,8 @@ min(7)
7
explain select min(7) from t2i join t1i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join)
1 SIMPLE t2i ALL NULL NULL NULL NULL 1 NULL
1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer (Block Nested Loop)
select min(7) from t2i join t1i;
min(7)
NULL
@ -202,8 +203,8 @@ max(7)
7
explain select max(7) from t2i join t1i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join)
1 SIMPLE t2i ALL NULL NULL NULL NULL 1 NULL
1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer (Block Nested Loop)
select max(7) from t2i join t1i;
max(7)
NULL
@ -234,21 +235,21 @@ select 1, max(1) from t1i where 1=99;
explain select count(*), min(7), max(7) from t1m, t1i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found
1 SIMPLE t1i ALL NULL NULL NULL NULL 1
1 SIMPLE t1i ALL NULL NULL NULL NULL 1 NULL
select count(*), min(7), max(7) from t1m, t1i;
count(*) min(7) max(7)
0 NULL NULL
explain select count(*), min(7), max(7) from t1m, t2i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
1 SIMPLE t2i ALL NULL NULL NULL NULL 1 NULL
select count(*), min(7), max(7) from t1m, t2i;
count(*) min(7) max(7)
0 NULL NULL
explain select count(*), min(7), max(7) from t2m, t1i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2m system NULL NULL NULL NULL 1
1 SIMPLE t1i ALL NULL NULL NULL NULL 1
1 SIMPLE t2m system NULL NULL NULL NULL 1 NULL
1 SIMPLE t1i ALL NULL NULL NULL NULL 1 NULL
select count(*), min(7), max(7) from t2m, t1i;
count(*) min(7) max(7)
0 NULL NULL
@ -316,7 +317,7 @@ INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
DELETE IGNORE FROM t1 WHERE i = 1;
Warnings:
Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION)
Error 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION)
SELECT * FROM t1, t2;
i i
1 1
@ -335,7 +336,7 @@ a count(a)
1 1
NULL 1
drop table t1;
create table t1 (f1 int, f2 char(1), primary key(f1,f2));
create table t1 (f1 int, f2 char(1), primary key(f1,f2)) stats_persistent=0;
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;
@ -371,7 +372,7 @@ dept varchar(20) NOT NULL,
age tinyint(3) unsigned NOT NULL,
PRIMARY KEY (id),
INDEX (name,dept)
) ENGINE=InnoDB;
) ENGINE=InnoDB STATS_PERSISTENT=0;
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'),
@ -544,7 +545,7 @@ stat_id int NOT NULL,
acct_id int DEFAULT NULL,
INDEX idx1 (stat_id, acct_id),
INDEX idx2 (acct_id)
) ENGINE=InnoDB;
) ENGINE=InnoDB STATS_PERSISTENT=0;
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),
@ -679,6 +680,8 @@ 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;
set @@sort_buffer_size=8192;
Warnings:
Warning 1292 Truncated incorrect sort_buffer_size value: '8192'
SELECT COUNT(*) FROM t1;
COUNT(*)
3072
@ -695,7 +698,7 @@ EXPLAIN
SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c)
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge idx_b,idx_c idx_c,idx_b 8,4 NULL # Using sort_union(idx_c,idx_b); Using where
1 SIMPLE t1 index_merge idx_b,idx_c idx_c,idx_b 5,4 NULL # Using sort_union(idx_c,idx_b); Using where
SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c)
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
COUNT(*)
@ -779,7 +782,7 @@ 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;
EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 5 NULL 128
1 SIMPLE t1 index NULL b 5 NULL 128 NULL
EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using filesort
@ -1171,7 +1174,7 @@ c b d
3 2 40
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 NULL
SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
c b d
1 1 50
@ -1187,7 +1190,7 @@ c b d
3 2 40
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL c 8 NULL 3
1 SIMPLE t1 index NULL c 8 NULL 3 NULL
SELECT c,b,d FROM t1 GROUP BY c,b;
c b d
1 1 50
@ -1428,15 +1431,11 @@ DROP TABLE t1;
#
create table t1 (a bit(1) not null,b int) engine=myisam;
create table t2 (c int) engine=innodb;
set @save_optimizer_switch=@@optimizer_switch;
set @@optimizer_switch='in_to_exists=on,materialization=off';
explain
select b from t1 where a not in (select max(b) from t1,t2 group by a) group by a;
select b from t1 where a not in (select b from t1,t2 group by a) group by a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1
set optimizer_switch=@save_optimizer_switch;
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
DROP TABLE t1,t2;
End of 5.0 tests
CREATE TABLE `t2` (
@ -1479,15 +1478,10 @@ k a c
1 6 2
2 7 NULL
insert ignore into t2 values (null,6,1),(10,8,1);
Warnings:
Warning 1062 Duplicate entry '6' for key 'idx_1'
select last_insert_id();
last_insert_id()
0
insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
Warnings:
Warning 1062 Duplicate entry '6' for key 'idx_1'
Warning 1062 Duplicate entry '8' for key 'idx_1'
select last_insert_id();
last_insert_id()
11
@ -1607,17 +1601,7 @@ TRUNCATE t1;
INSERT INTO t1 VALUES (1,'init');
CREATE PROCEDURE p1()
BEGIN
# 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;
INSERT INTO t2 VALUES ();
END|
BEGIN;
@ -1752,7 +1736,7 @@ EXPLAIN
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 NULL
2 DERIVED t1 ref c3,c2 c3 5 const 2 Using where; Using filesort
DROP TABLE t1;
CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3))
@ -1766,7 +1750,7 @@ EXPLAIN
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 NULL
2 DERIVED t1 ref c3,c2 c3 9 const 2 Using where; Using filesort
DROP TABLE t1;
CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2),
@ -1781,11 +1765,38 @@ EXPLAIN
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 NULL
2 DERIVED t1 ref c3,c2 c3 7 const 2 Using where; Using filesort
DROP TABLE t1;
End of 5.1 tests
#
# Bug#43600: Incorrect type conversion caused wrong result.
#
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;
explain select * from t1, t2 where t2.a=t1.a and t2.b + 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 NULL
1 SIMPLE t2 ref a a 4 test.t1.a 1 Using index condition
select * from t1, t2 where t2.a=t1.a and t2.b + 1;
a a b filler
0 0 1 filler
1 1 1 filler
2 2 1 filler
3 3 1 filler
4 4 1 filler
drop table t1,t2;
# End of test case for the bug#43600
#
# Bug#42643: InnoDB does not support replication of TRUNCATE TABLE
#
# Check that a TRUNCATE TABLE statement, needing an exclusive meta
@ -1817,15 +1828,21 @@ a
# Connection default
DROP TABLE t1;
drop table if exists t1, t2, t3;
#
# BUG#35850: Performance regression in 5.1.23/5.1.24
#
create table t1(a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 (a int, b int, pk int, key(a,b), primary key(pk)) engine=innodb;
insert into t2 select @a:=A.a+10*(B.a + 10*C.a),@a, @a from t1 A, t1 B, t1 C;
this must use key 'a', not PRIMARY:
# this must use key 'a', not PRIMARY:
explain select a from t2 where a=b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL a 10 NULL # Using where; Using index
drop table t1, t2;
#
# Bug #40360: Binlog related errors with binlog off
#
SET SESSION BINLOG_FORMAT=STATEMENT;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
select @@session.sql_log_bin, @@session.binlog_format, @@session.tx_isolation;
@ -1835,12 +1852,19 @@ select @@session.sql_log_bin, @@session.binlog_format, @@session.tx_isolation;
CREATE TABLE t1 ( a INT ) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
DROP TABLE t1;
#
# Bug#37284 Crash in Field_string::type()
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a char(50)) ENGINE=InnoDB;
CREATE INDEX i1 on t1 (a(3));
SELECT * FROM t1 WHERE a = 'abcde';
a
DROP TABLE t1;
#
# Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of
# requested column
#
CREATE TABLE foo (a int, b int, c char(10),
PRIMARY KEY (c(3)),
KEY b (b)
@ -1858,6 +1882,9 @@ INSERT INTO foo VALUES
(4,5,'uvwxyz'), (5,6,'meotnsyglt'), (4,5,'asfdewe');
INSERT INTO bar SELECT * FROM foo;
INSERT INTO foo2 SELECT * FROM foo;
ANALYZE TABLE bar;
ANALYZE TABLE foo;
ANALYZE TABLE foo2;
EXPLAIN SELECT c FROM bar WHERE b>2;;
id 1
select_type SIMPLE
@ -1925,6 +1952,9 @@ ref NULL
rows 6
Extra Using where; Using index
DROP TABLE foo, bar, foo2;
#
# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table
#
DROP TABLE IF EXISTS t1,t3,t2;
DROP FUNCTION IF EXISTS f1;
CREATE FUNCTION f1() RETURNS VARCHAR(250)
@ -1946,6 +1976,9 @@ DEALLOCATE PREPARE stmt1;
DEALLOCATE PREPARE stmt3;
DROP TABLE t1,t3,t2;
DROP FUNCTION f1;
#
# Bug#37016: TRUNCATE TABLE removes some rows but not all
#
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
CREATE TABLE t2 (id INT PRIMARY KEY,
@ -2152,6 +2185,9 @@ DROP TABLE t4;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
#
# Bug#43580: Issue with Innodb on multi-table update
#
CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE = INNODB;
CREATE TABLE t2 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB;
CREATE TABLE t3 (a INT, b INT KEY, KEY (a)) ENGINE = INNODB;
@ -2257,6 +2293,7 @@ INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1;
INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1;
INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1;
INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1;
ANALYZE TABLE t1;
EXPLAIN SELECT * FROM t1 WHERE b=1 AND c=1 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref i2 i2 8 const,const 1 Using where; Using filesort
@ -2265,7 +2302,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref i2 i2 8 const,const 1 Using where; Using filesort
EXPLAIN SELECT * FROM t1 FORCE INDEX(PRIMARY) WHERE b=1 AND c=1 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 128 Using where
1 SIMPLE t1 index NULL PRIMARY 4 NULL {checked} Using where
DROP TABLE t1;
#
# Bug #47963: Wrong results when index is used
@ -2335,7 +2372,7 @@ DROP TABLE t1,t2;
# Bug #49324: more valgrind errors in test_if_skip_sort_order
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ;
#should not cause valgrind warnings
# should not cause valgrind warnings
SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a;
1
DROP TABLE t1;
@ -2347,9 +2384,11 @@ create table t1(f1 int not null primary key, f2 int) engine=innodb;
create table t2(f1 int not null, key (f1)) engine=innodb;
insert into t1 values (1,1),(2,2),(3,3);
insert into t2 values (1),(2),(3);
analyze table t1;
analyze table t2;
explain select t1.* from t1 left join t2 using(f1) group by t1.f1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 3
1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 NULL
1 SIMPLE t2 ref f1 f1 4 test.t1.f1 1 Using index
drop table t1,t2;
#
@ -2363,6 +2402,9 @@ INSERT INTO t1 VALUES (1,1,1,1,1,1), (2,2,2,2,2,2), (3,3,3,3,3,3),
(4,4,4,4,4,4), (5,5,5,5,5,5), (6,6,6,6,6,6),
(7,7,7,7,7,7), (8,8,8,8,8,8), (9,9,9,9,9,9),
(11,11,11,11,11,11);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
EXPLAIN SELECT COUNT(*) FROM t1;
id 1
select_type SIMPLE
@ -2411,36 +2453,6 @@ Comment
Index_comment
DROP TABLE t1;
#
# Bug #53334: wrong result for outer join with impossible ON condition
# (see the same test case for MyISAM in join.test)
#
create table t1 (id int primary key);
create table t2 (id int);
insert into t1 values (75);
insert into t1 values (79);
insert into t1 values (78);
insert into t1 values (77);
replace into t1 values (76);
replace into t1 values (76);
insert into t1 values (104);
insert into t1 values (103);
insert into t1 values (102);
insert into t1 values (101);
insert into t1 values (105);
insert into t1 values (106);
insert into t1 values (107);
insert into t2 values (107),(75),(1000);
select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0
where t2.id=75 and t1.id is null;
id id
NULL 75
explain select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0
where t2.id=75 and t1.id is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY NULL NULL NULL 1 Impossible ON condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
drop table t1,t2;
#
# Bug #47453: InnoDB incorrectly changes TIMESTAMP columns when
# JOINed during an UPDATE
#
@ -2448,7 +2460,7 @@ CREATE TABLE t1 (d INT) ENGINE=InnoDB;
CREATE TABLE t2 (a INT, b INT,
c TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP) ENGINE=InnoDB;
set up our data elements
# set up our data elements
INSERT INTO t1 (d) VALUES (1);
INSERT INTO t2 (a,b) VALUES (1,1);
SELECT SECOND(c) INTO @bug47453 FROM t2;
@ -2463,7 +2475,7 @@ SELECT SLEEP(1);
SLEEP(1)
0
UPDATE t1 JOIN t2 ON d=a SET b=1 WHERE a=1;
#should be 0
# should be 0
SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a;
SECOND(c)-@bug47453
0
@ -2533,6 +2545,7 @@ KEY idx1 (f2,f5,f4),
KEY idx2 (f2,f4)
) ENGINE=InnoDB;
LOAD DATA INFILE '../../std_data/intersect-bug50389.tsv' INTO TABLE t1;
ANALYZE TABLE t1;
SELECT * FROM t1 WHERE f1 IN
(3305028,3353871,3772880,3346860,4228206,3336022,
3470988,3305175,3329875,3817277,3856380,3796193,
@ -2555,7 +2568,7 @@ EXPLAIN SELECT * FROM t1 WHERE f1 IN
3784744,4180925,4559596,3963734,3856391,4494153)
AND f5 = 'abcdefghijklmnopwrst' AND f2 = 1221457 AND f4 = 0 ;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge PRIMARY,idx1,idx2 idx2,idx1,PRIMARY 7,60,4 NULL 1 Using intersect(idx2,idx1,PRIMARY); Using where
1 SIMPLE t1 ref PRIMARY,idx1,idx2 idx1 60 const,const,const 18 Using index condition
DROP TABLE t1;
#
# Bug#51431 Wrong sort order after import of dump file
@ -2568,7 +2581,7 @@ f4 tinyint(1) NOT NULL,
PRIMARY KEY (f1),
UNIQUE KEY (f2, f3),
KEY (f4)
) ENGINE=InnoDB;
) ENGINE=InnoDB STATS_PERSISTENT=0;
INSERT INTO t1 VALUES
(1,1,991,1), (2,1,992,1), (3,1,993,1), (4,1,994,1), (5,1,995,1),
(6,1,996,1), (7,1,997,1), (8,1,998,1), (10,1,999,1), (11,1,9910,1),
@ -2598,44 +2611,10 @@ ALTER TABLE t1 COMMENT 'test';
UNLOCK TABLES;
DROP TABLE t1;
#
# Bug#55826: create table .. select crashes with when KILL_BAD_DATA
# is returned
#
CREATE TABLE t1(a INT) ENGINE=innodb;
INSERT INTO t1 VALUES (0);
SET SQL_MODE='STRICT_ALL_TABLES';
CREATE TABLE t2
SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`;
ERROR 22007: Incorrect datetime value: ''
DROP TABLE t1;
SET SQL_MODE=DEFAULT;
#
# Bug#55580: segfault in read_view_sees_trx_id
#
CREATE TABLE t1 (a INT) ENGINE=Innodb;
CREATE TABLE t2 (a INT) ENGINE=Innodb;
INSERT INTO t1 VALUES (1),(2);
INSERT INTO t2 VALUES (1),(2);
START TRANSACTION;
SELECT * FROM t2 LOCK IN SHARE MODE;
a
1
2
START TRANSACTION;
SELECT * FROM t1 LOCK IN SHARE MODE;
a
1
2
SELECT * FROM t1 FOR UPDATE;
# should not crash
SELECT * FROM t1 GROUP BY (SELECT a FROM t2 LIMIT 1 FOR UPDATE) + t1.a;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
DROP TABLE t1,t2;
#
# Bug#55656: mysqldump can be slower after bug #39653 fix
#
CREATE TABLE t1 (a INT , b INT, c INT, d INT,
KEY (b), PRIMARY KEY (a,b)) ENGINE=INNODB;
KEY (b), PRIMARY KEY (a,b)) ENGINE=INNODB STATS_PERSISTENT=0;
INSERT INTO t1 VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3);
EXPLAIN SELECT COUNT(*) FROM t1;
id 1
@ -2669,8 +2648,8 @@ select_type SIMPLE
table t1
type index
possible_keys NULL
key PRIMARY
key_len 8
key b
key_len 13
ref NULL
rows 3
Extra Using index
@ -2689,58 +2668,6 @@ rows 3
Extra Using index
DROP TABLE t1;
#
# Bug#56862 Execution of a query that uses index merge returns a wrong result
#
CREATE TABLE t1 (
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
a int,
b int,
INDEX idx(a))
ENGINE=INNODB;
INSERT INTO t1(a,b) VALUES
(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
(6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700),
(13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000);
INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1;
INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1;
INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1 VALUES (1000000, 0, 0);
SET SESSION sort_buffer_size = 1024*36;
EXPLAIN
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 1536 Using sort_union(idx,PRIMARY); Using where
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
COUNT(*)
1537
SET SESSION sort_buffer_size = DEFAULT;
DROP TABLE t1;
#
# ALTER TABLE IGNORE didn't ignore duplicates for unique add index
#
create table t1 (a int primary key, b int) engine = innodb;
insert into t1 values (1,1),(2,1);
alter ignore table t1 add unique `main` (b);
select * from t1;
a b
1 1
drop table t1;
End of 5.1 tests
#
#
# Bug#55826: create table .. select crashes with when KILL_BAD_DATA
# is returned
#
@ -2749,59 +2676,18 @@ INSERT INTO t1 VALUES (0);
SET SQL_MODE='STRICT_ALL_TABLES';
CREATE TABLE t2
SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`;
ERROR 22007: Incorrect datetime value: ''
ERROR 22007: Incorrect datetime value: '' for column 'NOW()' at row 2
DROP TABLE t1;
SET SQL_MODE=DEFAULT;
#
# Bug#56862 Execution of a query that uses index merge returns a wrong result
# Bug#56862 Moved to innodb_16k.test
#
CREATE TABLE t1 (
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
a int,
b int,
INDEX idx(a))
ENGINE=INNODB;
INSERT INTO t1(a,b) VALUES
(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
(6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700),
(13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000);
INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1;
INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1;
INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1 VALUES (1000000, 0, 0);
SET SESSION sort_buffer_size = 1024*36;
EXPLAIN
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 1536 Using sort_union(idx,PRIMARY); Using where
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
COUNT(*)
1537
SET SESSION sort_buffer_size = DEFAULT;
DROP TABLE t1;
#
# Test for bug #39932 "create table fails if column for FK is in different
# case than in corr index".
#
drop tables if exists t1, t2;
create table t1 (pk int primary key) engine=InnoDB;
# Even although the below statement uses uppercased field names in
# foreign key definition it still should be able to find explicitly
# created supporting index. So it should succeed and should not
# create any additional supporting indexes.
create table t2 (fk int, key x (fk),
constraint x foreign key (FK) references t1 (PK)) engine=InnoDB;
show create table t2;
@ -2813,130 +2699,6 @@ t2 CREATE TABLE `t2` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t2, t1;
#
# Bug #663818: wrong result when BNLH is used
#
CREATE TABLE t1(pk int NOT NULL PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES
(1), (2), (11), (12), (13), (14),
(15), (16), (17), (18), (19);
CREATE TABLE t2(pk int NOT NULL PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t2 VALUES
(1), (10), (11), (12), (13), (14),
(15), (16), (17), (18), (19), (20), (21);
SET SESSION join_buffer_size=10000;
Warnings:
Warning 1292 Truncated incorrect join_buffer_size value: '10000'
SET SESSION join_cache_level=3;
EXPLAIN
SELECT t1.pk FROM t1,t2
WHERE t1.pk = t2.pk AND t2.pk <> 8;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 11 Using where; Using index
1 SIMPLE t2 hash_index PRIMARY #hash#PRIMARY:PRIMARY 4:4 test.t1.pk 13 Using join buffer (flat, BNLH join)
SELECT t1.pk FROM t1,t2
WHERE t1.pk = t2.pk AND t2.pk <> 8;
pk
1
11
12
13
14
15
16
17
18
19
SET SESSION join_cache_level=1;
EXPLAIN
SELECT t1.pk FROM t1,t2
WHERE t1.pk = t2.pk AND t2.pk <> 8;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 11 Using where; Using index
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 Using index
SELECT t1.pk FROM t1,t2
WHERE t1.pk = t2.pk AND t2.pk <> 8;
pk
1
11
12
13
14
15
16
17
18
19
DROP TABLE t1,t2;
SET SESSION join_cache_level=DEFAULT;
SET SESSION join_buffer_size=DEFAULT;
#
# Bug#668644: HAVING + ORDER BY
#
CREATE TABLE t1 (
pk int NOT NULL PRIMARY KEY, i int DEFAULT NULL,
INDEX idx (i)
) ENGINE=INNODB;
INSERT INTO t1 VALUES
(6,-1636630528),(2,-1097924608),(1,6),(3,6),(4,1148715008),(5,1541734400);
CREATE TABLE t2 (
i int DEFAULT NULL,
pk int NOT NULL PRIMARY KEY,
INDEX idx (i)
) ENGINE= INNODB;
INSERT INTO t2 VALUES
(-1993998336,20),(-1036582912,1),(-733413376,5),(-538247168,16),
(-514260992,4),(-249561088,9),(1,2),(1,6),(2,10),(2,19),(4,17),
(5,14),(5,15),(6,8),(7,13),(8,18),(9,11),(9,12),(257425408,7),
(576061440,3);
EXPLAIN
SELECT t1 .i AS f FROM t1, t2
WHERE t2.i = t1.pk AND t1.pk BETWEEN 0 AND 224
HAVING f > 7
ORDER BY f;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY idx 5 NULL 6 Using where; Using index
1 SIMPLE t2 ref idx idx 5 test.t1.pk 1 Using index
SELECT t1 .i AS f FROM t1, t2
WHERE t2.i = t1.pk AND t1.pk BETWEEN 0 AND 224
HAVING f > 7
ORDER BY f;
f
1148715008
1541734400
1541734400
DROP TABLE t1, t2;
#
# Test for bug #56619 - Assertion failed during
# ALTER TABLE RENAME, DISABLE KEYS
#
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a INT, INDEX(a)) engine=innodb;
ALTER TABLE t1 RENAME TO t2, DISABLE KEYS;
DROP TABLE IF EXISTS t1, t2;
#
# Bug#702322: HAVING with two ANDed predicates + ORDER BY
#
CREATE TABLE t1 (pk int PRIMARY KEY, a int, KEY (a)) ENGINE=InnoDB;
CREATE TABLE t2 (a int, KEY (a)) ENGINE=InnoDB;
INSERT INTO t1 VALUES
(18,0),(9,10),(8,11),(2,15),(7,19),(1,20);
SET SESSION join_cache_level = 0;
EXPLAIN
SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.pk = t2.a
WHERE t1.pk >= 6 HAVING t1.a<> 0 AND t1.a <> 11
ORDER BY t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using index condition; Using filesort
1 SIMPLE t2 ref a a 5 test.t1.pk 1 Using index
SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.pk = t2.a
WHERE t1.pk >= 6 HAVING t1.a<> 0 AND t1.a <> 11
ORDER BY t1.a;
a
10
19
DROP TABLE t1,t2;
End of 5.3 tests
#
# Test for bug #11762012 - "54553: INNODB ASSERTS IN HA_INNOBASE::
# UPDATE_ROW, TEMPORARY TABLE, TABLE LOCK".
#
@ -2952,7 +2714,39 @@ LOCK TABLES t1 READ;
UPDATE t1 SET c = 5;
UNLOCK TABLES;
DROP TEMPORARY TABLE t1;
End of 5.1 tests
# End of 5.1 tests
#
# Bug#49604 "6.0 processing compound WHERE clause incorrectly
# with Innodb - extra rows"
#
CREATE TABLE t1 (
c1 INT NOT NULL,
c2 INT,
PRIMARY KEY (c1),
KEY k1 (c2)
) ENGINE=InnoDB;
INSERT INTO t1 VALUES (12,1);
INSERT INTO t1 VALUES (15,1);
INSERT INTO t1 VALUES (16,1);
INSERT INTO t1 VALUES (22,1);
INSERT INTO t1 VALUES (20,2);
CREATE TABLE t2 (
c1 INT NOT NULL,
c2 INT,
PRIMARY KEY (c1)
) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,2);
INSERT INTO t2 VALUES (2,9);
SELECT STRAIGHT_JOIN t2.c2, t1.c2, t2.c1
FROM t1 JOIN t2 ON t1.c2 = t2.c1
WHERE t2.c1 IN (2, 1, 6) OR t2.c1 NOT IN (1);
c2 c2 c1
2 1 1
2 1 1
2 1 1
2 1 1
9 2 2
DROP TABLE t1, t2;
#
# Bug#44613 SELECT statement inside FUNCTION takes a shared lock
#
@ -2979,13 +2773,86 @@ COMMIT;
DROP TABLE t1;
DROP FUNCTION f1;
#
# Bug#42744: Crash when using a join buffer to join a table with a blob
# column and an additional column used for duplicate elimination.
#
CREATE TABLE t1 (a tinyblob) ENGINE=InnoDB;
CREATE TABLE t2 (a int PRIMARY KEY, b tinyblob) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('1'), (NULL);
INSERT INTO t2 VALUES (1, '1');
EXPLAIN
SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Start temporary
1 SIMPLE t2 index NULL PRIMARY 4 NULL 1 Using index; Using join buffer (Block Nested Loop)
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop)
SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2);
b
1
DROP TABLE t1,t2;
#
# Bug#48093: 6.0 Server not processing equivalent IN clauses properly
# with Innodb tables
#
CREATE TABLE t1 (
i int(11) DEFAULT NULL,
v1 varchar(1) DEFAULT NULL,
v2 varchar(20) DEFAULT NULL,
KEY i (i),
KEY v (v1,i)
) ENGINE=innodb;
INSERT INTO t1 VALUES (1,'f','no');
INSERT INTO t1 VALUES (2,'u','yes-u');
INSERT INTO t1 VALUES (2,'h','yes-h');
INSERT INTO t1 VALUES (3,'d','no');
SELECT v2
FROM t1
WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2;
v2
yes-u
yes-h
# Should not use index_merge
EXPLAIN
SELECT v2
FROM t1
WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref i,v i 5 const 2 Using where
DROP TABLE t1;
#
# Bug#54606 innodb fast alter table + pack_keys=0
# prevents adding new indexes
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT, b CHAR(9), c INT, key(b))
ENGINE=InnoDB
PACK_KEYS=0;
CREATE INDEX a ON t1 (a);
CREATE INDEX c on t1 (c);
DROP TABLE t1;
End of 5.1 tests
#
# Additional coverage for refactoring which is made as part
# of fix for Bug#27480 "Extend CREATE TEMPORARY TABLES privilege
# to allow temp table operations".
#
# Check that OPTIMIZE table works for temporary InnoDB tables.
DROP TABLE IF EXISTS t1;
CREATE TEMPORARY TABLE t1 (a INT) ENGINE=InnoDB;
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK
DROP TABLE t1;
#
# Bug#11762345 54927: DROPPING AND ADDING AN INDEX IN ONE
# COMMAND CAN FAIL IN INNODB PLUGIN 1.0
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (id int, a int, b int, PRIMARY KEY (id),
INDEX a (a)) ENGINE=innodb;
ALTER TABLE t1 DROP INDEX a, ADD INDEX a (b, a);
ALTER TABLE t1 DROP INDEX a, ADD INDEX (a, b);
DROP TABLE t1;
End of 6.0 tests