summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorbar@mysql.com <>2005-10-21 14:41:56 +0500
committerbar@mysql.com <>2005-10-21 14:41:56 +0500
commita167ddc6e7886e2b681511bde2c82ec5c2379290 (patch)
tree283d5930afab08637d4b0260622f6e7b3cea7db6 /sql
parentc8ca75264ca432d6798e10e1fb731e6a356915b7 (diff)
downloadmariadb-git-a167ddc6e7886e2b681511bde2c82ec5c2379290.tar.gz
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.
Diffstat (limited to 'sql')
-rw-r--r--sql/item_strfunc.h9
-rw-r--r--sql/sql_yacc.yy2
2 files changed, 8 insertions, 3 deletions
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index b01d75b8e02..5525c046b95 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -444,12 +444,15 @@ public:
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"; }
};
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 82f9c5a288f..c99abc7d349 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -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 ')'