summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 01eb1ca506a..3875f73a36f 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2772,6 +2772,8 @@ Item *Item_func_case::find_item(String *str)
/* Compare every WHEN argument with it and return the first match */
for (uint i=0 ; i < ncases ; i+=2)
{
+ if (args[i]->real_item()->type() == NULL_ITEM)
+ continue;
cmp_type= item_cmp_type(left_result_type, args[i]->result_type());
DBUG_ASSERT(cmp_type != ROW_RESULT);
DBUG_ASSERT(cmp_items[(uint)cmp_type]);
@@ -4010,9 +4012,17 @@ longlong Item_func_in::val_int()
return (longlong) (!null_value && tmp != negated);
}
+ if ((null_value= args[0]->real_item()->type() == NULL_ITEM))
+ return 0;
+
have_null= 0;
for (uint i= 1 ; i < arg_count ; i++)
{
+ if (args[i]->real_item()->type() == NULL_ITEM)
+ {
+ have_null= TRUE;
+ continue;
+ }
Item_result cmp_type= item_cmp_type(left_result_type, args[i]->result_type());
in_item= cmp_items[(uint)cmp_type];
DBUG_ASSERT(in_item);
@@ -4576,13 +4586,14 @@ Item_func::optimize_type Item_func_like::select_optimize() const
if (args[1]->const_item())
{
String* res2= args[1]->val_str((String *)&cmp.value2);
+ const char *ptr2;
- if (!res2)
+ if (!res2 || !(ptr2= res2->ptr()))
return OPTIMIZE_NONE;
- if (*res2->ptr() != wild_many)
+ if (*ptr2 != wild_many)
{
- if (args[0]->result_type() != STRING_RESULT || *res2->ptr() != wild_one)
+ if (args[0]->result_type() != STRING_RESULT || *ptr2 != wild_one)
return OPTIMIZE_OP;
}
}