diff options
Diffstat (limited to 'mysql-test/r/func_isnull.result')
-rw-r--r-- | mysql-test/r/func_isnull.result | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/mysql-test/r/func_isnull.result b/mysql-test/r/func_isnull.result index 2dbe3d036f9..88c5bfd5468 100644 --- a/mysql-test/r/func_isnull.result +++ b/mysql-test/r/func_isnull.result @@ -24,3 +24,87 @@ INSERT INTO t1( id ) VALUES ( NULL ); SELECT t1.id FROM t1 WHERE (id is not null and id is null ); id DROP TABLE t1; +# End of 5.1 tests +# +# MDEV-14911: IS NULL for field from mergeable view +# +CREATE TABLE t1 (d1 datetime NOT NULL); +INSERT INTO t1 VALUES +('0000-00-00 00:00:00'), ('0000-00-00 00:00:00'), ('1979-09-03 20:49:36'); +SELECT * FROM t1; +d1 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +1979-09-03 20:49:36 +SELECT * FROM t1 WHERE d1 IS NULL; +d1 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE d1 IS NULL; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`d1` AS `d1` from `test`.`t1` where (`test`.`t1`.`d1` = 0) +SELECT count(*) FROM t1 WHERE d1 IS NULL; +count(*) +2 +CREATE VIEW v1 AS (SELECT * FROM t1); +SELECT * FROM v1; +d1 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +1979-09-03 20:49:36 +SELECT * FROM v1 WHERE d1 IS NULL; +d1 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +EXPLAIN EXTENDED SELECT * FROM v1 WHERE d1 IS NULL; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`d1` AS `d1` from `test`.`t1` where (`test`.`t1`.`d1` = 0) +SELECT count(*) FROM v1 WHERE d1 IS NULL; +count(*) +2 +SET @save_optimizer_switch=@@optimizer_switch; +SET SESSION optimizer_switch='derived_merge=off'; +SELECT count(*) FROM ( SELECT * FROM t1 ) AS a1 WHERE d1 IS NULL; +count(*) +2 +SET SESSION optimizer_switch='derived_merge=on'; +SELECT count(*) FROM ( SELECT * FROM t1 ) AS a1 WHERE d1 IS NULL; +count(*) +2 +SET optimizer_switch=@save_optimizer_switch; +CREATE TABLE t2 (d1 datetime NOT NULL); +INSERT INTO t2 VALUES +('1980-09-03 20:49:36'), ('0000-00-00 00:00:00'), ('1979-09-03 20:49:36'); +SELECT * FROM t2 LEFT JOIN t1 ON t2.d1=t1.d1 WHERE t1.d1 IS NULL; +d1 d1 +0000-00-00 00:00:00 0000-00-00 00:00:00 +0000-00-00 00:00:00 0000-00-00 00:00:00 +1980-09-03 20:49:36 NULL +EXPLAIN EXTENDED +SELECT * FROM t2 LEFT JOIN t1 ON t2.d1=t1.d1 WHERE t1.d1 IS NULL; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) +Warnings: +Note 1003 select `test`.`t2`.`d1` AS `d1`,`test`.`t1`.`d1` AS `d1` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`d1` = `test`.`t2`.`d1`)) where ((`test`.`t1`.`d1` = 0) or isnull(`test`.`t1`.`d1`)) +SELECT * FROM t2 LEFT JOIN v1 ON t2.d1=v1.d1 WHERE v1.d1 IS NULL; +d1 d1 +0000-00-00 00:00:00 0000-00-00 00:00:00 +0000-00-00 00:00:00 0000-00-00 00:00:00 +1980-09-03 20:49:36 NULL +EXPLAIN EXTENDED +SELECT * FROM t2 LEFT JOIN v1 ON t2.d1=v1.d1 WHERE v1.d1 IS NULL; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) +Warnings: +Note 1003 select `test`.`t2`.`d1` AS `d1`,`test`.`t1`.`d1` AS `d1` from `test`.`t2` left join (`test`.`t1`) on((`test`.`t1`.`d1` = `test`.`t2`.`d1`)) where ((`test`.`t1`.`d1` = 0) or isnull(`test`.`t1`.`d1`)) +DROP VIEW v1; +DROP TABLE t1,t2; +# +# End of 5.5 tests +# |