New CHARSET() function

parent 44347c5a
......@@ -1911,12 +1911,25 @@ String *Item_func_conv_charset3::val_str(String *str)
return str;
}
String *Item_func_charset::val_str(String *str)
{
String *res = args[0]->val_str(str);
if ((null_value=(args[0]->null_value || !res->charset())))
return 0;
str->copy(res->charset()->name,strlen(res->charset()->name));
return str;
}
void Item_func_conv_charset3::fix_length_and_dec()
{
/* BAR TODO: What to do here??? */
}
String *Item_func_hex::val_str(String *str)
{
if (args[0]->result_type() != STRING_RESULT)
......
......@@ -503,6 +503,18 @@ class Item_func_conv_charset3 :public Item_str_func
const char *func_name() const { return "conv_charset3"; }
};
class Item_func_charset :public Item_str_func
{
public:
Item_func_charset(Item *a) :Item_str_func(a) {}
String *val_str(String *);
const char *func_name() const { return "charset"; }
void fix_length_and_dec()
{
max_length=20; // should be enough
};
};
/*******************************************************
Spatial functions
......
......@@ -1784,6 +1784,8 @@ simple_expr:
{ $$= new Item_func_atan($3,$5); }
| CHAR_SYM '(' expr_list ')'
{ $$= new Item_func_char(*$3); }
| CHARSET '(' expr ')'
{ $$= new Item_func_charset($3); }
| COALESCE '(' expr_list ')'
{ $$= new Item_func_coalesce(* $3); }
| CONCAT '(' 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