diff options
author | unknown <bar@mysql.com> | 2005-11-29 09:25:51 +0400 |
---|---|---|
committer | unknown <bar@mysql.com> | 2005-11-29 09:25:51 +0400 |
commit | 5b6a28d12d0fd7e198f0fd77ffe69ce4aff9a9be (patch) | |
tree | d5e23cec857cc492d18719f3749afb49aaa4d64a /sql/item_strfunc.h | |
parent | 00274bc52052d383a2b507ca4683a19839652bd4 (diff) | |
parent | 0fa8fc66df7c6450dcf6d7dd2b18146ebae7b44d (diff) | |
download | mariadb-git-5b6a28d12d0fd7e198f0fd77ffe69ce4aff9a9be.tar.gz |
Merge mysql.com:/usr/home/bar/mysql-4.1.b10446
into mysql.com:/usr/home/bar/mysql-5.0
mysql-test/r/ctype_recoding.result:
Auto merged
sql/item.cc:
Auto merged
sql/item_strfunc.cc:
Auto merged
sql/item_strfunc.h:
Auto merged
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"; } |