diff options
author | unknown <serg@serg.mylan> | 2005-01-24 15:48:25 +0100 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2005-01-24 15:48:25 +0100 |
commit | 8bdb500105f97e3007e652f73d99c373d38f2aad (patch) | |
tree | d0b61b703f3c601368669e4acab45d7567a4669b /sql/item_timefunc.cc | |
parent | 3671fe1f72e02393d2a42c4defead8b5633c4394 (diff) | |
download | mariadb-git-8bdb500105f97e3007e652f73d99c373d38f2aad.tar.gz |
fixes/cleanups according to Coverity report
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index f9c9d1f013d..39c88c8b0a3 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2112,20 +2112,25 @@ void Item_char_typecast::print(String *str) String *Item_char_typecast::val_str(String *str) { DBUG_ASSERT(fixed == 1); - String *res, *res1; + String *res; uint32 length; - if (!charset_conversion && !(res= args[0]->val_str(str))) +#if 0 + if (!charset_conversion) { - null_value= 1; - return 0; + if (!(res= args[0]->val_str(str))) + { + null_value= 1; + return 0; + } } else +#endif { // Convert character set if differ uint dummy_errors; - if (!(res1= args[0]->val_str(&tmp_value)) || - str->copy(res1->ptr(), res1->length(), res1->charset(), + if (!(res= args[0]->val_str(&tmp_value)) || + str->copy(res->ptr(), res->length(), res->charset(), cast_cs, &dummy_errors)) { null_value= 1; @@ -2135,13 +2140,13 @@ String *Item_char_typecast::val_str(String *str) } res->set_charset(cast_cs); - + /* Cut the tail if cast with length and the result is longer than cast length, e.g. CAST('string' AS CHAR(1)) */ - if (cast_length >= 0 && + if (cast_length >= 0 && (res->length() > (length= (uint32) res->charpos(cast_length)))) { // Safe even if const arg if (!res->alloced_length()) @@ -2150,7 +2155,7 @@ String *Item_char_typecast::val_str(String *str) res= &str_value; } res->length((uint) length); - } + } null_value= 0; return res; } |