Commit 061406ba authored by unknown's avatar unknown

Merge mysql.com:/opt/local/work/mysql-4.1-9379

into  mysql.com:/opt/local/work/mysql-5.0-root


sql/item.cc:
  Auto merged
mysql-test/r/ps.result:
  Manual merge.
mysql-test/t/ps.test:
  Manual merge.
sql/item_func.cc:
  Manual merge.
parents b7033fb3 98248f04
......@@ -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;
......@@ -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;
......@@ -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;
......@@ -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;
}
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment