mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
New CHARSET() function
This commit is contained in:
parent
44347c5a54
commit
c5b8f48cf5
3 changed files with 27 additions and 0 deletions
|
@ -1911,12 +1911,25 @@ outp:
|
|||
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 @@ public:
|
|||
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 ')'
|
||||
|
|
Loading…
Reference in a new issue