Bug #53366 odbc connector for C should return support for unicode characters
Submitted: 3 May 2010 11:04 Modified: 3 May 2010 12:08
Reporter: wim delvaux Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.1.6 OS:Any
Assigned to: CPU Architecture:Any
Tags: unicode detection

[3 May 2010 11:04] wim delvaux
Description:
I use qt 4.6.2 under windows.  Qt tries to detect if the odbc driver is unicode capable by performing SQLGETINFO requests about supported conversions by the driver.  It requsts SQL_CONVERT_LONGVARCHAR, SQL_CONVERT_CHAR or SQL_CONVERT_VARCHAR and expects the driver to return a bit flag where one of SQL_CVT_WLONGVARCHAR, SQL_CVT_WCHAR or SQL_CVT_WVARCHAR is set.

However the odbc drivers' sqlgetinfo function ONLY sets NON unicode flags as in info.c line 152

    MYINFO_SET_ULONG(SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL |
                     SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT |
                     SQL_CVT_REAL | SQL_CVT_DOUBLE | SQL_CVT_VARCHAR |
                     SQL_CVT_LONGVARCHAR | SQL_CVT_BIT | SQL_CVT_TINYINT |
                     SQL_CVT_BIGINT | SQL_CVT_DATE | SQL_CVT_TIME |
                     SQL_CVT_TIMESTAMP);

as a consequence unicode characters are not processed properly by qt since is assumes all texts are ASCII

How to repeat:
use any qt database program under windows.  Also OpenOffice 3.2 has the same problems with detection of unicode support by the driver.  However I do not know if openoffice uses the same detection mechanism

Suggested fix:
Modify line 152 to

    MYINFO_SET_ULONG(SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL |
                     SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT |
                     SQL_CVT_REAL | SQL_CVT_DOUBLE | SQL_CVT_VARCHAR |
                     SQL_CVT_LONGVARCHAR | SQL_CVT_BIT | SQL_CVT_TINYINT |
                     SQL_CVT_BIGINT | SQL_CVT_DATE | SQL_CVT_TIME |
                     SQL_CVT_TIMESTAMP | SQL_CVT_WLONGVARCHAR | SQL_CVT_WCHAR |
                     SQL_CVT_WVARCHAR )
[3 May 2010 12:08] Bogdan Degtyariov
Duplicate of http://bugs.mysql.com/bug.php?id=43855
Fixed in 5.1.7