-- v3: odbc32: Find the driver filename through the ODBCINST.INI key. odbc32: Fix setting the Driver registry value. odbc32/tests: Add tests for SQLTransact(). odbc32: Get rid of the wrappers for SQLGetDiagRecA() and SQLDataSourcesA(). odbc32: Avoid a clang warning.
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 08fdba52439..76733140b74 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1327,7 +1327,7 @@ static SQLRETURN error_win32_a( struct handle *env, struct handle *con, struct h
if (env) win32_funcs = env->win32_funcs; else if (con) win32_funcs = con->win32_funcs; - else if (stmt) win32_funcs = stmt->win32_funcs; + else win32_funcs = stmt->win32_funcs;
if (win32_funcs->SQLError) return win32_funcs->SQLError( env ? env->win32_handle : NULL, con ? con->win32_handle : NULL, @@ -4066,7 +4066,7 @@ static SQLRETURN error_win32_w( struct handle *env, struct handle *con, struct h
if (env) win32_funcs = env->win32_funcs; else if (con) win32_funcs = con->win32_funcs; - else if (stmt) win32_funcs = stmt->win32_funcs; + else win32_funcs = stmt->win32_funcs;
if (win32_funcs->SQLErrorW) return win32_funcs->SQLErrorW( env ? env->win32_handle : NULL, con ? con->win32_handle : NULL,
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/odbc32.spec | 4 ++-- dlls/odbc32/proxyodbc.c | 19 ------------------- 2 files changed, 2 insertions(+), 21 deletions(-)
diff --git a/dlls/odbc32/odbc32.spec b/dlls/odbc32/odbc32.spec index c42bf55c3eb..0de9bf2bf70 100644 --- a/dlls/odbc32/odbc32.spec +++ b/dlls/odbc32/odbc32.spec @@ -136,7 +136,7 @@ 233 stub SQLGetDescFieldA 234 stub SQLGetDescRecA 235 stub SQLGetDiagFieldA -236 stdcall SQLGetDiagRecA(long long long ptr ptr ptr long ptr) +236 stdcall SQLGetDiagRecA(long long long ptr ptr ptr long ptr) SQLGetDiagRec 238 stub SQLGetStmtAttrA 239 stub SQLSetConnectAttrA 240 stub SQLColumnsA @@ -150,7 +150,7 @@ 254 stub SQLTablesA 255 stub SQLBrowseConnectA 256 stub SQLColumnPrivilegesA -257 stdcall SQLDataSourcesA(long long str long ptr ptr long ptr) +257 stdcall SQLDataSourcesA(long long str long ptr ptr long ptr) SQLDataSources 260 stub SQLForeignKeysA 262 stub SQLNativeSqlA 265 stub SQLPrimaryKeysA diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 76733140b74..50565214775 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1176,14 +1176,6 @@ done: return ret; }
-SQLRETURN WINAPI SQLDataSourcesA(SQLHENV EnvironmentHandle, SQLUSMALLINT Direction, SQLCHAR *ServerName, - SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1, SQLCHAR *Description, - SQLSMALLINT BufferLength2, SQLSMALLINT *NameLength2) -{ - return SQLDataSources( EnvironmentHandle, Direction, ServerName, BufferLength1, NameLength1, Description, - BufferLength2, NameLength2 ); -} - static SQLRETURN describe_col_unix_a( struct handle *handle, SQLUSMALLINT col_number, SQLCHAR *col_name, SQLSMALLINT buflen, SQLSMALLINT *retlen, SQLSMALLINT *data_type, SQLULEN *col_size, SQLSMALLINT *decimal_digits, SQLSMALLINT *nullable ) @@ -5480,17 +5472,6 @@ SQLRETURN WINAPI SQLSetStmtAttrW(SQLHSTMT StatementHandle, SQLINTEGER Attribute, return ret; }
-/************************************************************************* - * SQLGetDiagRecA [ODBC32.236] - */ -SQLRETURN WINAPI SQLGetDiagRecA(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT RecNumber, - SQLCHAR *SqlState, SQLINTEGER *NativeError, SQLCHAR *MessageText, - SQLSMALLINT BufferLength, SQLSMALLINT *TextLength) -{ - return SQLGetDiagRec( HandleType, Handle, RecNumber, SqlState, NativeError, MessageText, BufferLength, - TextLength ); -} - /*********************************************************************** * DllMain [Internal] Initializes the internal 'ODBC32.DLL'. */
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/tests/odbc32.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/dlls/odbc32/tests/odbc32.c b/dlls/odbc32/tests/odbc32.c index 9293b98b049..10b5b933d80 100644 --- a/dlls/odbc32/tests/odbc32.c +++ b/dlls/odbc32/tests/odbc32.c @@ -137,6 +137,18 @@ static void test_SQLConnect( void ) ok( timeout != 0xdeadbeef, "timeout not set\n" ); ok( size == -1, "size set\n" );
+ ret = SQLTransact( NULL, NULL, SQL_COMMIT ); + ok( ret == SQL_INVALID_HANDLE, "got %d\n", ret ); + + ret = SQLTransact( env, NULL, SQL_COMMIT ); + ok( ret == SQL_SUCCESS, "got %d\n", ret ); + + ret = SQLTransact( NULL, con, SQL_COMMIT ); + ok( ret == SQL_SUCCESS, "got %d\n", ret ); + + ret = SQLTransact( env, con, SQL_COMMIT ); + ok( ret == SQL_SUCCESS, "got %d\n", ret ); + ret = SQLDisconnect( con ); ok( ret == SQL_SUCCESS, "got %d\n", ret );
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/unixlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/unixlib.c b/dlls/odbc32/unixlib.c index 6f244514d7d..550a0681a9f 100644 --- a/dlls/odbc32/unixlib.c +++ b/dlls/odbc32/unixlib.c @@ -209,7 +209,7 @@ static void replicate_odbcinst_to_registry( SQLHENV env )
if ((key_driver = create_key( key_odbcinst, desc, wcslen( desc ) * sizeof(WCHAR) ))) { - static const WCHAR driverW[] = {'D','r','i','v','e','r',0}, driver_eqW[] = {'D','r','i','v','e','r','='}; + static const WCHAR driverW[] = {'D','r','i','v','e','r'}, driver_eqW[] = {'D','r','i','v','e','r','='}; const WCHAR *driver = NULL, *ptr = attrs;
while (*ptr) @@ -223,7 +223,7 @@ static void replicate_odbcinst_to_registry( SQLHENV env ) ptr += wcslen( ptr ) + 1; } if (driver) set_value( key_driver, driverW, sizeof(driverW), REG_SZ, (const BYTE *)driver, - wcslen(driver) * sizeof(WCHAR) ); + (wcslen(driver) + 1) * sizeof(WCHAR) ); NtClose( key_driver ); } }
From: Hans Leidekker hans@codeweavers.com
I found an installer that doesn't set the driver filename in the data source. --- dlls/odbc32/proxyodbc.c | 54 +++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 23 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 50565214775..c2625fc5f8a 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -842,9 +842,9 @@ static WCHAR *strdupAW( const char *src ) return dst; }
-static HKEY open_odbcini_key( HKEY root ) +static HKEY open_sources_key( HKEY root ) { - static const WCHAR sourcesW[] = L"Software\ODBC\ODBC.INI"; + static const WCHAR sourcesW[] = L"Software\ODBC\ODBC.INI\ODBC Data Sources"; HKEY key; if (!RegCreateKeyExW( root, sourcesW, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL )) return key; return NULL; @@ -860,27 +860,43 @@ static WCHAR *get_reg_value( HKEY key, const WCHAR *name ) return NULL; }
+static HKEY open_odbcinst_key( void ) +{ + static const WCHAR odbcinstW[] = L"Software\ODBC\ODBCINST.INI"; + HKEY key; + if (!RegCreateKeyExW( HKEY_LOCAL_MACHINE, odbcinstW, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL )) return key; + return NULL; +} + static WCHAR *get_driver_filename( const SQLWCHAR *source ) { - HKEY key_root, key_source; - WCHAR *ret = NULL; + HKEY key_sources, key_odbcinst, key_driver; + WCHAR *driver_name, *ret;
- if (!(key_root = open_odbcini_key( HKEY_CURRENT_USER ))) return NULL; - if (!RegOpenKeyExW( key_root, source, 0, KEY_READ, &key_source )) + if (!(key_sources = open_sources_key( HKEY_CURRENT_USER ))) return NULL; + if (!(driver_name = get_reg_value( key_sources, source ))) { - ret = get_reg_value( key_source, L"Driver" ); - RegCloseKey( key_source ); + RegCloseKey( key_sources ); + if (!(key_sources = open_sources_key( HKEY_LOCAL_MACHINE ))) return NULL; + if (!(driver_name = get_reg_value( key_sources, source ))) + { + RegCloseKey( key_sources ); + return NULL; + } } - RegCloseKey( key_root ); - if (ret) return ret; + RegCloseKey( key_sources );
- if (!(key_root = open_odbcini_key( HKEY_LOCAL_MACHINE ))) return NULL; - if (!RegOpenKeyExW( key_root, source, 0, KEY_READ, &key_source )) + if (!(key_odbcinst = open_odbcinst_key()) || RegOpenKeyExW( key_odbcinst, driver_name, 0, KEY_READ, &key_driver )) { - ret = get_reg_value( key_source, L"Driver" ); - RegCloseKey( key_source ); + RegCloseKey( key_odbcinst ); + free( driver_name ); + return NULL; } - RegCloseKey( key_root ); + + ret = get_reg_value( key_driver, L"Driver" ); + + RegCloseKey( key_driver ); + RegCloseKey( key_odbcinst ); return ret; }
@@ -1100,14 +1116,6 @@ SQLRETURN WINAPI SQLCopyDesc(SQLHDESC SourceDescHandle, SQLHDESC TargetDescHandl return ret; }
-static HKEY open_sources_key( HKEY root ) -{ - static const WCHAR sourcesW[] = L"Software\ODBC\ODBC.INI\ODBC Data Sources"; - HKEY key; - if (!RegCreateKeyExW( root, sourcesW, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL )) return key; - return NULL; -} - /************************************************************************* * SQLDataSources [ODBC32.057] */
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=147218
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/odbc32/proxyodbc.c:1327 error: patch failed: dlls/odbc32/proxyodbc.c:1176 Task: Patch failed to apply