Below is the list of changes that have just been committed into a local
5.1 repository of gshchepa. When gshchepa does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-02-28 02:11:18+04:00, gshchepa@stripped +7 -0
Fixed bug#28759: 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 system charset.
mysql-test/r/func_time.result@stripped, 2008-02-28 01:41:11+04:00, gshchepa@stripped +12 -0
Added test case for bug #28759.
mysql-test/t/func_time-master.opt@stripped, 2008-02-28 01:40:31+04:00, gshchepa@stripped +1
-0
Added the "test_lc_time_sz" debugging option for bug #28759.
mysql-test/t/func_time-master.opt@stripped, 2008-02-28 01:40:31+04:00, gshchepa@stripped +0
-0
mysql-test/t/func_time.test@stripped, 2008-02-28 01:41:12+04:00, gshchepa@stripped +9 -0
Added test case for bug #28759.
sql/item_timefunc.cc@stripped, 2008-02-28 01:41:13+04:00, gshchepa@stripped +4 -2
Fixed bug #28759.
Item_func_monthname::val_str and Item_func_dayname::val_str
methods have been modified to convert predefined month/day
names from UTF-8 to system charset.
sql/item_timefunc.h@stripped, 2008-02-28 01:41:14+04:00, gshchepa@stripped +4 -4
Fixed bug #28759.
Item_func_monthname::fix_length_and_dec and
Item_func_dayname::fix_length_and_dec methods have been
modified to use system charset for STRING_RESULT.
sql/mysql_priv.h@stripped, 2008-02-28 01:41:15+04:00, gshchepa@stripped +10 -0
Fixed bug #28759.
MAX_MONTH_NAME_LEN and MAX_DAY_NAME_LEN constants has
been defined (see the test_lc_time_sz function for
initial calculation).
sql/mysqld.cc@stripped, 2008-02-28 01:41:16+04:00, gshchepa@stripped +30 -0
Fixed bug #28759.
test_lc_time_sz function and "test_lc_time_sz" server
debugging option have been added.
The test_lc_time_sz function controls modifications
of the locale database in debugging mode.
The --debug=...,test_lc_time_sz server option enables
execution of the test_lc_time_sz function.
diff -Nrup a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
--- a/mysql-test/r/func_time.result 2008-02-25 17:03:27 +04:00
+++ b/mysql-test/r/func_time.result 2008-02-28 01:41:11 +04:00
@@ -1318,4 +1318,16 @@ date_sub("0069-01-01 00:00:01",INTERVAL
select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND)
0168-12-31 23:59:59
+SELECT CHARSET(DAYNAME(19700101));
+CHARSET(DAYNAME(19700101))
+utf8
+SELECT CHARSET(MONTHNAME(19700101));
+CHARSET(MONTHNAME(19700101))
+utf8
+SELECT LOWER(DAYNAME(19700101));
+LOWER(DAYNAME(19700101))
+thursday
+SELECT LOWER(MONTHNAME(19700101));
+LOWER(MONTHNAME(19700101))
+january
End of 5.1 tests
diff -Nrup a/mysql-test/t/func_time-master.opt b/mysql-test/t/func_time-master.opt
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysql-test/t/func_time-master.opt 2008-02-28 01:40:31 +04:00
@@ -0,0 +1 @@
+--loose-debug=d,test_lc_time_sz
diff -Nrup a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
--- a/mysql-test/t/func_time.test 2008-02-27 19:13:11 +04:00
+++ b/mysql-test/t/func_time.test 2008-02-28 01:41:12 +04:00
@@ -826,5 +826,14 @@ select date_sub("90-01-01 00:00:01",INTE
select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND);
select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND);
+#
+# Bug #28759: DAYNAME() and MONTHNAME() return binary string
+#
+
+SELECT CHARSET(DAYNAME(19700101));
+SELECT CHARSET(MONTHNAME(19700101));
+
+SELECT LOWER(DAYNAME(19700101));
+SELECT LOWER(MONTHNAME(19700101));
--echo End of 5.1 tests
diff -Nrup a/sql/item_timefunc.cc b/sql/item_timefunc.cc
--- a/sql/item_timefunc.cc 2008-01-10 15:18:28 +04:00
+++ b/sql/item_timefunc.cc 2008-02-28 01:41:13 +04:00
@@ -1041,7 +1041,8 @@ String* Item_func_monthname::val_str(Str
}
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);
+ str->length(0);
+ str->append(month_name, strlen(month_name), &my_charset_utf8_unicode_ci);
return str;
}
@@ -1172,7 +1173,8 @@ String* Item_func_dayname::val_str(Strin
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);
+ str->length(0);
+ str->append(day_name, strlen(day_name), &my_charset_utf8_unicode_ci);
return str;
}
diff -Nrup a/sql/item_timefunc.h b/sql/item_timefunc.h
--- a/sql/item_timefunc.h 2008-01-10 15:18:28 +04:00
+++ b/sql/item_timefunc.h 2008-02-28 01:41:14 +04:00
@@ -123,9 +123,9 @@ public:
enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec()
{
- collation.set(&my_charset_bin);
+ collation.set(system_charset_info);
decimals=0;
- max_length=10*my_charset_bin.mbmaxlen;
+ max_length= MAX_MONTH_NAME_LEN * collation.collation->mbmaxlen;
maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
@@ -298,9 +298,9 @@ class Item_func_dayname :public Item_fun
enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec()
{
- collation.set(&my_charset_bin);
+ collation.set(system_charset_info);
decimals=0;
- max_length=9*MY_CHARSET_BIN_MB_MAXLEN;
+ max_length= MAX_DAY_NAME_LEN * collation.collation->mbmaxlen;
maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
diff -Nrup a/sql/mysql_priv.h b/sql/mysql_priv.h
--- a/sql/mysql_priv.h 2007-12-14 17:01:09 +04:00
+++ b/sql/mysql_priv.h 2008-02-28 01:41:15 +04:00
@@ -120,6 +120,16 @@ enum Derivation
};
+/*
+ Maximal number of UTF-8 characters in month/day name
+ over the locale database (see the sql_locale.cc file).
+ Both values should be checked/updated after every
+ modification of that database. The test_lc_time_sz
+ function (see mysqld.cc) controls such modifications.
+*/
+#define MAX_MONTH_NAME_LEN 18
+#define MAX_DAY_NAME_LEN 14
+
typedef struct my_locale_st
{
uint number;
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc 2008-02-13 13:11:05 +04:00
+++ b/sql/mysqld.cc 2008-02-28 01:41:16 +04:00
@@ -3739,6 +3739,34 @@ void decrement_handler_count()
#endif /* defined(__NT__) || defined(HAVE_SMEM) */
+#ifndef DBUG_OFF
+/*
+ Debugging helper function to keep the locale database
+ (see sql_locale.cc) and the MAX_MONTH_NAME_LEN and
+ MAX_DAY_NAME_LEN variable values in consistent state.
+*/
+static void test_lc_time_sz()
+{
+ uint max_month_len= 0;
+ uint max_day_len = 0;
+ for (MY_LOCALE **loc= my_locales; *loc; loc++)
+ {
+ for (const char **month= (*loc)->month_names->type_names; *month; month++)
+ set_if_bigger(max_month_len,
+ my_numchars_mb(&my_charset_utf8_general_ci,
+ *month, *month + strlen(*month)));
+ for (const char **day= (*loc)->day_names->type_names; *day; day++)
+ set_if_bigger(max_day_len,
+ my_numchars_mb(&my_charset_utf8_general_ci,
+ *day, *day + strlen(*day)));
+ }
+ DBUG_ASSERT(max_month_len <= MAX_MONTH_NAME_LEN);
+ DBUG_ASSERT(max_day_len <= MAX_DAY_NAME_LEN);
+ return;
+}
+#endif//DBUG_OFF
+
+
#ifndef EMBEDDED_LIBRARY
#ifdef __WIN__
int win_main(int argc, char **argv)
@@ -3839,6 +3867,8 @@ int main(int argc, char **argv)
libwrapName= my_progname+dirname_length(my_progname);
openlog(libwrapName, LOG_PID, LOG_AUTH);
#endif
+
+ DBUG_EXECUTE_IF("test_lc_time_sz", test_lc_time_sz(););
/*
We have enough space for fiddling with the argv, continue