diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index 7fe8e76cb5ba369313c79e805d9d71612cafb853..490cde82ca36fde5081abd8e03bfaf424a88cc19 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -871,3 +871,17 @@ drop table t1;
 select convert(_koi8r'É' using utf8) < convert(_koi8r'Ê' using utf8);
 convert(_koi8r'É' using utf8) < convert(_koi8r'Ê' using utf8)
 1
+set names latin1;
+create table t1 (a varchar(10)) character set utf8;
+insert into t1 values ('test');
+select ifnull(a,'') from t1;
+ifnull(a,'')
+test
+drop table t1;
+select repeat(_utf8'+',3) as h union select NULL;
+h
++++
+NULL
+select ifnull(NULL, _utf8'string');
+ifnull(NULL, _utf8'string')
+string
diff --git a/mysql-test/r/func_system.result b/mysql-test/r/func_system.result
index 9aa936f1c784032f36d5ce71a024c1bff0ef3bbb..5ec5d7d724e1fb7c636164a79d24207c83ba0cbf 100644
--- a/mysql-test/r/func_system.result
+++ b/mysql-test/r/func_system.result
@@ -75,4 +75,8 @@ select * from t1 where a=database();
 a
 select * from t1 where a=user();
 a
+insert into t1 values ('a');
+select left(concat(a,version()),1) from t1;
+left(concat(a,version()),1)
+a
 drop table t1;
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index 2c498cd1922f0fff9589ab3a28c33cabad92adb0..194354f8718652c17e9d525e7a6171cf7d96427a 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -707,3 +707,14 @@ drop table t1;
 # Bug#8385: utf8_general_ci treats Cyrillic letters I and SHORT I as the same
 #
 select convert(_koi8r'É' using utf8) < convert(_koi8r'Ê' using utf8);
+
+#
+# Bugs#5980: NULL requires a characterset in a union
+#
+set names latin1;
+create table t1 (a varchar(10)) character set utf8;
+insert into t1 values ('test');
+select ifnull(a,'') from t1;
+drop table t1;
+select repeat(_utf8'+',3) as h union select NULL;
+select ifnull(NULL, _utf8'string');
diff --git a/mysql-test/t/func_system.test b/mysql-test/t/func_system.test
index 7fff165e057bd41427f18c9ee26aab872e5aa34c..bbfef25bcfea1f5ac76be916c46483a982e6bc9f 100644
--- a/mysql-test/t/func_system.test
+++ b/mysql-test/t/func_system.test
@@ -38,4 +38,6 @@ create table t1 (a char(10)) character set latin1;
 select * from t1 where a=version();
 select * from t1 where a=database();
 select * from t1 where a=user();
+insert into t1 values ('a');
+select left(concat(a,version()),1) from t1;
 drop table t1;