summaryrefslogtreecommitdiff
path: root/mysql-test/r
diff options
context:
space:
mode:
authorunknown <igor@olga.mysql.com>2006-12-11 18:57:23 -0800
committerunknown <igor@olga.mysql.com>2006-12-11 18:57:23 -0800
commit33446269e18d0506802ca89df30f89e3e5978154 (patch)
treef30fbed68f4f735eb329fc23c690cc0fb123c96b /mysql-test/r
parent1c1c35d2b5c27172e3d9becd76c8fe01db118647 (diff)
downloadmariadb-git-33446269e18d0506802ca89df30f89e3e5978154.tar.gz
Fixed bug #24670: optimizations that are legal only for subqueries without tables
and no WHERE condition were applied for any subquery without tables. mysql-test/r/subselect.result: Added a test case for bug #24670. mysql-test/t/subselect.test: Added a test case for bug #24670. sql/item_subselect.cc: Fixed bug #24670: optimizations that are legal only for subqueries without tables and no WHERE condition were applied for any subquery without tables. Removed an assertion that caused an abort for subqueries without tables and no WHERE condition. Blocked substitution of a single-row subquery without tables for the constant row from its select list when the subquery contained a WHERE condition. This optimization is valid only for subquries without tables with no conditions. Any subquery without tables with WHERE clause returns NULL if the WHERE condition is FALSE. Erroneously it was always considered as non-nullable that could trigger another optimization concerning IS NULL predicates which is applicable only for non-nullable expressions and ultimately led to a wrong result returned by the outer query. Added a proper implementation of the virtual method may_be_null for class subselect_single_select_engine. sql/item_subselect.h: Fixed bug #24670: optimizations that are legal only for subqueries without tables and no WHERE condition were applied for any subquery without tables. Made method may_by_null for class subselect_engine vvirtual.
Diffstat (limited to 'mysql-test/r')
-rw-r--r--mysql-test/r/subselect.result13
1 files changed, 13 insertions, 0 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 89315342f5e..a4ea8e21d61 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -3013,3 +3013,16 @@ t3 CREATE TABLE `t3` (
`a` datetime default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1,t2,t3;
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1), (2);
+SELECT a FROM t1 WHERE (SELECT 1 FROM DUAL WHERE 1=0) > 0;
+a
+SELECT a FROM t1 WHERE (SELECT 1 FROM DUAL WHERE 1=0) IS NULL;
+a
+1
+2
+EXPLAIN SELECT a FROM t1 WHERE (SELECT 1 FROM DUAL WHERE 1=0) IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+DROP TABLE t1;