Bug #23264 MyODBC driver returns 'x' instead of empty string when IF applies on TEXT field
Submitted: 13 Oct 2006 17:35 Modified: 25 Jan 15:57
Reporter: Bogdan Degtyariov
Status: Open
Category:Connector/ODBC Severity:S2 (Serious)
Version:3.51 OS:Any
Assigned to: Bogdan Degtyariov Target Version:
Tags: IIS

[13 Oct 2006 17:35] Bogdan Degtyariov
Description:
mysql> CREATE TEMPORARY TABLE test_if_text_x_bug(mytext TEXT NULL, myvarchar VARCHAR(255)
NULL)

Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO test_if_text_x_bug(mytext,myvarchar) VALUES('abc', 'def')

mysql> SELECT IF (0, mytext, '') AS expr1, IF (0, mytext, 'abc') AS expr2, IF (0,
myvarchar, '') AS expr3 FROM test_if_text_x_bug
-> ;
+-------+-------+-------+
| expr1 | expr2 | expr3 |
+-------+-------+-------+
|       | abc   |       |
+-------+-------+-------+

whereas MyODBC returns 'x' for expr1

How to repeat:
Run the .asp script from the file below
[13 Oct 2006 17:36] Bogdan Degtyariov
test case

Attachment: mysql_x_bug.asp (application/octet-stream, text), 2.22 KiB.

[24 Oct 2006 16:30] Bogdan Degtyariov
SQLGetData() returns SQL_NO_DATA_FOUND status when result is empty string. However, it
should fill the data buffer with \0 character in any case to prevent using old result
that is already in the buffer
[13 Oct 2007 17:26] Simon Ferragne
I get the same problem. Did you find a solution?
[25 Jan 15:57] Tonci Grgin
Bogdan, reopening on the basis of Matthew's remark in Bug#30496.
[26 Jan 17:22] Jess Balint
SQLGetData() should NOT touch the buffer if returning SQL_NO_DATA.