@@ -1179,14 +1179,31 @@ Item *Item_param::safe_charset_converter(const CHARSET_INFO *tocs)
11791179{
11801180 if (const_item ())
11811181 {
1182- uint cnv_errors;
1183- String *ostr= val_str (&cnvstr);
1184- cnvitem->str_value .copy (ostr->ptr (), ostr->length (),
1185- ostr->charset (), tocs, &cnv_errors);
1186- if (cnv_errors)
1187- return NULL ;
1188- cnvitem->str_value .mark_as_const ();
1189- cnvitem->max_length = cnvitem->str_value .numchars () * tocs->mbmaxlen ;
1182+ Item *cnvitem;
1183+ String tmp, cstr, *ostr= val_str (&tmp);
1184+
1185+ if (null_value)
1186+ {
1187+ cnvitem= new Item_null ();
1188+ if (cnvitem == NULL )
1189+ return NULL ;
1190+
1191+ cnvitem->collation .set (tocs);
1192+ }
1193+ else
1194+ {
1195+ uint conv_errors;
1196+ cstr.copy (ostr->ptr (), ostr->length (), ostr->charset (), tocs,
1197+ &conv_errors);
1198+
1199+ if (conv_errors || !(cnvitem= new Item_string (cstr.ptr (), cstr.length (),
1200+ cstr.charset (),
1201+ collation.derivation )))
1202+ return NULL ;
1203+
1204+ cnvitem->str_value .copy ();
1205+ cnvitem->str_value .mark_as_const ();
1206+ }
11901207 return cnvitem;
11911208 }
11921209 return Item::safe_charset_converter (tocs);
@@ -3420,8 +3437,6 @@ Item_param::Item_param(uint pos_in_query_arg) :
34203437 value is set.
34213438 */
34223439 maybe_null= 1 ;
3423- cnvitem= new Item_string (" " , 0 , &my_charset_bin, DERIVATION_COERCIBLE);
3424- cnvstr.set (cnvbuf, sizeof (cnvbuf), &my_charset_bin);
34253440}
34263441
34273442
0 commit comments