@@ -4729,7 +4729,7 @@ bool user_var_entry::realloc(uint length)
47294729 @retval true on allocation error
47304730
47314731*/
4732- bool user_var_entry::store (void *from, uint length, Item_result type)
4732+ bool user_var_entry::store (const void *from, uint length, Item_result type)
47334733{
47344734 // Store strings with end \0
47354735 if (realloc (length + MY_TEST (type == STRING_RESULT)))
@@ -4763,7 +4763,7 @@ bool user_var_entry::store(void *from, uint length, Item_result type)
47634763 true failure
47644764*/
47654765
4766- bool user_var_entry::store (void *ptr, uint length, Item_result type,
4766+ bool user_var_entry::store (const void *ptr, uint length, Item_result type,
47674767 const CHARSET_INFO *cs, Derivation dv,
47684768 bool unsigned_arg)
47694769{
@@ -4776,7 +4776,7 @@ bool user_var_entry::store(void *ptr, uint length, Item_result type,
47764776
47774777
47784778bool
4779- Item_func_set_user_var::update_hash (void *ptr, uint length,
4779+ Item_func_set_user_var::update_hash (const void *ptr, uint length,
47804780 Item_result res_type,
47814781 const CHARSET_INFO *cs, Derivation dv,
47824782 bool unsigned_arg)
@@ -4790,8 +4790,16 @@ Item_func_set_user_var::update_hash(void *ptr, uint length,
47904790 null_value= ((Item_field*)args[0 ])->field ->is_null ();
47914791 else
47924792 null_value= args[0 ]->null_value ;
4793+
4794+ if (ptr == NULL )
4795+ {
4796+ DBUG_ASSERT (length == 0 );
4797+ null_value= true ;
4798+ }
4799+
47934800 if (null_value && null_item)
47944801 res_type= entry->type (); // Don't change type of item
4802+
47954803 if (null_value)
47964804 entry->set_null_value (res_type);
47974805 else if (entry->store (ptr, length, res_type, cs, dv, unsigned_arg))
@@ -5046,24 +5054,24 @@ Item_func_set_user_var::update()
50465054 switch (cached_result_type) {
50475055 case REAL_RESULT:
50485056 {
5049- res= update_hash (( void *) &save_result.vreal ,sizeof (save_result.vreal ),
5057+ res= update_hash (&save_result.vreal ,sizeof (save_result.vreal ),
50505058 REAL_RESULT, default_charset (), DERIVATION_IMPLICIT, 0 );
50515059 break ;
50525060 }
50535061 case INT_RESULT:
50545062 {
5055- res= update_hash (( void *) &save_result.vint , sizeof (save_result.vint ),
5063+ res= update_hash (&save_result.vint , sizeof (save_result.vint ),
50565064 INT_RESULT, default_charset (), DERIVATION_IMPLICIT,
50575065 unsigned_flag);
50585066 break ;
50595067 }
50605068 case STRING_RESULT:
50615069 {
50625070 if (!save_result.vstr ) // Null value
5063- res= update_hash (( void *) 0 , 0 , STRING_RESULT, &my_charset_bin,
5071+ res= update_hash (NULL , 0 , STRING_RESULT, &my_charset_bin,
50645072 DERIVATION_IMPLICIT, 0 );
50655073 else
5066- res= update_hash (( void *) save_result.vstr ->ptr (),
5074+ res= update_hash (save_result.vstr ->ptr (),
50675075 save_result.vstr ->length (), STRING_RESULT,
50685076 save_result.vstr ->charset (),
50695077 DERIVATION_IMPLICIT, 0 );
@@ -5072,10 +5080,10 @@ Item_func_set_user_var::update()
50725080 case DECIMAL_RESULT:
50735081 {
50745082 if (!save_result.vdec ) // Null value
5075- res= update_hash (( void *) 0 , 0 , DECIMAL_RESULT, &my_charset_bin,
5083+ res= update_hash (NULL , 0 , DECIMAL_RESULT, &my_charset_bin,
50765084 DERIVATION_IMPLICIT, 0 );
50775085 else
5078- res= update_hash (( void *) save_result.vdec ,
5086+ res= update_hash (save_result.vdec ,
50795087 sizeof (my_decimal), DECIMAL_RESULT,
50805088 default_charset (), DERIVATION_IMPLICIT, 0 );
50815089 break ;
0 commit comments