-- v2: odbc32: Use SQLSetConnectAttrW() instead of SQLSetConnectAttr() if possible. odbc32: Use SQLFreeHandle() instead of SQLFreeEnv/Connect(). odbc32: Set parent functions before creating the environment handle. odbc32: Accept SQL_FETCH_NEXT in SQLDataSources/Drivers() if the key has not been opened. odbc32: Factor out helpers to create driver environment and connection handles. odbc32: Implement SQLGetInfo(SQL_ODBC_VER). odbc32: Default to ODBC version 2. odbc32: Handle options in SQLFreeStmt(). odbc32: Stub SQLGetEnvAttr(SQL_ATTR_CONNECTION_POOLING). odbc32: Implement SQLGet/SetConnectAttr(SQL_ATTR_CONNECTION_TIMEOUT). odbc32: Implement SQLGet/SetConnectAttr(SQL_ATTR_LOGIN_TIMEOUT).
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 98 ++++++++++++++++++++++++++++++++++++-- dlls/odbc32/tests/odbc32.c | 30 ++++++++++++ dlls/odbc32/unixlib.h | 1 + 3 files changed, 126 insertions(+), 3 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 57930e59ad4..1e2bd0db2f6 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -824,6 +824,30 @@ static SQLRETURN prepare_env( struct handle *handle ) return SQL_SUCCESS; }
+static SQLRETURN set_con_attr( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +{ + SQLRETURN ret = SQL_ERROR; + + if (handle->unix_handle) + { + struct SQLSetConnectAttr_params params = { handle->unix_handle, attr, value, len }; + ret = ODBC_CALL( SQLSetConnectAttr, ¶ms ); + } + else if (handle->win32_handle) + { + ret = handle->win32_funcs->SQLSetConnectAttr( handle->win32_handle, attr, value, len ); + } + return ret; +} + +static SQLRETURN prepare_con( struct handle *handle ) +{ + SQLRETURN ret; + if ((ret = set_con_attr( handle, SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER)(ULONG_PTR)handle->con_attr_login_timeout, 0 ))) + return ret; + return SQL_SUCCESS; +} + /************************************************************************* * SQLConnect [ODBC32.007] */ @@ -865,6 +889,7 @@ SQLRETURN WINAPI SQLConnect(SQLHDBC ConnectionHandle, SQLCHAR *ServerName, SQLSM handle->parent->win32_funcs = handle->win32_funcs; if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, handle->parent->win32_handle, &handle->win32_handle )))) goto done; + if (!SUCCESS((ret = prepare_con( handle )))) goto done;
ret = handle->win32_funcs->SQLConnect( handle->win32_handle, ServerName, NameLength1, UserName, NameLength2, Authentication, NameLength3 ); @@ -882,6 +907,7 @@ SQLRETURN WINAPI SQLConnect(SQLHDBC ConnectionHandle, SQLCHAR *ServerName, SQLSM
params_alloc_connect.EnvironmentHandle = handle->parent->unix_handle; if (!SUCCESS((ret = ODBC_CALL( SQLAllocConnect, ¶ms_alloc_connect )))) goto done; + if (!SUCCESS((ret = prepare_con( handle )))) goto done;
params_connect.ConnectionHandle = handle->unix_handle; ret = ODBC_CALL( SQLConnect, ¶ms_connect ); @@ -1430,7 +1456,7 @@ SQLRETURN WINAPI SQLGetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribut SQLINTEGER BufferLength, SQLINTEGER *StringLength) { struct handle *handle = ConnectionHandle; - SQLRETURN ret = SQL_ERROR; + SQLRETURN ret = SQL_SUCCESS;
TRACE("(ConnectionHandle %p, Attribute %d, Value %p, BufferLength %d, StringLength %p)\n", ConnectionHandle, Attribute, Value, BufferLength, StringLength); @@ -1448,6 +1474,20 @@ SQLRETURN WINAPI SQLGetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribut ret = handle->win32_funcs->SQLGetConnectAttr( handle->win32_handle, Attribute, Value, BufferLength, StringLength ); } + else + { + switch (Attribute) + { + case SQL_ATTR_LOGIN_TIMEOUT: + *(SQLINTEGER *)Value = handle->con_attr_login_timeout; + break; + + default: + FIXME( "unhandled attribute %d\n", Attribute ); + ret = SQL_ERROR; + break; + } + }
TRACE("Returning %d\n", ret); return ret; @@ -1990,7 +2030,7 @@ SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribut SQLINTEGER StringLength) { struct handle *handle = ConnectionHandle; - SQLRETURN ret = SQL_ERROR; + SQLRETURN ret = SQL_SUCCESS;
TRACE("(ConnectionHandle %p, Attribute %d, Value %p, StringLength %d)\n", ConnectionHandle, Attribute, Value, StringLength); @@ -2006,6 +2046,20 @@ SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribut { ret = handle->win32_funcs->SQLSetConnectAttr( handle->win32_handle, Attribute, Value, StringLength ); } + else + { + switch (Attribute) + { + case SQL_ATTR_LOGIN_TIMEOUT: + handle->con_attr_login_timeout = (UINT32)(ULONG_PTR)Value; + break; + + default: + FIXME( "unhandled attribute %d\n", Attribute ); + ret = SQL_ERROR; + break; + } + }
TRACE("Returning %d\n", ret); return ret; @@ -2523,6 +2577,7 @@ SQLRETURN WINAPI SQLBrowseConnect(SQLHDBC ConnectionHandle, SQLCHAR *InConnectio handle->parent->win32_funcs = handle->win32_funcs; if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, handle->parent->win32_handle, &handle->win32_handle )))) goto done; + if (!SUCCESS((ret = prepare_con( handle )))) goto done;
ret = handle->win32_funcs->SQLBrowseConnect( handle->win32_handle, InConnectionString, StringLength1, OutConnectionString, BufferLength, StringLength2 ); @@ -2540,6 +2595,7 @@ SQLRETURN WINAPI SQLBrowseConnect(SQLHDBC ConnectionHandle, SQLCHAR *InConnectio
params_alloc_connect.EnvironmentHandle = handle->parent->unix_handle; if (!SUCCESS((ret = ODBC_CALL( SQLAllocConnect, ¶ms_alloc_connect )))) goto done; + if (!SUCCESS((ret = prepare_con( handle )))) goto done;
params.ConnectionHandle = handle->unix_handle; ret = ODBC_CALL( SQLBrowseConnect, ¶ms ); @@ -3194,6 +3250,7 @@ SQLRETURN WINAPI SQLDriverConnect(SQLHDBC ConnectionHandle, SQLHWND WindowHandle handle->parent->win32_funcs = handle->win32_funcs; if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, handle->parent->win32_handle, &handle->win32_handle )))) goto done; + if (!SUCCESS((ret = prepare_con( handle )))) goto done;
ret = handle->win32_funcs->SQLDriverConnect( handle->win32_handle, WindowHandle, InConnectionString, Length, OutConnectionString, BufferLength, Length2, DriverCompletion ); @@ -3211,6 +3268,7 @@ SQLRETURN WINAPI SQLDriverConnect(SQLHDBC ConnectionHandle, SQLHWND WindowHandle
params_alloc_connect.EnvironmentHandle = handle->parent->unix_handle; if (!SUCCESS((ret = ODBC_CALL( SQLAllocConnect, ¶ms_alloc_connect )))) goto done; + if (!SUCCESS((ret = prepare_con( handle )))) goto done;
params.ConnectionHandle = handle->unix_handle; ret = ODBC_CALL( SQLDriverConnect, ¶ms ); @@ -3361,6 +3419,7 @@ SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle, WCHAR *ServerName, SQLSMA handle->parent->win32_funcs = handle->win32_funcs; if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, handle->parent->win32_handle, &handle->win32_handle )))) goto done; + if (!SUCCESS((ret = prepare_con( handle )))) goto done;
ret = handle->win32_funcs->SQLConnectW( handle->win32_handle, ServerName, NameLength1, UserName, NameLength2, Authentication, NameLength3 ); @@ -3378,6 +3437,7 @@ SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle, WCHAR *ServerName, SQLSMA
params_alloc_connect.EnvironmentHandle = handle->parent->unix_handle; if (!SUCCESS((ret = ODBC_CALL( SQLAllocConnect, ¶ms_alloc_connect )))) goto done; + if (!SUCCESS((ret = prepare_con( handle )))) goto done;
params_connect.ConnectionHandle = handle->unix_handle; ret = ODBC_CALL( SQLConnectW, ¶ms_connect ); @@ -3624,7 +3684,7 @@ SQLRETURN WINAPI SQLGetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribu SQLINTEGER BufferLength, SQLINTEGER *StringLength) { struct handle *handle = ConnectionHandle; - SQLRETURN ret = SQL_ERROR; + SQLRETURN ret = SQL_SUCCESS;
TRACE("(ConnectionHandle %p, Attribute %d, Value %p, BufferLength %d, StringLength %p)\n", ConnectionHandle, Attribute, Value, BufferLength, StringLength); @@ -3642,6 +3702,20 @@ SQLRETURN WINAPI SQLGetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribu ret = handle->win32_funcs->SQLGetConnectAttrW( handle->win32_handle, Attribute, Value, BufferLength, StringLength ); } + else + { + switch (Attribute) + { + case SQL_ATTR_LOGIN_TIMEOUT: + *(SQLINTEGER *)Value = handle->con_attr_login_timeout; + break; + + default: + FIXME( "unhandled attribute %d\n", Attribute ); + ret = SQL_ERROR; + break; + } + }
TRACE("Returning %d\n", ret); return ret; @@ -3831,6 +3905,20 @@ SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribu { ret = handle->win32_funcs->SQLSetConnectAttrW( handle->win32_handle, Attribute, Value, StringLength ); } + else + { + switch (Attribute) + { + case SQL_ATTR_LOGIN_TIMEOUT: + handle->con_attr_login_timeout = (UINT32)(ULONG_PTR)Value; + break; + + default: + FIXME( "unhandled attribute %d\n", Attribute ); + ret = SQL_ERROR; + break; + } + }
TRACE("Returning %d\n", ret); return ret; @@ -3915,6 +4003,7 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl handle->parent->win32_funcs = handle->win32_funcs; if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, handle->parent->win32_handle, &handle->win32_handle )))) goto done; + if (!SUCCESS((ret = prepare_con( handle )))) goto done;
ret = handle->win32_funcs->SQLDriverConnectW( handle->win32_handle, WindowHandle, InConnectionString, Length, OutConnectionString, BufferLength, Length2, DriverCompletion ); @@ -3932,6 +4021,7 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl
params_alloc_connect.EnvironmentHandle = handle->parent->unix_handle; if (!SUCCESS((ret = ODBC_CALL( SQLAllocConnect, ¶ms_alloc_connect )))) goto done; + if (!SUCCESS((ret = prepare_con( handle )))) goto done;
params.ConnectionHandle = handle->unix_handle; ret = ODBC_CALL( SQLDriverConnectW, ¶ms ); @@ -4195,6 +4285,7 @@ SQLRETURN WINAPI SQLBrowseConnectW(SQLHDBC ConnectionHandle, SQLWCHAR *InConnect handle->parent->win32_funcs = handle->win32_funcs; if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, handle->parent->win32_handle, &handle->win32_handle )))) goto done; + if (!SUCCESS((ret = prepare_con( handle )))) goto done;
ret = handle->win32_funcs->SQLBrowseConnectW( handle->win32_handle, InConnectionString, StringLength1, OutConnectionString, BufferLength, StringLength2 ); @@ -4212,6 +4303,7 @@ SQLRETURN WINAPI SQLBrowseConnectW(SQLHDBC ConnectionHandle, SQLWCHAR *InConnect
params_alloc_connect.EnvironmentHandle = handle->parent->unix_handle; if (!SUCCESS((ret = ODBC_CALL( SQLAllocConnect, ¶ms_alloc_connect )))) goto done; + if (!SUCCESS((ret = prepare_con( handle )))) goto done;
params.ConnectionHandle = handle->unix_handle; ret = ODBC_CALL( SQLBrowseConnectW, ¶ms ); diff --git a/dlls/odbc32/tests/odbc32.c b/dlls/odbc32/tests/odbc32.c index 950b86ba036..0288260d3d3 100644 --- a/dlls/odbc32/tests/odbc32.c +++ b/dlls/odbc32/tests/odbc32.c @@ -478,6 +478,35 @@ static void test_SQLSetEnvAttr(void) ok( ret == SQL_SUCCESS, "got %d\n", ret ); }
+static void test_SQLSetConnectAttr(void) +{ + SQLUINTEGER timeout; + SQLHENV env; + SQLHDBC con; + SQLRETURN ret; + + ret = SQLAllocEnv( &env ); + ok( ret == SQL_SUCCESS, "got %d\n", ret ); + + ret = SQLAllocConnect( env, &con ); + ok( ret == SQL_SUCCESS, "got %d\n", ret ); + + timeout = 10; + ret = SQLSetConnectAttr( con, SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER)(ULONG_PTR)timeout, sizeof(timeout) ); + ok( ret == SQL_SUCCESS, "got %d\n", ret ); + + timeout = 0; + ret = SQLGetConnectAttr( con, SQL_ATTR_LOGIN_TIMEOUT, &timeout, sizeof(timeout), NULL ); + ok( ret == SQL_SUCCESS, "got %d\n", ret ); + ok( timeout == 10, "wrong timeout %d\n", timeout ); + + ret = SQLFreeConnect( con ); + ok( ret == SQL_SUCCESS, "got %d\n", ret ); + + ret = SQLFreeEnv( env ); + ok( ret == SQL_SUCCESS, "got %d\n", ret ); +} + START_TEST(odbc32) { test_SQLAllocHandle(); @@ -488,4 +517,5 @@ START_TEST(odbc32) test_SQLDrivers(); test_SQLExecDirect(); test_SQLSetEnvAttr(); + test_SQLSetConnectAttr(); } diff --git a/dlls/odbc32/unixlib.h b/dlls/odbc32/unixlib.h index 966ade5ad72..c26317012b5 100644 --- a/dlls/odbc32/unixlib.h +++ b/dlls/odbc32/unixlib.h @@ -192,6 +192,7 @@ struct handle struct handle *parent; /* attributes */ UINT32 env_attr_version; + UINT32 con_attr_login_timeout; /* drivers and data sources */ UINT32 drivers_idx; void *drivers_key;
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 24 +++++++++++++++++++++--- dlls/odbc32/unixlib.h | 1 + 2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 1e2bd0db2f6..c9db219c203 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -816,10 +816,11 @@ static SQLRETURN set_env_attr( struct handle *handle, SQLINTEGER attr, SQLPOINTE return ret; }
+#define INT_PTR(val) (SQLPOINTER)(ULONG_PTR)val static SQLRETURN prepare_env( struct handle *handle ) { SQLRETURN ret; - if ((ret = set_env_attr( handle, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)(ULONG_PTR)handle->env_attr_version, 0 ))) + if ((ret = set_env_attr( handle, SQL_ATTR_ODBC_VERSION, INT_PTR(handle->env_attr_version), 0 ))) return ret; return SQL_SUCCESS; } @@ -843,8 +844,9 @@ static SQLRETURN set_con_attr( struct handle *handle, SQLINTEGER attr, SQLPOINTE static SQLRETURN prepare_con( struct handle *handle ) { SQLRETURN ret; - if ((ret = set_con_attr( handle, SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER)(ULONG_PTR)handle->con_attr_login_timeout, 0 ))) - return ret; + + if ((ret = set_con_attr( handle, SQL_ATTR_CONNECTION_TIMEOUT, INT_PTR(handle->con_attr_con_timeout), 0 ))) return ret; + if ((ret = set_con_attr( handle, SQL_ATTR_LOGIN_TIMEOUT, INT_PTR(handle->con_attr_login_timeout), 0 ))) return ret; return SQL_SUCCESS; }
@@ -1478,6 +1480,10 @@ SQLRETURN WINAPI SQLGetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribut { switch (Attribute) { + case SQL_ATTR_CONNECTION_TIMEOUT: + *(SQLINTEGER *)Value = handle->con_attr_con_timeout; + break; + case SQL_ATTR_LOGIN_TIMEOUT: *(SQLINTEGER *)Value = handle->con_attr_login_timeout; break; @@ -2050,6 +2056,10 @@ SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribut { switch (Attribute) { + case SQL_ATTR_CONNECTION_TIMEOUT: + handle->con_attr_con_timeout = (UINT32)(ULONG_PTR)Value; + break; + case SQL_ATTR_LOGIN_TIMEOUT: handle->con_attr_login_timeout = (UINT32)(ULONG_PTR)Value; break; @@ -3706,6 +3716,10 @@ SQLRETURN WINAPI SQLGetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribu { switch (Attribute) { + case SQL_ATTR_CONNECTION_TIMEOUT: + *(SQLINTEGER *)Value = handle->con_attr_con_timeout; + break; + case SQL_ATTR_LOGIN_TIMEOUT: *(SQLINTEGER *)Value = handle->con_attr_login_timeout; break; @@ -3909,6 +3923,10 @@ SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribu { switch (Attribute) { + case SQL_ATTR_CONNECTION_TIMEOUT: + handle->con_attr_con_timeout = (UINT32)(ULONG_PTR)Value; + break; + case SQL_ATTR_LOGIN_TIMEOUT: handle->con_attr_login_timeout = (UINT32)(ULONG_PTR)Value; break; diff --git a/dlls/odbc32/unixlib.h b/dlls/odbc32/unixlib.h index c26317012b5..4241d06c892 100644 --- a/dlls/odbc32/unixlib.h +++ b/dlls/odbc32/unixlib.h @@ -192,6 +192,7 @@ struct handle struct handle *parent; /* attributes */ UINT32 env_attr_version; + UINT32 con_attr_con_timeout; UINT32 con_attr_login_timeout; /* drivers and data sources */ UINT32 drivers_idx;
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 4 ++++ dlls/odbc32/tests/odbc32.c | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index c9db219c203..d1c1a7cfadd 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1738,6 +1738,10 @@ SQLRETURN WINAPI SQLGetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute, { switch (Attribute) { + case SQL_ATTR_CONNECTION_POOLING: + *(SQLINTEGER *)Value = SQL_CP_OFF; + break; + case SQL_ATTR_ODBC_VERSION: *(SQLINTEGER *)Value = handle->env_attr_version; break; diff --git a/dlls/odbc32/tests/odbc32.c b/dlls/odbc32/tests/odbc32.c index 0288260d3d3..01b8795e86e 100644 --- a/dlls/odbc32/tests/odbc32.c +++ b/dlls/odbc32/tests/odbc32.c @@ -82,7 +82,7 @@ static void test_SQLConnect( void ) SQLHENV env; SQLHDBC con; SQLRETURN ret; - SQLINTEGER size, version; + SQLINTEGER size, version, pooling; SQLUINTEGER timeout; SQLSMALLINT len; char str[32]; @@ -99,6 +99,11 @@ static void test_SQLConnect( void ) ok( size == -1, "size set\n" ); trace( "ODBC version %d\n", version );
+ pooling = -1; + ret = SQLGetEnvAttr( env, SQL_ATTR_CONNECTION_POOLING, &pooling, sizeof(pooling), NULL ); + ok( ret == SQL_SUCCESS, "got %d\n", ret ); + ok( !pooling, "got %d\n", pooling ); + ret = SQLAllocConnect( env, &con ); ok( ret == SQL_SUCCESS, "got %d\n", ret );
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index d1c1a7cfadd..5dc8e8649ce 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1377,17 +1377,23 @@ SQLRETURN WINAPI SQLFreeEnv(SQLHENV EnvironmentHandle) return ret; }
-static void free_bindings( struct handle *handle ) +static void free_col_bindings( struct handle *handle ) { if (handle->bind_col.param) { free( handle->bind_col.param->len ); free( handle->bind_col.param ); + handle->bind_col.param = NULL; } +} + +static void free_param_bindings( struct handle *handle ) +{ if (handle->bind_parameter.param) { free( handle->bind_parameter.param->len ); free( handle->bind_parameter.param ); + handle->bind_parameter.param = NULL; } }
@@ -1407,7 +1413,6 @@ SQLRETURN WINAPI SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) { struct SQLFreeHandle_params params = { HandleType, handle->unix_handle }; ret = ODBC_CALL( SQLFreeHandle, ¶ms ); - free_bindings( handle ); } else if (handle->win32_handle) { @@ -1416,6 +1421,8 @@ SQLRETURN WINAPI SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
RegCloseKey( handle->drivers_key ); RegCloseKey( handle->sources_key ); + free_col_bindings( handle ); + free_param_bindings( handle ); free( handle );
TRACE("Returning %d\n", ret); @@ -1438,14 +1445,32 @@ SQLRETURN WINAPI SQLFreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option) { struct SQLFreeStmt_params params = { handle->unix_handle, Option }; ret = ODBC_CALL( SQLFreeStmt, ¶ms ); - free_bindings( handle ); } else if (handle->win32_handle) { ret = handle->win32_funcs->SQLFreeStmt( handle->win32_handle, Option ); }
- free( handle ); + switch (Option) + { + case SQL_CLOSE: + break; + + case SQL_UNBIND: + free_col_bindings( handle ); + break; + + case SQL_RESET_PARAMS: + free_param_bindings( handle ); + break; + + case SQL_DROP: + default: + free_col_bindings( handle ); + free_param_bindings( handle ); + free( handle ); + break; + }
TRACE("Returning %d\n", ret); return ret;
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 5dc8e8649ce..925abcfc063 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -385,6 +385,7 @@ static struct handle *create_handle( struct handle *parent ) struct handle *ret; if (!(ret = calloc( 1, sizeof(*ret) ))) return NULL; ret->parent = parent; + ret->env_attr_version = SQL_OV_ODBC2; ret->row_count = 1; return ret; }
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 38 ++++++++++++++++++++++++++++++++++++++ dlls/odbc32/tests/odbc32.c | 22 ++++++++++++---------- 2 files changed, 50 insertions(+), 10 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 925abcfc063..c48e9c60917 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1823,6 +1823,25 @@ SQLRETURN WINAPI SQLGetInfo(SQLHDBC ConnectionHandle, SQLUSMALLINT InfoType, SQL
if (!handle) return SQL_INVALID_HANDLE;
+ switch (InfoType) + { + case SQL_ODBC_VER: + { + const char version[] = "03.80.0000"; + int len = sizeof(version); + char *value = InfoValue; + + if (StringLength) *StringLength = len; + if (value && BufferLength >= len) + { + strcpy( value, version ); + if (StringLength) *StringLength = len - 1; + } + return SQL_SUCCESS; + } + default: break; + } + if (handle->unix_handle) { struct SQLGetInfo_params params = { handle->unix_handle, InfoType, InfoValue, BufferLength, StringLength }; @@ -4122,6 +4141,25 @@ SQLRETURN WINAPI SQLGetInfoW(SQLHDBC ConnectionHandle, SQLUSMALLINT InfoType, SQ
if (!handle) return SQL_INVALID_HANDLE;
+ switch (InfoType) + { + case SQL_ODBC_VER: + { + const WCHAR version[] = L"03.80.0000"; + int len = ARRAY_SIZE(version); + WCHAR *value = InfoValue; + + if (StringLength) *StringLength = len; + if (value && BufferLength >= len) + { + wcscpy( value, version ); + if (StringLength) *StringLength = len - 1; + } + return SQL_SUCCESS; + } + default: break; + } + if (handle->unix_handle) { struct SQLGetInfoW_params params = { handle->unix_handle, InfoType, InfoValue, BufferLength, StringLength }; diff --git a/dlls/odbc32/tests/odbc32.c b/dlls/odbc32/tests/odbc32.c index 01b8795e86e..8282e5a47ea 100644 --- a/dlls/odbc32/tests/odbc32.c +++ b/dlls/odbc32/tests/odbc32.c @@ -107,6 +107,18 @@ static void test_SQLConnect( void ) ret = SQLAllocConnect( env, &con ); ok( ret == SQL_SUCCESS, "got %d\n", ret );
+ len = -1; + ret = SQLGetInfo( con, SQL_ODBC_VER, NULL, 0, &len ); + ok( ret == SQL_SUCCESS, "got %d\n", ret ); + ok( len != -1, "len not set\n" ); + + memset( str, 0, sizeof(str) ); + ret = SQLGetInfo( con, SQL_ODBC_VER, str, sizeof(str), &len ); + ok( ret == SQL_SUCCESS, "got %d\n", ret ); + ok( str[0], "empty string\n" ); + ok( len == strlen(str), "got %d\n", len ); + trace( "version %s\n", str ); + ret = SQLConnect( con, (SQLCHAR *)"winetest", 8, (SQLCHAR *)"winetest", 8, (SQLCHAR *)"winetest", 8 ); if (ret == SQL_ERROR) diag( con, SQL_HANDLE_DBC ); if (ret != SQL_SUCCESS) @@ -124,16 +136,6 @@ static void test_SQLConnect( void ) ok( timeout != 0xdeadbeef, "timeout not set\n" ); ok( size == -1, "size set\n" );
- len = -1; - memset( str, 0, sizeof(str) ); - ret = SQLGetInfo( con, SQL_ODBC_VER, str, sizeof(str), &len ); - if (ret == SQL_SUCCESS) - { - ok( str[0], "empty string\n" ); - ok( len != -1, "len not set\n" ); - trace( "version %s\n", str ); - } - ret = SQLDisconnect( con ); ok( ret == SQL_SUCCESS, "got %d\n", ret );
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 166 ++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 98 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index c48e9c60917..410f79649e1 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -826,6 +826,23 @@ static SQLRETURN prepare_env( struct handle *handle ) return SQL_SUCCESS; }
+static SQLRETURN create_env( struct handle *handle, BOOL unix ) +{ + SQLRETURN ret; + + if (unix) + { + struct SQLAllocEnv_params params = { &handle->unix_handle }; + if ((ret = ODBC_CALL( SQLAllocEnv, ¶ms ))) return ret; + } + else + { + if ((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_ENV, NULL, &handle->win32_handle ))) return ret; + } + + return prepare_env( handle ); +} + static SQLRETURN set_con_attr( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) { SQLRETURN ret = SQL_ERROR; @@ -851,6 +868,25 @@ static SQLRETURN prepare_con( struct handle *handle ) return SQL_SUCCESS; }
+static SQLRETURN create_con( struct handle *handle ) +{ + struct handle *parent = handle->parent; + SQLRETURN ret; + + if (parent->unix_handle) + { + struct SQLAllocConnect_params params = { parent->unix_handle, &handle->unix_handle }; + if ((ret = ODBC_CALL( SQLAllocConnect, ¶ms ))) return ret; + } + else + { + if ((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, parent->win32_handle, &handle->win32_handle ))) + return ret; + } + + return prepare_con( handle ); +} + /************************************************************************* * SQLConnect [ODBC32.007] */ @@ -885,35 +921,24 @@ SQLRETURN WINAPI SQLConnect(SQLHDBC ConnectionHandle, SQLCHAR *ServerName, SQLSM } TRACE( "using Windows driver %s\n", debugstr_w(filename) );
- if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_ENV, NULL, - &handle->parent->win32_handle )))) goto done; - if (!SUCCESS((ret = prepare_env( handle->parent )))) goto done; - + if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; handle->parent->win32_funcs = handle->win32_funcs; - if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, handle->parent->win32_handle, - &handle->win32_handle )))) goto done; - if (!SUCCESS((ret = prepare_con( handle )))) goto done; + if (!SUCCESS((ret = create_con( handle )))) goto done;
ret = handle->win32_funcs->SQLConnect( handle->win32_handle, ServerName, NameLength1, UserName, NameLength2, Authentication, NameLength3 ); } else { - struct SQLAllocEnv_params params_alloc_env = { &handle->parent->unix_handle }; - struct SQLAllocConnect_params params_alloc_connect = { 0, &handle->unix_handle }; - struct SQLConnect_params params_connect = { 0, ServerName, NameLength1, UserName, NameLength2, - Authentication, NameLength3 }; + struct SQLConnect_params params = { 0, ServerName, NameLength1, UserName, NameLength2, Authentication, + NameLength3 };
TRACE( "using Unix driver %s\n", debugstr_w(filename) ); - if (!SUCCESS((ret = ODBC_CALL( SQLAllocEnv, ¶ms_alloc_env )))) goto done; - if (!SUCCESS((ret = prepare_env( handle->parent )))) goto done; + if (!SUCCESS((ret = create_env( handle->parent, TRUE )))) goto done; + if (!SUCCESS((ret = create_con( handle )))) goto done;
- params_alloc_connect.EnvironmentHandle = handle->parent->unix_handle; - if (!SUCCESS((ret = ODBC_CALL( SQLAllocConnect, ¶ms_alloc_connect )))) goto done; - if (!SUCCESS((ret = prepare_con( handle )))) goto done; - - params_connect.ConnectionHandle = handle->unix_handle; - ret = ODBC_CALL( SQLConnect, ¶ms_connect ); + params.ConnectionHandle = handle->unix_handle; + ret = ODBC_CALL( SQLConnect, ¶ms ); }
done: @@ -2629,32 +2654,21 @@ SQLRETURN WINAPI SQLBrowseConnect(SQLHDBC ConnectionHandle, SQLCHAR *InConnectio } TRACE( "using Windows driver %s\n", debugstr_w(filename) );
- if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_ENV, NULL, - &handle->parent->win32_handle )))) goto done; - if (!SUCCESS((ret = prepare_env( handle->parent )))) goto done; - + if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; handle->parent->win32_funcs = handle->win32_funcs; - if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, handle->parent->win32_handle, - &handle->win32_handle )))) goto done; - if (!SUCCESS((ret = prepare_con( handle )))) goto done; + if (!SUCCESS((ret = create_con( handle )))) goto done;
ret = handle->win32_funcs->SQLBrowseConnect( handle->win32_handle, InConnectionString, StringLength1, OutConnectionString, BufferLength, StringLength2 ); } else { - struct SQLAllocEnv_params params_alloc_env = { &handle->parent->unix_handle }; - struct SQLAllocConnect_params params_alloc_connect = { 0, &handle->unix_handle }; struct SQLBrowseConnect_params params = { 0, InConnectionString, StringLength1, OutConnectionString, BufferLength, StringLength2 };
TRACE( "using Unix driver %s\n", debugstr_w(filename) ); - if (!SUCCESS((ret = ODBC_CALL( SQLAllocEnv, ¶ms_alloc_env )))) goto done; - if (!SUCCESS((ret = prepare_env( handle->parent )))) goto done; - - params_alloc_connect.EnvironmentHandle = handle->parent->unix_handle; - if (!SUCCESS((ret = ODBC_CALL( SQLAllocConnect, ¶ms_alloc_connect )))) goto done; - if (!SUCCESS((ret = prepare_con( handle )))) goto done; + if (!SUCCESS((ret = create_env( handle->parent, TRUE )))) goto done; + if (!SUCCESS((ret = create_con( handle )))) goto done;
params.ConnectionHandle = handle->unix_handle; ret = ODBC_CALL( SQLBrowseConnect, ¶ms ); @@ -3302,32 +3316,21 @@ SQLRETURN WINAPI SQLDriverConnect(SQLHDBC ConnectionHandle, SQLHWND WindowHandle } TRACE( "using Windows driver %s\n", debugstr_w(filename) );
- if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_ENV, NULL, - &handle->parent->win32_handle )))) goto done; - if (!SUCCESS((ret = prepare_env( handle->parent )))) goto done; - + if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; handle->parent->win32_funcs = handle->win32_funcs; - if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, handle->parent->win32_handle, - &handle->win32_handle )))) goto done; - if (!SUCCESS((ret = prepare_con( handle )))) goto done; + if (!SUCCESS((ret = create_con( handle )))) goto done;
ret = handle->win32_funcs->SQLDriverConnect( handle->win32_handle, WindowHandle, InConnectionString, Length, OutConnectionString, BufferLength, Length2, DriverCompletion ); } else { - struct SQLAllocEnv_params params_alloc_env = { &handle->parent->unix_handle }; - struct SQLAllocConnect_params params_alloc_connect = { 0, &handle->unix_handle }; struct SQLDriverConnect_params params = { 0, WindowHandle, InConnectionString, Length, OutConnectionString, BufferLength, Length2, DriverCompletion };
TRACE( "using Unix driver %s\n", debugstr_w(filename) ); - if (!SUCCESS((ret = ODBC_CALL( SQLAllocEnv, ¶ms_alloc_env )))) goto done; - if (!SUCCESS((ret = prepare_env( handle->parent )))) goto done; - - params_alloc_connect.EnvironmentHandle = handle->parent->unix_handle; - if (!SUCCESS((ret = ODBC_CALL( SQLAllocConnect, ¶ms_alloc_connect )))) goto done; - if (!SUCCESS((ret = prepare_con( handle )))) goto done; + if (!SUCCESS((ret = create_env( handle->parent, TRUE )))) goto done; + if (!SUCCESS((ret = create_con( handle )))) goto done;
params.ConnectionHandle = handle->unix_handle; ret = ODBC_CALL( SQLDriverConnect, ¶ms ); @@ -3471,35 +3474,24 @@ SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle, WCHAR *ServerName, SQLSMA } TRACE( "using Windows driver %s\n", debugstr_w(filename) );
- if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_ENV, NULL, - &handle->parent->win32_handle )))) goto done; - if (!SUCCESS((ret = prepare_env( handle->parent )))) goto done; - + if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; handle->parent->win32_funcs = handle->win32_funcs; - if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, handle->parent->win32_handle, - &handle->win32_handle )))) goto done; - if (!SUCCESS((ret = prepare_con( handle )))) goto done; + if (!SUCCESS((ret = create_con( handle )))) goto done;
ret = handle->win32_funcs->SQLConnectW( handle->win32_handle, ServerName, NameLength1, UserName, NameLength2, Authentication, NameLength3 ); } else { - struct SQLAllocEnv_params params_alloc_env = { &handle->parent->unix_handle }; - struct SQLAllocConnect_params params_alloc_connect = { 0, &handle->unix_handle }; - struct SQLConnectW_params params_connect = { 0, ServerName, NameLength1, UserName, NameLength2, - Authentication, NameLength3 }; + struct SQLConnectW_params params = { 0, ServerName, NameLength1, UserName, NameLength2, Authentication, + NameLength3 };
TRACE( "using Unix driver %s\n", debugstr_w(filename) ); - if (!SUCCESS((ret = ODBC_CALL( SQLAllocEnv, ¶ms_alloc_env )))) goto done; - if (!SUCCESS((ret = prepare_env( handle->parent )))) goto done; + if (!SUCCESS((ret = create_env( handle->parent, TRUE )))) goto done; + if (!SUCCESS((ret = create_con( handle )))) goto done;
- params_alloc_connect.EnvironmentHandle = handle->parent->unix_handle; - if (!SUCCESS((ret = ODBC_CALL( SQLAllocConnect, ¶ms_alloc_connect )))) goto done; - if (!SUCCESS((ret = prepare_con( handle )))) goto done; - - params_connect.ConnectionHandle = handle->unix_handle; - ret = ODBC_CALL( SQLConnectW, ¶ms_connect ); + params.ConnectionHandle = handle->unix_handle; + ret = ODBC_CALL( SQLConnectW, ¶ms ); }
done: @@ -4063,32 +4055,21 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl } TRACE( "using Windows driver %s\n", debugstr_w(filename) );
- if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_ENV, NULL, - &handle->parent->win32_handle )))) goto done; - if (!SUCCESS((ret = prepare_env( handle->parent )))) goto done; - + if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; handle->parent->win32_funcs = handle->win32_funcs; - if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, handle->parent->win32_handle, - &handle->win32_handle )))) goto done; - if (!SUCCESS((ret = prepare_con( handle )))) goto done; + if (!SUCCESS((ret = create_con( handle )))) goto done;
ret = handle->win32_funcs->SQLDriverConnectW( handle->win32_handle, WindowHandle, InConnectionString, Length, OutConnectionString, BufferLength, Length2, DriverCompletion ); } else { - struct SQLAllocEnv_params params_alloc_env = { &handle->parent->unix_handle }; - struct SQLAllocConnect_params params_alloc_connect = { 0, &handle->unix_handle }; struct SQLDriverConnectW_params params = { 0, WindowHandle, InConnectionString, Length, OutConnectionString, BufferLength, Length2, DriverCompletion };
TRACE( "using Unix driver %s\n", debugstr_w(filename) ); - if (!SUCCESS((ret = ODBC_CALL( SQLAllocEnv, ¶ms_alloc_env )))) goto done; - if (!SUCCESS((ret = prepare_env( handle->parent )))) goto done; - - params_alloc_connect.EnvironmentHandle = handle->parent->unix_handle; - if (!SUCCESS((ret = ODBC_CALL( SQLAllocConnect, ¶ms_alloc_connect )))) goto done; - if (!SUCCESS((ret = prepare_con( handle )))) goto done; + if (!SUCCESS((ret = create_env( handle->parent, TRUE )))) goto done; + if (!SUCCESS((ret = create_con( handle )))) goto done;
params.ConnectionHandle = handle->unix_handle; ret = ODBC_CALL( SQLDriverConnectW, ¶ms ); @@ -4364,32 +4345,21 @@ SQLRETURN WINAPI SQLBrowseConnectW(SQLHDBC ConnectionHandle, SQLWCHAR *InConnect } TRACE( "using Windows driver %s\n", debugstr_w(filename) );
- if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_ENV, NULL, - &handle->parent->win32_handle )))) goto done; - if (!SUCCESS((ret = prepare_env( handle->parent )))) goto done; - + if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; handle->parent->win32_funcs = handle->win32_funcs; - if (!SUCCESS((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, handle->parent->win32_handle, - &handle->win32_handle )))) goto done; - if (!SUCCESS((ret = prepare_con( handle )))) goto done; + if (!SUCCESS((ret = create_con( handle )))) goto done;
ret = handle->win32_funcs->SQLBrowseConnectW( handle->win32_handle, InConnectionString, StringLength1, OutConnectionString, BufferLength, StringLength2 ); } else { - struct SQLAllocEnv_params params_alloc_env = { &handle->parent->unix_handle }; - struct SQLAllocConnect_params params_alloc_connect = { 0, &handle->unix_handle }; struct SQLBrowseConnectW_params params = { 0, InConnectionString, StringLength1, OutConnectionString, BufferLength, StringLength2 };
TRACE( "using Unix driver %s\n", debugstr_w(filename) ); - if (!SUCCESS((ret = ODBC_CALL( SQLAllocEnv, ¶ms_alloc_env )))) goto done; - if (!SUCCESS((ret = prepare_env( handle->parent )))) goto done; - - params_alloc_connect.EnvironmentHandle = handle->parent->unix_handle; - if (!SUCCESS((ret = ODBC_CALL( SQLAllocConnect, ¶ms_alloc_connect )))) goto done; - if (!SUCCESS((ret = prepare_con( handle )))) goto done; + if (!SUCCESS((ret = create_env( handle->parent, TRUE )))) goto done; + if (!SUCCESS((ret = create_con( handle )))) goto done;
params.ConnectionHandle = handle->unix_handle; ret = ODBC_CALL( SQLBrowseConnectW, ¶ms );
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 410f79649e1..6a62e998bed 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1000,7 +1000,7 @@ SQLRETURN WINAPI SQLDataSources(SQLHENV EnvironmentHandle, SQLUSMALLINT Directio
if (!handle) return SQL_INVALID_HANDLE;
- if (Direction == SQL_FETCH_FIRST) + if (Direction == SQL_FETCH_FIRST || (Direction == SQL_FETCH_NEXT && !handle->sources_key)) { handle->sources_idx = 0; handle->sources_system = FALSE; @@ -3185,7 +3185,7 @@ SQLRETURN WINAPI SQLDrivers(SQLHENV EnvironmentHandle, SQLUSMALLINT Direction, S
if (!handle) return SQL_INVALID_HANDLE;
- if (Direction == SQL_FETCH_FIRST) + if (Direction == SQL_FETCH_FIRST || (Direction == SQL_FETCH_NEXT && !handle->drivers_key)) { handle->drivers_idx = 0; RegCloseKey( handle->drivers_key ); @@ -4425,7 +4425,7 @@ SQLRETURN WINAPI SQLDataSourcesW(SQLHENV EnvironmentHandle, SQLUSMALLINT Directi
if (!handle) return SQL_INVALID_HANDLE;
- if (Direction == SQL_FETCH_FIRST) + if (Direction == SQL_FETCH_FIRST || (Direction == SQL_FETCH_NEXT && !handle->sources_key)) { handle->sources_idx = 0; handle->sources_system = FALSE; @@ -4699,7 +4699,7 @@ SQLRETURN WINAPI SQLDriversW(SQLHENV EnvironmentHandle, SQLUSMALLINT Direction,
if (!handle) return SQL_INVALID_HANDLE;
- if (Direction == SQL_FETCH_FIRST) + if (Direction == SQL_FETCH_FIRST || (Direction == SQL_FETCH_NEXT && !handle->drivers_key)) { handle->drivers_idx = 0; RegCloseKey( handle->drivers_key );
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 6a62e998bed..e2b63a9d9fd 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -914,7 +914,7 @@ SQLRETURN WINAPI SQLConnect(SQLHDBC ConnectionHandle, SQLCHAR *ServerName, SQLSM
if (has_suffix( filename, L".dll" )) { - if (!(handle->win32_funcs = load_driver( filename ))) + if (!(handle->win32_funcs = handle->parent->win32_funcs = load_driver( filename ))) { WARN( "failed to load driver %s\n", debugstr_w(filename) ); goto done; @@ -922,7 +922,6 @@ SQLRETURN WINAPI SQLConnect(SQLHDBC ConnectionHandle, SQLCHAR *ServerName, SQLSM TRACE( "using Windows driver %s\n", debugstr_w(filename) );
if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; - handle->parent->win32_funcs = handle->win32_funcs; if (!SUCCESS((ret = create_con( handle )))) goto done;
ret = handle->win32_funcs->SQLConnect( handle->win32_handle, ServerName, NameLength1, UserName, NameLength2, @@ -2647,7 +2646,7 @@ SQLRETURN WINAPI SQLBrowseConnect(SQLHDBC ConnectionHandle, SQLCHAR *InConnectio
if (has_suffix( filename, L".dll" )) { - if (!(handle->win32_funcs = load_driver( filename ))) + if (!(handle->win32_funcs = handle->parent->win32_funcs = load_driver( filename ))) { WARN( "failed to load driver %s\n", debugstr_w(filename) ); goto done; @@ -2655,7 +2654,6 @@ SQLRETURN WINAPI SQLBrowseConnect(SQLHDBC ConnectionHandle, SQLCHAR *InConnectio TRACE( "using Windows driver %s\n", debugstr_w(filename) );
if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; - handle->parent->win32_funcs = handle->win32_funcs; if (!SUCCESS((ret = create_con( handle )))) goto done;
ret = handle->win32_funcs->SQLBrowseConnect( handle->win32_handle, InConnectionString, StringLength1, @@ -3309,7 +3307,7 @@ SQLRETURN WINAPI SQLDriverConnect(SQLHDBC ConnectionHandle, SQLHWND WindowHandle
if (has_suffix( filename, L".dll" )) { - if (!(handle->win32_funcs = load_driver( filename ))) + if (!(handle->win32_funcs = handle->parent->win32_funcs = load_driver( filename ))) { WARN( "failed to load driver %s\n", debugstr_w(filename) ); goto done; @@ -3317,7 +3315,6 @@ SQLRETURN WINAPI SQLDriverConnect(SQLHDBC ConnectionHandle, SQLHWND WindowHandle TRACE( "using Windows driver %s\n", debugstr_w(filename) );
if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; - handle->parent->win32_funcs = handle->win32_funcs; if (!SUCCESS((ret = create_con( handle )))) goto done;
ret = handle->win32_funcs->SQLDriverConnect( handle->win32_handle, WindowHandle, InConnectionString, Length, @@ -3467,7 +3464,7 @@ SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle, WCHAR *ServerName, SQLSMA
if (has_suffix( filename, L".dll" )) { - if (!(handle->win32_funcs = load_driver( filename ))) + if (!(handle->win32_funcs = handle->parent->win32_funcs = load_driver( filename ))) { WARN( "failed to load driver %s\n", debugstr_w(filename) ); goto done; @@ -3475,7 +3472,6 @@ SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle, WCHAR *ServerName, SQLSMA TRACE( "using Windows driver %s\n", debugstr_w(filename) );
if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; - handle->parent->win32_funcs = handle->win32_funcs; if (!SUCCESS((ret = create_con( handle )))) goto done;
ret = handle->win32_funcs->SQLConnectW( handle->win32_handle, ServerName, NameLength1, UserName, NameLength2, @@ -4048,7 +4044,7 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl
if (has_suffix( filename, L".dll" )) { - if (!(handle->win32_funcs = load_driver( filename ))) + if (!(handle->win32_funcs = handle->parent->win32_funcs = load_driver( filename ))) { WARN( "failed to load driver %s\n", debugstr_w(filename) ); goto done; @@ -4056,7 +4052,6 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl TRACE( "using Windows driver %s\n", debugstr_w(filename) );
if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; - handle->parent->win32_funcs = handle->win32_funcs; if (!SUCCESS((ret = create_con( handle )))) goto done;
ret = handle->win32_funcs->SQLDriverConnectW( handle->win32_handle, WindowHandle, InConnectionString, Length, @@ -4338,7 +4333,7 @@ SQLRETURN WINAPI SQLBrowseConnectW(SQLHDBC ConnectionHandle, SQLWCHAR *InConnect
if (has_suffix( filename, L".dll" )) { - if (!(handle->win32_funcs = load_driver( filename ))) + if (!(handle->win32_funcs = handle->parent->win32_funcs = load_driver( filename ))) { WARN( "failed to load driver %s\n", debugstr_w(filename) ); goto done; @@ -4346,7 +4341,6 @@ SQLRETURN WINAPI SQLBrowseConnectW(SQLHDBC ConnectionHandle, SQLWCHAR *InConnect TRACE( "using Windows driver %s\n", debugstr_w(filename) );
if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; - handle->parent->win32_funcs = handle->win32_funcs; if (!SUCCESS((ret = create_con( handle )))) goto done;
ret = handle->win32_funcs->SQLBrowseConnectW( handle->win32_handle, InConnectionString, StringLength1,
From: Hans Leidekker hans@codeweavers.com
The latter are not exported by some drivers. --- dlls/odbc32/proxyodbc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index e2b63a9d9fd..0fea12c89d6 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1359,12 +1359,12 @@ SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle)
if (handle->unix_handle) { - struct SQLFreeConnect_params params = { handle->unix_handle }; - ret = ODBC_CALL( SQLFreeConnect, ¶ms ); + struct SQLFreeHandle_params params = { SQL_HANDLE_DBC, handle->unix_handle }; + ret = ODBC_CALL( SQLFreeHandle, ¶ms ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLFreeConnect( handle->win32_handle ); + ret = handle->win32_funcs->SQLFreeHandle( SQL_HANDLE_DBC, handle->win32_handle ); }
free( handle ); @@ -1386,12 +1386,12 @@ SQLRETURN WINAPI SQLFreeEnv(SQLHENV EnvironmentHandle)
if (handle->unix_handle) { - struct SQLFreeEnv_params params = { handle->unix_handle }; - ret = ODBC_CALL( SQLFreeEnv, ¶ms ); + struct SQLFreeHandle_params params = { SQL_HANDLE_ENV, handle->unix_handle }; + ret = ODBC_CALL( SQLFreeHandle, ¶ms ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLFreeEnv( handle->win32_handle ); + ret = handle->win32_funcs->SQLFreeHandle( SQL_HANDLE_ENV, handle->win32_handle ); }
RegCloseKey( handle->drivers_key );
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 0fea12c89d6..d0ac6119c26 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -854,7 +854,20 @@ static SQLRETURN set_con_attr( struct handle *handle, SQLINTEGER attr, SQLPOINTE } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetConnectAttr( handle->win32_handle, attr, value, len ); + switch (attr) + { + case SQL_ATTR_CURRENT_CATALOG: + case SQL_ATTR_TRACEFILE: + case SQL_ATTR_TRANSLATE_LIB: + ERR( "string attribute %u not handled\n", attr ); + return SQL_ERROR; + default: + break; + } + if (handle->win32_funcs->SQLSetConnectAttrW) + ret = handle->win32_funcs->SQLSetConnectAttrW( handle->win32_handle, attr, value, len ); + else if (handle->win32_funcs->SQLSetConnectAttr) + ret = handle->win32_funcs->SQLSetConnectAttr( handle->win32_handle, attr, value, len ); } return ret; }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147044
Your paranoid android.
=== debian11b (64 bit WoW report) ===
user32: input.c:5870: Test failed: got pos (49,51) input.c:4305: Test succeeded inside todo block: button_down_hwnd_todo 1: got MSG_TEST_WIN hwnd 00000000007A00F4, msg WM_LBUTTONDOWN, wparam 0x1, lparam 0x320032
On Fri Jul 12 06:35:03 2024 +0000, Hans Leidekker wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/6050/diffs?diff_id=121960&start_sha=8bead8919329c29043734f8eb770a858437d7073#1df680afc3a512e30078a935b3e8384cd3e63705_857_857)
I tested SQLSetConnectAttr() and it turns out that string value handling is broken for the ANSI version (it truncates the value to the first character). So we don't need to worry about conversion. We can use SQLSetConnectAttrW() instead as long as we're not passing any of these string attributes. I have added a patch to this effect.
Thank Hans.
This allows thing to load for me without errors. The error that I'm now finding can be a another patchset.
This merge request was approved by Alistair Leslie-Hughes.