Bug #22646 LC_TIME_NAMES: Assignment to non-UTF8 target fails
Submitted: 24 Sep 2006 19:46 Modified: 24 Jan 2007 20:25
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1, 5.0, 5.1.12-beta-debug OS:Linux (SUSE 10.0 / 64-bit)
Assigned to: Alexander Barkov CPU Architecture:Any

[24 Sep 2006 19:46] Peter Gulutzan
Description:
I tried to use French 'fr_FR' dates in an INSERT statement,
and the result was failure. The target was latin1. But the
result is utf8, as is evident using a hexadecimal display.

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

mysql> create table tj (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 tj values (date_format('2004-02-02','%M'));
Query OK, 1 row affected (0.00 sec)

mysql> select hex(s1) from tj;
+------------------+
| hex(s1)          |
+------------------+
| 66C3A97672696572 |
+------------------+
1 row in set (0.00 sec)
[24 Sep 2006 23:52] MySQL Verification Team
Thank you for the bug report. Verified as described.
[8 Nov 2006 11:36] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/15014

ChangeSet@1.2545, 2006-11-08 15:37:54+04:00, bar@mysql.com +3 -0
  Bug#22646 LC_TIME_NAMES: Assignment to non-UTF8 target fails
  Problem: After introducing of LC_TIME_NAMES variable,  the 
  function date_format() can return international non-ascii
  characters in month and weekday names. Thus, it cannot return
  a binary string anymore, because inserting a result of date_format()
  into a column with non-utf8 character set produces garbage.
  Fix: date_format() now returns a character string, using
  "collation_connection" to detect character set and collation
  for the returned value. This allows to insert
  results of date_format() properly into columns with
  various character sets.
[14 Nov 2006 10:10] Sergei Glukhov
ok to push
[18 Jan 2007 15:26] Lars Thalmann
Pushed into 4.1.23, 5.0.36, 5.1.15
[24 Jan 2007 20:25] Paul DuBois
Noted in 4.1.23, 5.0.36, 5.1.15 changelogs, and modified
DATE_FORMAT() function description accordingly.

Incompatible change: Previously, the DATE_FORMAT() function returned
a binary string. Now it returns a string with a character set and
collation given by character_set_connection and collation_connection
so that it can return month and weekday names containing non-ASCII
characters.