summaryrefslogtreecommitdiff
path: root/mysql-test/t/select.test
diff options
context:
space:
mode:
authorRamil Kalimullin <ramil@mysql.com>2009-03-16 09:02:10 +0400
committerRamil Kalimullin <ramil@mysql.com>2009-03-16 09:02:10 +0400
commit0fd7a359da836ab3233023dcd1b7c6ab09c90be6 (patch)
tree5b5845023e8741b47740c58cc7ca9daee781e442 /mysql-test/t/select.test
parentb105e8f5bc0397fa35f7f79c42764bdb27f53b90 (diff)
downloadmariadb-git-0fd7a359da836ab3233023dcd1b7c6ab09c90be6.tar.gz
Fix for bug #42957: no results from
select where .. (col=col and col=col) or ... (false expression) Problem: optimizer didn't take into account a singular case when we eliminated all the predicates at the AND level of WHERE. That may lead to wrong results. Fix: replace (a=a AND a=a...) with TRUE if we eliminated all the predicates. mysql-test/r/select.result: Fix for bug #42957: no results from select where .. (col=col and col=col) or ... (false expression) - test result. mysql-test/t/select.test: Fix for bug #42957: no results from select where .. (col=col and col=col) or ... (false expression) - test case. sql/sql_select.cc: Fix for bug #42957: no results from select where .. (col=col and col=col) or ... (false expression) - replacing equality predicates by multiple equality items check if we eliminate all the predicates at the AND level and replace them with TRUE if so.
Diffstat (limited to 'mysql-test/t/select.test')
-rw-r--r--mysql-test/t/select.test16
1 files changed, 16 insertions, 0 deletions
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index ccdb53ec11f..8981ddbe2e4 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -3769,4 +3769,20 @@ SELECT date_nokey FROM C
DROP TABLE A,C;
+#
+# Bug #42957: no results from
+# select where .. (col=col and col=col) or ... (false expression)
+#
+CREATE TABLE t1 (a INT NOT NULL, b INT);
+INSERT INTO t1 VALUES (1, 1);
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
+SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL);
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20;
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20;
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20;
+DROP TABLE t1;
+
--echo End of 5.1 tests