Bug #25079 SQLSetStmtAttr with SQL_ATTR_ROW_BIND_TYPE fails
Submitted: 14 Dec 2006 20:20 Modified: 13 Sep 2007 18:07
Reporter: Andrew Preston Email Updates:
Status: Won't fix Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.00.10.0, ODBC-RC5 OS:Microsoft Windows (Windows XP)
Assigned to: Jess Balint CPU Architecture:Any

[14 Dec 2006 20:20] Andrew Preston
Description:
The code snippet below (the last function in a larger list) fails.

// set the statement parameters for row-wise binding
sql_retcode = SQLSetStmtAttr(sql_statement_handle, 
                             SQL_ATTR_ROW_BIND_TYPE, 
                             (SQLPOINTER)result_row_struct_size, 
                             0);

When the function returns, sql_retcode is set to SQL_ERROR. No additional information is available from SQLGetDiagRec. This snippet works with ODBC connector v3.51.12.0. The ODBC trace follows:

tclsh85         14d4-13ec       ENTER SQLAllocHandle
                SQLSMALLINT                  1 <SQL_HANDLE_ENV>
                SQLHANDLE           00000000
                SQLHANDLE *         0122DD68

tclsh85         14d4-13ec       EXIT  SQLAllocHandle  with return code 0 (SQL_SU
CCESS)
                SQLSMALLINT                  1 <SQL_HANDLE_ENV>
                SQLHANDLE           00000000
                SQLHANDLE *         0x0122DD68 ( 0x01271788)

tclsh85         14d4-13ec       ENTER SQLSetEnvAttr
                SQLHENV             01271788
                SQLINTEGER                 200 <SQL_ATTR_ODBC_VERSION>
                SQLPOINTER          0x00000003
                SQLINTEGER                   0

tclsh85         14d4-13ec       EXIT  SQLSetEnvAttr  with return code 0 (SQL_SUC
CESS)
                SQLHENV             01271788
                SQLINTEGER                 200 <SQL_ATTR_ODBC_VERSION>
                SQLPOINTER          0x00000003 (BADMEM)
                SQLINTEGER                   0

tclsh85         14d4-13ec       ENTER SQLAllocHandle
                SQLSMALLINT                  2 <SQL_HANDLE_DBC>
                SQLHANDLE           01271788
                SQLHANDLE *         0012F068

tclsh85         14d4-13ec       EXIT  SQLAllocHandle  with return code 0 (SQL_SU
CCESS)
                SQLSMALLINT                  2 <SQL_HANDLE_DBC>
                SQLHANDLE           01271788
                SQLHANDLE *         0x0012F068 ( 0x01271830)

tclsh85         14d4-13ec       ENTER SQLConnectW
                HDBC                01271830
                WCHAR *             0x01271938 [      -3] "cms_core_db_v5\ 0"
                SWORD                       -3
                WCHAR *             0x74329A38 [      -3] "******\ 0"
                SWORD                       -3
                WCHAR *             0x74329A38 [      -3] "******\ 0"
                SWORD                       -3

tclsh85         14d4-13ec       EXIT  SQLConnectW  with return code 0 (SQL_SUCCE
SS)
                HDBC                01271830
                WCHAR *             0x01271938 [      -3] "cms_core_db_v5\ 0"
                SWORD                       -3
                WCHAR *             0x74329A38 [      -3] "******\ 0"
                SWORD                       -3
                WCHAR *             0x74329A38 [      -3] "******\ 0"
                SWORD                       -3

tclsh85         14d4-13ec       ENTER SQLAllocHandle
                SQLSMALLINT                  3 <SQL_HANDLE_STMT>
                SQLHANDLE           01271830
                SQLHANDLE *         0012F05C

tclsh85         14d4-13ec       EXIT  SQLAllocHandle  with return code 0 (SQL_SU
CCESS)
                SQLSMALLINT                  3 <SQL_HANDLE_STMT>
                SQLHANDLE           01271830
                SQLHANDLE *         0x0012F05C ( 0x01271e00)

tclsh85         14d4-13ec       ENTER SQLBindParameter
                HSTMT               01271E00
                UWORD                        1
                SWORD                        1 <SQL_PARAM_INPUT>
                SWORD                        1 <SQL_C_CHAR>
                SWORD                       12 <SQL_VARCHAR>
                SQLULEN                   45
                SWORD                        0
                PTR                0x0012F090
                SQLLEN                     9
                SQLLEN *            0x0012EFDC

tclsh85         14d4-13ec       EXIT  SQLBindParameter  with return code 0 (SQL_
SUCCESS)
                HSTMT               01271E00
                UWORD                        1
                SWORD                        1 <SQL_PARAM_INPUT>
                SWORD                        1 <SQL_C_CHAR>
                SWORD                       12 <SQL_VARCHAR>
                SQLULEN                   45
                SWORD                        0
                PTR                0x0012F090
                SQLLEN                     9
                SQLLEN *            0x0012EFDC (-3)

tclsh85         14d4-13ec       ENTER SQLExecDirect
                HSTMT               01271E00
                UCHAR *             0x00FD52F8 [      -3] "SELECT `core_configur
ation`.`name`, `core_configuration`.`value` FROM `core_configuration` LEFT JOIN
(`managers`) ON (`managers`.`manager_id` = `core_configuration`.`manager_id`) WH
ERE `managers`.`name` = ?\ 0"
                SDWORD                    -3

tclsh85         14d4-13ec       EXIT  SQLExecDirect  with return code 0 (SQL_SUC
CESS)
                HSTMT               01271E00
                UCHAR *             0x00FD52F8 [      -3] "SELECT `core_configur
ation`.`name`, `core_configuration`.`value` FROM `core_configuration` LEFT JOIN
(`managers`) ON (`managers`.`manager_id` = `core_configuration`.`manager_id`) WH
ERE `managers`.`name` = ?\ 0"
                SDWORD                    -3

tclsh85         14d4-13ec       ENTER SQLSetStmtAttr
                SQLHSTMT            01271E00
                SQLINTEGER                   5 <SQL_ATTR_ROW_BIND_TYPE>
                SQLPOINTER          0x00000208
                SQLINTEGER                   0

tclsh85         14d4-13ec       EXIT  SQLSetStmtAttr  with return code -1 (SQL_E
RROR)
                SQLHSTMT            01271E00
                SQLINTEGER                   5 <SQL_ATTR_ROW_BIND_TYPE>
                SQLPOINTER          0x00000208
                SQLINTEGER                   0

tclsh85         14d4-13ec       ENTER SQLGetDiagRecW
                SQLSMALLINT                  3
                SQLHANDLE           01271E00
                SQLSMALLINT                  1
                SQLWCHAR *          0x0012EC50 (NYI)
                SQLINTEGER *        0x0012EF80
                SQLWCHAR *          0x012723B8 (NYI)
                SQLSMALLINT                512
                SQLSMALLINT *       0x0012ED68

tclsh85         14d4-13ec       EXIT  SQLGetDiagRecW  with return code 100 (SQL_
NO_DATA_FOUND)
                SQLSMALLINT                  3
                SQLHANDLE           01271E00
                SQLSMALLINT                  1
                SQLWCHAR *          0x0012EC50 (NYI)
                SQLINTEGER *        0x0012EF80
                SQLWCHAR *          0x012723B8 (NYI)
                SQLSMALLINT                512
                SQLSMALLINT *       0x0012ED68

How to repeat:
Call SQLSetStmtAttr with a statement handle and SQL_ATTR_ROW_BIND_TYPE.

Suggested fix:
SQLSetStmtAttr should accept the SQL_ATTR_ROW_BIND_TYPE attribute and set the row binding type accordingly. Or, if this function is not supported, useful error information should be returned by SQLGetDiagRec.
[15 Dec 2006 19:18] Jess Balint
Andrew, thanks for the bug report. We don't currently support this feature, but I'll fix the diagnostic issue.
[18 Dec 2006 7:02] Tonci Grgin
Hi Andrew and thanks for your report.
[13 Sep 2007 18:07] Jim Winstead
SQL_ATTR_ROW_BIND_TYPE should work fine in Connector/ODBC 3.51 and 5.1. No further development is happening on 5.0.