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 741555f6582..e8e08fb7d00 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; }
@@ -874,7 +906,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 ); @@ -930,7 +962,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; }