summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2013-08-20 17:08:03 +0300
committerunknown <timour@askmonty.org>2013-08-20 17:08:03 +0300
commit5fdb531d77e025cdf1738c424207b13e0a7608f5 (patch)
treefeb602ab7fe1fbd0a363da89298aedb3227a73b6 /sql/item_cmpfunc.cc
parent008371b627c8a8ddbc682820d3c4f9358fa1b950 (diff)
downloadmariadb-git-5fdb531d77e025cdf1738c424207b13e0a7608f5.tar.gz
Fix bug MDEV-4895 Valgrind warnings (Conditional jump or move depends on uninitialised value) in Field_datetime::get_date on GREATEST(..) IS NULL
Analysis: The cause of the valgrind warning was an attempt to evaluate a Field that was not yet read. The reason was that on one hand Item_func_isnotnull was marked as constant by Item_func_isnotnull::update_used_tables, and this allowed eval_const_cond() to be called. On the other hand Item_func_isnotnull::val_int() evaluated its argument as if it was not constant. Solution: The fix make sure that Item_func_isnotnull::val_int() doesn't evaluate its argument when it is constant and cannot be NULL, because the result is known in this case.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index de34a937262..fd688181c92 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -4621,6 +4621,8 @@ Item *and_expressions(Item *a, Item *b, Item **org_item)
longlong Item_func_isnull::val_int()
{
DBUG_ASSERT(fixed == 1);
+ if (const_item() && !args[0]->maybe_null)
+ return 0;
return args[0]->is_null() ? 1: 0;
}
@@ -4628,6 +4630,8 @@ longlong Item_is_not_null_test::val_int()
{
DBUG_ASSERT(fixed == 1);
DBUG_ENTER("Item_is_not_null_test::val_int");
+ if (const_item() && !args[0]->maybe_null)
+ DBUG_RETURN(1);
if (args[0]->is_null())
{
DBUG_PRINT("info", ("null"));