summaryrefslogtreecommitdiff
path: root/mysql-test/t/null.test
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2004-11-10 14:05:28 +0400
committerunknown <bar@mysql.com>2004-11-10 14:05:28 +0400
commitad63974d659417f5bf1a2943e8c78b3223f2414a (patch)
treee0ac510e9f74790b5573d5dcf11694810143adda /mysql-test/t/null.test
parent8edf7903f33c10f5b25e93ba6efe02ee104ba80e (diff)
downloadmariadb-git-ad63974d659417f5bf1a2943e8c78b3223f2414a.tar.gz
1. When mixing NULL to a character string,
the result takes its charset/collation attributes from the character string, e.g. SELECT func(NULL, _latin2'string') now returns a latin2 result. This is done by introducing a new derivation (aka coercibility) level DERIVATION_IGNORABLE, which is used with Item_null. 2. 'Pure' NULL is now BINARY(0), not CHAR(0). I.e. NULL is now more typeless. mysql-test/r/metadata.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/r/null.result: Testing mixing NULL with a character string with a number of functions. mysql-test/r/ps_2myisam.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/r/ps_3innodb.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/r/ps_4heap.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/r/ps_5merge.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/r/ps_6bdb.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/r/ps_7ndb.result: Fixing test results: CHAR(0) -> BINARY(0) for NULLs mysql-test/t/null.test: Testing mixing NULL with a character string with a number of functions. sql/item.cc: New derivation level. sql/item.h: New derivation level.
Diffstat (limited to 'mysql-test/t/null.test')
-rw-r--r--mysql-test/t/null.test67
1 files changed, 67 insertions, 0 deletions
diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test
index 7d30fd06ba7..9ddef252d67 100644
--- a/mysql-test/t/null.test
+++ b/mysql-test/t/null.test
@@ -119,3 +119,70 @@ alter table t1 change i i int not null;
explain select * from t1 where i=2 or i is null;
drop table t1;
+#
+# NULL has its own type BINARY(0) by default.
+# But NULL should be weaker than a constant
+# when mixing charsets/collations
+#
+set names latin2;
+# Check that result type is taken from a non-null string
+create table t1 select
+ null as c00,
+ if(1, null, 'string') as c01,
+ if(0, null, 'string') as c02,
+ ifnull(null, 'string') as c03,
+ ifnull('string', null) as c04,
+ case when 0 then null else 'string' end as c05,
+ case when 1 then null else 'string' end as c06,
+ coalesce(null, 'string') as c07,
+ coalesce('string', null) as c08,
+ least('string',null) as c09,
+ least(null, 'string') as c10,
+ greatest('string',null) as c11,
+ greatest(null, 'string') as c12,
+ nullif('string', null) as c13,
+ nullif(null, 'string') as c14,
+ trim('string' from null) as c15,
+ trim(null from 'string') as c16,
+ substring_index('string', null, 1) as c17,
+ substring_index(null, 'string', 1) as c18,
+ elt(1, null, 'string') as c19,
+ elt(1, 'string', null) as c20,
+ concat('string', null) as c21,
+ concat(null, 'string') as c22,
+ concat_ws('sep', 'string', null) as c23,
+ concat_ws('sep', null, 'string') as c24,
+ concat_ws(null, 'string', 'string') as c25,
+ make_set(3, 'string', null) as c26,
+ make_set(3, null, 'string') as c27,
+ export_set(3, null, 'off', 'sep') as c29,
+ export_set(3, 'on', null, 'sep') as c30,
+ export_set(3, 'on', 'off', null) as c31,
+ replace(null, 'from', 'to') as c32,
+ replace('str', null, 'to') as c33,
+ replace('str', 'from', null) as c34,
+ insert('str', 1, 2, null) as c35,
+ insert(null, 1, 2, 'str') as c36,
+ lpad('str', 10, null) as c37,
+ rpad(null, 10, 'str') as c38;
+
+show create table t1;
+drop table t1;
+
+#
+# Check that comparison is done according to
+# non-null string collation, i.e. case insensitively,
+# rather than according to NULL's collation, i.e. case sensitively
+#
+-- in field
+select
+ case 'str' when 'STR' then 'str' when null then 'null' end as c01,
+ case 'str' when null then 'null' when 'STR' then 'str' end as c02,
+ field(null, 'str1', 'str2') as c03,
+ field('str1','STR1', null) as c04,
+ field('str1', null, 'STR1') as c05,
+ 'string' in ('STRING', null) as c08,
+ 'string' in (null, 'STRING') as c09;
+
+# Restore charset to the default value.
+set names latin1;