Commit b91a6bd8 authored by Igor Babaev's avatar Igor Babaev

Fixed LP bug #879871.

The function add_ref_to_table_cond missed updating the value of
join_tab->pre_idx_push_select_cond after having updated the value
of join_tab->select->pre_idx_push_select_cond.
parent 402258ff
...@@ -724,3 +724,23 @@ SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 ...@@ -724,3 +724,23 @@ SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c; HAVING t1.c != 5 ORDER BY t1.c;
DROP TABLE t1,t2; DROP TABLE t1,t2;
--echo #
--echo # Bug#879871: InnoDB: possible ICP + GROUP BY primary index
--echo #
CREATE TABLE t1 (
a int NOT NULL, b int, c varchar(1), d varchar(1),
PRIMARY KEY (a), KEY c (c,b)
);
INSERT INTO t1 VALUES (10,8,'g','g');
SET SESSION optimizer_switch='index_condition_pushdown=off';
SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1;
SET SESSION optimizer_switch='index_condition_pushdown=on';
SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1;
DROP TABLE t1;
...@@ -686,5 +686,20 @@ HAVING t1.c != 5 ORDER BY t1.c; ...@@ -686,5 +686,20 @@ HAVING t1.c != 5 ORDER BY t1.c;
b c b c
1 4 1 4
DROP TABLE t1,t2; DROP TABLE t1,t2;
#
# Bug#879871: InnoDB: possible ICP + GROUP BY primary index
#
CREATE TABLE t1 (
a int NOT NULL, b int, c varchar(1), d varchar(1),
PRIMARY KEY (a), KEY c (c,b)
);
INSERT INTO t1 VALUES (10,8,'g','g');
SET SESSION optimizer_switch='index_condition_pushdown=off';
SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1;
a
SET SESSION optimizer_switch='index_condition_pushdown=on';
SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1;
a
DROP TABLE t1;
set optimizer_switch=@innodb_icp_tmp; set optimizer_switch=@innodb_icp_tmp;
set storage_engine= @save_storage_engine; set storage_engine= @save_storage_engine;
...@@ -692,5 +692,20 @@ HAVING t1.c != 5 ORDER BY t1.c; ...@@ -692,5 +692,20 @@ HAVING t1.c != 5 ORDER BY t1.c;
b c b c
1 4 1 4
DROP TABLE t1,t2; DROP TABLE t1,t2;
#
# Bug#879871: InnoDB: possible ICP + GROUP BY primary index
#
CREATE TABLE t1 (
a int NOT NULL, b int, c varchar(1), d varchar(1),
PRIMARY KEY (a), KEY c (c,b)
);
INSERT INTO t1 VALUES (10,8,'g','g');
SET SESSION optimizer_switch='index_condition_pushdown=off';
SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1;
a
SET SESSION optimizer_switch='index_condition_pushdown=on';
SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1;
a
DROP TABLE t1;
set storage_engine= @save_storage_engine; set storage_engine= @save_storage_engine;
set optimizer_switch=@maria_icp_tmp; set optimizer_switch=@maria_icp_tmp;
...@@ -690,6 +690,21 @@ HAVING t1.c != 5 ORDER BY t1.c; ...@@ -690,6 +690,21 @@ HAVING t1.c != 5 ORDER BY t1.c;
b c b c
1 4 1 4
DROP TABLE t1,t2; DROP TABLE t1,t2;
#
# Bug#879871: InnoDB: possible ICP + GROUP BY primary index
#
CREATE TABLE t1 (
a int NOT NULL, b int, c varchar(1), d varchar(1),
PRIMARY KEY (a), KEY c (c,b)
);
INSERT INTO t1 VALUES (10,8,'g','g');
SET SESSION optimizer_switch='index_condition_pushdown=off';
SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1;
a
SET SESSION optimizer_switch='index_condition_pushdown=on';
SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1;
a
DROP TABLE t1;
drop table if exists t0, t1, t1i, t1m; drop table if exists t0, t1, t1i, t1m;
# #
# BUG#826935 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed # BUG#826935 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed
......
...@@ -19969,7 +19969,8 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab) ...@@ -19969,7 +19969,8 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab)
Item *new_cond= and_conds(cond_copy, join_tab->select->pre_idx_push_select_cond); Item *new_cond= and_conds(cond_copy, join_tab->select->pre_idx_push_select_cond);
if (!new_cond->fixed && new_cond->fix_fields(thd, &new_cond)) if (!new_cond->fixed && new_cond->fix_fields(thd, &new_cond))
error= 1; error= 1;
join_tab->select->pre_idx_push_select_cond= new_cond; join_tab->pre_idx_push_select_cond=
join_tab->select->pre_idx_push_select_cond= new_cond;
} }
join_tab->set_select_cond(cond, __LINE__); join_tab->set_select_cond(cond, __LINE__);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment