SQLFreeSTMT doesn't use the generic function as it cause a crash when the FreeHandle was called (mysql).
-- v2: odbc32: Support Allocating SQL handles for ODBC v2 drivers. odbc32: SQLSetEnvAttr isnt supported in ODBC v2.0 odbc32: Support freeing SQL handles for ODBC v2 drivers.
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 c2625fc5f8a..aed377cbeef 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1571,6 +1571,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] */ @@ -1590,7 +1621,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 ); @@ -1617,7 +1648,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 ); @@ -1667,7 +1698,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 );
From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/odbc32/proxyodbc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index aed377cbeef..3e808106406 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -908,7 +908,7 @@ static int has_suffix( const WCHAR *str, const WCHAR *suffix )
static SQLRETURN set_env_attr( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) { - SQLRETURN ret = SQL_ERROR; + SQLRETURN ret = SQL_SUCCESS;
if (handle->unix_handle) { @@ -917,7 +917,8 @@ static SQLRETURN set_env_attr( struct handle *handle, SQLINTEGER attr, SQLPOINTE } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetEnvAttr( handle->win32_handle, attr, value, len ); + if (handle->win32_funcs->SQLSetEnvAttr) + ret = handle->win32_funcs->SQLSetEnvAttr( handle->win32_handle, attr, value, len ); } return ret; }
From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/odbc32/proxyodbc.c | 42 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 3e808106406..54e0800128e 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -410,6 +410,38 @@ SQLRETURN WINAPI SQLAllocEnv(SQLHENV *EnvironmentHandle) return ret; }
+static SQLRETURN allochandle_win32(struct handle *handle, SQLSMALLINT type, SQLHANDLE InputHandle, SQLHANDLE *OutputHandle) +{ + SQLRETURN ret = SQL_ERROR; + + if (handle->win32_funcs->SQLAllocHandle) + { + if ((ret = handle->win32_funcs->SQLAllocHandle( type, InputHandle, OutputHandle ))) + return ret; + } + else + { + /* ODBC v2 */ + if (type == SQL_HANDLE_ENV) + { + if (handle->win32_funcs->SQLAllocEnv) + ret = handle->win32_funcs->SQLAllocEnv( OutputHandle ); + } + else if (type == SQL_HANDLE_DBC) + { + if (handle->win32_funcs->SQLAllocConnect) + ret = handle->win32_funcs->SQLAllocConnect( InputHandle, OutputHandle ); + } + else if (type == SQL_HANDLE_STMT) + { + if (handle->win32_funcs->SQLAllocStmt) + ret = handle->win32_funcs->SQLAllocStmt( InputHandle, OutputHandle ); + } + } + + return ret; +} + /************************************************************************* * SQLAllocHandle [ODBC32.024] */ @@ -438,7 +470,7 @@ SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, S } else if (input->win32_handle) { - ret = input->win32_funcs->SQLAllocHandle( HandleType, input->win32_handle, &output->win32_handle ); + ret = allochandle_win32(input, HandleType, input->win32_handle, &output->win32_handle); if (SUCCESS( ret )) output->win32_funcs = input->win32_funcs; }
@@ -469,7 +501,7 @@ SQLRETURN WINAPI SQLAllocStmt(SQLHDBC ConnectionHandle, SQLHSTMT *StatementHandl } else if (con->win32_handle) { - ret = con->win32_funcs->SQLAllocStmt( con->win32_handle, &stmt->win32_handle ); + ret = allochandle_win32(con, SQL_HANDLE_STMT, con->win32_handle, &stmt->win32_handle ); if (SUCCESS( ret )) stmt->win32_funcs = con->win32_funcs; }
@@ -508,7 +540,7 @@ SQLRETURN WINAPI SQLAllocHandleStd(SQLSMALLINT HandleType, SQLHANDLE InputHandle } else if (input->win32_handle) { - ret = input->win32_funcs->SQLAllocHandleStd( HandleType, input->win32_handle, &output->win32_handle ); + ret = allochandle_win32(input, HandleType, input->win32_handle, &output->win32_handle); if (SUCCESS( ret )) output->win32_funcs = input->win32_funcs; }
@@ -943,7 +975,7 @@ static SQLRETURN create_env( struct handle *handle, BOOL is_unix ) } else { - if ((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_ENV, NULL, &handle->win32_handle ))) return ret; + if ((ret = allochandle_win32(handle, SQL_HANDLE_ENV, NULL, &handle->win32_handle ))) return ret; }
return prepare_env( handle ); @@ -999,7 +1031,7 @@ static SQLRETURN create_con( struct handle *handle ) } else { - if ((ret = handle->win32_funcs->SQLAllocHandle( SQL_HANDLE_DBC, parent->win32_handle, &handle->win32_handle ))) + if ((ret = allochandle_win32(handle, SQL_HANDLE_DBC, parent->win32_handle, &handle->win32_handle ))) return ret; }
This merge request was closed by Alistair Leslie-Hughes.