summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.cc
diff options
context:
space:
mode:
authorlars@mysql.com/black.(none) <>2006-12-08 23:33:39 +0100
committerlars@mysql.com/black.(none) <>2006-12-08 23:33:39 +0100
commite2e3f0e5c39cdd3637d9edfd896d219b79df4f0a (patch)
treee603834affcc44ee4ccebccd7ce99351c3f56e77 /sql/item_timefunc.cc
parent94eb027f6bd0f3a069d1a7d9fd6060ed53cb6693 (diff)
parentc82cd4a46eea3e44f948bf48c9175ef6883d5f95 (diff)
downloadmariadb-git-e2e3f0e5c39cdd3637d9edfd896d219b79df4f0a.tar.gz
Merge mysql.com:/home/bkroot/mysql-5.0-rpl
into mysql.com:/home/bk/MERGE/mysql-5.0-merge
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r--sql/item_timefunc.cc84
1 files changed, 36 insertions, 48 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 8504434aed5..b5e69ea8fe2 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;
@@ -1710,6 +1700,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)
@@ -1717,22 +1708,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
@@ -1877,6 +1864,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,