Bug #23264 MyODBC driver returns 'x' instead of empty string when IF applies on TEXT field
Submitted: 13 Oct 2006 15:35 Modified: 17 Dec 2009 5:25
Reporter: Bogdan Degtyariov Email Updates:
Status: Closed Impact on me:
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51 OS:Any
Assigned to: Bogdan Degtyariov CPU Architecture:Any
Tags: IIS

[13 Oct 2006 15:35] Bogdan Degtyariov
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 15:36] Bogdan Degtyariov
test case

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

[24 Oct 2006 14: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 15:26] Simon Ferragne
I get the same problem. Did you find a solution?
[25 Jan 2009 14:57] Tonci Grgin
Bogdan, reopening on the basis of Matthew's remark in Bug#30496.
[26 Jan 2009 16:22] Jess Balint
SQLGetData() should NOT touch the buffer if returning SQL_NO_DATA.
[17 Dec 2009 5:25] Bogdan Degtyariov
Verified with the driver version 3.51.27. No bug was detected using the old test case mysql_x_bug.asp (http://bugs.mysql.com/file.php?id=4614). The driver returned correct results even after changing connection string as indicated in the duplicated bug#30946:

Driver={MySQL ODBC 3.51 Driver};Server=***;Port=3306;Database=enrol;User=*

I am closing this bug report once again. If anybody still have similar problems, please attach your test case.
[24 Feb 2010 14:41] Tonci Grgin
Bug#42325 was marked as duplicate of this report.