diff options
author | monty@mashka.mysql.fi <> | 2002-11-11 15:57:35 +0200 |
---|---|---|
committer | monty@mashka.mysql.fi <> | 2002-11-11 15:57:35 +0200 |
commit | 876f3f4d308739805a0a1ac71c32c9dc3060a948 (patch) | |
tree | af6d24e40719efd42eef9d7580ef497455ddd45d /mysql-test/t | |
parent | b0f5c6d625a77ef51554a1f98f1fd27b4b3f7801 (diff) | |
download | mariadb-git-876f3f4d308739805a0a1ac71c32c9dc3060a948.tar.gz |
Fixed that NULL and 0 returns 0 instead of NULL
This is coded to not cause a speed impact on top level AND expressions where we don't care if an AND expression returns 0 or NULL
Diffstat (limited to 'mysql-test/t')
-rw-r--r-- | mysql-test/t/bool.test | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/mysql-test/t/bool.test b/mysql-test/t/bool.test new file mode 100644 index 00000000000..5754acf4bcd --- /dev/null +++ b/mysql-test/t/bool.test @@ -0,0 +1,28 @@ +# +# Test of boolean operations with NULL +# + +DROP TABLE IF EXISTS t1; + +SELECT IF(NULL AND 1, 1, 2), IF(1 AND NULL, 1, 2); +SELECT NULL AND 1, 1 AND NULL, 0 AND NULL, NULL and 0; + +create table t1 (a int); +insert into t1 values (0),(1),(NULL); +SELECT * FROM t1 WHERE IF(a AND 1, 0, 1); +SELECT * FROM t1 WHERE IF(1 AND a, 0, 1); +SELECT * FROM t1 where NOT(a AND 1); +SELECT * FROM t1 where NOT(1 AND a); +SELECT * FROM t1 where (a AND 1)=0; +SELECT * FROM t1 where (1 AND a)=0; +SELECT * FROM t1 where (1 AND a)=1; +SELECT * FROM t1 where (1 AND a) IS NULL; + +# Verify that NULL optimisation works in AND clause: +SET @a=0, @b=0; +SELECT * FROM t1 WHERE NULL AND (@a:=@a+1); +SELECT * FROM t1 WHERE NOT(a>=0 AND NULL AND (@b:=@b+1)); +SELECT * FROM t1 WHERE a=2 OR (NULL AND (@a:=@a+1)); +SELECT * FROM t1 WHERE NOT(a=2 OR (NULL AND (@b:=@b+1))); +SELECT @a, @b; +DROP TABLE t1; |