Bug #4578 MyODBC returning bad data for FROM_UNIXTIME() within a UNION
Submitted: 16 Jul 2004 19:11 Modified: 27 Jul 2004 19:13
Reporter: Dean Ellis Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51.07 OS:Windows (Windows)
Assigned to: Dean Ellis CPU Architecture:Any

[16 Jul 2004 19:11] Dean Ellis
Description:
FROM_UNIXTIME() used within a UNION is coming back (in ADO at least) as raw binary data.  Initially reported as returning NULL.  Cannot repeat with Connector/J or mysql so presumably the problem is MyODBC.

How to repeat:
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( a int );
INSERT INTO t1 VALUES (1089993944),(1089993945),(1089993946),(1089993947);
SELECT FROM_UNIXTIME(a) AS col1 FROM t1 UNION SELECT FROM_UNIXTIME(a) FROM t1;
SELECT CAST(FROM_UNIXTIME(a) AS CHAR) AS col1 FROM t1 UNION SELECT FROM_UNIXTIME(a) FROM t1;
DROP TABLE t1;

Query via ODBC.  First select has the problem; second select is a workaround.

Suggested fix:
n/a
[22 Jul 2004 20:44] Peter Harvey
C test

Attachment: test.c (application/octet-stream, text), 6.90 KiB.

[22 Jul 2004 20:45] Peter Harvey
Seems a C test works fine - see attached file. Will now investigate what funny business ADO may be doing.
[23 Jul 2004 1:59] Peter Harvey
Seems older driver works but current driver fails. This is because a check was added to see if the binary bit was set on the field flag. Presumably this would be reliable way to determine if the field is binary. So if a column is "VARCHAR(n) BINARY" we can call it binary and not a string/char. But in practice the binary bit in the field flag is not reliable - it seems to fail when field is a result of aggregate/function or such. I have removed this check such that a string field is a char or varchar type.

Changes pushed to bk.
[27 Jul 2004 19:13] Dean Ellis
Fixed in 3.51.09.