Commit f6f23ce8 authored by unknown's avatar unknown

MONTHNAME() & DAYNAME() are now UCS2 compatible

parent 79f8a525
...@@ -160,7 +160,10 @@ String* Item_func_monthname::val_str(String* str) ...@@ -160,7 +160,10 @@ String* Item_func_monthname::val_str(String* str)
return (String*) 0; return (String*) 0;
} }
null_value=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 // Returns the quarter of the year
...@@ -234,7 +237,10 @@ String* Item_func_dayname::val_str(String* str) ...@@ -234,7 +237,10 @@ String* Item_func_dayname::val_str(String* str)
uint weekday=(uint) val_int(); // Always Item_func_daynr() uint weekday=(uint) val_int(); // Always Item_func_daynr()
if (null_value) if (null_value)
return (String*) 0; 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: ...@@ -85,7 +85,12 @@ public:
const char *func_name() const { return "monthname"; } const char *func_name() const { return "monthname"; }
String *val_str(String *str); String *val_str(String *str);
enum Item_result result_type () const { return STRING_RESULT; } 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 ...@@ -192,7 +197,12 @@ class Item_func_dayname :public Item_func_weekday
const char *func_name() const { return "dayname"; } const char *func_name() const { return "dayname"; }
String *val_str(String *str); String *val_str(String *str);
enum Item_result result_type () const { return STRING_RESULT; } 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