Merge 10.4 into 10.5
This commit is contained in:
commit
8336371441
@ -2,11 +2,10 @@
|
||||
#
|
||||
# Index merge tests
|
||||
#
|
||||
# The variables
|
||||
# $engine_type -- storage engine to be tested
|
||||
# The variable
|
||||
# $merge_table_support -- 1 storage engine supports merge tables
|
||||
# -- 0 storage engine does not support merge tables
|
||||
# have to be set before sourcing this script.
|
||||
# has to be set before sourcing this script.
|
||||
#
|
||||
# Note: The comments/expectations refer to MyISAM.
|
||||
# They might be not valid for other storage engines.
|
||||
@ -16,15 +15,10 @@
|
||||
# old name was t/index_merge.test
|
||||
# main code went into include/index_merge1.inc
|
||||
#
|
||||
--source include/have_sequence.inc
|
||||
|
||||
--echo #---------------- Index merge test 1 -------------------------------------------
|
||||
|
||||
eval SET SESSION STORAGE_ENGINE = $engine_type;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t0, t1, t2, t3, t4;
|
||||
--enable_warnings
|
||||
|
||||
# Create and fill a table with simple keys
|
||||
create table t0
|
||||
(
|
||||
@ -32,20 +26,7 @@ create table t0
|
||||
INDEX i1(key1)
|
||||
);
|
||||
|
||||
--disable_query_log
|
||||
insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8);
|
||||
|
||||
let $1=7;
|
||||
set @d=8;
|
||||
begin;
|
||||
while ($1)
|
||||
{
|
||||
eval insert into t0 select key1+@d from t0;
|
||||
eval set @d=@d*2;
|
||||
dec $1;
|
||||
}
|
||||
commit;
|
||||
--enable_query_log
|
||||
insert into t0(key1) select seq from seq_1_to_1024;
|
||||
|
||||
alter table t0 add key2 int not null, add index i2(key2);
|
||||
alter table t0 add key3 int not null, add index i3(key3);
|
||||
@ -220,7 +201,7 @@ create table t4 (
|
||||
index i2_2(key2, key2_1)
|
||||
);
|
||||
|
||||
insert into t4 select key1,key1,key1 div 10, key1 % 10, key1 % 10, key1 from t0;
|
||||
insert into t4 select seq,seq,seq div 10, seq % 10, seq % 10, seq from seq_1_to_1024;
|
||||
|
||||
# the following will be handled by index_merge:
|
||||
select * from t4 where key1a = 3 or key1b = 4;
|
||||
@ -395,14 +376,13 @@ if ($merge_table_support)
|
||||
#
|
||||
# BUG#17314: Index_merge/intersection not choosen by the optimizer for MERGE tables
|
||||
#
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1 (
|
||||
a int, b int,
|
||||
filler1 char(200), filler2 char(200),
|
||||
key(a),key(b)
|
||||
);
|
||||
insert into t1 select @v:= A.a, @v, 't1', 'filler2' from t0 A, t0 B, t0 C;
|
||||
insert into t1 select @v:= seq % 10, @v, 't1', 'filler2' from seq_1_to_1000;
|
||||
|
||||
create table t2 like t1;
|
||||
|
||||
create table t3 (
|
||||
@ -416,8 +396,7 @@ explain select * from t1 where a=1 and b=1;
|
||||
--replace_column 9 #
|
||||
explain select * from t3 where a=1 and b=1;
|
||||
|
||||
drop table t3;
|
||||
drop table t0, t1, t2;
|
||||
drop table t1, t2, t3;
|
||||
}
|
||||
|
||||
#
|
||||
@ -517,16 +496,13 @@ DROP TABLE t1;
|
||||
--echo #
|
||||
--echo # BUG#40974: Incorrect query results when using clause evaluated using range check
|
||||
--echo #
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2);
|
||||
create table t2(a int, b int);
|
||||
insert into t2 values (1,1), (2, 1000);
|
||||
create table t3 (a int, b int, filler char(100), key(a), key(b));
|
||||
|
||||
insert into t3 select 1000, 1000,'filler' from t0 A, t0 B, t0 C;
|
||||
insert into t3 select 1000, 1000,'filler' from seq_1_to_1000;
|
||||
insert into t3 values (1,1,'data');
|
||||
insert into t3 values (1,1,'data');
|
||||
-- echo The plan should be ALL/ALL/ALL(Range checked for each record (index map: 0x3)
|
||||
@ -538,20 +514,14 @@ select * from t1
|
||||
where exists (select 1 from t2, t3
|
||||
where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1));
|
||||
|
||||
drop table t0, t1, t2, t3;
|
||||
drop table t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#44810: index merge and order by with low sort_buffer_size
|
||||
--echo # crashes server!
|
||||
--echo #
|
||||
CREATE TABLE t1(a VARCHAR(128),b VARCHAR(128),KEY(A),KEY(B));
|
||||
INSERT INTO t1 VALUES (REPEAT('a',128),REPEAT('b',128));
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT REPEAT('a',128),REPEAT('b',128) FROM seq_1_to_64;
|
||||
SET SESSION sort_buffer_size=1024*8;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%'
|
||||
|
@ -2,10 +2,6 @@
|
||||
#
|
||||
# Index merge tests
|
||||
#
|
||||
# The variable
|
||||
# $engine_type -- storage engine to be tested
|
||||
# has to be set before sourcing this script.
|
||||
#
|
||||
# Note: The comments/expectations refer to InnoDB.
|
||||
# They might be not valid for other storage engines.
|
||||
#
|
||||
@ -14,15 +10,10 @@
|
||||
# old name was t/index_merge_innodb.test
|
||||
# main code went into include/index_merge2.inc
|
||||
#
|
||||
--source include/have_sequence.inc
|
||||
|
||||
--echo #---------------- Index merge test 2 -------------------------------------------
|
||||
|
||||
eval SET SESSION STORAGE_ENGINE = $engine_type;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1,t2;
|
||||
--enable_warnings
|
||||
|
||||
create table t1
|
||||
(
|
||||
key1 int not null,
|
||||
@ -32,16 +23,7 @@ create table t1
|
||||
INDEX i2(key2)
|
||||
);
|
||||
|
||||
--disable_query_log
|
||||
let $1=200;
|
||||
begin;
|
||||
while ($1)
|
||||
{
|
||||
eval insert into t1 values (200-$1, $1);
|
||||
dec $1;
|
||||
}
|
||||
commit;
|
||||
--enable_query_log
|
||||
INSERT INTO t1 SELECT seq,200-seq FROM seq_0_to_200;
|
||||
|
||||
# No primary key
|
||||
explain select * from t1 where key1 < 5 or key2 > 197;
|
||||
@ -80,16 +62,8 @@ create table t1 (
|
||||
index (key2)
|
||||
);
|
||||
show warnings;
|
||||
--disable_query_log
|
||||
let $1=30;
|
||||
begin;
|
||||
while ($1)
|
||||
{
|
||||
eval insert into t1 (key1, key2, filler) values ($1/4, $1/8, 'filler-data');
|
||||
dec $1;
|
||||
}
|
||||
commit;
|
||||
--enable_query_log
|
||||
INSERT INTO t1 (key1, key2, filler)
|
||||
SELECT seq/4, seq/8, 'filler-data' FROM seq_30_to_0;
|
||||
explain select pk from t1 where key1 = 1 and key2 = 1;
|
||||
select pk from t1 where key2 = 1 and key1 = 1;
|
||||
select pk from t1 ignore index(key1,key2) where key2 = 1 and key1 = 1;
|
||||
@ -331,19 +305,7 @@ create table t1
|
||||
key3 int not null default 0
|
||||
);
|
||||
|
||||
insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8);
|
||||
|
||||
let $1=7;
|
||||
set @d=8;
|
||||
begin;
|
||||
while ($1)
|
||||
{
|
||||
eval insert into t1 (key1) select key1+@d from t1;
|
||||
eval set @d=@d*2;
|
||||
dec $1;
|
||||
}
|
||||
commit;
|
||||
|
||||
insert into t1(key1) select seq from seq_1_to_1024;
|
||||
alter table t1 add index i2(key2);
|
||||
alter table t1 add index i3(key3);
|
||||
update t1 set key2=key1,key3=key1;
|
||||
|
@ -2,24 +2,15 @@
|
||||
#
|
||||
# 2-sweeps read Index_merge test
|
||||
#
|
||||
# The variable
|
||||
# $engine_type -- storage engine to be tested
|
||||
# has to be set before sourcing this script.
|
||||
#
|
||||
# Last update:
|
||||
# 2006-08-02 ML test refactored
|
||||
# old name was index_merge_innodb2.test
|
||||
# main code went into include/index_merge_2sweeps.inc
|
||||
#
|
||||
--source include/have_sequence.inc
|
||||
|
||||
--echo #---------------- 2-sweeps read Index merge test 2 -------------------------------
|
||||
|
||||
eval SET SESSION STORAGE_ENGINE = $engine_type;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
create table t1 (
|
||||
pk int primary key,
|
||||
key1 int,
|
||||
@ -30,17 +21,8 @@ create table t1 (
|
||||
index(key2)
|
||||
);
|
||||
|
||||
|
||||
--disable_query_log
|
||||
begin;
|
||||
let $1=1000;
|
||||
while ($1)
|
||||
{
|
||||
eval insert into t1 values($1, $1, $1, 'filler-data','filler-data-2');
|
||||
dec $1;
|
||||
}
|
||||
commit;
|
||||
--enable_query_log
|
||||
insert into t1 select seq, seq, seq, 'filler-data', 'filler-data-2'
|
||||
from seq_1000_to_1;
|
||||
|
||||
select * from t1 where (key1 >= 2 and key1 <= 10) or (pk >= 4 and pk <=8 );
|
||||
|
||||
|
@ -17,11 +17,6 @@
|
||||
|
||||
--echo #---------------- ROR-index_merge tests -----------------------
|
||||
|
||||
eval SET SESSION STORAGE_ENGINE = $engine_type;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t0,t1,t2;
|
||||
--enable_warnings
|
||||
create table t1
|
||||
(
|
||||
/* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */
|
||||
|
@ -2,10 +2,6 @@
|
||||
#
|
||||
# Clustered PK ROR-index_merge tests
|
||||
#
|
||||
# The variable
|
||||
# $engine_type -- storage engine to be tested
|
||||
# has to be set before sourcing this script.
|
||||
#
|
||||
# Note: The comments/expectations refer to InnoDB.
|
||||
# They might be not valid for other storage engines.
|
||||
#
|
||||
@ -15,14 +11,10 @@
|
||||
# main code went into include/index_merge_ror_cpk.inc
|
||||
#
|
||||
|
||||
--source include/have_sequence.inc
|
||||
|
||||
--echo #---------------- Clustered PK ROR-index_merge tests -----------------------------
|
||||
|
||||
eval SET SESSION STORAGE_ENGINE = $engine_type;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
create table t1
|
||||
(
|
||||
pk1 int not null,
|
||||
|
@ -1,3 +1,4 @@
|
||||
SET @save_dbug = @@debug_dbug;
|
||||
set debug_dbug='+d,unstable_db_type';
|
||||
install soname 'ha_archive';
|
||||
create table t1 (a int) engine=archive;
|
||||
@ -32,4 +33,4 @@ t1.frm
|
||||
drop table t1;
|
||||
db.opt
|
||||
uninstall soname 'ha_archive';
|
||||
set debug_dbug='-d,unstable_db_type';
|
||||
set debug_dbug=@save_dbug;
|
||||
|
@ -7,6 +7,7 @@ if (!$HA_ARCHIVE_SO) {
|
||||
|
||||
let $mysqld_datadir= `select @@datadir`;
|
||||
|
||||
SET @save_dbug = @@debug_dbug;
|
||||
set debug_dbug='+d,unstable_db_type';
|
||||
|
||||
install soname 'ha_archive';
|
||||
@ -27,5 +28,4 @@ drop table t1;
|
||||
--list_files $mysqld_datadir/test
|
||||
uninstall soname 'ha_archive';
|
||||
|
||||
set debug_dbug='-d,unstable_db_type';
|
||||
|
||||
set debug_dbug=@save_dbug;
|
||||
|
@ -1,9 +1,12 @@
|
||||
connect disable_purge,localhost,root,,;
|
||||
# Disable the purge of InnoDB history, to make the test run faster.
|
||||
START TRANSACTION WITH CONSISTENT SNAPSHOT;
|
||||
connection default;
|
||||
SET STORAGE_ENGINE = InnoDB;
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
set optimizer_switch='index_merge_sort_intersection=off';
|
||||
set optimizer_switch='rowid_filter=off';
|
||||
#---------------- Index merge test 2 -------------------------------------------
|
||||
SET SESSION STORAGE_ENGINE = InnoDB;
|
||||
drop table if exists t1,t2;
|
||||
create table t1
|
||||
(
|
||||
key1 int not null,
|
||||
@ -11,6 +14,7 @@ key2 int not null,
|
||||
INDEX i1(key1),
|
||||
INDEX i2(key2)
|
||||
);
|
||||
INSERT INTO t1 SELECT seq,200-seq FROM seq_0_to_200;
|
||||
explain select * from t1 where key1 < 5 or key2 > 197;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
||||
@ -68,6 +72,8 @@ index (key2)
|
||||
);
|
||||
show warnings;
|
||||
Level Code Message
|
||||
INSERT INTO t1 (key1, key2, filler)
|
||||
SELECT seq/4, seq/8, 'filler-data' FROM seq_30_to_0;
|
||||
explain select pk from t1 where key1 = 1 and key2 = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,4 NULL 1 Using intersect(key1,key2); Using where; Using index
|
||||
@ -294,24 +300,7 @@ key1 int not null,
|
||||
key2 int not null default 0,
|
||||
key3 int not null default 0
|
||||
);
|
||||
insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8);
|
||||
set @d=8;
|
||||
begin;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
commit;
|
||||
insert into t1(key1) select seq from seq_1_to_1024;
|
||||
alter table t1 add index i2(key2);
|
||||
alter table t1 add index i3(key3);
|
||||
update t1 set key2=key1,key3=key1;
|
||||
@ -391,8 +380,6 @@ a b
|
||||
1 b
|
||||
DROP TABLE t1, t2;
|
||||
#---------------- 2-sweeps read Index merge test 2 -------------------------------
|
||||
SET SESSION STORAGE_ENGINE = InnoDB;
|
||||
drop table if exists t1;
|
||||
create table t1 (
|
||||
pk int primary key,
|
||||
key1 int,
|
||||
@ -402,6 +389,8 @@ filler2 char(200),
|
||||
index(key1),
|
||||
index(key2)
|
||||
);
|
||||
insert into t1 select seq, seq, seq, 'filler-data', 'filler-data-2'
|
||||
from seq_1000_to_1;
|
||||
select * from t1 where (key1 >= 2 and key1 <= 10) or (pk >= 4 and pk <=8 );
|
||||
pk key1 key2 filler filler2
|
||||
2 2 2 filler-data filler-data-2
|
||||
@ -529,8 +518,6 @@ pk key1 key2 filler filler2
|
||||
54 54 54 filler-data filler-data-2
|
||||
drop table t1;
|
||||
#---------------- Clustered PK ROR-index_merge tests -----------------------------
|
||||
SET SESSION STORAGE_ENGINE = InnoDB;
|
||||
drop table if exists t1;
|
||||
create table t1
|
||||
(
|
||||
pk1 int not null,
|
||||
@ -671,34 +658,27 @@ DROP TABLE t1,t2;
|
||||
#
|
||||
# BUG#56862/640419: Wrong result with sort_union index merge when one
|
||||
# of the merged index scans is the primary key scan
|
||||
#
|
||||
#
|
||||
CREATE TABLE t0(a int, b int) ENGINE=MyISAM;
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
a int,
|
||||
b int,
|
||||
INDEX idx(a))
|
||||
ENGINE=INNODB;
|
||||
begin;
|
||||
INSERT INTO t1(a,b) VALUES
|
||||
INSERT INTO t0(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(a,b) SELECT a,b FROM t1;
|
||||
INSERT INTO t1(a,b) SELECT a,b FROM t1;
|
||||
INSERT INTO t0(a,b) SELECT a+20, b+2000 FROM t0;
|
||||
INSERT INTO t0(a,b) SELECT a+40, b+4000 FROM t0;
|
||||
INSERT INTO t0(a,b) SELECT a+80, b+8000 FROM t0;
|
||||
begin;
|
||||
INSERT INTO t1(a,b) SELECT t0.a,t0.b FROM t0, seq_1_to_1024;
|
||||
INSERT INTO t1 VALUES (1000000, 0, 0);
|
||||
commit;
|
||||
DROP TABLE t0;
|
||||
SET SESSION sort_buffer_size = 1024*36;
|
||||
set @tmp_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='derived_merge=off,derived_with_keys=off';
|
||||
@ -762,8 +742,6 @@ DROP TABLE t1;
|
||||
#
|
||||
# BUG#1006164: Multi-table DELETE that uses innodb + index_merge/intersect may fail to delete rows
|
||||
#
|
||||
create table t0(a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1 (
|
||||
pk int auto_increment,
|
||||
zone_id int,
|
||||
@ -772,7 +750,7 @@ primary key(pk),
|
||||
key (zone_id),
|
||||
key (modified)
|
||||
) engine=innodb;
|
||||
insert into t1 (zone_id, modified) select 0,0 from t0 A, t0 B, t0 C, t0 D;
|
||||
insert into t1 (zone_id, modified) select 0,0 from seq_1_to_10000;
|
||||
update t1 set zone_id=487, modified=9 where pk=7259;
|
||||
update t1 set zone_id=487, modified=9 where pk=7260;
|
||||
update t1 set zone_id=830, modified=9 where pk=8434;
|
||||
@ -790,7 +768,7 @@ DELETE t1 FROM t1 WHERE t1.zone_id=830 AND modified=9;
|
||||
commit;
|
||||
select * from t1 where t1.zone_id=830 AND modified=9;
|
||||
pk zone_id modified
|
||||
drop table t0, t1;
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-376: Wrong result (missing rows) with index_merge+index_merge_intersection, join
|
||||
#
|
||||
@ -825,14 +803,11 @@ PRIMARY KEY (pk),
|
||||
KEY key1 (key1),
|
||||
KEY key2 (key2)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=12860259 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
|
||||
create table t2(a int);
|
||||
insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t3(a int);
|
||||
insert into t3 select A.a + B.a* 10 + C.a * 100 + D.a*1000 from t2 A, t2 B, t2 C, t2 D;
|
||||
insert into t1 (key1, key2, col1,col2,col3,col4)
|
||||
select a,a, a,a,a,a from t3;
|
||||
select seq,seq,seq,seq,seq,seq from seq_1_to_10000;
|
||||
SELECT sum(col1) FROM t1 FORCE INDEX (key1,key2) WHERE (key1 between 10 and 8191+10) or (key2= 5);
|
||||
sum(col1)
|
||||
33632261
|
||||
drop table t1,t2,t3;
|
||||
drop table t1;
|
||||
set optimizer_switch=@tmp_optimizer_switch;
|
||||
disconnect disable_purge;
|
||||
|
@ -14,7 +14,12 @@
|
||||
--source include/not_staging.inc
|
||||
--source include/have_innodb.inc
|
||||
|
||||
let $engine_type= InnoDB;
|
||||
connect disable_purge,localhost,root,,;
|
||||
--echo # Disable the purge of InnoDB history, to make the test run faster.
|
||||
START TRANSACTION WITH CONSISTENT SNAPSHOT;
|
||||
connection default;
|
||||
|
||||
SET STORAGE_ENGINE = InnoDB;
|
||||
# InnoDB does not support Merge tables (affects include/index_merge1.inc)
|
||||
let $merge_table_support= 0;
|
||||
|
||||
@ -38,7 +43,9 @@ set optimizer_switch='rowid_filter=off';
|
||||
--echo #
|
||||
--echo # BUG#56862/640419: Wrong result with sort_union index merge when one
|
||||
--echo # of the merged index scans is the primary key scan
|
||||
--echo #
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t0(a int, b int) ENGINE=MyISAM;
|
||||
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
@ -47,27 +54,19 @@ CREATE TABLE t1 (
|
||||
INDEX idx(a))
|
||||
ENGINE=INNODB;
|
||||
|
||||
begin;
|
||||
INSERT INTO t1(a,b) VALUES
|
||||
INSERT INTO t0(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(a,b) SELECT a,b FROM t1;
|
||||
INSERT INTO t1(a,b) SELECT a,b FROM t1;
|
||||
INSERT INTO t0(a,b) SELECT a+20, b+2000 FROM t0;
|
||||
INSERT INTO t0(a,b) SELECT a+40, b+4000 FROM t0;
|
||||
INSERT INTO t0(a,b) SELECT a+80, b+8000 FROM t0;
|
||||
begin;
|
||||
INSERT INTO t1(a,b) SELECT t0.a,t0.b FROM t0, seq_1_to_1024;
|
||||
INSERT INTO t1 VALUES (1000000, 0, 0);
|
||||
commit;
|
||||
DROP TABLE t0;
|
||||
|
||||
SET SESSION sort_buffer_size = 1024*36;
|
||||
set @tmp_optimizer_switch=@@optimizer_switch;
|
||||
@ -132,9 +131,6 @@ DROP TABLE t1;
|
||||
--echo # BUG#1006164: Multi-table DELETE that uses innodb + index_merge/intersect may fail to delete rows
|
||||
--echo #
|
||||
|
||||
create table t0(a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
|
||||
create table t1 (
|
||||
pk int auto_increment,
|
||||
zone_id int,
|
||||
@ -144,7 +140,7 @@ create table t1 (
|
||||
key (modified)
|
||||
) engine=innodb;
|
||||
|
||||
insert into t1 (zone_id, modified) select 0,0 from t0 A, t0 B, t0 C, t0 D;
|
||||
insert into t1 (zone_id, modified) select 0,0 from seq_1_to_10000;
|
||||
update t1 set zone_id=487, modified=9 where pk=7259;
|
||||
update t1 set zone_id=487, modified=9 where pk=7260;
|
||||
update t1 set zone_id=830, modified=9 where pk=8434;
|
||||
@ -158,7 +154,7 @@ DELETE t1 FROM t1 WHERE t1.zone_id=830 AND modified=9;
|
||||
commit;
|
||||
select * from t1 where t1.zone_id=830 AND modified=9;
|
||||
|
||||
drop table t0, t1;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-376: Wrong result (missing rows) with index_merge+index_merge_intersection, join
|
||||
@ -198,14 +194,10 @@ KEY key1 (key1),
|
||||
KEY key2 (key2)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=12860259 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
|
||||
|
||||
create table t2(a int);
|
||||
insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
|
||||
create table t3(a int);
|
||||
insert into t3 select A.a + B.a* 10 + C.a * 100 + D.a*1000 from t2 A, t2 B, t2 C, t2 D;
|
||||
|
||||
insert into t1 (key1, key2, col1,col2,col3,col4)
|
||||
select a,a, a,a,a,a from t3;
|
||||
select seq,seq,seq,seq,seq,seq from seq_1_to_10000;
|
||||
SELECT sum(col1) FROM t1 FORCE INDEX (key1,key2) WHERE (key1 between 10 and 8191+10) or (key2= 5);
|
||||
drop table t1,t2,t3;
|
||||
drop table t1;
|
||||
set optimizer_switch=@tmp_optimizer_switch;
|
||||
|
||||
disconnect disable_purge;
|
||||
|
@ -1,14 +1,14 @@
|
||||
SET STORAGE_ENGINE = MyISAM;
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
set optimizer_switch='rowid_filter=off';
|
||||
set optimizer_switch='index_merge_sort_intersection=off';
|
||||
#---------------- Index merge test 1 -------------------------------------------
|
||||
SET SESSION STORAGE_ENGINE = MyISAM;
|
||||
drop table if exists t0, t1, t2, t3, t4;
|
||||
create table t0
|
||||
(
|
||||
key1 int not null,
|
||||
INDEX i1(key1)
|
||||
);
|
||||
insert into t0(key1) select seq from seq_1_to_1024;
|
||||
alter table t0 add key2 int not null, add index i2(key2);
|
||||
alter table t0 add key3 int not null, add index i3(key3);
|
||||
alter table t0 add key4 int not null, add index i4(key4);
|
||||
@ -235,7 +235,7 @@ index i2_2(key2, key2_1)
|
||||
);
|
||||
Warnings:
|
||||
Note 1831 Duplicate index `i2_2`. This is deprecated and will be disallowed in a future release
|
||||
insert into t4 select key1,key1,key1 div 10, key1 % 10, key1 % 10, key1 from t0;
|
||||
insert into t4 select seq,seq,seq div 10, seq % 10, seq % 10, seq from seq_1_to_1024;
|
||||
select * from t4 where key1a = 3 or key1b = 4;
|
||||
key1a key1b key2 key2_1 key2_2 key3
|
||||
3 3 0 3 3 3
|
||||
@ -421,14 +421,12 @@ explain select * from t1 force index(cola,colb) WHERE cola = 'foo' AND colb = 'b
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge cola,colb cola,colb 3,3 NULL 32 Using intersect(cola,colb); Using where
|
||||
drop table t1;
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1 (
|
||||
a int, b int,
|
||||
filler1 char(200), filler2 char(200),
|
||||
key(a),key(b)
|
||||
);
|
||||
insert into t1 select @v:= A.a, @v, 't1', 'filler2' from t0 A, t0 B, t0 C;
|
||||
insert into t1 select @v:= seq % 10, @v, 't1', 'filler2' from seq_1_to_1000;
|
||||
create table t2 like t1;
|
||||
create table t3 (
|
||||
a int, b int,
|
||||
@ -441,8 +439,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
explain select * from t3 where a=1 and b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 index_merge a,b a,b 5,5 NULL # Using intersect(a,b); Using where
|
||||
drop table t3;
|
||||
drop table t0, t1, t2;
|
||||
drop table t1, t2, t3;
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES(1);
|
||||
CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b));
|
||||
@ -542,14 +539,12 @@ DROP TABLE t1;
|
||||
#
|
||||
# BUG#40974: Incorrect query results when using clause evaluated using range check
|
||||
#
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2);
|
||||
create table t2(a int, b int);
|
||||
insert into t2 values (1,1), (2, 1000);
|
||||
create table t3 (a int, b int, filler char(100), key(a), key(b));
|
||||
insert into t3 select 1000, 1000,'filler' from t0 A, t0 B, t0 C;
|
||||
insert into t3 select 1000, 1000,'filler' from seq_1_to_1000;
|
||||
insert into t3 values (1,1,'data');
|
||||
insert into t3 values (1,1,'data');
|
||||
The plan should be ALL/ALL/ALL(Range checked for each record (index map: 0x3)
|
||||
@ -567,19 +562,13 @@ where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1));
|
||||
a
|
||||
1
|
||||
2
|
||||
drop table t0, t1, t2, t3;
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# BUG#44810: index merge and order by with low sort_buffer_size
|
||||
# crashes server!
|
||||
#
|
||||
CREATE TABLE t1(a VARCHAR(128),b VARCHAR(128),KEY(A),KEY(B));
|
||||
INSERT INTO t1 VALUES (REPEAT('a',128),REPEAT('b',128));
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT REPEAT('a',128),REPEAT('b',128) FROM seq_1_to_64;
|
||||
SET SESSION sort_buffer_size=1024*8;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%'
|
||||
@ -592,8 +581,6 @@ SET SESSION sort_buffer_size=DEFAULT;
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
#---------------- ROR-index_merge tests -----------------------
|
||||
SET SESSION STORAGE_ENGINE = MyISAM;
|
||||
drop table if exists t0,t1,t2;
|
||||
create table t1
|
||||
(
|
||||
/* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */
|
||||
@ -842,8 +829,6 @@ SELECT * FROM t1;
|
||||
c1 c2 c3
|
||||
DROP TABLE t1,t2;
|
||||
#---------------- Index merge test 2 -------------------------------------------
|
||||
SET SESSION STORAGE_ENGINE = MyISAM;
|
||||
drop table if exists t1,t2;
|
||||
create table t1
|
||||
(
|
||||
key1 int not null,
|
||||
@ -851,6 +836,7 @@ key2 int not null,
|
||||
INDEX i1(key1),
|
||||
INDEX i2(key2)
|
||||
);
|
||||
INSERT INTO t1 SELECT seq,200-seq FROM seq_0_to_200;
|
||||
explain select * from t1 where key1 < 5 or key2 > 197;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
||||
@ -908,6 +894,8 @@ index (key2)
|
||||
);
|
||||
show warnings;
|
||||
Level Code Message
|
||||
INSERT INTO t1 (key1, key2, filler)
|
||||
SELECT seq/4, seq/8, 'filler-data' FROM seq_30_to_0;
|
||||
explain select pk from t1 where key1 = 1 and key2 = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref key1,key2 key1 5 const 4 Using where
|
||||
@ -1134,24 +1122,7 @@ key1 int not null,
|
||||
key2 int not null default 0,
|
||||
key3 int not null default 0
|
||||
);
|
||||
insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8);
|
||||
set @d=8;
|
||||
begin;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
insert into t1 (key1) select key1+@d from t1;
|
||||
set @d=@d*2;
|
||||
commit;
|
||||
insert into t1(key1) select seq from seq_1_to_1024;
|
||||
alter table t1 add index i2(key2);
|
||||
alter table t1 add index i3(key3);
|
||||
update t1 set key2=key1,key3=key1;
|
||||
@ -1231,8 +1202,6 @@ a b
|
||||
1 b
|
||||
DROP TABLE t1, t2;
|
||||
#---------------- 2-sweeps read Index merge test 2 -------------------------------
|
||||
SET SESSION STORAGE_ENGINE = MyISAM;
|
||||
drop table if exists t1;
|
||||
create table t1 (
|
||||
pk int primary key,
|
||||
key1 int,
|
||||
@ -1242,6 +1211,8 @@ filler2 char(200),
|
||||
index(key1),
|
||||
index(key2)
|
||||
);
|
||||
insert into t1 select seq, seq, seq, 'filler-data', 'filler-data-2'
|
||||
from seq_1000_to_1;
|
||||
select * from t1 where (key1 >= 2 and key1 <= 10) or (pk >= 4 and pk <=8 );
|
||||
pk key1 key2 filler filler2
|
||||
10 10 10 filler-data filler-data-2
|
||||
@ -1369,8 +1340,6 @@ pk key1 key2 filler filler2
|
||||
1 1 1 filler-data filler-data-2
|
||||
drop table t1;
|
||||
#---------------- Clustered PK ROR-index_merge tests -----------------------------
|
||||
SET SESSION STORAGE_ENGINE = MyISAM;
|
||||
drop table if exists t1;
|
||||
create table t1
|
||||
(
|
||||
pk1 int not null,
|
||||
@ -1731,22 +1700,7 @@ create table t0
|
||||
key1 int not null,
|
||||
INDEX i1(key1)
|
||||
);
|
||||
insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8);
|
||||
set @d=8;
|
||||
insert into t0 select key1+ @d from t0;
|
||||
set @d=@d*2;
|
||||
insert into t0 select key1+ @d from t0;
|
||||
set @d=@d*2;
|
||||
insert into t0 select key1+ @d from t0;
|
||||
set @d=@d*2;
|
||||
insert into t0 select key1+ @d from t0;
|
||||
set @d=@d*2;
|
||||
insert into t0 select key1+ @d from t0;
|
||||
set @d=@d*2;
|
||||
insert into t0 select key1+ @d from t0;
|
||||
set @d=@d*2;
|
||||
insert into t0 select key1+ @d from t0;
|
||||
set @d=@d*2;
|
||||
insert into t0 select * from seq_1_to_1024;
|
||||
alter table t0 add key2 int not null, add index i2(key2);
|
||||
alter table t0 add key3 int not null, add index i3(key3);
|
||||
alter table t0 add key8 int not null, add index i8(key8);
|
||||
|
@ -10,7 +10,7 @@
|
||||
# include/index_merge*.inc files
|
||||
#
|
||||
|
||||
let $engine_type= MyISAM;
|
||||
SET STORAGE_ENGINE = MyISAM;
|
||||
# MyISAM supports Merge tables
|
||||
let $merge_table_support= 1;
|
||||
|
||||
@ -34,7 +34,7 @@ insert into t1 select
|
||||
A.a * B.a*10 + C.a*100,
|
||||
A.a,
|
||||
'filler'
|
||||
from t0 A, t0 B, t0 C;
|
||||
from t0 A, t0 B, t0 C;
|
||||
|
||||
--echo This should use union:
|
||||
explain select * from t1 where a=1 or b=1;
|
||||
@ -254,15 +254,7 @@ create table t0
|
||||
INDEX i1(key1)
|
||||
);
|
||||
|
||||
insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8);
|
||||
let $1=7;
|
||||
set @d=8;
|
||||
while ($1)
|
||||
{
|
||||
eval insert into t0 select key1+ @d from t0;
|
||||
eval set @d=@d*2;
|
||||
dec $1;
|
||||
}
|
||||
insert into t0 select * from seq_1_to_1024;
|
||||
alter table t0 add key2 int not null, add index i2(key2);
|
||||
alter table t0 add key3 int not null, add index i3(key3);
|
||||
alter table t0 add key8 int not null, add index i8(key8);
|
||||
|
@ -6,6 +6,7 @@ SET @@GLOBAL.log_output='TABLE';
|
||||
FLUSH SLOW LOGS;
|
||||
SET @@GLOBAL.slow_query_log=ON;
|
||||
SET @@GLOBAL.log_slow_admin_statements=ON;
|
||||
SET @save_dbug = @@debug_dbug;
|
||||
SET SESSION debug_dbug="+d,simulate_slow_query";
|
||||
CREATE PROCEDURE show_slow_log()
|
||||
BEGIN
|
||||
@ -217,7 +218,7 @@ sql_text
|
||||
#
|
||||
# Clean up
|
||||
#
|
||||
SET SESSION debug_dbug="-d,simulate_slow_query";
|
||||
SET SESSION debug_dbug=@save_dbug;
|
||||
TRUNCATE mysql.slow_log;
|
||||
SET @@global.slow_query_log= @org_slow_query_log;
|
||||
SET @@global.log_output= @org_log_output;
|
||||
|
@ -9,6 +9,7 @@ SET @@GLOBAL.log_output='TABLE';
|
||||
FLUSH SLOW LOGS;
|
||||
SET @@GLOBAL.slow_query_log=ON;
|
||||
SET @@GLOBAL.log_slow_admin_statements=ON;
|
||||
SET @save_dbug = @@debug_dbug;
|
||||
SET SESSION debug_dbug="+d,simulate_slow_query";
|
||||
|
||||
DELIMITER $$;
|
||||
@ -86,7 +87,7 @@ CALL show_slow_log();
|
||||
--echo # Clean up
|
||||
--echo #
|
||||
|
||||
SET SESSION debug_dbug="-d,simulate_slow_query";
|
||||
SET SESSION debug_dbug=@save_dbug;
|
||||
TRUNCATE mysql.slow_log;
|
||||
SET @@global.slow_query_log= @org_slow_query_log;
|
||||
SET @@global.log_output= @org_log_output;
|
||||
|
@ -1,4 +1,3 @@
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
SET DEBUG_SYNC= 'RESET';
|
||||
#
|
||||
# Bug#42438: Crash ha_partition::change_table_ptr
|
||||
|
@ -8,10 +8,7 @@
|
||||
--source include/have_debug.inc
|
||||
--source include/have_innodb.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
SET DEBUG_SYNC= 'RESET';
|
||||
--enable_warnings
|
||||
|
||||
--echo #
|
||||
--echo # Bug#42438: Crash ha_partition::change_table_ptr
|
||||
|
@ -919,6 +919,7 @@ END;
|
||||
CLOSE c;
|
||||
SELECT a INTO @foo FROM t1 LIMIT 1; # Clear warning stack
|
||||
END|
|
||||
SET @save_dbug = @@debug_dbug;
|
||||
SET SESSION debug_dbug="+d,bug23032_emit_warning";
|
||||
CALL p1();
|
||||
Warning found!
|
||||
@ -938,7 +939,7 @@ End of Result Set found!
|
||||
Level Code Message
|
||||
Warning 1105 Unknown error
|
||||
Error 1329 No data - zero rows fetched, selected, or processed
|
||||
SET SESSION debug_dbug="-d,bug23032_emit_warning";
|
||||
SET SESSION debug_dbug=@save_dbug;
|
||||
DROP PROCEDURE p1;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -696,9 +696,10 @@ END|
|
||||
|
||||
delimiter ;|
|
||||
|
||||
SET @save_dbug = @@debug_dbug;
|
||||
SET SESSION debug_dbug="+d,bug23032_emit_warning";
|
||||
CALL p1();
|
||||
SET SESSION debug_dbug="-d,bug23032_emit_warning";
|
||||
SET SESSION debug_dbug=@save_dbug;
|
||||
|
||||
DROP PROCEDURE p1;
|
||||
DROP TABLE t1;
|
||||
|
@ -233,3 +233,48 @@ set global debug_dbug= @saved_dbug;
|
||||
drop table t1;
|
||||
set debug_sync=reset;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
|
||||
#
|
||||
# MDEV-18546 ASAN heap-use-after-free
|
||||
# in innobase_get_computed_value / row_purge
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
pk INT AUTO_INCREMENT,
|
||||
b BIT(15),
|
||||
v BIT(15) AS (b) VIRTUAL,
|
||||
PRIMARY KEY(pk),
|
||||
UNIQUE(v)
|
||||
) ENGINE=InnoDB;
|
||||
INSERT IGNORE INTO t1 (b) VALUES
|
||||
(NULL),(b'011'),(b'000110100'),
|
||||
(b'01101101010'),(b'01111001001011'),(NULL);
|
||||
SET GLOBAL innodb_debug_sync = "ib_clust_v_col_before_row_allocated "
|
||||
"SIGNAL before_row_allocated "
|
||||
"WAIT_FOR flush_unlock";
|
||||
SET GLOBAL innodb_debug_sync = "ib_open_after_dict_open "
|
||||
"SIGNAL purge_open "
|
||||
"WAIT_FOR select_open";
|
||||
set @saved_dbug= @@global.debug_dbug;
|
||||
set global debug_dbug= "+d,ib_purge_virtual_index_callback";
|
||||
connect purge_waiter,localhost,root;
|
||||
SET debug_sync= "now WAIT_FOR before_row_allocated";
|
||||
connection default;
|
||||
REPLACE INTO t1 (pk, b) SELECT pk, b FROM t1;
|
||||
connection purge_waiter;
|
||||
connection default;
|
||||
disconnect purge_waiter;
|
||||
FLUSH TABLES;
|
||||
SET GLOBAL innodb_debug_sync = reset;
|
||||
SET debug_sync= "now SIGNAL flush_unlock WAIT_FOR purge_open";
|
||||
SET GLOBAL innodb_debug_sync = reset;
|
||||
SET debug_sync= "ib_open_after_dict_open SIGNAL select_open";
|
||||
SELECT * FROM t1;
|
||||
pk b v
|
||||
1 NULL NULL
|
||||
2 |