mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
SELECT left(non_default_charset_field,n) GROUP BY 1
now works more correctly. Still needs fixes.
This commit is contained in:
parent
2753972c39
commit
2583ecd642
4 changed files with 17 additions and 1 deletions
|
@ -133,6 +133,9 @@ void Item_field::set_field(Field *field_par)
|
||||||
field_name=field_par->field_name;
|
field_name=field_par->field_name;
|
||||||
binary=field_par->binary();
|
binary=field_par->binary();
|
||||||
unsigned_flag=test(field_par->flags & UNSIGNED_FLAG);
|
unsigned_flag=test(field_par->flags & UNSIGNED_FLAG);
|
||||||
|
/* For string fields copy character set from original field */
|
||||||
|
if (!field_par->binary())
|
||||||
|
str_value.set_charset(((Field_str*)field_par)->charset());
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *Item_ident::full_name() const
|
const char *Item_ident::full_name() const
|
||||||
|
|
|
@ -78,6 +78,17 @@ Item_func::fix_fields(THD *thd,TABLE_LIST *tables)
|
||||||
maybe_null=1;
|
maybe_null=1;
|
||||||
if ((*arg)->binary)
|
if ((*arg)->binary)
|
||||||
binary=1;
|
binary=1;
|
||||||
|
/*
|
||||||
|
Change charset to arg charset if it is not equal to
|
||||||
|
default_charset_info. This will work for many cases,
|
||||||
|
but generally this should be done more carefull. Each string
|
||||||
|
function should have it's own fix_fields() method to correctly
|
||||||
|
setup it's result's character set taking in account arguments.
|
||||||
|
For example: left(a,b) should take in account only first argument,
|
||||||
|
but ignore the second one.
|
||||||
|
*/
|
||||||
|
if ((*arg)->str_value.charset() != default_charset_info)
|
||||||
|
str_value.set_charset((*arg)->str_value.charset());
|
||||||
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();
|
||||||
|
|
|
@ -759,6 +759,7 @@ String *Item_func_left::val_str(String *str)
|
||||||
if (!res->alloced_length())
|
if (!res->alloced_length())
|
||||||
{ // Don't change const str
|
{ // Don't change const str
|
||||||
str_value= *res; // Not malloced string
|
str_value= *res; // Not malloced string
|
||||||
|
str_value.set_charset(res->charset());
|
||||||
res= &str_value;
|
res= &str_value;
|
||||||
}
|
}
|
||||||
res->length((uint) length);
|
res->length((uint) length);
|
||||||
|
|
|
@ -3579,7 +3579,8 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
|
||||||
item->name,table,item->binary);
|
item->name,table,item->binary);
|
||||||
else
|
else
|
||||||
new_field= new Field_string(item->max_length,maybe_null,
|
new_field= new Field_string(item->max_length,maybe_null,
|
||||||
item->name,table,item->binary,default_charset_info);
|
item->name,table,item->binary,
|
||||||
|
item->str_value.charset());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (copy_func)
|
if (copy_func)
|
||||||
|
|
Loading…
Add table
Reference in a new issue