From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/odbc32/proxyodbc.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index b71ef7aac42..2a38197b243 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1401,6 +1401,37 @@ SQLRETURN WINAPI SQLFetchScroll(SQLHSTMT StatementHandle, SQLSMALLINT FetchOrien return ret; }
+static SQLRETURN freehandle_win32(struct handle *handle, SQLSMALLINT type, SQLUSMALLINT option) +{ + SQLRETURN ret = SQL_ERROR; + + if (handle->win32_funcs->SQLFreeHandle) + { + ret = handle->win32_funcs->SQLFreeHandle( type, handle->win32_handle ); + } + else + { + /* ODBC v2 */ + if (type == SQL_HANDLE_ENV) + { + if (handle->win32_funcs->SQLFreeEnv) + ret = handle->win32_funcs->SQLFreeEnv( handle->win32_handle ); + } + else if (type == SQL_HANDLE_DBC) + { + if (handle->win32_funcs->SQLFreeConnect) + ret = handle->win32_funcs->SQLFreeConnect( handle->win32_handle ); + } + else if (type == SQL_HANDLE_STMT) + { + if (handle->win32_funcs->SQLFreeStmt) + ret = handle->win32_funcs->SQLFreeStmt( handle->win32_handle, option ); + } + } + + return ret; +} + /************************************************************************* * SQLFreeConnect [ODBC32.014] */ @@ -1420,7 +1451,7 @@ SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle) } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLFreeHandle( SQL_HANDLE_DBC, handle->win32_handle ); + ret = freehandle_win32( handle, SQL_HANDLE_DBC, 0 ); }
free( handle ); @@ -1447,7 +1478,7 @@ SQLRETURN WINAPI SQLFreeEnv(SQLHENV EnvironmentHandle) } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLFreeHandle( SQL_HANDLE_ENV, handle->win32_handle ); + ret = freehandle_win32( handle, SQL_HANDLE_ENV, 0 ); }
RegCloseKey( handle->drivers_key ); @@ -1497,7 +1528,7 @@ SQLRETURN WINAPI SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLFreeHandle( HandleType, handle->win32_handle ); + ret = freehandle_win32( handle, HandleType, 0 ); }
RegCloseKey( handle->drivers_key );