summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/include/icp_tests.inc25
-rw-r--r--mysql-test/r/innodb_icp.result23
-rw-r--r--mysql-test/r/maria_icp.result23
-rw-r--r--mysql-test/r/myisam_icp.result23
-rw-r--r--mysql-test/r/myisam_mrr.result2
-rw-r--r--sql/handler.cc3
-rw-r--r--sql/handler.h7
-rw-r--r--sql/sql_select.cc4
-rw-r--r--storage/maria/ha_maria.cc3
-rw-r--r--storage/myisam/ha_myisam.cc3
-rw-r--r--storage/xtradb/handler/ha_innodb.cc2
11 files changed, 109 insertions, 9 deletions
diff --git a/mysql-test/include/icp_tests.inc b/mysql-test/include/icp_tests.inc
index 53099eda5ae..c41fab88293 100644
--- a/mysql-test/include/icp_tests.inc
+++ b/mysql-test/include/icp_tests.inc
@@ -468,6 +468,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 #
CREATE TABLE t1 ( f11 int) ;
diff --git a/mysql-test/r/innodb_icp.result b/mysql-test/r/innodb_icp.result
index 32bbccb5e80..8293b3fbf83 100644
--- a/mysql-test/r/innodb_icp.result
+++ b/mysql-test/r/innodb_icp.result
@@ -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) ;
diff --git a/mysql-test/r/maria_icp.result b/mysql-test/r/maria_icp.result
index 83d1a2b93bc..1ae227fd283 100644
--- a/mysql-test/r/maria_icp.result
+++ b/mysql-test/r/maria_icp.result
@@ -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) ;
diff --git a/mysql-test/r/myisam_icp.result b/mysql-test/r/myisam_icp.result
index 249b5a73f8b..cd51b0b9c94 100644
--- a/mysql-test/r/myisam_icp.result
+++ b/mysql-test/r/myisam_icp.result
@@ -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) ;
diff --git a/mysql-test/r/myisam_mrr.result b/mysql-test/r/myisam_mrr.result
index f98504bbcda..bf513779dc0 100644
--- a/mysql-test/r/myisam_mrr.result
+++ b/mysql-test/r/myisam_mrr.result
@@ -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;
diff --git a/sql/handler.cc b/sql/handler.cc
index 66e22aa40dc..6c5d3a580ec 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -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());
}
diff --git a/sql/handler.h b/sql/handler.h
index 46f5beb45d2..1f45b1a1e7d 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -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; }
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index af7cd3c0a7a..770472d4fe6 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -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);
}
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 12c291ac99d..a6636316efb 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -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)
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 84c16caebe1..2ee516bf9ec 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -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);
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index d48581380d2..031c7f6e1c0 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -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;
}
/*****************************************************************//**