Commit 12749eaf authored by unknown's avatar unknown

item_func.cc:

  Some reoganization
  Fixed that binary arguments do not affect result charset
  anymore
  For example, the second argument doesn't affect charset of result in LEFT(string,10)
sql_string.h:
  Strings are binary by default now


sql/sql_string.h:
  Strings are binary by default now
sql/item_func.cc:
  Some reoganization
  Fixed that binary arguments do not affect result charset
  anymore
  For example, the second argument doesn't affect charset of result in LEFT(string,10)
parent 99effd31
......@@ -105,11 +105,6 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return 0; // Fatal error if flag is set!
if (arg_count)
{ // Print purify happy
CHARSET_INFO *charset= 0;
/*
Set return character set to first argument if we are returning a
string.
*/
for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++)
{
if ((*arg)->fix_fields(thd, tables, arg) ||
......@@ -117,20 +112,22 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return 1; /* purecov: inspected */
if ((*arg)->maybe_null)
maybe_null=1;
if ((*arg)->binary())
charset= &my_charset_bin;
else if (!charset && (*arg)->result_type() == STRING_RESULT)
charset= (*arg)->charset();
if ((*arg)->result_type() == STRING_RESULT)
{
/*
Set return character set to first argument if we are returning a
string.
*/
if (args == arg)
set_charset(args[0]->charset());
else if ((*arg)->binary() || (charset() != (*arg)->charset()) )
set_charset(&my_charset_bin);
}
with_sum_func= with_sum_func || (*arg)->with_sum_func;
used_tables_cache|=(*arg)->used_tables();
const_item_cache&= (*arg)->const_item();
}
/*
We must set charset here as fix_length_and_dec() may want to change
charset
*/
if (charset && result_type() == STRING_RESULT)
set_charset(charset);
}
fix_length_and_dec();
fixed= 1;
......
......@@ -39,12 +39,12 @@ class String
String()
{
Ptr=0; str_length=Alloced_length=0; alloced=0;
str_charset=default_charset_info;
str_charset= &my_charset_bin;
}
String(uint32 length_arg)
{
alloced=0; Alloced_length=0; (void) real_alloc(length_arg);
str_charset=default_charset_info;
str_charset= &my_charset_bin;
}
String(const char *str, CHARSET_INFO *cs)
{
......
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