summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.h
diff options
context:
space:
mode:
authorSergey Glukhov <sergey.glukhov@oracle.com>2011-03-30 11:00:41 +0400
committerSergey Glukhov <sergey.glukhov@oracle.com>2011-03-30 11:00:41 +0400
commit3b7f044534ae24ce0a098d598bc7fc7a2b40fe4f (patch)
tree84457379ace3a7e68d4fa4f740bf6e89dcd3b5f0 /sql/item_timefunc.h
parent4e26a41f3e2cac5ec5016b862944c0116a18b0f6 (diff)
downloadmariadb-git-3b7f044534ae24ce0a098d598bc7fc7a2b40fe4f.tar.gz
Bug#11766126 59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
Valgrind warning happens because null values check happens too late in Item_func_month::val_str(after result string calculation).The fix is to check null value before result string calculation. mysql-test/r/func_time.result: test case mysql-test/t/func_time.test: test case sql/item_timefunc.h: check null value before result string calculation.
Diffstat (limited to 'sql/item_timefunc.h')
-rw-r--r--sql/item_timefunc.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 9c1ac512bcb..396b5bbb200 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -106,8 +106,11 @@ public:
{ DBUG_ASSERT(fixed == 1); return (double) Item_func_month::val_int(); }
String *val_str(String *str)
{
- str->set(val_int(), &my_charset_bin);
- return null_value ? 0 : str;
+ longlong nr= val_int();
+ if (null_value)
+ return 0;
+ str->set(nr, &my_charset_bin);
+ return str;
}
const char *func_name() const { return "month"; }
enum Item_result result_type () const { return INT_RESULT; }