summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.cc
diff options
context:
space:
mode:
authorSergey Glukhov <Sergey.Glukhov@sun.com>2008-12-23 18:08:04 +0400
committerSergey Glukhov <Sergey.Glukhov@sun.com>2008-12-23 18:08:04 +0400
commitc06df92af647e67731cb3a76bd91d57219407f01 (patch)
tree6e4d53e89ddfb94f9a4c162bc2a2cffb3cede106 /sql/item_timefunc.cc
parent7658444b9716497fcbad8de74478f52ba3f37ca9 (diff)
downloadmariadb-git-c06df92af647e67731cb3a76bd91d57219407f01.tar.gz
Bug#37575 UCASE fails on monthname
The MONTHNAME/DAYNAME functions returns binary string, so the LOWER/UPPER functions are not effective on the result of MONTHNAME/DAYNAME call. Character set of the MONTHNAME/DAYNAME function result has been changed to connection character set. include/m_ctype.h: added my_charset_repertoire function mysql-test/r/ctype_ucs.result: test result mysql-test/r/func_time.result: test result mysql-test/t/ctype_ucs.test: test case mysql-test/t/func_time.test: test case sql/item_timefunc.cc: Item_func_monthname::fix_length_and_dec and Item_func_dayname::fix_length_and_dec methods have been modified to use connection character set sql/item_timefunc.h: Item_func_monthname::fix_length_and_dec and Item_func_dayname::fix_length_and_dec methods have been modified to use connection character set sql/mysql_priv.h: added max_month_name_length, max_day_name_length fields into MY_LOCALE struct sql/mysqld.cc: The test_lc_time_sz function controls modifications of the locale database in debugging mode. sql/sql_locale.cc: initialization of max_month_name_length, max_day_name_length fields strings/ctype.c: added my_charset_repertoire function
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r--sql/item_timefunc.cc41
1 files changed, 34 insertions, 7 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index e9e92952908..38d9d62bd99 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -1036,12 +1036,25 @@ longlong Item_func_month::val_int()
}
+void Item_func_monthname::fix_length_and_dec()
+{
+ THD* thd= current_thd;
+ CHARSET_INFO *cs= thd->variables.collation_connection;
+ uint32 repertoire= my_charset_repertoire(cs);
+ locale= thd->variables.lc_time_names;
+ collation.set(cs, DERIVATION_COERCIBLE, repertoire);
+ decimals=0;
+ max_length= locale->max_month_name_length * collation.collation->mbmaxlen;
+ maybe_null=1;
+}
+
+
String* Item_func_monthname::val_str(String* str)
{
DBUG_ASSERT(fixed == 1);
const char *month_name;
- uint month= (uint) val_int();
- THD *thd= current_thd;
+ uint month= (uint) val_int();
+ uint err;
if (null_value || !month)
{
@@ -1049,8 +1062,9 @@ String* Item_func_monthname::val_str(String* str)
return (String*) 0;
}
null_value=0;
- month_name= thd->variables.lc_time_names->month_names->type_names[month-1];
- str->set(month_name, strlen(month_name), system_charset_info);
+ month_name= locale->month_names->type_names[month-1];
+ str->copy(month_name, strlen(month_name), &my_charset_utf8_bin,
+ collation.collation, &err);
return str;
}
@@ -1169,19 +1183,32 @@ longlong Item_func_weekday::val_int()
odbc_type) + test(odbc_type);
}
+void Item_func_dayname::fix_length_and_dec()
+{
+ THD* thd= current_thd;
+ CHARSET_INFO *cs= thd->variables.collation_connection;
+ uint32 repertoire= my_charset_repertoire(cs);
+ locale= thd->variables.lc_time_names;
+ collation.set(cs, DERIVATION_COERCIBLE, repertoire);
+ decimals=0;
+ max_length= locale->max_day_name_length * collation.collation->mbmaxlen;
+ maybe_null=1;
+}
+
String* Item_func_dayname::val_str(String* str)
{
DBUG_ASSERT(fixed == 1);
uint weekday=(uint) val_int(); // Always Item_func_daynr()
const char *day_name;
- THD *thd= current_thd;
+ uint err;
if (null_value)
return (String*) 0;
- day_name= thd->variables.lc_time_names->day_names->type_names[weekday];
- str->set(day_name, strlen(day_name), system_charset_info);
+ day_name= locale->day_names->type_names[weekday];
+ str->copy(day_name, strlen(day_name), &my_charset_utf8_bin,
+ collation.collation, &err);
return str;
}