diff options
author | unknown <bar@mysql.com/bar.intranet.mysql.r18.ru> | 2006-11-20 15:06:33 +0400 |
---|---|---|
committer | unknown <bar@mysql.com/bar.intranet.mysql.r18.ru> | 2006-11-20 15:06:33 +0400 |
commit | 9dba7743507ccb299b185b8c74b8de87f743c9b0 (patch) | |
tree | 3014fcb89b0c22724579c8d505792c534f720fd4 /sql | |
parent | 3b55f3e36d5fe3cc8097f055abcb59cc1df95db1 (diff) | |
parent | 42b4264d4be085df4340c5336bb3a6a62ed137f1 (diff) | |
download | mariadb-git-9dba7743507ccb299b185b8c74b8de87f743c9b0.tar.gz |
Merge mysql.com:/usr/home/bar/mysql-4.1.b22646
into mysql.com:/usr/home/bar/mysql-5.0.b22646
mysql-test/t/ctype_utf8.test:
Auto merged
mysql-test/r/ctype_utf8.result:
After merge fix
sql/item_timefunc.cc:
After merge fix
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_timefunc.cc | 84 |
1 files changed, 36 insertions, 48 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index a776d8a5ff7..57f29ecaf2a 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -609,16 +609,10 @@ bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time, uint weekday; ulong length; const char *ptr, *end; - MY_LOCALE *locale; THD *thd= current_thd; - char buf[STRING_BUFFER_USUAL_SIZE]; - String tmp(buf, sizeof(buf), thd->variables.character_set_results); - uint errors= 0; + MY_LOCALE *locale= thd->variables.lc_time_names; - tmp.length(0); str->length(0); - str->set_charset(&my_charset_bin); - locale = thd->variables.lc_time_names; if (l_time->neg) str->append('-'); @@ -632,41 +626,37 @@ bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time, { switch (*++ptr) { case 'M': - if (!l_time->month) - return 1; - tmp.copy(locale->month_names->type_names[l_time->month-1], - strlen(locale->month_names->type_names[l_time->month-1]), - system_charset_info, tmp.charset(), &errors); - str->append(tmp.ptr(), tmp.length()); - break; + if (!l_time->month) + return 1; + str->append(locale->month_names->type_names[l_time->month-1], + strlen(locale->month_names->type_names[l_time->month-1]), + system_charset_info); + break; case 'b': - if (!l_time->month) - return 1; - tmp.copy(locale->ab_month_names->type_names[l_time->month-1], - strlen(locale->ab_month_names->type_names[l_time->month-1]), - system_charset_info, tmp.charset(), &errors); - str->append(tmp.ptr(), tmp.length()); - break; + if (!l_time->month) + return 1; + str->append(locale->ab_month_names->type_names[l_time->month-1], + strlen(locale->ab_month_names->type_names[l_time->month-1]), + system_charset_info); + break; case 'W': - if (type == MYSQL_TIMESTAMP_TIME) - return 1; - weekday= calc_weekday(calc_daynr(l_time->year,l_time->month, - l_time->day),0); - tmp.copy(locale->day_names->type_names[weekday], - strlen(locale->day_names->type_names[weekday]), - system_charset_info, tmp.charset(), &errors); - str->append(tmp.ptr(), tmp.length()); - break; + if (type == MYSQL_TIMESTAMP_TIME) + return 1; + weekday= calc_weekday(calc_daynr(l_time->year,l_time->month, + l_time->day),0); + str->append(locale->day_names->type_names[weekday], + strlen(locale->day_names->type_names[weekday]), + system_charset_info); + break; case 'a': - if (type == MYSQL_TIMESTAMP_TIME) - return 1; - weekday=calc_weekday(calc_daynr(l_time->year,l_time->month, - l_time->day),0); - tmp.copy(locale->ab_day_names->type_names[weekday], - strlen(locale->ab_day_names->type_names[weekday]), - system_charset_info, tmp.charset(), &errors); - str->append(tmp.ptr(), tmp.length()); - break; + if (type == MYSQL_TIMESTAMP_TIME) + return 1; + weekday=calc_weekday(calc_daynr(l_time->year,l_time->month, + l_time->day),0); + str->append(locale->ab_day_names->type_names[weekday], + strlen(locale->ab_day_names->type_names[weekday]), + system_charset_info); + break; case 'D': if (type == MYSQL_TIMESTAMP_TIME) return 1; @@ -1721,6 +1711,7 @@ longlong Item_func_sec_to_time::val_int() void Item_func_date_format::fix_length_and_dec() { + THD* thd= current_thd; /* Must use this_item() in case it's a local SP variable (for ->max_length and ->str_value) @@ -1728,22 +1719,18 @@ void Item_func_date_format::fix_length_and_dec() Item *arg1= args[1]->this_item(); decimals=0; - collation.set(&my_charset_bin); + collation.set(thd->variables.collation_connection); if (arg1->type() == STRING_ITEM) { // Optimize the normal case fixed_length=1; - - /* - The result is a binary string (no reason to use collation->mbmaxlen - This is becasue make_date_time() only returns binary strings - */ - max_length= format_length(&arg1->str_value); + max_length= format_length(&arg1->str_value) * + collation.collation->mbmaxlen; } else { fixed_length=0; - /* The result is a binary string (no reason to use collation->mbmaxlen */ - max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10; + max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 * + collation.collation->mbmaxlen; set_if_smaller(max_length,MAX_BLOB_WIDTH); } maybe_null=1; // If wrong date @@ -1888,6 +1875,7 @@ String *Item_func_date_format::val_str(String *str) date_time_format.format.length= format->length(); /* Create the result string */ + str->set_charset(collation.collation); if (!make_date_time(&date_time_format, &l_time, is_time_format ? MYSQL_TIMESTAMP_TIME : MYSQL_TIMESTAMP_DATE, |