Bug #62068 Charset Fails When A Datetime Field Exists In The Where Clause
Submitted: 3 Aug 2011 9:12 Modified: 3 Sep 2011 10:45
Reporter: Abdullah Battal Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Charsets Severity:S2 (Serious)
Version:5.1.33-community OS:Windows (7)
Assigned to: CPU Architecture:Any
Tags: Charset Datetime Where-Clause

[3 Aug 2011 9:12] Abdullah Battal
Description:
On a latin5 encoded table, below query outputs question marks instead of correct Turkish characters:

SELECT YA.PROGRAMNAME
FROM    TABLE_Y YA
WHERE   YA.PROGRAMID=9845 
AND YA.ENDDATE>NOW()    -- outputs: Zaman?n Tan???

However; when the line containing the datetime comparison in the where clause is omitted, the query yields the correct output in expense of controlling the ENDDATE:

SELECT YA.PROGRAMNAME
FROM    TABLE_Y YA
WHERE   YA.PROGRAMID=9845    -- outputs: Zamanın Tanığı

The datetime field somehow messes the charset, when included in the WHERE clause. I've tried "SET NAMES latin5" but didn't work.

How to repeat:
Create a test table with four columns using default charset as latin5,
and add two lines like below:

PROGRAMNAME - PROGRAMID - ENDDATE - DESCRIPTION
-----------------------------------------------
'Zamanın Tanığı' - 9845 - '2011-08-01 00:00:00' - 'Description of past program'
'Zamanın Tanığı' - 9845 - '2011-08-31 00:00:00' - 'Description of future program'

Then run the queries given in the bug description.
[3 Aug 2011 9:45] Valeriy Kravchuk
Please, check if the same problem still happens with a newer version, 5.1.58.
[3 Aug 2011 10:44] Peter Laursen
Not reproducible for me with 5.1.58.

SET NAMES UTF8;
USE test;

CREATE TABLE `test`.`table_y`( 
   `programname` VARCHAR(20) , 
   `programid` INT , 
   `enddate` DATETIME , 
   `description` VARCHAR(100) 
 )  ENGINE='Default' CHARSET=latin5;
 
INSERT INTO table_y VALUES ('Zamanın Tanığı', 9845, '2011-08-01 00:00:00','Description of past program');
INSERT INTO table_y VALUES ('Zamanın Tanığı', 9845, '2011-08-31 00:00:00', 'Description of future program');
 
SELECT YA.PROGRAMNAME
FROM    TABLE_Y YA
WHERE   YA.PROGRAMID=9845 
AND YA.ENDDATE>NOW();    
-- outputs: Zamanın Tanığı

(using SQLyog as client, SET NAMES UFT8 is always done by SQLyog as it is the only client character set it supports).

Peter
(not a MySQL person)
[3 Sep 2011 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".