Commit d134e6f2 authored by bar@bar.mysql.r18.ru's avatar bar@bar.mysql.r18.ru

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
parent c813cc69
...@@ -105,11 +105,6 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -105,11 +105,6 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return 0; // Fatal error if flag is set! return 0; // Fatal error if flag is set!
if (arg_count) if (arg_count)
{ // Print purify happy { // 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++) for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++)
{ {
if ((*arg)->fix_fields(thd, tables, arg) || if ((*arg)->fix_fields(thd, tables, arg) ||
...@@ -117,20 +112,22 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -117,20 +112,22 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return 1; /* purecov: inspected */ return 1; /* purecov: inspected */
if ((*arg)->maybe_null) if ((*arg)->maybe_null)
maybe_null=1; maybe_null=1;
if ((*arg)->binary())
charset= &my_charset_bin; if ((*arg)->result_type() == STRING_RESULT)
else if (!charset && (*arg)->result_type() == STRING_RESULT) {
charset= (*arg)->charset(); /*
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; with_sum_func= with_sum_func || (*arg)->with_sum_func;
used_tables_cache|=(*arg)->used_tables(); used_tables_cache|=(*arg)->used_tables();
const_item_cache&= (*arg)->const_item(); 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(); fix_length_and_dec();
fixed= 1; fixed= 1;
......
...@@ -39,12 +39,12 @@ public: ...@@ -39,12 +39,12 @@ public:
String() String()
{ {
Ptr=0; str_length=Alloced_length=0; alloced=0; Ptr=0; str_length=Alloced_length=0; alloced=0;
str_charset=default_charset_info; str_charset= &my_charset_bin;
} }
String(uint32 length_arg) String(uint32 length_arg)
{ {
alloced=0; Alloced_length=0; (void) real_alloc(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) 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