Commit 8a7acf8a authored by bar@bar.mysql.r18.ru's avatar bar@bar.mysql.r18.ru

MONTHNAME() & DAYNAME() are now UCS2 compatible

parent 8fa71530
......@@ -153,14 +153,17 @@ longlong Item_func_month::val_int()
String* Item_func_monthname::val_str(String* str)
{
uint month=(uint) Item_func_month::val_int();
uint month=(uint) Item_func_month::val_int();
if (!month) // This is also true for NULL
{
null_value=1;
return (String*) 0;
}
null_value=0;
return &month_names[month-1];
String *m=&month_names[month-1];
str->copy(m->ptr(), m->length(), m->charset(), thd_charset());
return str;
}
// Returns the quarter of the year
......@@ -234,7 +237,10 @@ String* Item_func_dayname::val_str(String* str)
uint weekday=(uint) val_int(); // Always Item_func_daynr()
if (null_value)
return (String*) 0;
return &day_names[weekday];
String *d=&day_names[weekday];
str->copy(d->ptr(), d->length(), d->charset(), thd_charset());
return str;
}
......
......@@ -85,7 +85,12 @@ public:
const char *func_name() const { return "monthname"; }
String *val_str(String *str);
enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec() { decimals=0; max_length=10; maybe_null=1; }
void fix_length_and_dec()
{
decimals=0;
max_length=10*thd_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -192,7 +197,12 @@ class Item_func_dayname :public Item_func_weekday
const char *func_name() const { return "dayname"; }
String *val_str(String *str);
enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec() { decimals=0; max_length=9; maybe_null=1; }
void fix_length_and_dec()
{
decimals=0;
max_length=9*thd_charset()->mbmaxlen;
maybe_null=1;
}
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment