summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_strfunc.h')
-rw-r--r--sql/item_strfunc.h63
1 files changed, 47 insertions, 16 deletions
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 4832ddbd1b1..22134733393 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -100,6 +100,7 @@ public:
void update_used_tables();
bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
{
+ DBUG_ASSERT(fixed == 0);
return (separator->fix_fields(thd, tlist, &separator) ||
separator->check_cols(1) ||
Item_func::fix_fields(thd, tlist, ref));
@@ -153,7 +154,7 @@ class Item_str_conv :public Item_str_func
public:
Item_str_conv(Item *item) :Item_str_func(item) {}
void fix_length_and_dec()
- {
+ {
collation.set(args[0]->collation);
max_length = args[0]->max_length;
}
@@ -411,6 +412,7 @@ public:
String *val_str(String *str);
bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
{
+ DBUG_ASSERT(fixed == 0);
return (item->fix_fields(thd, tlist, &item) ||
item->check_cols(1) ||
Item_func::fix_fields(thd, tlist, ref));
@@ -500,10 +502,10 @@ public:
Item_func_conv(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {}
const char *func_name() const { return "conv"; }
String *val_str(String *);
- void fix_length_and_dec()
- {
+ void fix_length_and_dec()
+ {
collation.set(default_charset());
- decimals=0; max_length=64;
+ decimals=0; max_length=64;
}
};
@@ -515,14 +517,29 @@ public:
Item_func_hex(Item *a) :Item_str_func(a) {}
const char *func_name() const { return "hex"; }
String *val_str(String *);
- void fix_length_and_dec()
- {
+ void fix_length_and_dec()
+ {
collation.set(default_charset());
decimals=0;
max_length=args[0]->max_length*2*collation.collation->mbmaxlen;
}
};
+class Item_func_unhex :public Item_str_func
+{
+ String tmp_value;
+public:
+ Item_func_unhex(Item *a) :Item_str_func(a) {}
+ const char *func_name() const { return "unhex"; }
+ String *val_str(String *);
+ void fix_length_and_dec()
+ {
+ collation.set(&my_charset_bin);
+ decimals=0;
+ max_length=(1+args[0]->max_length)/2;
+ }
+};
+
class Item_func_binary :public Item_str_func
{
@@ -530,16 +547,17 @@ public:
Item_func_binary(Item *a) :Item_str_func(a) {}
String *val_str(String *a)
{
+ DBUG_ASSERT(fixed == 1);
String *tmp=args[0]->val_str(a);
null_value=args[0]->null_value;
if (tmp)
tmp->set_charset(&my_charset_bin);
return tmp;
}
- void fix_length_and_dec()
- {
- collation.set(&my_charset_bin);
- max_length=args[0]->max_length;
+ void fix_length_and_dec()
+ {
+ collation.set(&my_charset_bin);
+ max_length=args[0]->max_length;
}
void print(String *str);
};
@@ -553,7 +571,7 @@ public:
String *val_str(String *);
const char *func_name() const { return "load_file"; }
void fix_length_and_dec()
- {
+ {
collation.set(&my_charset_bin, DERIVATION_COERCIBLE);
maybe_null=1;
max_length=MAX_BLOB_WIDTH;
@@ -589,10 +607,10 @@ public:
Item_func_quote(Item *a) :Item_str_func(a) {}
const char *func_name() const { return "quote"; }
String *val_str(String *);
- void fix_length_and_dec()
- {
+ void fix_length_and_dec()
+ {
collation.set(args[0]->collation);
- max_length= args[0]->max_length * 2 + 2;
+ max_length= args[0]->max_length * 2 + 2;
}
};
@@ -600,7 +618,7 @@ class Item_func_conv_charset :public Item_str_func
{
CHARSET_INFO *conv_charset;
public:
- Item_func_conv_charset(Item *a, CHARSET_INFO *cs) :Item_str_func(a)
+ Item_func_conv_charset(Item *a, CHARSET_INFO *cs) :Item_str_func(a)
{ conv_charset=cs; }
String *val_str(String *);
void fix_length_and_dec();
@@ -625,7 +643,7 @@ 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()
+ void fix_length_and_dec()
{
collation.set(system_charset_info);
max_length= 64 * collation.collation->mbmaxlen; // should be enough
@@ -691,3 +709,16 @@ public:
String *val_str(String *) ZLIB_DEPENDED_FUNCTION
};
+#define UUID_LENGTH (8+1+4+1+4+1+4+1+12)
+class Item_func_uuid: public Item_str_func
+{
+public:
+ Item_func_uuid(): Item_str_func() {}
+ void fix_length_and_dec() {
+ collation.set(system_charset_info);
+ max_length= UUID_LENGTH;
+ }
+ const char *func_name() const{ return "uuid"; }
+ String *val_str(String *);
+};
+