Loading mysql-test/r/ps.result +19 −0 Original line number Diff line number Diff line Loading @@ -740,3 +740,22 @@ execute stmt using @user_id, @id; partner_id deallocate prepare stmt; drop table t1, t2, t3, t4; prepare stmt from 'select ?=?'; set @a='CHRISTINE '; set @b='CHRISTINE'; execute stmt using @a, @b; ?=? 1 execute stmt using @a, @b; ?=? 1 set @a=1, @b=2; execute stmt using @a, @b; ?=? 0 set @a='CHRISTINE '; set @b='CHRISTINE'; execute stmt using @a, @b; ?=? 1 deallocate prepare stmt; mysql-test/t/ps.test +15 −0 Original line number Diff line number Diff line Loading @@ -773,3 +773,18 @@ execute stmt using @user_id, @id; execute stmt using @user_id, @id; deallocate prepare stmt; drop table t1, t2, t3, t4; # # Bug#9379: make sure that Item::collation is reset when one sets # a parameter marker from a string variable. # prepare stmt from 'select ?=?'; set @a='CHRISTINE '; set @b='CHRISTINE'; execute stmt using @a, @b; execute stmt using @a, @b; set @a=1, @b=2; execute stmt using @a, @b; set @a='CHRISTINE '; set @b='CHRISTINE'; execute stmt using @a, @b; deallocate prepare stmt; sql/item.cc +3 −0 Original line number Diff line number Diff line Loading @@ -1942,6 +1942,7 @@ void Item_param::reset() to the binary log. */ str_value.set_charset(&my_charset_bin); collation.set(&my_charset_bin, DERIVATION_COERCIBLE); state= NO_VALUE; maybe_null= 1; null_value= 0; Loading Loading @@ -2243,6 +2244,8 @@ bool Item_param::convert_str_value(THD *thd) */ str_value_ptr.set(str_value.ptr(), str_value.length(), str_value.charset()); /* Synchronize item charset with value charset */ collation.set(str_value.charset(), DERIVATION_COERCIBLE); } return rc; } Loading sql/item_func.cc +14 −1 Original line number Diff line number Diff line Loading @@ -192,11 +192,24 @@ bool Item_func::agg_arg_charsets(DTCollation &coll, } if ((*arg)->type() == FIELD_ITEM) ((Item_field *)(*arg))->no_const_subst= 1; /* If in statement prepare, then we create a converter for two constant items, do it once and then reuse it. If we're in execution of a prepared statement, arena is NULL, and the conv was created in runtime memory. This can be the case only if the argument is a parameter marker ('?'), because for all true constants the charset converter has already been created in prepare. In this case register the change for rollback. */ if (arena) *arg= conv; else thd->change_item_tree(arg, conv); /* We do not check conv->fixed, because Item_func_conv_charset which can be return by safe_charset_converter can't be fixed at creation */ *arg= conv; conv->fix_fields(thd, arg); } if (arena) Loading Loading
mysql-test/r/ps.result +19 −0 Original line number Diff line number Diff line Loading @@ -740,3 +740,22 @@ execute stmt using @user_id, @id; partner_id deallocate prepare stmt; drop table t1, t2, t3, t4; prepare stmt from 'select ?=?'; set @a='CHRISTINE '; set @b='CHRISTINE'; execute stmt using @a, @b; ?=? 1 execute stmt using @a, @b; ?=? 1 set @a=1, @b=2; execute stmt using @a, @b; ?=? 0 set @a='CHRISTINE '; set @b='CHRISTINE'; execute stmt using @a, @b; ?=? 1 deallocate prepare stmt;
mysql-test/t/ps.test +15 −0 Original line number Diff line number Diff line Loading @@ -773,3 +773,18 @@ execute stmt using @user_id, @id; execute stmt using @user_id, @id; deallocate prepare stmt; drop table t1, t2, t3, t4; # # Bug#9379: make sure that Item::collation is reset when one sets # a parameter marker from a string variable. # prepare stmt from 'select ?=?'; set @a='CHRISTINE '; set @b='CHRISTINE'; execute stmt using @a, @b; execute stmt using @a, @b; set @a=1, @b=2; execute stmt using @a, @b; set @a='CHRISTINE '; set @b='CHRISTINE'; execute stmt using @a, @b; deallocate prepare stmt;
sql/item.cc +3 −0 Original line number Diff line number Diff line Loading @@ -1942,6 +1942,7 @@ void Item_param::reset() to the binary log. */ str_value.set_charset(&my_charset_bin); collation.set(&my_charset_bin, DERIVATION_COERCIBLE); state= NO_VALUE; maybe_null= 1; null_value= 0; Loading Loading @@ -2243,6 +2244,8 @@ bool Item_param::convert_str_value(THD *thd) */ str_value_ptr.set(str_value.ptr(), str_value.length(), str_value.charset()); /* Synchronize item charset with value charset */ collation.set(str_value.charset(), DERIVATION_COERCIBLE); } return rc; } Loading
sql/item_func.cc +14 −1 Original line number Diff line number Diff line Loading @@ -192,11 +192,24 @@ bool Item_func::agg_arg_charsets(DTCollation &coll, } if ((*arg)->type() == FIELD_ITEM) ((Item_field *)(*arg))->no_const_subst= 1; /* If in statement prepare, then we create a converter for two constant items, do it once and then reuse it. If we're in execution of a prepared statement, arena is NULL, and the conv was created in runtime memory. This can be the case only if the argument is a parameter marker ('?'), because for all true constants the charset converter has already been created in prepare. In this case register the change for rollback. */ if (arena) *arg= conv; else thd->change_item_tree(arg, conv); /* We do not check conv->fixed, because Item_func_conv_charset which can be return by safe_charset_converter can't be fixed at creation */ *arg= conv; conv->fix_fields(thd, arg); } if (arena) Loading