Skip to content

Commit abdb790

Browse files
author
Tor Didriksen
committed
Backport
Bug #11764313 57135: CRASH IN ITEM_FUNC_CASE::FIND_ITEM WITH CASE WHEN Bug #11764818 57692: Crash in item_func_in::val_int() with ZEROFILL
1 parent 862fc0f commit abdb790

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

sql/item_cmpfunc.cc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -3045,6 +3045,15 @@ void Item_func_case::fix_length_and_dec()
30453045
return;
30463046
}
30473047
}
3048+
/*
3049+
Set cmp_context of all WHEN arguments. This prevents
3050+
Item_field::equal_fields_propagator() from transforming a
3051+
zerofill argument into a string constant. Such a change would
3052+
require rebuilding cmp_items.
3053+
*/
3054+
for (i= 0; i < ncases; i+= 2)
3055+
args[i]->cmp_context= item_cmp_type(left_result_type,
3056+
args[i]->result_type());
30483057
}
30493058

30503059
if (else_expr_num == -1 || args[else_expr_num]->maybe_null)
@@ -4032,6 +4041,16 @@ void Item_func_in::fix_length_and_dec()
40324041
}
40334042
}
40344043
}
4044+
/*
4045+
Set cmp_context of all arguments. This prevents
4046+
Item_field::equal_fields_propagator() from transforming a zerofill integer
4047+
argument into a string constant. Such a change would require rebuilding
4048+
cmp_itmes.
4049+
*/
4050+
for (arg= args + 1, arg_end= args + arg_count; arg != arg_end ; arg++)
4051+
{
4052+
arg[0]->cmp_context= item_cmp_type(left_result_type, arg[0]->result_type());
4053+
}
40354054
max_length= 1;
40364055
}
40374056

0 commit comments

Comments
 (0)