#At file:///home/kgeorge/mysql/work/B41437-5.0-bugteam/ based on revid:joro@stripped
2725 Georgi Kodinov 2009-01-09
Bug #41437: Value stored in 'case' lacks charset, causes segfault
When substituting system constant functions with a constant result
the server was not expecting that the function may return NULL.
Fixed by checking for NULL and returning Item_null (in the relevant
collation) if the result of the system constant function was NULL.
modified:
mysql-test/r/mysql.result
mysql-test/t/mysql.test
sql/item_strfunc.cc
per-file messages:
mysql-test/r/mysql.result
Bug #41437: test case
mysql-test/t/mysql.test
Bug #41437: test case.
Relies on database() returning NULL if no database is
selected.
sql/item_strfunc.cc
Bug #41437: Check for NULL result on evaluating the system
constant function and return a constant NULL item.
=== modified file 'mysql-test/r/mysql.result'
--- a/mysql-test/r/mysql.result 2008-12-11 17:26:03 +0000
+++ b/mysql-test/r/mysql.result 2009-01-09 11:50:18 +0000
@@ -186,4 +186,6 @@ delimiter
2
2
2
+@z:='1' @z=database()
+1 NULL
End of 5.0 tests
=== modified file 'mysql-test/t/mysql.test'
--- a/mysql-test/t/mysql.test 2008-12-11 17:26:03 +0000
+++ b/mysql-test/t/mysql.test 2009-01-09 11:50:18 +0000
@@ -309,4 +309,9 @@ EOF
--exec $MYSQL -c < $MYSQLTEST_VARDIR/tmp/bug38158.sql 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/bug38158.sql;
+#
+# Bug #41437: Value stored in 'case' lacks charset, causees segfault
+#
+--exec $MYSQL -e "select @z:='1',@z=database()"
+
--echo End of 5.0 tests
=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc 2008-07-10 23:51:58 +0000
+++ b/sql/item_strfunc.cc 2009-01-09 11:50:18 +0000
@@ -1696,6 +1696,12 @@ Item *Item_func_sysconst::safe_charset_c
Item_string *conv;
uint conv_errors;
String tmp, cstr, *ostr= val_str(&tmp);
+ if (null_value)
+ {
+ Item *null_item= new Item_null((char *) fully_qualified_func_name());
+ null_item->collation.set (tocs);
+ return null_item;
+ }
cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors);
if (conv_errors ||
!(conv= new Item_static_string_func(fully_qualified_func_name(),
| Thread |
|---|
| • bzr commit into mysql-5.0-bugteam branch (joro:2725) Bug#41437 | Georgi Kodinov | 9 Jan |