Bug #29128 LC_TIME_NAMES=fr_FR, assignment to non-UTF8 target fails with MONTHNAME()
Submitted: 15 Jun 2007 5:28 Modified: 27 Feb 2009 5:30
Reporter: Alexander Barkov Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Charsets Severity:S3 (Non-critical)
Version:5.0, 5.1, 4.1 OS:Any
Assigned to: Assigned Account CPU Architecture:Any

[15 Jun 2007 5:28] Alexander Barkov
Description:
mysql> drop table if exists t1;
Query OK, 0 rows affected (0.00 sec)

mysql> set names utf8;
Query OK, 0 rows affected (0.00 sec)

mysql> create table t1(s1 char(20) character set latin1);
Query OK, 0 rows affected (0.00 sec)

mysql> set LC_TIME_NAMES = 'fr_FR';
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values (monthname('2004-02-02'));
Query OK, 1 row affected (0.00 sec)

mysql> select hex(s1) from t1;
+------------------+
| hex(s1)          |
+------------------+
| 66C3A97672696572 |
+------------------+
1 row in set (0.00 sec)

February in French is "février". The second letter is
"SMALL LETTER E WITH ACUTE ABOVE". It's latin1 code is 0xE9.

The result is wrong:
66 + C3A9 + 7672696572

The correct result should be:
66 +  E9  + 7672696572

Conversion from utf8 to latin1 didn't happen.

The same problem happends with DAYNAME():

mysql> set lc_time_names=sv_SE;
Query OK, 0 rows affected (0.00 sec)

mysql> select dayname('2004-02-01');
+-----------------------+
| dayname('2004-02-01') |
+-----------------------+
| söndag               |
+-----------------------+
1 row in set (0.00 sec)

mysql> insert into t1 values (dayname('2004-02-01'));
Query OK, 1 row affected (0.00 sec)

mysql> select hex(s1) from t1;
+----------------+
| hex(s1)        |
+----------------+
| 73C3B66E646167 |
+----------------+
1 row in set (0.00 sec)

The above result is wrong again.
The correct result should be:
73 + F6 + 6E646167
where 0xF6 is latin1 code for "SMALL LETTER O WITH DIAERESIS".

How to repeat:
Run the above tests.

Suggested fix:
Monthname() and Dayname() must be converted to the target character set.
[15 Jun 2007 6:53] Sveta Smirnova
Thank you for the report.

Verified as described.
[23 Nov 2007 6:31] Alexander Barkov
This bug should be fixed at the same time:

Bug #14368 UPPER and LOWER functions don't work with DAYNAME
[27 Feb 2009 5:30] Alexander Barkov
Duplicate for Bug#37575