diff options
author | bar@mysql.com <> | 2005-11-29 09:25:51 +0400 |
---|---|---|
committer | bar@mysql.com <> | 2005-11-29 09:25:51 +0400 |
commit | 0f73558ee3d8ca74af60b0a4d1de788ac84721ea (patch) | |
tree | d5e23cec857cc492d18719f3749afb49aaa4d64a /sql/item_strfunc.h | |
parent | 1a391f71f5be721b66411abef025bbf24f2821d8 (diff) | |
parent | 5c1ba75cfdc69ff473039839457d8c83060633ed (diff) | |
download | mariadb-git-0f73558ee3d8ca74af60b0a4d1de788ac84721ea.tar.gz |
Merge mysql.com:/usr/home/bar/mysql-4.1.b10446
into mysql.com:/usr/home/bar/mysql-5.0
Diffstat (limited to 'sql/item_strfunc.h')
-rw-r--r-- | sql/item_strfunc.h | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 522b17bf80e..50ec0b36ce8 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -652,10 +652,40 @@ public: class Item_func_conv_charset :public Item_str_func { + bool use_cached_value; public: + bool safe; CHARSET_INFO *conv_charset; // keep it public - Item_func_conv_charset(Item *a, CHARSET_INFO *cs) :Item_str_func(a) - { conv_charset=cs; } + Item_func_conv_charset(Item *a, CHARSET_INFO *cs) :Item_str_func(a) + { conv_charset= cs; use_cached_value= 0; safe= 0; } + Item_func_conv_charset(Item *a, CHARSET_INFO *cs, bool cache_if_const) + :Item_str_func(a) + { + DBUG_ASSERT(args[0]->fixed); + conv_charset= cs; + if (cache_if_const && args[0]->const_item()) + { + uint errors= 0; + String tmp, *str= args[0]->val_str(&tmp); + if (!str || str_value.copy(str->ptr(), str->length(), + str->charset(), conv_charset, &errors)) + null_value= 1; + use_cached_value= 1; + safe= (errors == 0); + } + else + { + use_cached_value= 0; + /* + Conversion from and to "binary" is safe. + Conversion to Unicode is safe. + Other kind of conversions are potentially lossy. + */ + safe= (args[0]->collation.collation == &my_charset_bin || + cs == &my_charset_bin || + (cs->state & MY_CS_UNICODE)); + } + } String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "convert"; } |