Commit 7bc6a83b authored by Igor Babaev's avatar Igor Babaev

Backported the fix and the test case for bug #58816 from mysql-5.6 code line.

parent a8f5b5e8
......@@ -467,6 +467,31 @@ set optimizer_switch=@save_optimizer_switch;
DROP TABLE t1, t2;
--echo #
--echo # Bug #58816 "Extra temporary duplicate rows in result set when
--echo # switching ICP off"
--echo #
set @save_optimizer_switch= @@optimizer_switch;
CREATE TABLE t1 (
pk INT NOT NULL,
c1 INT NOT NULL,
PRIMARY KEY (pk)
);
INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1);
EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3;
SET SESSION optimizer_switch='index_condition_pushdown=off';
SELECT pk, c1 FROM t1 WHERE pk <> 3;
DROP TABLE t1;
set optimizer_switch= @save_optimizer_switch;
--echo #
--echo # BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89
--echo #
......
......@@ -439,6 +439,29 @@ pk i
set optimizer_switch=@save_optimizer_switch;
DROP TABLE t1, t2;
#
# Bug #58816 "Extra temporary duplicate rows in result set when
# switching ICP off"
#
set @save_optimizer_switch= @@optimizer_switch;
CREATE TABLE t1 (
pk INT NOT NULL,
c1 INT NOT NULL,
PRIMARY KEY (pk)
);
INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1);
EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3;
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
SET SESSION optimizer_switch='index_condition_pushdown=off';
SELECT pk, c1 FROM t1 WHERE pk <> 3;
pk c1
1 9
2 7
4 3
5 1
DROP TABLE t1;
set optimizer_switch= @save_optimizer_switch;
#
# BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89
#
CREATE TABLE t1 ( f11 int) ;
......
......@@ -445,6 +445,29 @@ pk i
set optimizer_switch=@save_optimizer_switch;
DROP TABLE t1, t2;
#
# Bug #58816 "Extra temporary duplicate rows in result set when
# switching ICP off"
#
set @save_optimizer_switch= @@optimizer_switch;
CREATE TABLE t1 (
pk INT NOT NULL,
c1 INT NOT NULL,
PRIMARY KEY (pk)
);
INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1);
EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 5 Using where
SET SESSION optimizer_switch='index_condition_pushdown=off';
SELECT pk, c1 FROM t1 WHERE pk <> 3;
pk c1
1 9
2 7
4 3
5 1
DROP TABLE t1;
set optimizer_switch= @save_optimizer_switch;
#
# BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89
#
CREATE TABLE t1 ( f11 int) ;
......
......@@ -443,6 +443,29 @@ pk i
set optimizer_switch=@save_optimizer_switch;
DROP TABLE t1, t2;
#
# Bug #58816 "Extra temporary duplicate rows in result set when
# switching ICP off"
#
set @save_optimizer_switch= @@optimizer_switch;
CREATE TABLE t1 (
pk INT NOT NULL,
c1 INT NOT NULL,
PRIMARY KEY (pk)
);
INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1);
EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 5 Using where
SET SESSION optimizer_switch='index_condition_pushdown=off';
SELECT pk, c1 FROM t1 WHERE pk <> 3;
pk c1
1 9
2 7
4 3
5 1
DROP TABLE t1;
set optimizer_switch= @save_optimizer_switch;
#
# BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89
#
CREATE TABLE t1 ( f11 int) ;
......
......@@ -350,7 +350,7 @@ GROUP BY t2.pk
);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
2 SUBQUERY t2 ref int_key int_key 5 const 1 100.00 Using index condition; Using where; Using filesort
2 SUBQUERY t2 ref int_key int_key 5 const 1 100.00 Using where; Using filesort
Warnings:
Note 1003 select min(1) AS `MIN(t1.pk)` from `test`.`t1` where exists(select `test`.`t2`.`pk` from `test`.`t2` where isnull(`test`.`t2`.`int_key`) group by `test`.`t2`.`pk`)
DROP TABLE t1, t2;
......
......@@ -4878,6 +4878,9 @@ int handler::ha_reset()
/* reset the bitmaps to point to defaults */
table->default_column_bitmaps();
pushed_cond= NULL;
/* Reset information about pushed engine conditions */
cancel_pushed_idx_cond();
/* Reset information about pushed index conditions */
DBUG_RETURN(reset());
}
......
......@@ -2393,6 +2393,13 @@ public:
*/
virtual void cond_pop() { return; };
virtual Item *idx_cond_push(uint keyno, Item* idx_cond) { return idx_cond; }
/** Reset information about pushed index conditions */
virtual void cancel_pushed_idx_cond()
{
pushed_idx_cond= NULL;
pushed_idx_cond_keyno= MAX_KEY;
in_range_check_pushed_down= false;
}
virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
uint table_changes)
{ return COMPATIBLE_DATA_NO; }
......
......@@ -18002,7 +18002,11 @@ use_filesort:
select->quick= save_quick;
}
if (orig_cond_saved)
{
tab->table->file->cancel_pushed_idx_cond();
tab->set_cond(orig_cond);
}
DBUG_RETURN(0);
}
......
......@@ -2538,9 +2538,6 @@ int ha_maria::extra(enum ha_extra_function operation)
int ha_maria::reset(void)
{
pushed_idx_cond= NULL;
pushed_idx_cond_keyno= MAX_KEY;
in_range_check_pushed_down= FALSE;
ma_set_index_cond_func(file, NULL, 0);
ds_mrr.dsmrr_close();
if (file->trn)
......
......@@ -1971,9 +1971,6 @@ int ha_myisam::extra(enum ha_extra_function operation)
int ha_myisam::reset(void)
{
pushed_idx_cond= NULL;
pushed_idx_cond_keyno= MAX_KEY;
in_range_check_pushed_down= FALSE;
mi_set_index_cond_func(file, NULL, 0);
ds_mrr.dsmrr_close();
return mi_reset(file);
......
......@@ -2016,8 +2016,6 @@ ha_innobase::reset_template(void)
/* Reset index condition pushdown state */
prebuilt->idx_cond = NULL;
prebuilt->idx_cond_n_cols = 0;
pushed_idx_cond = NULL;
pushed_idx_cond_keyno = MAX_KEY;
}
/*****************************************************************//**
......
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