summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2014-01-25 00:26:40 +0400
committerSergey Petrunya <psergey@askmonty.org>2014-01-25 00:26:40 +0400
commit669c6620af9a9996a66ca9b339d4fb05eb6bf944 (patch)
treed19180b17a4d623dab6c92776d4a2bd85060485a
parentd106dc059746157239d951551093fec049a7b73a (diff)
downloadmariadb-git-669c6620af9a9996a66ca9b339d4fb05eb6bf944.tar.gz
[Backport to 5.3]
MDEV-5337: Wrong result in mariadb 5.5.32 with ORDER BY + LIMIT when index_condition_pushdown=on - in test_if_skip_sort_order(), correct the condition under which we have the code that restores the previously pushed index condition.
-rw-r--r--mysql-test/r/innodb_icp.result25
-rw-r--r--mysql-test/t/innodb_icp.test28
-rw-r--r--sql/sql_select.cc2
3 files changed, 54 insertions, 1 deletions
diff --git a/mysql-test/r/innodb_icp.result b/mysql-test/r/innodb_icp.result
index 53a76b2a3f3..19c4ac25a88 100644
--- a/mysql-test/r/innodb_icp.result
+++ b/mysql-test/r/innodb_icp.result
@@ -851,5 +851,30 @@ insert into t1 values ('',1);
select 1 from t1 where b <= 1 and a <> '';
1
drop table t1;
+#
+# MDEV-5337: Wrong result in mariadb 5.5.32 with ORDER BY + LIMIT when index_condition_pushdown=on
+# MDEV-5512: Wrong result (WHERE clause ignored) with multiple clauses using Percona-XtraDB engine
+#
+create table t1(a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2 (pk int primary key,
+key1 char(32),
+key2 char(32),
+key(key1),
+key(key2)
+) engine=innodb;
+insert into t2 select
+A.a+10*B.a+100*C.a,
+concat('rare-', A.a+10*B.a),
+concat('rare-', A.a+10*B.a)
+from
+t1 A, t1 B, t1 C;
+update t2 set key1='frequent-val' where pk between 100 and 350;
+select * from t2 ignore key(PRIMARY)
+where key1='frequent-val' and key2 between 'rare-400' and 'rare-450' order by pk limit 2;
+pk key1 key2
+141 frequent-val rare-41
+142 frequent-val rare-42
+drop table t1, t2;
set optimizer_switch=@innodb_icp_tmp;
set storage_engine= @save_storage_engine;
diff --git a/mysql-test/t/innodb_icp.test b/mysql-test/t/innodb_icp.test
index 0fb42355f96..f7828ec7bb2 100644
--- a/mysql-test/t/innodb_icp.test
+++ b/mysql-test/t/innodb_icp.test
@@ -12,6 +12,34 @@ set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
--source include/icp_tests.inc
+--echo #
+--echo # MDEV-5337: Wrong result in mariadb 5.5.32 with ORDER BY + LIMIT when index_condition_pushdown=on
+--echo # MDEV-5512: Wrong result (WHERE clause ignored) with multiple clauses using Percona-XtraDB engine
+--echo #
+
+create table t1(a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t2 (pk int primary key,
+ key1 char(32),
+ key2 char(32),
+ key(key1),
+ key(key2)
+) engine=innodb;
+
+insert into t2 select
+ A.a+10*B.a+100*C.a,
+ concat('rare-', A.a+10*B.a),
+ concat('rare-', A.a+10*B.a)
+from
+ t1 A, t1 B, t1 C;
+update t2 set key1='frequent-val' where pk between 100 and 350;
+select * from t2 ignore key(PRIMARY)
+where key1='frequent-val' and key2 between 'rare-400' and 'rare-450' order by pk limit 2;
+
+drop table t1, t2;
+
+
set optimizer_switch=@innodb_icp_tmp;
set storage_engine= @save_storage_engine;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 289b75b5804..3e5652f2a16 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -19091,7 +19091,7 @@ check_reverse_order:
tab->limit= best_select_limit;
}
}
- else if (tab->type != JT_ALL)
+ else if (tab->type != JT_ALL || tab->select->quick)
{
/*
We're about to use a quick access to the table.