summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authorAlexander Barkov <alexander.barkov@oracle.com>2011-02-10 11:18:08 +0300
committerAlexander Barkov <alexander.barkov@oracle.com>2011-02-10 11:18:08 +0300
commitcb6b340b0f51c48e0d7f294f85933d540387bb2b (patch)
treea73b08968075c435d6f6de1754f250ceeff37274 /sql/item_strfunc.cc
parenta90d37e734e89fca2bcfe96cfc93b1c0a72df6ba (diff)
downloadmariadb-git-cb6b340b0f51c48e0d7f294f85933d540387bb2b.tar.gz
Bug#31384 DATE_ADD() and DATE_SUB() return binary data
Problem: DATE_ADD() is a hybrid function and can return DATE, DATETIME or VARCHAR data type depending on arguments. In case of VARCHAR data type, DATE_ADD() reported "binary" character set, which was wrong. Fix: make DATE_ADD() return @character_set_connection in VARCHAR context. @ mysql-test/include/ctype_numconv.inc Adding tests @ mysql-test/r/ctype_binary.result Adding tests @ mysql-test/r/ctype_cp1251.result Adding tests @ mysql-test/r/ctype_latin1.result Adding tests @ mysql-test/r/ctype_ucs.result Adding tests @ mysql-test/r/ctype_utf8.result Adding tests @ sql/item_strfunc.cc - Moving code from Item_str_ascii_func::val_str() to Item_str_func::val_str_from_val_str_ascii(), as this code needs to be shared by Item_date_add_interval. - Adding str2 parameter to be used as a buffer, instead of using private ascii_buf member. @ sql/item_strfunc.h - Moving code from Item_str_ascii_func::val_str() to Item_str_func::val_str_from_val_str_ascii() - Removing "String *val_str_convert_from_ascii(String *str, String *ascii_buf)" prototype as it was neither used nor declared. @ sql/item_timefunc.h - Overwriting parent's charset_for_protocol() method, becase we need to behave differenlty in VARCHAR and DATE/DATETYPE context. - Adding ascii_buf for conversion. - Adding val_str_ascii() prototype. - Adding val_str() which uses newly added Item_str_func::val_str_from_val_str_ascii(), passing ascii_buf as a conversion buffer.
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 25eb08ffa75..0248c133f60 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -70,7 +70,7 @@ String my_empty_string("",default_charset_info);
Normally conversion does not happen, and val_str_ascii() is immediately
returned instead.
*/
-String *Item_str_ascii_func::val_str(String *str)
+String *Item_str_func::val_str_from_val_str_ascii(String *str, String *str2)
{
DBUG_ASSERT(fixed == 1);
@@ -82,19 +82,19 @@ String *Item_str_ascii_func::val_str(String *str)
return res;
}
- DBUG_ASSERT(str != &ascii_buf);
+ DBUG_ASSERT(str != str2);
uint errors;
- String *res= val_str_ascii(&ascii_buf);
+ String *res= val_str_ascii(str);
if (!res)
return 0;
- if ((null_value= str->copy(res->ptr(), res->length(),
- &my_charset_latin1, collation.collation,
- &errors)))
+ if ((null_value= str2->copy(res->ptr(), res->length(),
+ &my_charset_latin1, collation.collation,
+ &errors)))
return 0;
- return str;
+ return str2;
}