From 88e86a23c06d34584652fa75a514ef8045f46c9f Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Fri, 7 Jun 2024 12:55:05 +1000 Subject: [PATCH] Updated odbc-remove-unixodbc patchset Fixes: https://bugs.winehq.org/show_bug.cgi?id=56786 Add support for "Driver=" argument in connection string. --- ...8-odbc32-Implement-SQLDriverConnectW.patch | 44 ++++++++++++++----- ...-version-when-creating-driver-enviro.patch | 13 +++--- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/patches/odbc-remove-unixodbc/0008-odbc32-Implement-SQLDriverConnectW.patch b/patches/odbc-remove-unixodbc/0008-odbc32-Implement-SQLDriverConnectW.patch index 60d92374..282dc3bd 100644 --- a/patches/odbc-remove-unixodbc/0008-odbc32-Implement-SQLDriverConnectW.patch +++ b/patches/odbc-remove-unixodbc/0008-odbc32-Implement-SQLDriverConnectW.patch @@ -1,14 +1,14 @@ -From ed0548c0f726d46beb1684845572e6b27c2de46b Mon Sep 17 00:00:00 2001 +From ad1448a074504eab53c3b465a7636abc1da42317 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Sat, 4 Feb 2023 09:16:29 +1100 Subject: [PATCH] odbc32: Implement SQLDriverConnectW --- - dlls/odbc32/proxyodbc.c | 334 +++++++++++++++++++++++++++++++++++++++- - 1 file changed, 333 insertions(+), 1 deletion(-) + dlls/odbc32/proxyodbc.c | 359 +++++++++++++++++++++++++++++++++++++++- + 1 file changed, 357 insertions(+), 2 deletions(-) diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c -index 8306dc89878..b44aa7fcc2b 100644 +index 57cb27ed3c3..b610b604ca9 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -53,10 +53,247 @@ struct SQLHDBC_data @@ -276,11 +276,11 @@ index 8306dc89878..b44aa7fcc2b 100644 free(hdbc); return SQL_SUCCESS; -@@ -1596,6 +1836,62 @@ SQLRETURN WINAPI SQLColumnsW(SQLHSTMT StatementHandle, WCHAR *CatalogName, SQLSM +@@ -1596,6 +1836,65 @@ SQLRETURN WINAPI SQLColumnsW(SQLHSTMT StatementHandle, WCHAR *CatalogName, SQLSM return ret; } -+static HMODULE load_odbc_driver(const WCHAR *driver) ++static HMODULE load_odbc_driver(const WCHAR *driver, BOOL use_dsn) +{ + long ret; + HMODULE hmod; @@ -288,7 +288,10 @@ index 8306dc89878..b44aa7fcc2b 100644 + HKEY hkey; + WCHAR regpath[256]; + -+ wcscpy(regpath, L"Software\\ODBC\\ODBC.INI\\"); ++ if (use_dsn) ++ wcscpy(regpath, L"Software\\ODBC\\ODBC.INI\\"); ++ else ++ wcscpy(regpath, L"Software\\ODBC\\ODBCINST.INI\\"); + wcscat(regpath, driver); + + if ((ret = RegOpenKeyW(HKEY_CURRENT_USER, regpath, &hkey)) != ERROR_SUCCESS) @@ -339,7 +342,7 @@ index 8306dc89878..b44aa7fcc2b 100644 /************************************************************************* * SQLDriverConnectW [ODBC32.141] */ -@@ -1603,13 +1899,49 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl +@@ -1603,13 +1902,69 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl SQLSMALLINT Length, WCHAR *OutConnectionString, SQLSMALLINT BufferLength, SQLSMALLINT *Length2, SQLUSMALLINT DriverCompletion) { @@ -348,11 +351,13 @@ index 8306dc89878..b44aa7fcc2b 100644 SQLRETURN ret = SQL_ERROR; + WCHAR dsn[128]; + WCHAR *p; ++ BOOL is_dsn = TRUE; - FIXME("(ConnectionHandle %p, WindowHandle %p, InConnectionString %s, Length %d, OutConnectionString %p," + TRACE("(ConnectionHandle %p, WindowHandle %p, InConnectionString %s, Length %d, OutConnectionString %p," " BufferLength %d, Length2 %p, DriverCompletion %d)\n", ConnectionHandle, WindowHandle, - debugstr_wn(InConnectionString, Length), Length, OutConnectionString, BufferLength, Length2, +- debugstr_wn(InConnectionString, Length), Length, OutConnectionString, BufferLength, Length2, ++ Length == SQL_NTS ? debugstr_w(InConnectionString) : debugstr_wn(InConnectionString, Length), Length, OutConnectionString, BufferLength, Length2, DriverCompletion); + p = wcsstr(InConnectionString, L"DSN="); @@ -362,8 +367,19 @@ index 8306dc89878..b44aa7fcc2b 100644 + + lstrcpynW(dsn, p+4, end - (p + 3)); + } ++ else ++ { ++ p = wcsstr(InConnectionString, L"Driver="); ++ if (p) ++ { ++ WCHAR *end = wcsstr(p, L";"); + -+ driver = load_odbc_driver(dsn); ++ lstrcpynW(dsn, p+7, end - (p + 6)); ++ is_dsn = FALSE; ++ } ++ } ++ ++ driver = load_odbc_driver(dsn, is_dsn); + if (!driver) + return SQL_ERROR; + @@ -375,6 +391,14 @@ index 8306dc89878..b44aa7fcc2b 100644 + connection->pSQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &connection->driver_env); + connection->pSQLAllocHandle(SQL_HANDLE_DBC, connection->driver_env, &connection->driver_hdbc); + } ++ else if(connection->pSQLAllocConnect && connection->pSQLAllocEnv) ++ { ++ connection->pSQLAllocEnv(&connection->driver_env); ++ ++ connection->pSQLAllocConnect(connection->driver_env, &connection->driver_hdbc); ++ } ++ else ++ ERR("No functions to allocated Environment handles found.\n"); + + if(!connection->pSQLDriverConnectW) + { diff --git a/patches/odbc-remove-unixodbc/0039-odbc32-Pass-ODBC-version-when-creating-driver-enviro.patch b/patches/odbc-remove-unixodbc/0039-odbc32-Pass-ODBC-version-when-creating-driver-enviro.patch index cadc7996..e2df2c07 100644 --- a/patches/odbc-remove-unixodbc/0039-odbc32-Pass-ODBC-version-when-creating-driver-enviro.patch +++ b/patches/odbc-remove-unixodbc/0039-odbc32-Pass-ODBC-version-when-creating-driver-enviro.patch @@ -1,18 +1,17 @@ -From 51a3447adf38839ab44b8b7e91baf5de66055125 Mon Sep 17 00:00:00 2001 +From e74193b1a57027b193e190fa41c5b85eee39e1b8 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 8 Feb 2023 09:03:40 +1100 -Subject: [PATCH 39/42] odbc32: Pass ODBC version when creating driver - environment +Subject: [PATCH] odbc32: Pass ODBC version when creating driver environment --- dlls/odbc32/proxyodbc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c -index 46872add8b0..851d2535ca1 100644 +index 901e2dca006..35ff5b7fc35 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c -@@ -2552,6 +2552,11 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl +@@ -2546,6 +2546,11 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl if (connection->pSQLAllocHandle) { connection->pSQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &connection->driver_env); @@ -23,7 +22,7 @@ index 46872add8b0..851d2535ca1 100644 + connection->pSQLAllocHandle(SQL_HANDLE_DBC, connection->driver_env, &connection->driver_hdbc); } - + else if(connection->pSQLAllocConnect && connection->pSQLAllocEnv) -- -2.39.1 +2.43.0