Commit cfc78dae authored by unknown's avatar unknown

Bug#13233

  select distinct char(column) fails with utf8
ctype_utf8.result, ctype_utf8.test:
  Adding test case
sql_yacc.yy:
  Adding new syntax.
item_strfunc.h:
  Fixing wrong max_length calculation.
  Also, adding CHAR(x USING charset),
  for easier migrating from 4.1 to 5.0,
  according to Monty's suggestion.


sql/item_strfunc.h:
  Bug#13233
  select distinct char(column) fails with utf8
  Also, adding CHAR(x USING charset),
  for easier migrating from 4.1 to 5.0.
sql/sql_yacc.yy:
  Adding new syntax.
mysql-test/t/ctype_utf8.test:
  Adding test case
mysql-test/r/ctype_utf8.result:
  Adding test case
parent 35100d95
......@@ -1061,3 +1061,12 @@ create table t1 (a varchar(255)) default charset=utf8;
select * from t1 where find_in_set('-1', a);
a
drop table t1;
create table t1 (a int);
insert into t1 values (48),(49),(50);
set names utf8;
select distinct char(a) from t1;
char(a)
0
1
2
drop table t1;
......@@ -873,4 +873,13 @@ create table t1 (a varchar(255)) default charset=utf8;
select * from t1 where find_in_set('-1', a);
drop table t1;
#
# Bug#13233: select distinct char(column) fails with utf8
#
create table t1 (a int);
insert into t1 values (48),(49),(50);
set names utf8;
select distinct char(a) from t1;
drop table t1;
# End of 4.1 tests
......@@ -444,12 +444,15 @@ class Item_func_format :public Item_str_func
class Item_func_char :public Item_str_func
{
public:
Item_func_char(List<Item> &list) :Item_str_func(list) {}
Item_func_char(List<Item> &list) :Item_str_func(list)
{ collation.set(default_charset()); }
Item_func_char(List<Item> &list, CHARSET_INFO *cs) :Item_str_func(list)
{ collation.set(cs); }
String *val_str(String *);
void fix_length_and_dec()
{
collation.set(default_charset());
maybe_null=0; max_length=arg_count;
maybe_null=0;
max_length=arg_count * collation.collation->mbmaxlen;
}
const char *func_name() const { return "char"; }
};
......
......@@ -2924,6 +2924,8 @@ simple_expr:
{ $$= new Item_func_atan($3,$5); }
| CHAR_SYM '(' expr_list ')'
{ $$= new Item_func_char(*$3); }
| CHAR_SYM '(' expr_list USING charset_name ')'
{ $$= new Item_func_char(*$3, $5); }
| CHARSET '(' expr ')'
{ $$= new Item_func_charset($3); }
| COALESCE '(' expr_list ')'
......
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