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.h68
1 files changed, 50 insertions, 18 deletions
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index b01d75b8e02..d85210984d9 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -32,7 +32,7 @@ public:
Item_str_func(Item *a,Item *b,Item *c,Item *d, Item* e) :Item_func(a,b,c,d,e) {decimals=NOT_FIXED_DEC; }
Item_str_func(List<Item> &list) :Item_func(list) {decimals=NOT_FIXED_DEC; }
longlong val_int();
- double val();
+ double val_real();
enum Item_result result_type () const { return STRING_RESULT; }
void left_right_max_length();
};
@@ -134,13 +134,14 @@ public:
class Item_str_conv :public Item_str_func
{
+protected:
+ uint multiply;
+ uint (*converter)(CHARSET_INFO *cs, char *src, uint srclen,
+ char *dst, uint dstlen);
+ String tmp_value;
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;
- }
+ String *val_str(String *);
};
@@ -148,16 +149,28 @@ class Item_func_lcase :public Item_str_conv
{
public:
Item_func_lcase(Item *item) :Item_str_conv(item) {}
- String *val_str(String *);
const char *func_name() const { return "lcase"; }
+ void fix_length_and_dec()
+ {
+ collation.set(args[0]->collation);
+ multiply= collation.collation->casedn_multiply;
+ converter= collation.collation->cset->casedn;
+ max_length= args[0]->max_length * multiply;
+ }
};
class Item_func_ucase :public Item_str_conv
{
public:
Item_func_ucase(Item *item) :Item_str_conv(item) {}
- String *val_str(String *);
const char *func_name() const { return "ucase"; }
+ void fix_length_and_dec()
+ {
+ collation.set(args[0]->collation);
+ multiply= collation.collation->caseup_multiply;
+ converter= collation.collation->cset->caseup;
+ max_length= args[0]->max_length * multiply;
+ }
};
@@ -202,7 +215,7 @@ public:
Item_func_substr_index(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {}
String *val_str(String *);
void fix_length_and_dec();
- const char *func_name() const { return "substr_index"; }
+ const char *func_name() const { return "substring_index"; }
};
@@ -245,7 +258,7 @@ public:
Returns strcat('*', octet2hex(sha1(sha1(password)))). '*' stands for new
password format, sha1(sha1(password) is so-called hash_stage2 value.
Length of returned string is always 41 byte. To find out how entire
- authentification procedure works, see comments in password.c.
+ authentication procedure works, see comments in password.c.
*/
class Item_func_password :public Item_str_func
@@ -310,7 +323,7 @@ public:
Item_func_encrypt(Item *a, Item *b): Item_str_func(a,b) {}
String *val_str(String *);
void fix_length_and_dec() { maybe_null=1; max_length = 13; }
- const char *func_name() const { return "ecrypt"; }
+ const char *func_name() const { return "encrypt"; }
};
#include "sql_crypt.h"
@@ -387,7 +400,7 @@ class Item_func_elt :public Item_str_func
{
public:
Item_func_elt(List<Item> &list) :Item_str_func(list) {}
- double val();
+ double val_real();
longlong val_int();
String *val_str(String *str);
void fix_length_and_dec();
@@ -403,13 +416,12 @@ class Item_func_make_set :public Item_str_func
public:
Item_func_make_set(Item *a,List<Item> &list) :Item_str_func(list),item(a) {}
String *val_str(String *str);
- bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
+ bool fix_fields(THD *thd, Item **ref)
{
DBUG_ASSERT(fixed == 0);
- return (!item->fixed &&
- item->fix_fields(thd, tlist, &item) ||
+ return ((!item->fixed && item->fix_fields(thd, &item)) ||
item->check_cols(1) ||
- Item_func::fix_fields(thd, tlist, ref));
+ Item_func::fix_fields(thd, ref));
}
void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
void fix_length_and_dec();
@@ -421,6 +433,14 @@ public:
return item->walk(processor, arg) ||
Item_str_func::walk(processor, arg);
}
+ Item *transform(Item_transformer transformer, byte *arg)
+ {
+ Item *new_item= item->transform(transformer, arg);
+ if (!new_item)
+ return 0;
+ item= new_item;
+ return Item_str_func::transform(transformer, arg);
+ }
void print(String *str);
};
@@ -554,6 +574,7 @@ public:
max_length=args[0]->max_length;
}
void print(String *str);
+ const char *func_name() const { return "cast_as_binary"; }
};
@@ -629,7 +650,13 @@ public:
void fix_length_and_dec();
bool eq(const Item *item, bool binary_cmp) const;
const char *func_name() const { return "collate"; }
- void print(String *str) { print_op(str); }
+ enum Functype func_type() const { return COLLATE_FUNC; }
+ void print(String *str);
+ Item_field *filed_for_view_update()
+ {
+ /* this function is transparent for view updating */
+ return args[0]->filed_for_view_update();
+ }
};
class Item_func_charset :public Item_str_func
@@ -715,7 +742,12 @@ public:
Item_func_uuid(): Item_str_func() {}
void fix_length_and_dec() {
collation.set(system_charset_info);
- max_length= UUID_LENGTH;
+ /*
+ NOTE! uuid() should be changed to use 'ascii'
+ charset when hex(), format(), md5(), etc, and implicit
+ number-to-string conversion will use 'ascii'
+ */
+ max_length= UUID_LENGTH * system_charset_info->mbmaxlen;
}
const char *func_name() const{ return "uuid"; }
String *val_str(String *);