Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions mysql-test/main/range.result
Original file line number Diff line number Diff line change
Expand Up @@ -3736,6 +3736,27 @@ DROP TABLE t1;
#
# End of 10.5 tests
#
#
# MDEV-37913: disable_index_merge_plans causes SELECT data loss when more than 100 ORs
#
CREATE TABLE t1 (
id int primary key,
key1 int,
index(key1)
);
INSERT INTO t1 VALUES
(1, 1),
(2, 1),
(3, 2);
$query;
id key1
1 1
2 1
3 2
drop table t1;
#
# End of 10.11 tests
#
set global innodb_stats_persistent= @innodb_stats_persistent_save;
set global innodb_stats_persistent_sample_pages=
@innodb_stats_persistent_sample_pages_save;
26 changes: 26 additions & 0 deletions mysql-test/main/range.test
Original file line number Diff line number Diff line change
Expand Up @@ -2533,6 +2533,32 @@ DROP TABLE t1;
--echo # End of 10.5 tests
--echo #

--echo #
--echo # MDEV-37913: disable_index_merge_plans causes SELECT data loss when more than 100 ORs
--echo #
CREATE TABLE t1 (
id int primary key,
key1 int,
index(key1)
);

INSERT INTO t1 VALUES
(1, 1),
(2, 1),
(3, 2);

let $query=`
select concat('select * from t1 where (key1 = 2 AND id = 3) ',
REPEAT(' OR (key1 = 1)', 100))
`;

evalp $query;

drop table t1;

--echo #
--echo # End of 10.11 tests
--echo #
set global innodb_stats_persistent= @innodb_stats_persistent_save;
set global innodb_stats_persistent_sample_pages=
@innodb_stats_persistent_sample_pages_save;
21 changes: 21 additions & 0 deletions mysql-test/main/range_mrr_icp.result
Original file line number Diff line number Diff line change
Expand Up @@ -3725,6 +3725,27 @@ DROP TABLE t1;
#
# End of 10.5 tests
#
#
# MDEV-37913: disable_index_merge_plans causes SELECT data loss when more than 100 ORs
#
CREATE TABLE t1 (
id int primary key,
key1 int,
index(key1)
);
INSERT INTO t1 VALUES
(1, 1),
(2, 1),
(3, 2);
$query;
id key1
1 1
2 1
3 2
drop table t1;
#
# End of 10.11 tests
#
set global innodb_stats_persistent= @innodb_stats_persistent_save;
set global innodb_stats_persistent_sample_pages=
@innodb_stats_persistent_sample_pages_save;
Expand Down
9 changes: 7 additions & 2 deletions sql/opt_range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9974,8 +9974,6 @@ tree_or(RANGE_OPT_PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2)
{
bool must_be_ored= sel_trees_must_be_ored(param, tree1, tree2, ored_keys);
no_imerge_from_ranges= must_be_ored;
if (param->disable_index_merge_plans)
no_imerge_from_ranges= true;

if (no_imerge_from_ranges && no_merges1 && no_merges2)
{
Expand Down Expand Up @@ -10025,6 +10023,13 @@ tree_or(RANGE_OPT_PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2)
DBUG_RETURN(result);
}

/*
Ok, the result now has the ranges that one gets for (RT1 OR RT2).
If construction of SEL_IMERGE is disabled, stop right here.
*/
if (param->disable_index_merge_plans)
DBUG_RETURN(result);

SEL_IMERGE *imerge_from_ranges;
if (!(imerge_from_ranges= new SEL_IMERGE()))
result= NULL;
Expand Down