Bug #37050 IF doesn't work when dates are results
Submitted: 28 May 2008 21:17 Modified: 11 Jun 2008 6:47
Reporter: Jerry Potokar Email Updates:
Status: Won't fix Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.1.4 OS:Any
Assigned to: CPU Architecture:Any
Tags: myodbc utf-8 unicode

[28 May 2008 21:17] Jerry Potokar
Description:
Something is wrong using ASP with utf-8/unicode and mysql IF statement. If the results of IF is a date or datetime the output in ASP page is garbled.

How to repeat:
IF(1>2, dayname(now()), dayname(now())) as datum produces wierd text when using response.write(datum) in ASP page.
[6 Jun 2008 23:07] Jess Balint
Result set is binary:

mysql> select dayname(now());
Field   1:  `dayname(now())`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  binary (63)
Length:     9
Max_length: 6
Decimals:   0
Flags:      BINARY

+----------------+
| dayname(now()) |
+----------------+
| Friday         |
+----------------+
1 row in set (0.00 sec)
[7 Jun 2008 11:44] Jerry Potokar
My data uses utf-8 and collation Slovenian. It doesn't work from ASP page.
[7 Jun 2008 18:38] Jess Balint
Jerry, the problem is not your data, but the result of the dayname() function.
[11 Jun 2008 6:46] Tonci Grgin
Jerry, what Jess wants to say is that "binary" is used everywhere in MySQL and it's hard for connector to tell whether to treat "binary" as true binary data or should it be UTF8, for example, like in ad-hoc queries. This is a known problem, please search BugsDB. For now, you can either parse out starting "0x" (as your result is returned in form of "0xcorectresult" or use CAST AS CHAR.
[11 Jun 2008 6:47] Tonci Grgin
Closing as "Won't fix" as proper patch should be in server.