From abf4b4db07f23b4b3b1354159c737c55fdb230cd Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Thu, 8 May 2025 12:15:13 +1000 Subject: [PATCH] Updated odbc32-fixes patchset Some older ANSI drivers have a limit on the number of environment handles that can be created. So reuse existing environment variable for each connection when possible. --- ...Connect-W-reuse-environment-handle-i.patch | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 patches/odbc32-fixes/0025-odbc32-SQLDriverConnect-W-reuse-environment-handle-i.patch diff --git a/patches/odbc32-fixes/0025-odbc32-SQLDriverConnect-W-reuse-environment-handle-i.patch b/patches/odbc32-fixes/0025-odbc32-SQLDriverConnect-W-reuse-environment-handle-i.patch new file mode 100644 index 00000000..69018037 --- /dev/null +++ b/patches/odbc32-fixes/0025-odbc32-SQLDriverConnect-W-reuse-environment-handle-i.patch @@ -0,0 +1,61 @@ +From 2af873781003a7daa60c8e7f4652afb0d8097009 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Wed, 7 May 2025 14:26:13 +1000 +Subject: [PATCH] odbc32: SQLDriverConnect/W reuse environment handle is + possible + +--- + dlls/odbc32/proxyodbc.c | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index 770b455ad5d..93c0ddc817c 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -5792,6 +5792,8 @@ SQLRETURN WINAPI SQLDriverConnect(SQLHDBC ConnectionHandle, SQLHWND WindowHandle + + if (has_suffix( filename, L".dll" )) + { ++ struct environment *env; ++ + if (!(con->hdr.win32_funcs = con->hdr.parent->win32_funcs = load_driver( filename ))) + { + WARN( "failed to load driver %s\n", debugstr_w(filename) ); +@@ -5799,7 +5801,11 @@ SQLRETURN WINAPI SQLDriverConnect(SQLHDBC ConnectionHandle, SQLHWND WindowHandle + } + TRACE( "using Windows driver %s\n", debugstr_w(filename) ); + +- if (!SUCCESS((ret = create_env( (struct environment *)con->hdr.parent, FALSE )))) goto done; ++ env = (struct environment *)find_object_type(SQL_HANDLE_ENV, con->hdr.parent); ++ if (!env || !env->hdr.win32_handle) ++ { ++ if (!SUCCESS((ret = create_env( (struct environment *)con->hdr.parent, FALSE )))) goto done; ++ } + if (!SUCCESS((ret = create_con( con )))) goto done; + + ret = driver_connect_win32_a( con, WindowHandle, strA, Length, OutConnectionString, BufferLength, Length2, +@@ -7179,6 +7185,7 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl + + if (has_suffix( filename, L".dll" )) + { ++ struct environment *env; + if (!(con->hdr.win32_funcs = con->hdr.parent->win32_funcs = load_driver( filename ))) + { + WARN( "failed to load driver %s\n", debugstr_w(filename) ); +@@ -7186,7 +7193,12 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl + } + TRACE( "using Windows driver %s\n", debugstr_w(filename) ); + +- if (!SUCCESS((ret = create_env( (struct environment *)con->hdr.parent, FALSE )))) goto done; ++ env = (struct environment *)find_object_type(SQL_HANDLE_ENV, con->hdr.parent); ++ if (!env || !env->hdr.win32_handle) ++ { ++ if (!SUCCESS((ret = create_env( (struct environment *)con->hdr.parent, FALSE )))) goto done; ++ } ++ + if (!SUCCESS((ret = create_con( con )))) goto done; + + ret = driver_connect_win32_w( con, WindowHandle, InConnectionString, Length, OutConnectionString, +-- +2.47.2 +