Bug #49993 | SQLColAttribute with SQL_DESC_COUNT returns SQL_ERROR | ||
---|---|---|---|
Submitted: | 30 Dec 2009 14:57 | Modified: | 1 Feb 2010 10:11 |
Reporter: | Scott Selvia | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | Connector / ODBC | Severity: | S2 (Serious) |
Version: | 5.1.6 64-Bit | OS: | Windows (Windows 7 x64) |
Assigned to: | Assigned Account | CPU Architecture: | Any |
Tags: | SQL_DESC_COUNT, SQLColAttribute |
[30 Dec 2009 14:57]
Scott Selvia
[5 Jan 2010 15:03]
Scott Selvia
More details on the issue: SQLSTATE = 07009 SQLMESSAGE = [MySQL][ODBC 5.1 Driver][mysqld-5.1.41-community-log]Invalid descriptor index
[1 Feb 2010 10:11]
Tonci Grgin
Hi Scott and thanks for your report. Using arbitrary table and Microsoft generic ODBC client odbcte32w (unicode, 64 bit). The problem is that you specify invalid column index, 0, in your call thus generating the error. I think this is *not* a bug in 5.1 driver but rather in 3.51: Successfully connected to DSN '3-51-27-on-opensol'. SQLExecDirect: In: hstmt = 0x001D5B70, szSqlStr = "select * from testkeys where 1=0", cbSqlStr = -3 Return: SQL_SUCCESS=0 SQLColAttribute: In: StatementHandle = 0x001D5B70, ColumnNumber = 0, FieldIdentifier = SQL_DESC_COUNT=1001, CharacterAttributePtr = 0x037C0020, BufferLength = 300, StringLengthPtr = 0x0055EC18, NumericAttributePtr = 0x00553CC0, fFieldIndentifier Type = SQL_C_SLONG=-16 Return: SQL_SUCCESS=0 Out: *CharacterAttributePtr = <unmodified>, *StringLengthPtr = <unmodified>, *NumericAttributePtr = 4 TST1001: Buffer CharacterAttributePtr was not updated. TST1001: Buffer StringLengthPtr was not updated. Get Data All: "Id", "FldUKP1", "FldUKP2", "Fld3OrdIndex" 0 rows fetched from 4 columns. Now, according to http://msdn.microsoft.com/en-us/library/ms713558(VS.85).aspx, 5.1 returns correct error: 07009 Invalid descriptor index (DM) The value specified for ColumnNumber was equal to 0, and the SQL_ATTR_USE_BOOKMARKS statement attribute was SQL_UB_OFF. In any case, I think this is a valid feature request to make both connector version behave the same. Even though it makes not much sense checking column attributes on non-existent column, maybe a better way would be to return resultset as c/ODBC 3.51 does... Workaround is more than acceptable, call the function with proper column index.