From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index e5d57052c16..df6f146af54 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -314,6 +314,15 @@ static BOOL load_function_table( HMODULE module, struct win32_driver *driver ) #undef LOAD_FUNCPTR }
+static CRITICAL_SECTION loader_cs; +static CRITICAL_SECTION_DEBUG loader_cs_debug = +{ + 0, 0, &loader_cs, + { &loader_cs_debug.ProcessLocksList, &loader_cs_debug.ProcessLocksList }, + 0, 0, { (ULONG_PTR)(__FILE__ ": loader_cs") } +}; +static CRITICAL_SECTION loader_cs = { &loader_cs_debug, -1, 0, 0, 0, 0 }; + static struct { UINT32 count; @@ -341,12 +350,21 @@ static const struct win32_funcs *load_driver( const WCHAR *filename ) WCHAR *ptr; UINT32 i;
+ EnterCriticalSection( &loader_cs ); for (i = 0; i < win32_drivers.count; i++) { - if (!wcsicmp( filename, win32_drivers.drivers[i]->filename )) return &win32_drivers.drivers[i]->funcs; + if (!wcsicmp( filename, win32_drivers.drivers[i]->filename )) + { + LeaveCriticalSection( &loader_cs ); + return &win32_drivers.drivers[i]->funcs; + } }
- if (!(driver = malloc( sizeof(*driver) + (wcslen(filename) + 1) * sizeof(WCHAR) ))) return NULL; + if (!(driver = malloc( sizeof(*driver) + (wcslen(filename) + 1) * sizeof(WCHAR) ))) + { + LeaveCriticalSection( &loader_cs ); + return NULL; + } ptr = (WCHAR *)(driver + 1); wcscpy( ptr, filename ); driver->filename = ptr; @@ -355,6 +373,7 @@ static const struct win32_funcs *load_driver( const WCHAR *filename ) if (!module) { free( driver ); + LeaveCriticalSection( &loader_cs ); return NULL; }
@@ -362,9 +381,11 @@ static const struct win32_funcs *load_driver( const WCHAR *filename ) { FreeLibrary( module ); free( driver ); + LeaveCriticalSection( &loader_cs ); return NULL; }
+ LeaveCriticalSection( &loader_cs ); return &driver->funcs; }
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 1010 +++++++++++++++++++++++++++++++-------- 1 file changed, 800 insertions(+), 210 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index df6f146af54..c9de14a3820 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -431,6 +431,23 @@ SQLRETURN WINAPI SQLAllocEnv(SQLHENV *EnvironmentHandle) return ret; }
+static SQLRETURN alloc_handle_unix( SQLSMALLINT type, struct handle *input, struct handle *output ) +{ + struct SQLAllocHandle_params params = { type, input->unix_handle, &output->unix_handle }; + return ODBC_CALL( SQLAllocHandle, ¶ms ); +} + +static SQLRETURN alloc_handle_win32( SQLSMALLINT type, struct handle *input, struct handle *output ) +{ + if (input->win32_funcs->SQLAllocHandle) + { + SQLRETURN ret = input->win32_funcs->SQLAllocHandle( type, input->win32_handle, &output->win32_handle ); + if (SUCCESS( ret )) output->win32_funcs = input->win32_funcs; + return ret; + } + return SQL_ERROR; +} + /************************************************************************* * SQLAllocHandle [ODBC32.024] */ @@ -454,13 +471,11 @@ SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, S
if (input->unix_handle) { - struct SQLAllocHandle_params params = { HandleType, input->unix_handle, &output->unix_handle }; - ret = ODBC_CALL( SQLAllocHandle, ¶ms ); + ret = alloc_handle_unix( HandleType, input, output ); } else if (input->win32_handle) { - ret = input->win32_funcs->SQLAllocHandle( HandleType, input->win32_handle, &output->win32_handle ); - if (SUCCESS( ret )) output->win32_funcs = input->win32_funcs; + ret = alloc_handle_win32( HandleType, input, output ); }
if (SUCCESS( ret )) *OutputHandle = output; @@ -470,6 +485,22 @@ SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, S return ret; }
+static SQLRETURN alloc_stmt_unix( struct handle *con, struct handle *stmt ) +{ + struct SQLAllocStmt_params params = { con->unix_handle, &stmt->unix_handle }; + return ODBC_CALL( SQLAllocStmt, ¶ms ); +} + +static SQLRETURN alloc_stmt_win32( struct handle *con, struct handle *stmt ) +{ + if (con->win32_funcs->SQLAllocStmt) + { + SQLRETURN ret = con->win32_funcs->SQLAllocStmt( con->win32_handle, &stmt->win32_handle ); + if (SUCCESS( ret )) stmt->win32_funcs = con->win32_funcs; + } + return SQL_ERROR; +} + /************************************************************************* * SQLAllocStmt [ODBC32.003] */ @@ -485,13 +516,11 @@ SQLRETURN WINAPI SQLAllocStmt(SQLHDBC ConnectionHandle, SQLHSTMT *StatementHandl
if (con->unix_handle) { - struct SQLAllocStmt_params params = { con->unix_handle, &stmt->unix_handle }; - ret = ODBC_CALL( SQLAllocStmt, ¶ms ); + ret = alloc_stmt_unix( con, stmt ); } else if (con->win32_handle) { - ret = con->win32_funcs->SQLAllocStmt( con->win32_handle, &stmt->win32_handle ); - if (SUCCESS( ret )) stmt->win32_funcs = con->win32_funcs; + ret = alloc_stmt_win32( con, stmt ); }
if (SUCCESS( ret )) *StatementHandle = stmt; @@ -501,6 +530,23 @@ SQLRETURN WINAPI SQLAllocStmt(SQLHDBC ConnectionHandle, SQLHSTMT *StatementHandl return ret; }
+static SQLRETURN alloc_handle_std_unix( SQLSMALLINT type, struct handle *input, struct handle *output ) +{ + struct SQLAllocHandleStd_params params = { type, input->unix_handle, &output->unix_handle }; + return ODBC_CALL( SQLAllocHandleStd, ¶ms ); +} + +static SQLRETURN alloc_handle_std_win32( SQLSMALLINT type, struct handle *input, struct handle *output ) +{ + if (input->win32_funcs->SQLAllocHandleStd) + { + SQLRETURN ret = input->win32_funcs->SQLAllocHandleStd( type, input->win32_handle, &output->win32_handle ); + if (SUCCESS( ret )) output->win32_funcs = input->win32_funcs; + return ret; + } + return SQL_ERROR; +} + /************************************************************************* * SQLAllocHandleStd [ODBC32.077] */ @@ -524,13 +570,11 @@ SQLRETURN WINAPI SQLAllocHandleStd(SQLSMALLINT HandleType, SQLHANDLE InputHandle
if (input->unix_handle) { - struct SQLAllocHandleStd_params params = { HandleType, input->unix_handle, &output->unix_handle }; - ret = ODBC_CALL( SQLAllocHandleStd, ¶ms ); + ret = alloc_handle_std_unix( HandleType, input, output ); } else if (input->win32_handle) { - ret = input->win32_funcs->SQLAllocHandleStd( HandleType, input->win32_handle, &output->win32_handle ); - if (SUCCESS( ret )) output->win32_funcs = input->win32_funcs; + ret = alloc_handle_std_win32( HandleType, input, output ); }
if (SUCCESS( ret )) *OutputHandle = output; @@ -565,6 +609,38 @@ static BOOL alloc_binding( struct param_binding *binding, USHORT type, UINT colu return TRUE; }
+static SQLRETURN bind_col_unix( struct handle *handle, SQLUSMALLINT column, SQLSMALLINT type, SQLPOINTER value, + SQLLEN buflen, SQLLEN *retlen ) +{ + struct SQLBindCol_params params = { handle->unix_handle, column, type, value, buflen }; + UINT i = column - 1; + SQLRETURN ret; + + if (!column) + { + FIXME( "column 0 not handled\n" ); + return SQL_ERROR; + } + + if (!alloc_binding( &handle->bind_col, SQL_PARAM_INPUT_OUTPUT, column, handle->row_count )) + return SQL_ERROR; + handle->bind_col.param[i].col.target_type = type; + handle->bind_col.param[i].col.target_value = value; + handle->bind_col.param[i].col.buffer_length = buflen; + + if (retlen) params.StrLen_or_Ind = handle->bind_col.param[i].len; + if (SUCCESS(( ret = ODBC_CALL( SQLBindCol, ¶ms )))) handle->bind_col.param[i].ptr = retlen; + return ret; +} + +static SQLRETURN bind_col_win32( struct handle *handle, SQLUSMALLINT column, SQLSMALLINT type, SQLPOINTER value, + SQLLEN buflen, SQLLEN *retlen ) +{ + if (handle->win32_funcs->SQLBindCol) + return SQLBindCol( handle->win32_handle, column, type, value, buflen, retlen ); + return SQL_ERROR; +} + /************************************************************************* * SQLBindCol [ODBC32.004] */ @@ -581,28 +657,11 @@ SQLRETURN WINAPI SQLBindCol(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber,
if (handle->unix_handle) { - UINT i = ColumnNumber - 1; - struct SQLBindCol_params params = { handle->unix_handle, ColumnNumber, TargetType, TargetValue, BufferLength }; - - if (!ColumnNumber) - { - FIXME( "column 0 not handled\n" ); - return SQL_ERROR; - } - - if (!alloc_binding( &handle->bind_col, SQL_PARAM_INPUT_OUTPUT, ColumnNumber, handle->row_count )) - return SQL_ERROR; - handle->bind_col.param[i].col.target_type = TargetType; - handle->bind_col.param[i].col.target_value = TargetValue; - handle->bind_col.param[i].col.buffer_length = BufferLength; - - if (StrLen_or_Ind) params.StrLen_or_Ind = handle->bind_col.param[i].len; - if (SUCCESS(( ret = ODBC_CALL( SQLBindCol, ¶ms )))) handle->bind_col.param[i].ptr = StrLen_or_Ind; + ret = bind_col_unix( handle, ColumnNumber, TargetType, TargetValue, BufferLength, StrLen_or_Ind ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLBindCol( handle->win32_handle, ColumnNumber, TargetType, TargetValue, - BufferLength, StrLen_or_Ind ); + ret = bind_col_win32( handle, ColumnNumber, TargetType, TargetValue, BufferLength, StrLen_or_Ind ); }
TRACE ("Returning %d\n", ret); @@ -631,6 +690,19 @@ SQLRETURN WINAPI SQLBindParam(SQLHSTMT StatementHandle, SQLUSMALLINT ParameterNu return SQL_ERROR; }
+static SQLRETURN cancel_unix( struct handle *handle ) +{ + struct SQLCancel_params params = { handle->unix_handle }; + return ODBC_CALL( SQLCancel, ¶ms ); +} + +static SQLRETURN cancel_win32( struct handle *handle ) +{ + if (handle->win32_funcs->SQLCancel) + return handle->win32_funcs->SQLCancel( handle->win32_handle ); + return SQL_ERROR; +} + /************************************************************************* * SQLCancel [ODBC32.005] */ @@ -645,18 +717,30 @@ SQLRETURN WINAPI SQLCancel(SQLHSTMT StatementHandle)
if (handle->unix_handle) { - struct SQLCancel_params params = { handle->unix_handle }; - ret = ODBC_CALL( SQLCancel, ¶ms ); + ret = cancel_unix( handle ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLCancel( handle->win32_handle ); + ret = cancel_win32( handle ); }
TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN close_cursor_unix( struct handle *handle ) +{ + struct SQLCloseCursor_params params = { handle->unix_handle }; + return ODBC_CALL( SQLCloseCursor, ¶ms ); +} + +static SQLRETURN close_cursor_win32( struct handle *handle ) +{ + if (handle->win32_funcs->SQLCloseCursor) + return handle->win32_funcs->SQLCloseCursor( handle->win32_handle ); + return SQL_ERROR; +} + /************************************************************************* * SQLCloseCursor [ODBC32.026] */ @@ -671,12 +755,11 @@ SQLRETURN WINAPI SQLCloseCursor(SQLHSTMT StatementHandle)
if (handle->unix_handle) { - struct SQLCloseCursor_params params = { handle->unix_handle }; - ret = ODBC_CALL( SQLCloseCursor, ¶ms ); + ret = close_cursor_unix( handle ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLCloseCursor( handle->win32_handle ); + ret = close_cursor_win32( handle ); }
TRACE("Returning %d\n", ret); @@ -1109,6 +1192,19 @@ done: return ret; }
+static SQLRETURN copy_desc_unix( struct handle *source, struct handle *target ) +{ + struct SQLCopyDesc_params params = { source->unix_handle, target->unix_handle }; + return ODBC_CALL( SQLCopyDesc, ¶ms ); +} + +static SQLRETURN copy_desc_win32( struct handle *source, struct handle *target ) +{ + if (source->win32_funcs->SQLCopyDesc) + return source->win32_funcs->SQLCopyDesc( source->win32_handle, target->win32_handle ); + return SQL_ERROR; +} + /************************************************************************* * SQLCopyDesc [ODBC32.028] */ @@ -1123,12 +1219,11 @@ SQLRETURN WINAPI SQLCopyDesc(SQLHDESC SourceDescHandle, SQLHDESC TargetDescHandl
if (source->unix_handle) { - struct SQLCopyDesc_params params = { source->unix_handle, target->unix_handle }; - ret = ODBC_CALL( SQLCopyDesc, ¶ms ); + ret = copy_desc_unix( source, target ); } else if (source->win32_handle) { - ret = source->win32_funcs->SQLCopyDesc( source->win32_handle, target->win32_handle ); + ret = copy_desc_win32( source, target ); }
TRACE("Returning %d\n", ret); @@ -1276,6 +1371,19 @@ SQLRETURN WINAPI SQLDescribeCol(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNum return ret; }
+static SQLRETURN disconnect_unix( struct handle *handle ) +{ + struct SQLDisconnect_params params = { handle->unix_handle }; + return ODBC_CALL( SQLDisconnect, ¶ms ); +} + +static SQLRETURN disconnect_win32( struct handle *handle ) +{ + if (handle->win32_funcs->SQLDisconnect) + return handle->win32_funcs->SQLDisconnect( handle->win32_handle ); + return SQL_ERROR; +} + /************************************************************************* * SQLDisconnect [ODBC32.009] */ @@ -1290,18 +1398,30 @@ SQLRETURN WINAPI SQLDisconnect(SQLHDBC ConnectionHandle)
if (handle->unix_handle) { - struct SQLDisconnect_params params = { handle->unix_handle }; - ret = ODBC_CALL( SQLDisconnect, ¶ms ); + ret = disconnect_unix( handle ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLDisconnect( handle->win32_handle ); + ret = disconnect_win32( handle ); }
TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN end_tran_unix( SQLSMALLINT handle_type, struct handle *handle, SQLSMALLINT completion_type ) +{ + struct SQLEndTran_params params = { handle_type, handle->unix_handle, completion_type }; + return ODBC_CALL( SQLEndTran, ¶ms ); +} + +static SQLRETURN end_tran_win32( SQLSMALLINT handle_type, struct handle *handle, SQLSMALLINT completion_type ) +{ + if (handle->win32_funcs->SQLEndTran) + return handle->win32_funcs->SQLEndTran( handle_type, handle->win32_handle, completion_type ); + return SQL_ERROR; +} + /************************************************************************* * SQLEndTran [ODBC32.029] */ @@ -1316,12 +1436,11 @@ SQLRETURN WINAPI SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLIN
if (handle->unix_handle) { - struct SQLEndTran_params params = { HandleType, handle->unix_handle, CompletionType }; - ret = ODBC_CALL( SQLEndTran, ¶ms ); + ret = end_tran_unix( HandleType, handle, CompletionType ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLEndTran( HandleType, handle->win32_handle, CompletionType ); + ret = end_tran_win32( HandleType, handle, CompletionType ); }
TRACE("Returning %d\n", ret); @@ -1508,6 +1627,23 @@ static void update_result_lengths( struct handle *handle, USHORT type ) } }
+static SQLRETURN execute_unix( struct handle *handle ) +{ + struct SQLExecute_params params = { handle->unix_handle }; + SQLRETURN ret; + + update_result_lengths( handle, SQL_PARAM_INPUT ); + if (SUCCESS((ret = ODBC_CALL( SQLExecute, ¶ms )))) update_result_lengths( handle, SQL_PARAM_OUTPUT ); + return ret; +} + +static SQLRETURN execute_win32( struct handle *handle ) +{ + if (handle->win32_funcs->SQLExecute) + return handle->win32_funcs->SQLExecute( handle->win32_handle ); + return SQL_ERROR; +} + /************************************************************************* * SQLExecute [ODBC32.012] */ @@ -1522,19 +1658,33 @@ SQLRETURN WINAPI SQLExecute(SQLHSTMT StatementHandle)
if (handle->unix_handle) { - struct SQLExecute_params params = { handle->unix_handle }; - update_result_lengths( handle, SQL_PARAM_INPUT ); - if (SUCCESS(( ret = ODBC_CALL( SQLExecute, ¶ms )))) update_result_lengths( handle, SQL_PARAM_OUTPUT ); + ret = execute_unix( handle ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLExecute( handle->win32_handle ); + ret = execute_win32( handle ); }
TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN fetch_unix( struct handle *handle ) +{ + struct SQLFetch_params params = { handle->unix_handle }; + SQLRETURN ret; + + if (SUCCESS(( ret = ODBC_CALL( SQLFetch, ¶ms )))) update_result_lengths( handle, SQL_PARAM_OUTPUT ); + return ret; +} + +static SQLRETURN fetch_win32( struct handle *handle ) +{ + if (handle->win32_funcs->SQLFetch) + return handle->win32_funcs->SQLFetch( handle->win32_handle ); + return SQL_ERROR; +} + /************************************************************************* * SQLFetch [ODBC32.013] */ @@ -1549,18 +1699,33 @@ SQLRETURN WINAPI SQLFetch(SQLHSTMT StatementHandle)
if (handle->unix_handle) { - struct SQLFetch_params params = { handle->unix_handle }; - if (SUCCESS(( ret = ODBC_CALL( SQLFetch, ¶ms )))) update_result_lengths( handle, SQL_PARAM_OUTPUT ); + ret = fetch_unix( handle ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLFetch( handle->win32_handle ); + ret = fetch_win32( handle ); }
TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN fetch_scroll_unix( struct handle *handle, SQLSMALLINT orientation, SQLLEN offset ) +{ + struct SQLFetchScroll_params params = { handle->unix_handle, orientation, offset }; + SQLRETURN ret; + + if (SUCCESS((ret = ODBC_CALL( SQLFetchScroll, ¶ms )))) update_result_lengths( handle, SQL_PARAM_OUTPUT ); + return ret; +} + +static SQLRETURN fetch_scroll_win32( struct handle *handle, SQLSMALLINT orientation, SQLLEN offset ) +{ + if (handle->win32_funcs->SQLFetchScroll) + return handle->win32_funcs->SQLFetchScroll( handle->win32_handle, orientation, offset ); + return SQL_ERROR; +} + /************************************************************************* * SQLFetchScroll [ODBC32.030] */ @@ -1576,18 +1741,32 @@ SQLRETURN WINAPI SQLFetchScroll(SQLHSTMT StatementHandle, SQLSMALLINT FetchOrien
if (handle->unix_handle) { - struct SQLFetchScroll_params params = { handle->unix_handle, FetchOrientation, FetchOffset }; - if (SUCCESS(( ret = ODBC_CALL( SQLFetchScroll, ¶ms )))) update_result_lengths( handle, SQL_PARAM_OUTPUT ); + ret = fetch_scroll_unix( handle, FetchOrientation, FetchOffset ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLFetchScroll( handle->win32_handle, FetchOrientation, FetchOffset ); + ret = fetch_scroll_win32( handle, FetchOrientation, FetchOffset ); }
TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN free_connect_unix( struct handle *handle ) +{ + struct SQLFreeConnect_params params = { handle->unix_handle }; + return ODBC_CALL( SQLFreeConnect, ¶ms ); +} + +static SQLRETURN free_connect_win32( struct handle *handle ) +{ + if (handle->win32_funcs->SQLFreeHandle) + return handle->win32_funcs->SQLFreeHandle( SQL_HANDLE_DBC, handle->win32_handle ); + if (handle->win32_funcs->SQLFreeConnect) + return handle->win32_funcs->SQLFreeConnect( handle->win32_handle ); + return SQL_ERROR; +} + /************************************************************************* * SQLFreeConnect [ODBC32.014] */ @@ -1602,12 +1781,11 @@ SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle)
if (handle->unix_handle) { - struct SQLFreeHandle_params params = { SQL_HANDLE_DBC, handle->unix_handle }; - ret = ODBC_CALL( SQLFreeHandle, ¶ms ); + ret = free_connect_unix( handle ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLFreeHandle( SQL_HANDLE_DBC, handle->win32_handle ); + ret = free_connect_win32( handle ); }
free( handle ); @@ -1615,6 +1793,21 @@ SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle) return ret; }
+static SQLRETURN free_env_unix( struct handle *handle ) +{ + struct SQLFreeEnv_params params = { handle->unix_handle }; + return ODBC_CALL( SQLFreeEnv, ¶ms ); +} + +static SQLRETURN free_env_win32( struct handle *handle ) +{ + if (handle->win32_funcs->SQLFreeHandle) + return handle->win32_funcs->SQLFreeHandle( SQL_HANDLE_ENV, handle->win32_handle ); + if (handle->win32_funcs->SQLFreeEnv) + return handle->win32_funcs->SQLFreeEnv( handle->win32_handle ); + return SQL_ERROR; +} + /************************************************************************* * SQLFreeEnv [ODBC32.015] */ @@ -1629,12 +1822,11 @@ SQLRETURN WINAPI SQLFreeEnv(SQLHENV EnvironmentHandle)
if (handle->unix_handle) { - struct SQLFreeHandle_params params = { SQL_HANDLE_ENV, handle->unix_handle }; - ret = ODBC_CALL( SQLFreeHandle, ¶ms ); + ret = free_env_unix( handle ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLFreeHandle( SQL_HANDLE_ENV, handle->win32_handle ); + ret = free_env_win32( handle ); }
RegCloseKey( handle->drivers_key ); @@ -1665,6 +1857,19 @@ static void free_param_bindings( struct handle *handle ) } }
+static SQLRETURN free_handle_unix( SQLSMALLINT type, struct handle *handle ) +{ + struct SQLFreeHandle_params params = { type, handle->unix_handle }; + return ODBC_CALL( SQLFreeHandle, ¶ms ); +} + +static SQLRETURN free_handle_win32( SQLSMALLINT type, struct handle *handle ) +{ + if (handle->win32_funcs->SQLFreeHandle) + return handle->win32_funcs->SQLFreeHandle( type, handle->win32_handle ); + return SQL_ERROR; +} + /************************************************************************* * SQLFreeHandle [ODBC32.031] */ @@ -1679,12 +1884,11 @@ SQLRETURN WINAPI SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
if (handle->unix_handle) { - struct SQLFreeHandle_params params = { HandleType, handle->unix_handle }; - ret = ODBC_CALL( SQLFreeHandle, ¶ms ); + ret = free_handle_unix( HandleType, handle ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLFreeHandle( HandleType, handle->win32_handle ); + ret = free_handle_win32( HandleType, handle ); }
RegCloseKey( handle->drivers_key ); @@ -1697,6 +1901,19 @@ SQLRETURN WINAPI SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) return ret; }
+static SQLRETURN free_stmt_unix( struct handle *handle, SQLUSMALLINT option ) +{ + struct SQLFreeStmt_params params = { handle->unix_handle, option }; + return ODBC_CALL( SQLFreeStmt, ¶ms ); +} + +static SQLRETURN free_stmt_win32( struct handle *handle, SQLUSMALLINT option ) +{ + if (handle->win32_funcs->SQLFreeStmt) + return handle->win32_funcs->SQLFreeStmt( handle->win32_handle, option ); + return SQL_ERROR; +} + /************************************************************************* * SQLFreeStmt [ODBC32.016] */ @@ -1711,12 +1928,11 @@ SQLRETURN WINAPI SQLFreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option)
if (handle->unix_handle) { - struct SQLFreeStmt_params params = { handle->unix_handle, Option }; - ret = ODBC_CALL( SQLFreeStmt, ¶ms ); + ret = free_stmt_unix( handle, Option ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLFreeStmt( handle->win32_handle, Option ); + ret = free_stmt_win32( handle, Option ); }
switch (Option) @@ -1942,6 +2158,25 @@ SQLRETURN WINAPI SQLGetCursorName(SQLHSTMT StatementHandle, SQLCHAR *CursorName, return ret; }
+static SQLRETURN get_data_unix( struct handle *handle, SQLUSMALLINT column, SQLSMALLINT type, SQLPOINTER value, + SQLLEN buflen, SQLLEN *retlen ) +{ + INT64 len; + SQLRETURN ret; + struct SQLGetData_params params = { handle->unix_handle, column, type, value, buflen, &len }; + + if (SUCCESS((ret = ODBC_CALL( SQLGetData, ¶ms )))) *retlen = len; + return ret; +} + +static SQLRETURN get_data_win32( struct handle *handle, SQLUSMALLINT column, SQLSMALLINT type, SQLPOINTER value, + SQLLEN buflen, SQLLEN *retlen ) +{ + if (handle->win32_funcs->SQLGetData) + return handle->win32_funcs->SQLGetData( handle->win32_handle, column, type, value, buflen, retlen ); + return SQL_ERROR; +} + /************************************************************************* * SQLGetData [ODBC32.043] */ @@ -1958,15 +2193,11 @@ SQLRETURN WINAPI SQLGetData(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber,
if (handle->unix_handle) { - INT64 len; - struct SQLGetData_params params = { handle->unix_handle, ColumnNumber, TargetType, TargetValue, - BufferLength, &len }; - if (SUCCESS((ret = ODBC_CALL( SQLGetData, ¶ms )))) *StrLen_or_Ind = len; + ret = get_data_unix( handle, ColumnNumber, TargetType, TargetValue, BufferLength, StrLen_or_Ind ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLGetData( handle->win32_handle, ColumnNumber, TargetType, TargetValue, - BufferLength, StrLen_or_Ind ); + ret = get_data_win32( handle, ColumnNumber, TargetType, TargetValue, BufferLength, StrLen_or_Ind ); }
TRACE("Returning %d\n", ret); @@ -2260,6 +2491,21 @@ SQLRETURN WINAPI SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMAL return ret; }
+static SQLRETURN get_env_attr_unix( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER buflen, + SQLINTEGER *retlen ) +{ + struct SQLGetEnvAttr_params params = { handle->unix_handle, attr, value, buflen, retlen }; + return ODBC_CALL( SQLGetEnvAttr, ¶ms ); +} + +static SQLRETURN get_env_attr_win32( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER buflen, + SQLINTEGER *retlen ) +{ + if (handle->win32_funcs->SQLGetEnvAttr) + return handle->win32_funcs->SQLGetEnvAttr( handle->win32_handle, attr, value, buflen, retlen ); + return SQL_ERROR; +} + /************************************************************************* * SQLGetEnvAttr [ODBC32.037] */ @@ -2276,12 +2522,11 @@ SQLRETURN WINAPI SQLGetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute,
if (handle->unix_handle) { - struct SQLGetEnvAttr_params params = { handle->unix_handle, Attribute, Value, BufferLength, StringLength }; - ret = ODBC_CALL( SQLGetEnvAttr, ¶ms ); + ret = get_env_attr_unix( handle, Attribute, Value, BufferLength, StringLength ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLGetEnvAttr( handle->win32_handle, Attribute, Value, BufferLength, StringLength ); + ret = get_env_attr_win32( handle, Attribute, Value, BufferLength, StringLength ); } else { @@ -2306,6 +2551,19 @@ SQLRETURN WINAPI SQLGetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute, return ret; }
+static SQLRETURN get_functions_unix( struct handle *handle, SQLUSMALLINT id, SQLUSMALLINT *supported ) +{ + struct SQLGetFunctions_params params = { handle->unix_handle, id, supported }; + return ODBC_CALL( SQLGetFunctions, ¶ms ); +} + +static SQLRETURN get_functions_win32( struct handle *handle, SQLUSMALLINT id, SQLUSMALLINT *supported ) +{ + if (handle->win32_funcs->SQLGetFunctions) + return handle->win32_funcs->SQLGetFunctions( handle->win32_handle, id, supported ); + return SQL_ERROR; +} + /************************************************************************* * SQLGetFunctions [ODBC32.044] */ @@ -2320,12 +2578,11 @@ SQLRETURN WINAPI SQLGetFunctions(SQLHDBC ConnectionHandle, SQLUSMALLINT Function
if (handle->unix_handle) { - struct SQLGetFunctions_params params = { handle->unix_handle, FunctionId, Supported }; - ret = ODBC_CALL( SQLGetFunctions, ¶ms ); + ret = get_functions_unix( handle, FunctionId, Supported ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLGetFunctions( handle->win32_handle, FunctionId, Supported ); + ret = get_functions_win32( handle, FunctionId, Supported ); }
TRACE("Returning %d\n", ret); @@ -2522,6 +2779,19 @@ SQLRETURN WINAPI SQLGetStmtAttr(SQLHSTMT StatementHandle, SQLINTEGER Attribute, return ret; }
+static SQLRETURN get_stmt_option_unix( struct handle *handle, SQLUSMALLINT option, SQLPOINTER value ) +{ + struct SQLGetStmtOption_params params = { handle->unix_handle, option, value }; + return ODBC_CALL( SQLGetStmtOption, ¶ms ); +} + +static SQLRETURN get_stmt_option_win32( struct handle *handle, SQLUSMALLINT option, SQLPOINTER value ) +{ + if (handle->win32_funcs->SQLGetStmtOption) + return handle->win32_funcs->SQLGetStmtOption( handle->win32_handle, option, value ); + return SQL_ERROR; +} + /************************************************************************* * SQLGetStmtOption [ODBC32.046] */ @@ -2536,12 +2806,11 @@ SQLRETURN WINAPI SQLGetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option,
if (handle->unix_handle) { - struct SQLGetStmtOption_params params = { handle->unix_handle, Option, Value }; - ret = ODBC_CALL( SQLGetStmtOption, ¶ms ); + ret = get_stmt_option_unix( handle, Option, Value ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLGetStmtOption( handle->win32_handle, Option, Value ); + ret = get_stmt_option_win32( handle, Option, Value ); }
TRACE("Returning %d\n", ret); @@ -2588,6 +2857,19 @@ SQLRETURN WINAPI SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType) return ret; }
+static SQLRETURN get_num_result_cols_unix( struct handle *handle, SQLSMALLINT *count ) +{ + struct SQLNumResultCols_params params = { handle->unix_handle, count }; + return ODBC_CALL( SQLNumResultCols, ¶ms ); +} + +static SQLRETURN get_num_result_cols_win32( struct handle *handle, SQLSMALLINT *count ) +{ + if (handle->win32_funcs->SQLNumResultCols) + return handle->win32_funcs->SQLNumResultCols( handle->win32_handle, count ); + return SQL_ERROR; +} + /************************************************************************* * SQLNumResultCols [ODBC32.018] */ @@ -2602,18 +2884,30 @@ SQLRETURN WINAPI SQLNumResultCols(SQLHSTMT StatementHandle, SQLSMALLINT *ColumnC
if (handle->unix_handle) { - struct SQLNumResultCols_params params = { handle->unix_handle, ColumnCount }; - ret = ODBC_CALL( SQLNumResultCols, ¶ms ); + ret = get_num_result_cols_unix( handle, ColumnCount ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLNumResultCols( handle->win32_handle, ColumnCount ); + ret = get_num_result_cols_win32( handle, ColumnCount ); }
TRACE("Returning %d ColumnCount %d\n", ret, *ColumnCount); return ret; }
+static SQLRETURN get_param_data_unix( struct handle *handle, SQLPOINTER *value ) +{ + struct SQLParamData_params params = { handle->unix_handle, value }; + return ODBC_CALL( SQLParamData, ¶ms ); +} + +static SQLRETURN get_param_data_win32( struct handle *handle, SQLPOINTER *value ) +{ + if (handle->win32_funcs->SQLParamData) + return handle->win32_funcs->SQLParamData( handle->win32_handle, value ); + return SQL_ERROR; +} + /************************************************************************* * SQLParamData [ODBC32.048] */ @@ -2628,12 +2922,11 @@ SQLRETURN WINAPI SQLParamData(SQLHSTMT StatementHandle, SQLPOINTER *Value)
if (handle->unix_handle) { - struct SQLParamData_params params = { handle->unix_handle, Value }; - ret = ODBC_CALL( SQLParamData, ¶ms ); + ret = get_param_data_unix( handle, Value ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLParamData( handle->win32_handle, Value ); + ret = get_param_data_win32( handle, Value ); }
TRACE("Returning %d\n", ret); @@ -2690,6 +2983,19 @@ SQLRETURN WINAPI SQLPrepare(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQ return ret; }
+static SQLRETURN put_data_unix( struct handle *handle, SQLPOINTER *data, SQLLEN len ) +{ + struct SQLPutData_params params = { handle->unix_handle, data, len }; + return ODBC_CALL( SQLPutData, ¶ms ); +} + +static SQLRETURN put_data_win32( struct handle *handle, SQLPOINTER *data, SQLLEN len ) +{ + if (handle->win32_funcs->SQLPutData) + return handle->win32_funcs->SQLPutData( handle->win32_handle, data, len ); + return SQL_ERROR; +} + /************************************************************************* * SQLPutData [ODBC32.049] */ @@ -2704,18 +3010,34 @@ SQLRETURN WINAPI SQLPutData(SQLHSTMT StatementHandle, SQLPOINTER Data, SQLLEN St
if (handle->unix_handle) { - struct SQLPutData_params params = { handle->unix_handle, Data, StrLen_or_Ind }; - ret = ODBC_CALL( SQLPutData, ¶ms ); + ret = put_data_unix( handle, Data, StrLen_or_Ind ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLPutData( handle->win32_handle, Data, StrLen_or_Ind ); + ret = put_data_win32( handle, Data, StrLen_or_Ind ); }
TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN row_count_unix( struct handle *handle, SQLLEN *count ) +{ + INT64 count64; + struct SQLRowCount_params params = { handle->unix_handle, &count64 }; + SQLRETURN ret; + + if (SUCCESS((ret = ODBC_CALL( SQLRowCount, ¶ms ))) && count) *count = count64; + return ret; +} + +static SQLRETURN row_count_win32( struct handle *handle, SQLLEN *count ) +{ + if (handle->win32_funcs->SQLRowCount) + return handle->win32_funcs->SQLRowCount( handle->win32_handle, count ); + return SQL_ERROR; +} + /************************************************************************* * SQLRowCount [ODBC32.020] */ @@ -2730,23 +3052,31 @@ SQLRETURN WINAPI SQLRowCount(SQLHSTMT StatementHandle, SQLLEN *RowCount)
if (handle->unix_handle) { - INT64 count; - struct SQLRowCount_params params = { handle->unix_handle, &count }; - if (SUCCESS((ret = ODBC_CALL( SQLRowCount, ¶ms ))) && RowCount) - { - *RowCount = count; - TRACE(" RowCount %s\n", debugstr_sqllen(*RowCount)); - } + ret = row_count_unix( handle, RowCount ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLRowCount( handle->win32_handle, RowCount ); + ret = row_count_win32( handle, RowCount ); }
+ if (SUCCESS(ret) && RowCount) TRACE(" RowCount %s\n", debugstr_sqllen(*RowCount)); TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN set_connect_attr_unix( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +{ + struct SQLSetConnectAttr_params params = { handle->unix_handle, attr, value, len }; + return ODBC_CALL( SQLSetConnectAttr, ¶ms ); +} + +static SQLRETURN set_connect_attr_win32( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +{ + if (handle->win32_funcs->SQLSetConnectAttr) + return handle->win32_funcs->SQLSetConnectAttr( handle->win32_handle, attr, value, len ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetConnectAttr [ODBC32.039] */ @@ -2763,12 +3093,11 @@ SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribut
if (handle->unix_handle) { - struct SQLSetConnectAttr_params params = { handle->unix_handle, Attribute, Value, StringLength }; - ret = ODBC_CALL( SQLSetConnectAttr, ¶ms ); + ret = set_connect_attr_unix( handle, Attribute, Value, StringLength ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetConnectAttr( handle->win32_handle, Attribute, Value, StringLength ); + ret = set_connect_attr_win32( handle, Attribute, Value, StringLength ); } else { @@ -2793,6 +3122,19 @@ SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribut return ret; }
+static SQLRETURN set_connect_option_unix( struct handle *handle, SQLUSMALLINT attr, SQLULEN value ) +{ + struct SQLSetConnectOption_params params = { handle->unix_handle, attr, value }; + return ODBC_CALL( SQLSetConnectOption, ¶ms ); +} + +static SQLRETURN set_connect_option_win32( struct handle *handle, SQLUSMALLINT attr, SQLULEN value ) +{ + if (handle->win32_funcs->SQLSetConnectOption) + return handle->win32_funcs->SQLSetConnectOption( handle->win32_handle, attr, value ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetConnectOption [ODBC32.050] */ @@ -2807,18 +3149,30 @@ SQLRETURN WINAPI SQLSetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Opti
if (handle->unix_handle) { - struct SQLSetConnectOption_params params = { handle->unix_handle, Option, Value }; - ret = ODBC_CALL( SQLSetConnectOption, ¶ms ); + ret = set_connect_option_unix( handle, Option, Value ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetConnectOption( handle->win32_handle, Option, Value ); + ret = set_connect_option_win32( handle, Option, Value ); }
TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN set_cursor_name_unix_a( struct handle *handle, SQLCHAR *name, SQLSMALLINT len ) +{ + struct SQLSetCursorName_params params = { handle->unix_handle, name, len }; + return ODBC_CALL( SQLSetCursorName, ¶ms ); +} + +static SQLRETURN set_cursor_name_win32_a( struct handle *handle, SQLCHAR *name, SQLSMALLINT len ) +{ + if (handle->win32_funcs->SQLSetCursorName) + return handle->win32_funcs->SQLSetCursorName( handle->win32_handle, name, len ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetCursorName [ODBC32.021] */ @@ -2834,18 +3188,32 @@ SQLRETURN WINAPI SQLSetCursorName(SQLHSTMT StatementHandle, SQLCHAR *CursorName,
if (handle->unix_handle) { - struct SQLSetCursorName_params params = { handle->unix_handle, CursorName, NameLength }; - ret = ODBC_CALL( SQLSetCursorName, ¶ms ); + ret = set_cursor_name_unix_a( handle, CursorName, NameLength ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetCursorName( handle->win32_handle, CursorName, NameLength ); + ret = set_cursor_name_win32_a( handle, CursorName, NameLength ); }
TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN set_desc_field_unix( struct handle *handle, SQLSMALLINT record, SQLSMALLINT id, SQLPOINTER value, + SQLINTEGER len ) +{ + struct SQLSetDescField_params params = { handle->unix_handle, record, id, value, len }; + return ODBC_CALL( SQLSetDescField, ¶ms ); +} + +static SQLRETURN set_desc_field_win32( struct handle *handle, SQLSMALLINT record, SQLSMALLINT id, SQLPOINTER value, + SQLINTEGER len ) +{ + if (handle->win32_funcs->SQLSetDescField) + return handle->win32_funcs->SQLSetDescField( handle->win32_handle, record, id, value, len ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetDescField [ODBC32.073] */ @@ -2862,20 +3230,43 @@ SQLRETURN WINAPI SQLSetDescField(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumbe
if (handle->unix_handle) { - struct SQLSetDescField_params params = { handle->unix_handle, RecNumber, FieldIdentifier, Value, - BufferLength }; - ret = ODBC_CALL( SQLSetDescField, ¶ms ); + ret = set_desc_field_unix( handle, RecNumber, FieldIdentifier, Value, BufferLength ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetDescField( handle->win32_handle, RecNumber, FieldIdentifier, Value, - BufferLength ); + ret = set_desc_field_win32( handle, RecNumber, FieldIdentifier, Value, BufferLength ); }
TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN set_desc_rec_unix( struct handle *handle, SQLSMALLINT record, SQLSMALLINT type, SQLSMALLINT subtype, + SQLLEN len, SQLSMALLINT precision, SQLSMALLINT scale, SQLPOINTER data, + SQLLEN *retlen, SQLLEN *indicator ) +{ + SQLRETURN ret; + INT64 len64, ind64; + struct SQLSetDescRec_params params = { handle->unix_handle, record, type, subtype, len, precision, scale, data, + &len64, &ind64 }; + if (SUCCESS((ret = ODBC_CALL( SQLSetDescRec, ¶ms )))) + { + *retlen = len64; + *indicator = ind64; + } + return ret; +} + +static SQLRETURN set_desc_rec_win32( struct handle *handle, SQLSMALLINT record, SQLSMALLINT type, SQLSMALLINT subtype, + SQLLEN len, SQLSMALLINT precision, SQLSMALLINT scale, SQLPOINTER data, + SQLLEN *retlen, SQLLEN *indicator ) +{ + if (handle->win32_funcs->SQLSetDescRec) + return handle->win32_funcs->SQLSetDescRec( handle->win32_handle, record, type, subtype, len, precision, scale, + data, retlen, indicator ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetDescRec [ODBC32.074] */ @@ -2894,25 +3285,32 @@ SQLRETURN WINAPI SQLSetDescRec(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber,
if (handle->unix_handle) { - INT64 stringlen, indicator; - struct SQLSetDescRec_params params = { handle->unix_handle, RecNumber, Type, SubType, Length, Precision, - Scale, Data, &stringlen, &indicator }; - if (SUCCESS((ret = ODBC_CALL( SQLSetDescRec, ¶ms )))) - { - *StringLength = stringlen; - *Indicator = indicator; - } + ret = set_desc_rec_unix( handle, RecNumber, Type, SubType, Length, Precision, Scale, Data, StringLength, + Indicator ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetDescRec( handle->win32_handle, RecNumber, Type, SubType, Length, Precision, - Scale, Data, StringLength, Indicator ); + ret = set_desc_rec_win32( handle, RecNumber, Type, SubType, Length, Precision, Scale, Data, StringLength, + Indicator ); }
TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN set_env_attr_unix( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +{ + struct SQLSetEnvAttr_params params = { handle->unix_handle, attr, value, len }; + return ODBC_CALL( SQLSetEnvAttr, ¶ms ); +} + +static SQLRETURN set_env_attr_win32( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +{ + if (handle->win32_funcs->SQLSetEnvAttr) + return handle->win32_funcs->SQLSetEnvAttr( handle->win32_handle, attr, value, len ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetEnvAttr [ODBC32.075] */ @@ -2927,12 +3325,11 @@ SQLRETURN WINAPI SQLSetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute,
if (handle->unix_handle) { - struct SQLSetEnvAttr_params params = { handle->unix_handle, Attribute, Value, StringLength }; - ret = ODBC_CALL( SQLSetEnvAttr, ¶ms ); + ret = set_env_attr_unix( handle, Attribute, Value, StringLength ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetEnvAttr( handle->win32_handle, Attribute, Value, StringLength ); + ret = set_env_attr_win32( handle, Attribute, Value, StringLength ); } else { @@ -2957,6 +3354,28 @@ SQLRETURN WINAPI SQLSetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute, return ret; }
+static SQLRETURN set_param_unix( struct handle *handle, SQLUSMALLINT param, SQLSMALLINT value_type, + SQLSMALLINT param_type, SQLULEN precision, SQLSMALLINT scale, SQLPOINTER value, + SQLLEN *retlen ) +{ + INT64 len; + SQLRETURN ret; + struct SQLSetParam_params params = { handle->unix_handle, param, value_type, param_type, precision, scale, + value, &len }; + if (SUCCESS((ret = ODBC_CALL( SQLSetParam, ¶ms )))) *retlen = len; + return ret; +} + +static SQLRETURN set_param_win32( struct handle *handle, SQLUSMALLINT param, SQLSMALLINT value_type, + SQLSMALLINT param_type, SQLULEN precision, SQLSMALLINT scale, SQLPOINTER value, + SQLLEN *retlen ) +{ + if (handle->win32_funcs->SQLSetParam) + return handle->win32_funcs->SQLSetParam( handle->win32_handle, param, value_type, param_type, precision, + scale, value, retlen ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetParam [ODBC32.022] */ @@ -2975,15 +3394,13 @@ SQLRETURN WINAPI SQLSetParam(SQLHSTMT StatementHandle, SQLUSMALLINT ParameterNum
if (handle->unix_handle) { - INT64 len; - struct SQLSetParam_params params = { handle->unix_handle, ParameterNumber, ValueType, ParameterType, - LengthPrecision, ParameterScale, ParameterValue, &len }; - if (SUCCESS((ret = ODBC_CALL( SQLSetParam, ¶ms )))) *StrLen_or_Ind = len; + ret = set_param_unix( handle, ParameterNumber, ValueType, ParameterType, LengthPrecision, ParameterScale, + ParameterValue, StrLen_or_Ind ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetParam( handle->win32_handle, ParameterNumber, ValueType, ParameterType, - LengthPrecision, ParameterScale, ParameterValue, StrLen_or_Ind ); + ret = set_param_win32( handle, ParameterNumber, ValueType, ParameterType, LengthPrecision, ParameterScale, + ParameterValue, StrLen_or_Ind ); }
TRACE("Returning %d\n", ret); @@ -3045,6 +3462,31 @@ static BOOL resize_result_lengths( struct handle *handle, UINT size ) return TRUE; }
+static SQLRETURN set_stmt_attr_unix( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +{ + struct SQLSetStmtAttr_params params = { handle->unix_handle, attr, value, len }; + SQLRETURN ret; + + if (SUCCESS((ret = ODBC_CALL( SQLSetStmtAttr, ¶ms )))) + { + SQLULEN row_count = (SQLULEN)value; + if (attr == SQL_ATTR_ROW_ARRAY_SIZE && row_count != handle->row_count) + { + TRACE( "resizing result length array\n" ); + if (!resize_result_lengths( handle, row_count )) ret = SQL_ERROR; + else handle->row_count = row_count; + } + } + return ret; +} + +static SQLRETURN set_stmt_attr_win32( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +{ + if (handle->win32_funcs->SQLSetStmtAttr) + return handle->win32_funcs->SQLSetStmtAttr( handle->win32_handle, attr, value, len ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetStmtAttr [ODBC32.076] */ @@ -3061,27 +3503,30 @@ SQLRETURN WINAPI SQLSetStmtAttr(SQLHSTMT StatementHandle, SQLINTEGER Attribute,
if (handle->unix_handle) { - struct SQLSetStmtAttr_params params = { handle->unix_handle, Attribute, Value, StringLength }; - if (SUCCESS((ret = ODBC_CALL( SQLSetStmtAttr, ¶ms )))) - { - SQLULEN row_count = (SQLULEN)Value; - if (Attribute == SQL_ATTR_ROW_ARRAY_SIZE && row_count != handle->row_count) - { - TRACE( "resizing result length array\n" ); - if (!resize_result_lengths( handle, row_count )) ret = SQL_ERROR; - else handle->row_count = row_count; - } - } + ret = set_stmt_attr_unix( handle, Attribute, Value, StringLength ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetStmtAttr( handle->win32_handle, Attribute, Value, StringLength ); + ret = set_stmt_attr_win32( handle, Attribute, Value, StringLength ); }
TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN set_stmt_option_unix( struct handle *handle, SQLUSMALLINT option, SQLULEN value ) +{ + struct SQLSetStmtOption_params params = { handle->unix_handle, option, value }; + return ODBC_CALL( SQLSetStmtOption, ¶ms ); +} + +static SQLRETURN set_stmt_option_win32( struct handle *handle, SQLUSMALLINT option, SQLULEN value ) +{ + if (handle->win32_funcs->SQLSetStmtOption) + return handle->win32_funcs->SQLSetStmtOption( handle->win32_handle, option, value ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetStmtOption [ODBC32.051] */ @@ -3096,12 +3541,11 @@ SQLRETURN WINAPI SQLSetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option,
if (handle->unix_handle) { - struct SQLSetStmtOption_params params = { handle->unix_handle, Option, Value }; - ret = ODBC_CALL( SQLSetStmtOption, ¶ms ); + ret = set_stmt_option_unix( handle, Option, Value ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetStmtOption( handle->win32_handle, Option, Value ); + ret = set_stmt_option_win32( handle, Option, Value ); }
TRACE("Returning %d\n", ret); @@ -3209,6 +3653,24 @@ SQLRETURN WINAPI SQLTables(SQLHSTMT StatementHandle, SQLCHAR *CatalogName, SQLSM return ret; }
+static SQLRETURN transact_unix( struct handle *env, struct handle *con, SQLUSMALLINT completion ) +{ + struct SQLTransact_params params = { env ? env->unix_handle : 0, con ? con->unix_handle : 0, completion }; + return ODBC_CALL( SQLTransact, ¶ms ); +} + +static SQLRETURN transact_win32( struct handle *env, struct handle *con, SQLUSMALLINT completion ) +{ + const struct win32_funcs *win32_funcs; + + if (env) win32_funcs = env->win32_funcs; + else win32_funcs = con->win32_funcs; + + if (win32_funcs->SQLTransact) + return win32_funcs->SQLTransact( env ? env->win32_handle : NULL, con ? con->win32_handle : NULL, completion ); + return SQL_ERROR; +} + /************************************************************************* * SQLTransact [ODBC32.023] */ @@ -3224,17 +3686,11 @@ SQLRETURN WINAPI SQLTransact(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle
if ((env && env->unix_handle) || (con && con->unix_handle)) { - struct SQLTransact_params params = { env ? env->unix_handle : 0, con ? con->unix_handle : 0, CompletionType }; - ret = ODBC_CALL( SQLTransact, ¶ms ); + ret = transact_unix( env, con, CompletionType ); } else if ((env && env->win32_handle) || (con && con->win32_handle)) { - const struct win32_funcs *win32_funcs; - - if (env) win32_funcs = env->win32_funcs; - else win32_funcs = con->win32_funcs; - - ret = win32_funcs->SQLTransact( env ? env->win32_handle : NULL, con ? con->win32_handle : NULL, CompletionType ); + ret = transact_win32( env, con, CompletionType ); }
TRACE("Returning %d\n", ret); @@ -3363,6 +3819,22 @@ done: return ret; }
+static SQLRETURN bulk_operations_unix( struct handle *handle, SQLSMALLINT operation ) +{ + struct SQLBulkOperations_params params = { handle->unix_handle, operation }; + SQLRETURN ret; + + if (SUCCESS((ret = ODBC_CALL( SQLBulkOperations, ¶ms )))) update_result_lengths( handle, SQL_PARAM_OUTPUT ); + return ret; +} + +static SQLRETURN bulk_operations_win32( struct handle *handle, SQLSMALLINT operation ) +{ + if (handle->win32_funcs->SQLBulkOperations) + return handle->win32_funcs->SQLBulkOperations( handle->win32_handle, operation ); + return SQL_ERROR; +} + /************************************************************************* * SQLBulkOperations [ODBC32.078] */ @@ -3377,12 +3849,11 @@ SQLRETURN WINAPI SQLBulkOperations(SQLHSTMT StatementHandle, SQLSMALLINT Operati
if (handle->unix_handle) { - struct SQLBulkOperations_params params = { handle->unix_handle, Operation }; - if (SUCCESS(( ret = ODBC_CALL( SQLBulkOperations, ¶ms )))) update_result_lengths( handle, SQL_PARAM_OUTPUT ); + ret = bulk_operations_unix( handle, Operation ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLBulkOperations( handle->win32_handle, Operation ); + ret = bulk_operations_win32( handle, Operation ); }
TRACE("Returning %d\n", ret); @@ -3535,6 +4006,25 @@ SQLRETURN WINAPI SQLColumnPrivileges(SQLHSTMT StatementHandle, SQLCHAR *CatalogN return ret; }
+static SQLRETURN describe_param_unix( struct handle *handle, SQLUSMALLINT param, SQLSMALLINT *type, SQLULEN *size, + SQLSMALLINT *digits, SQLSMALLINT *nullable ) +{ + UINT64 size64; + struct SQLDescribeParam_params params = { handle->unix_handle, param, type, &size64, digits, nullable }; + SQLRETURN ret; + + if (SUCCESS((ret = ODBC_CALL( SQLDescribeParam, ¶ms )))) *size = size64; + return ret; +} + +static SQLRETURN describe_param_win32( struct handle *handle, SQLUSMALLINT param, SQLSMALLINT *type, SQLULEN *size, + SQLSMALLINT *digits, SQLSMALLINT *nullable ) +{ + if (handle->win32_funcs->SQLDescribeParam) + return handle->win32_funcs->SQLDescribeParam( handle->win32_handle, param, type, size, digits, nullable ); + return SQL_ERROR; +} + /************************************************************************* * SQLDescribeParam [ODBC32.058] */ @@ -3551,21 +4041,36 @@ SQLRETURN WINAPI SQLDescribeParam(SQLHSTMT StatementHandle, SQLUSMALLINT Paramet
if (handle->unix_handle) { - UINT64 size; - struct SQLDescribeParam_params params = { handle->unix_handle, ParameterNumber, DataType, &size, - DecimalDigits, Nullable }; - if (SUCCESS((ret = ODBC_CALL( SQLDescribeParam, ¶ms )))) *ParameterSize = size; + ret = describe_param_unix( handle, ParameterNumber, DataType, ParameterSize, DecimalDigits, Nullable ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLDescribeParam( handle->win32_handle, ParameterNumber, DataType, ParameterSize, - DecimalDigits, Nullable ); + ret = describe_param_win32( handle, ParameterNumber, DataType, ParameterSize, DecimalDigits, Nullable ); }
TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN extended_fetch_unix( struct handle *handle, SQLUSMALLINT orientation, SQLLEN offset, + SQLULEN *count, SQLUSMALLINT *status ) +{ + UINT64 count64; + struct SQLExtendedFetch_params params = { handle->unix_handle, orientation, offset, &count64, status }; + SQLRETURN ret; + + if (SUCCESS((ret = ODBC_CALL( SQLExtendedFetch, ¶ms )))) *count = count64; + return ret; +} + +static SQLRETURN extended_fetch_win32( struct handle *handle, SQLUSMALLINT orientation, SQLLEN offset, + SQLULEN *count, SQLUSMALLINT *status ) +{ + if (handle->win32_funcs->SQLExtendedFetch) + return handle->win32_funcs->SQLExtendedFetch( handle->win32_handle, orientation, offset, count, status ); + return SQL_ERROR; +} + /************************************************************************* * SQLExtendedFetch [ODBC32.059] */ @@ -3582,15 +4087,11 @@ SQLRETURN WINAPI SQLExtendedFetch(SQLHSTMT StatementHandle, SQLUSMALLINT FetchOr
if (handle->unix_handle) { - UINT64 count; - struct SQLExtendedFetch_params params = { handle->unix_handle, FetchOrientation, FetchOffset, &count, - RowStatusArray }; - if (SUCCESS((ret = ODBC_CALL( SQLExtendedFetch, ¶ms )))) *RowCount = count; + ret = extended_fetch_unix( handle, FetchOrientation, FetchOffset, RowCount, RowStatusArray ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLExtendedFetch( handle->win32_handle, FetchOrientation, FetchOffset, RowCount, - RowStatusArray ); + ret = extended_fetch_win32( handle, FetchOrientation, FetchOffset, RowCount, RowStatusArray ); }
TRACE("Returning %d\n", ret); @@ -3681,6 +4182,19 @@ SQLRETURN WINAPI SQLForeignKeys(SQLHSTMT StatementHandle, SQLCHAR *PkCatalogName return ret; }
+static SQLRETURN more_results_unix( struct handle *handle ) +{ + struct SQLMoreResults_params params = { handle->unix_handle }; + return ODBC_CALL( SQLMoreResults, ¶ms ); +} + +static SQLRETURN more_results_win32( struct handle *handle ) +{ + if (handle->win32_funcs->SQLMoreResults) + return handle->win32_funcs->SQLMoreResults( handle->win32_handle ); + return SQL_ERROR; +} + /************************************************************************* * SQLMoreResults [ODBC32.061] */ @@ -3695,12 +4209,11 @@ SQLRETURN WINAPI SQLMoreResults(SQLHSTMT StatementHandle)
if (handle->unix_handle) { - struct SQLMoreResults_params params = { handle->unix_handle }; - ret = ODBC_CALL( SQLMoreResults, ¶ms ); + ret = more_results_unix( handle ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLMoreResults( handle->win32_handle ); + ret = more_results_win32( handle ); }
TRACE("Returning %d\n", ret); @@ -3774,6 +4287,19 @@ SQLRETURN WINAPI SQLNativeSql(SQLHDBC ConnectionHandle, SQLCHAR *InStatementText return ret; }
+static SQLRETURN num_params_unix( struct handle *handle, SQLSMALLINT *count ) +{ + struct SQLNumParams_params params = { handle->unix_handle, count }; + return ODBC_CALL( SQLNumParams, ¶ms ); +} + +static SQLRETURN num_params_win32( struct handle *handle, SQLSMALLINT *count ) +{ + if (handle->win32_funcs->SQLNumParams) + return handle->win32_funcs->SQLNumParams( handle->win32_handle, count ); + return SQL_ERROR; +} + /************************************************************************* * SQLNumParams [ODBC32.063] */ @@ -3788,18 +4314,34 @@ SQLRETURN WINAPI SQLNumParams(SQLHSTMT StatementHandle, SQLSMALLINT *ParameterCo
if (handle->unix_handle) { - struct SQLNumParams_params params = { handle->unix_handle, ParameterCount }; - ret = ODBC_CALL( SQLNumParams, ¶ms ); + ret = num_params_unix( handle, ParameterCount ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLNumParams( handle->win32_handle, ParameterCount ); + ret = num_params_win32( handle, ParameterCount ); }
TRACE("Returning %d\n", ret); return ret; }
+static SQLRETURN param_options_unix( struct handle *handle, SQLULEN row_count, SQLULEN *row_number ) +{ + UINT64 row; + struct SQLParamOptions_params params = { handle->unix_handle, row_count, &row }; + SQLRETURN ret; + + if (SUCCESS((ret = ODBC_CALL( SQLParamOptions, ¶ms )))) *row_number = row; + return ret; +} + +static SQLRETURN param_options_win32( struct handle *handle, SQLULEN row_count, SQLULEN *row_number ) +{ + if (handle->win32_funcs->SQLParamOptions) + return handle->win32_funcs->SQLParamOptions( handle->win32_handle, row_count, row_number ); + return SQL_ERROR; +} + /************************************************************************* * SQLParamOptions [ODBC32.064] */ @@ -3815,13 +4357,11 @@ SQLRETURN WINAPI SQLParamOptions(SQLHSTMT StatementHandle, SQLULEN RowCount, SQL
if (handle->unix_handle) { - UINT64 row; - struct SQLParamOptions_params params = { handle->unix_handle, RowCount, &row }; - if (SUCCESS((ret = ODBC_CALL( SQLParamOptions, ¶ms )))) *RowNumber = row; + ret = param_options_unix( handle, RowCount, RowNumber ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLParamOptions( handle->win32_handle, RowCount, RowNumber ); + ret = param_options_win32( handle, RowCount, RowNumber ); }
TRACE("Returning %d\n", ret); @@ -4021,6 +4561,23 @@ SQLRETURN WINAPI SQLProcedures(SQLHSTMT StatementHandle, SQLCHAR *CatalogName, S return ret; }
+static SQLRETURN set_pos_unix( struct handle *handle, SQLSETPOSIROW row, SQLUSMALLINT op, SQLUSMALLINT lock ) +{ + struct SQLSetPos_params params = { handle->unix_handle, row, op, lock }; + SQLRETURN ret; + + if (SUCCESS(( ret = ODBC_CALL( SQLSetPos, ¶ms ))) && op == SQL_REFRESH) + update_result_lengths( handle, SQL_PARAM_OUTPUT ); + return ret; +} + +static SQLRETURN set_pos_win32( struct handle *handle, SQLSETPOSIROW row, SQLUSMALLINT op, SQLUSMALLINT lock ) +{ + if (handle->win32_funcs->SQLSetPos) + return handle->win32_funcs->SQLSetPos( handle->win32_handle, row, op, lock ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetPos [ODBC32.068] */ @@ -4037,13 +4594,11 @@ SQLRETURN WINAPI SQLSetPos(SQLHSTMT StatementHandle, SQLSETPOSIROW RowNumber, SQ
if (handle->unix_handle) { - struct SQLSetPos_params params = { handle->unix_handle, RowNumber, Operation, LockType }; - if (SUCCESS(( ret = ODBC_CALL( SQLSetPos, ¶ms ))) && Operation == SQL_REFRESH) - update_result_lengths( handle, SQL_PARAM_OUTPUT ); + ret = set_pos_unix( handle, RowNumber, Operation, LockType ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetPos( handle->win32_handle, RowNumber, Operation, LockType ); + ret = set_pos_win32( handle, RowNumber, Operation, LockType ); }
TRACE("Returning %d\n", ret); @@ -4151,6 +4706,45 @@ done: return ret; }
+static SQLRETURN bind_parameter_unix( struct handle *handle, SQLUSMALLINT param, SQLSMALLINT io_type, + SQLSMALLINT value_type, SQLSMALLINT param_type, SQLULEN size, + SQLSMALLINT digits, SQLPOINTER value, SQLLEN buflen, SQLLEN *len ) +{ + struct SQLBindParameter_params params = { handle->unix_handle, param, io_type, value_type, param_type, size, + digits, value, buflen }; + UINT i = param - 1; + SQLRETURN ret; + + if (!param) + { + FIXME( "parameter 0 not handled\n" ); + return SQL_ERROR; + } + if (!alloc_binding( &handle->bind_parameter, io_type, param, handle->row_count )) return SQL_ERROR; + handle->bind_parameter.param[i].parameter.input_output_type = io_type; + handle->bind_parameter.param[i].parameter.value_type = value_type; + handle->bind_parameter.param[i].parameter.parameter_type = param_type; + handle->bind_parameter.param[i].parameter.column_size = size; + handle->bind_parameter.param[i].parameter.decimal_digits = digits; + handle->bind_parameter.param[i].parameter.parameter_value = value; + handle->bind_parameter.param[i].parameter.buffer_length = buflen; + + params.StrLen_or_Ind = handle->bind_parameter.param[i].len; + *(UINT64 *)params.StrLen_or_Ind = *len; + if (SUCCESS((ret = ODBC_CALL( SQLBindParameter, ¶ms )))) handle->bind_parameter.param[i].ptr = len; + return ret; +} + +static SQLRETURN bind_parameter_win32( struct handle *handle, SQLUSMALLINT param, SQLSMALLINT io_type, + SQLSMALLINT value_type, SQLSMALLINT param_type, SQLULEN size, + SQLSMALLINT digits, SQLPOINTER value, SQLLEN buflen, SQLLEN *len ) +{ + if (handle->win32_funcs->SQLBindParameter) + return handle->win32_funcs->SQLBindParameter( handle->win32_handle, param, io_type, value_type, param_type, + size, digits, value, buflen, len ); + return SQL_ERROR; +} + /************************************************************************* * SQLBindParameter [ODBC32.072] */ @@ -4160,7 +4754,6 @@ SQLRETURN WINAPI SQLBindParameter(SQLHSTMT StatementHandle, SQLUSMALLINT Paramet SQLLEN *StrLen_or_Ind) { struct handle *handle = StatementHandle; - UINT i = ParameterNumber - 1; SQLRETURN ret = SQL_ERROR;
TRACE("(StatementHandle %p, ParameterNumber %d, InputOutputType %d, ValueType %d, ParameterType %d, " @@ -4169,33 +4762,16 @@ SQLRETURN WINAPI SQLBindParameter(SQLHSTMT StatementHandle, SQLUSMALLINT Paramet DecimalDigits, ParameterValue, debugstr_sqllen(BufferLength), StrLen_or_Ind);
if (!handle) return SQL_INVALID_HANDLE; - if (!ParameterNumber) - { - FIXME( "parameter 0 not handled\n" ); - return SQL_ERROR; - } - if (!alloc_binding( &handle->bind_parameter, InputOutputType, ParameterNumber, handle->row_count )) return SQL_ERROR; - handle->bind_parameter.param[i].parameter.input_output_type = InputOutputType; - handle->bind_parameter.param[i].parameter.value_type = ValueType; - handle->bind_parameter.param[i].parameter.parameter_type = ParameterType; - handle->bind_parameter.param[i].parameter.column_size = ColumnSize; - handle->bind_parameter.param[i].parameter.decimal_digits = DecimalDigits; - handle->bind_parameter.param[i].parameter.parameter_value = ParameterValue; - handle->bind_parameter.param[i].parameter.buffer_length = BufferLength;
if (handle->unix_handle) { - struct SQLBindParameter_params params = { handle->unix_handle, ParameterNumber, InputOutputType, ValueType, - ParameterType, ColumnSize, DecimalDigits, ParameterValue, - BufferLength, handle->bind_parameter.param[i].len }; - *(UINT64 *)params.StrLen_or_Ind = *StrLen_or_Ind; - if (SUCCESS((ret = ODBC_CALL( SQLBindParameter, ¶ms )))) handle->bind_parameter.param[i].ptr = StrLen_or_Ind; + ret = bind_parameter_unix( handle, ParameterNumber, InputOutputType, ValueType, ParameterType, ColumnSize, + DecimalDigits, ParameterValue, BufferLength, StrLen_or_Ind ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLBindParameter( handle->win32_handle, ParameterNumber, InputOutputType, ValueType, - ParameterType, ColumnSize, DecimalDigits, ParameterValue, - BufferLength, StrLen_or_Ind ); + ret = bind_parameter_win32( handle, ParameterNumber, InputOutputType, ValueType, ParameterType, ColumnSize, + DecimalDigits, ParameterValue, BufferLength, StrLen_or_Ind ); }
TRACE("Returning %d\n", ret); @@ -4304,6 +4880,21 @@ done: return ret; }
+static SQLRETURN set_scroll_options_unix( struct handle *handle, SQLUSMALLINT concurrency, SQLLEN keyset_size, + SQLUSMALLINT rowset_size ) +{ + struct SQLSetScrollOptions_params params = { handle->unix_handle, concurrency, keyset_size, rowset_size }; + return ODBC_CALL( SQLSetScrollOptions, ¶ms ); +} + +static SQLRETURN set_scroll_options_win32( struct handle *handle, SQLUSMALLINT concurrency, SQLLEN keyset_size, + SQLUSMALLINT rowset_size ) +{ + if (handle->win32_funcs->SQLSetScrollOptions) + return handle->win32_funcs->SQLSetScrollOptions( handle->win32_handle, concurrency, keyset_size, rowset_size ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetScrollOptions [ODBC32.069] */ @@ -4320,12 +4911,11 @@ SQLRETURN WINAPI SQLSetScrollOptions(SQLHSTMT StatementHandle, SQLUSMALLINT Conc
if (handle->unix_handle) { - struct SQLSetScrollOptions_params params = { handle->unix_handle, Concurrency, KeySetSize, RowSetSize }; - ret = ODBC_CALL( SQLSetScrollOptions, ¶ms ); + ret = set_scroll_options_unix( handle, Concurrency, KeySetSize, RowSetSize ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetScrollOptions( handle->win32_handle, Concurrency, KeySetSize, RowSetSize ); + ret = set_scroll_options_win32( handle, Concurrency, KeySetSize, RowSetSize ); }
TRACE("Returning %d\n", ret);
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 47 +++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 9 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index c9de14a3820..2482164e652 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -3064,19 +3064,35 @@ SQLRETURN WINAPI SQLRowCount(SQLHSTMT StatementHandle, SQLLEN *RowCount) return ret; }
-static SQLRETURN set_connect_attr_unix( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +static SQLRETURN set_connect_attr_unix_a( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) { struct SQLSetConnectAttr_params params = { handle->unix_handle, attr, value, len }; return ODBC_CALL( SQLSetConnectAttr, ¶ms ); }
-static SQLRETURN set_connect_attr_win32( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +static SQLRETURN set_connect_attr_win32_a( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) { + SQLRETURN ret = SQL_ERROR; + if (handle->win32_funcs->SQLSetConnectAttr) return handle->win32_funcs->SQLSetConnectAttr( handle->win32_handle, attr, value, len ); - return SQL_ERROR; -}
+ if (handle->win32_funcs->SQLSetConnectAttrW) + { + switch (attr) + { + case SQL_ATTR_CURRENT_CATALOG: + case SQL_ATTR_TRACEFILE: + case SQL_ATTR_TRANSLATE_LIB: + FIXME( "string attribute %u not handled\n", attr ); + return SQL_ERROR; + default: break; + } + + ret = handle->win32_funcs->SQLSetConnectAttrW( handle->win32_handle, attr, value, len ); + } + return ret; +} /************************************************************************* * SQLSetConnectAttr [ODBC32.039] */ @@ -3093,11 +3109,11 @@ SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribut
if (handle->unix_handle) { - ret = set_connect_attr_unix( handle, Attribute, Value, StringLength ); + ret = set_connect_attr_unix_a( handle, Attribute, Value, StringLength ); } else if (handle->win32_handle) { - ret = set_connect_attr_win32( handle, Attribute, Value, StringLength ); + ret = set_connect_attr_win32_a( handle, Attribute, Value, StringLength ); } else { @@ -5727,6 +5743,20 @@ SQLRETURN WINAPI SQLGetStmtAttrW(SQLHSTMT StatementHandle, SQLINTEGER Attribute, return ret; }
+static SQLRETURN set_connect_attr_unix_w( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +{ + struct SQLSetConnectAttrW_params params = { handle->unix_handle, attr, value, len }; + return ODBC_CALL( SQLSetConnectAttrW, ¶ms ); +} + +static SQLRETURN set_connect_attr_win32_w( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +{ + if (handle->win32_funcs->SQLSetConnectAttrW) + return handle->win32_funcs->SQLSetConnectAttrW( handle->win32_handle, attr, value, len ); + if (handle->win32_funcs->SQLSetConnectAttr) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetConnectAttrW [ODBC32.139] */ @@ -5743,12 +5773,11 @@ SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribu
if (handle->unix_handle) { - struct SQLSetConnectAttrW_params params = { handle->unix_handle, Attribute, Value, StringLength }; - ret = ODBC_CALL( SQLSetConnectAttrW, ¶ms ); + ret = set_connect_attr_unix_w( handle, Attribute, Value, StringLength ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetConnectAttrW( handle->win32_handle, Attribute, Value, StringLength ); + ret = set_connect_attr_win32_w( handle, Attribute, Value, StringLength ); } else {
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 46 ++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 2482164e652..3c779a7c4d9 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -3138,17 +3138,34 @@ SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribut return ret; }
-static SQLRETURN set_connect_option_unix( struct handle *handle, SQLUSMALLINT attr, SQLULEN value ) +static SQLRETURN set_connect_option_unix_a( struct handle *handle, SQLUSMALLINT attr, SQLULEN value ) { struct SQLSetConnectOption_params params = { handle->unix_handle, attr, value }; return ODBC_CALL( SQLSetConnectOption, ¶ms ); }
-static SQLRETURN set_connect_option_win32( struct handle *handle, SQLUSMALLINT attr, SQLULEN value ) +static SQLRETURN set_connect_option_win32_a( struct handle *handle, SQLUSMALLINT attr, SQLULEN value ) { + SQLRETURN ret = SQL_ERROR; + if (handle->win32_funcs->SQLSetConnectOption) return handle->win32_funcs->SQLSetConnectOption( handle->win32_handle, attr, value ); - return SQL_ERROR; + + if (handle->win32_funcs->SQLSetConnectOptionW) + { + switch (attr) + { + case SQL_ATTR_CURRENT_CATALOG: + case SQL_ATTR_TRACEFILE: + case SQL_ATTR_TRANSLATE_LIB: + FIXME( "string option %u not handled\n", attr ); + return SQL_ERROR; + default: break; + } + + ret = handle->win32_funcs->SQLSetConnectOptionW( handle->win32_handle, attr, value ); + } + return ret; }
/************************************************************************* @@ -3165,11 +3182,11 @@ SQLRETURN WINAPI SQLSetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Opti
if (handle->unix_handle) { - ret = set_connect_option_unix( handle, Option, Value ); + ret = set_connect_option_unix_a( handle, Option, Value ); } else if (handle->win32_handle) { - ret = set_connect_option_win32( handle, Option, Value ); + ret = set_connect_option_win32_a( handle, Option, Value ); }
TRACE("Returning %d\n", ret); @@ -6078,6 +6095,20 @@ SQLRETURN WINAPI SQLGetTypeInfoW(SQLHSTMT StatementHandle, SQLSMALLINT DataType) return ret; }
+static SQLRETURN set_connect_option_unix_w( struct handle *handle, SQLUSMALLINT option, SQLULEN value ) +{ + struct SQLSetConnectOptionW_params params = { handle->unix_handle, option, value }; + return ODBC_CALL( SQLSetConnectOptionW, ¶ms ); +} + +static SQLRETURN set_connect_option_win32_w( struct handle *handle, SQLUSMALLINT option, SQLULEN value ) +{ + if (handle->win32_funcs->SQLSetConnectOptionW) + return handle->win32_funcs->SQLSetConnectOptionW( handle->win32_handle, option, value ); + if (handle->win32_funcs->SQLSetConnectOption) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetConnectOptionW [ODBC32.150] */ @@ -6092,12 +6123,11 @@ SQLRETURN WINAPI SQLSetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Opt
if (handle->unix_handle) { - struct SQLSetConnectOptionW_params params = { handle->unix_handle, Option, Value }; - ret = ODBC_CALL( SQLSetConnectOptionW, ¶ms ); + ret = set_connect_option_unix_w( handle, Option, Value ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetConnectOptionW( handle->win32_handle, Option, Value ); + ret = set_connect_option_win32_w( handle, Option, Value ); }
TRACE("Returning %d\n", ret);
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 3c779a7c4d9..63e206b3d21 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -3201,9 +3201,19 @@ static SQLRETURN set_cursor_name_unix_a( struct handle *handle, SQLCHAR *name, S
static SQLRETURN set_cursor_name_win32_a( struct handle *handle, SQLCHAR *name, SQLSMALLINT len ) { + SQLRETURN ret = SQL_ERROR; + if (handle->win32_funcs->SQLSetCursorName) return handle->win32_funcs->SQLSetCursorName( handle->win32_handle, name, len ); - return SQL_ERROR; + + if (handle->win32_funcs->SQLSetCursorNameW) + { + WCHAR *strW; + if (!(strW = strnAtoW( name, len ))) return SQL_ERROR; + ret = handle->win32_funcs->SQLSetCursorNameW( handle->win32_handle, strW, len ); + free( strW ); + } + return ret; }
/************************************************************************* @@ -5362,6 +5372,20 @@ SQLRETURN WINAPI SQLPrepareW(SQLHSTMT StatementHandle, SQLWCHAR *StatementText, return ret; }
+static SQLRETURN set_cursor_name_unix_w( struct handle *handle, SQLWCHAR *name, SQLSMALLINT len ) +{ + struct SQLSetCursorNameW_params params = { handle->unix_handle, name, len }; + return ODBC_CALL( SQLSetCursorNameW, ¶ms ); +} + +static SQLRETURN set_cursor_name_win32_w( struct handle *handle, SQLWCHAR *name, SQLSMALLINT len ) +{ + if (handle->win32_funcs->SQLSetCursorNameW) + return handle->win32_funcs->SQLSetCursorNameW( handle->win32_handle, name, len ); + if (handle->win32_funcs->SQLSetCursorName) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetCursorNameW [ODBC32.121] */ @@ -5377,12 +5401,11 @@ SQLRETURN WINAPI SQLSetCursorNameW(SQLHSTMT StatementHandle, SQLWCHAR *CursorNam
if (handle->unix_handle) { - struct SQLSetCursorNameW_params params = { handle->unix_handle, CursorName, NameLength }; - ret = ODBC_CALL( SQLSetCursorNameW, ¶ms ); + ret = set_cursor_name_unix_w( handle, CursorName, NameLength ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetCursorNameW( handle->win32_handle, CursorName, NameLength ); + ret = set_cursor_name_win32_w( handle, CursorName, NameLength ); }
TRACE("Returning %d\n", ret);
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 65 +++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 12 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 63e206b3d21..0042d51b09e 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -3242,19 +3242,47 @@ SQLRETURN WINAPI SQLSetCursorName(SQLHSTMT StatementHandle, SQLCHAR *CursorName, return ret; }
-static SQLRETURN set_desc_field_unix( struct handle *handle, SQLSMALLINT record, SQLSMALLINT id, SQLPOINTER value, - SQLINTEGER len ) +static SQLRETURN set_desc_field_unix_a( struct handle *handle, SQLSMALLINT record, SQLSMALLINT id, SQLPOINTER value, + SQLINTEGER len ) { struct SQLSetDescField_params params = { handle->unix_handle, record, id, value, len }; return ODBC_CALL( SQLSetDescField, ¶ms ); }
-static SQLRETURN set_desc_field_win32( struct handle *handle, SQLSMALLINT record, SQLSMALLINT id, SQLPOINTER value, - SQLINTEGER len ) +static SQLRETURN set_desc_field_win32_a( struct handle *handle, SQLSMALLINT record, SQLSMALLINT id, SQLPOINTER value, + SQLINTEGER len ) { + SQLRETURN ret = SQL_ERROR; + if (handle->win32_funcs->SQLSetDescField) return handle->win32_funcs->SQLSetDescField( handle->win32_handle, record, id, value, len ); - return SQL_ERROR; + + if (handle->win32_funcs->SQLSetDescFieldW) + { + WCHAR *strW = NULL; + + switch (id) + { + case SQL_DESC_BASE_COLUMN_NAME: + case SQL_DESC_BASE_TABLE_NAME: + case SQL_DESC_CATALOG_NAME: + case SQL_DESC_LABEL: + case SQL_DESC_LITERAL_PREFIX: + case SQL_DESC_LITERAL_SUFFIX: + case SQL_DESC_LOCAL_TYPE_NAME: + case SQL_DESC_NAME: + case SQL_DESC_SCHEMA_NAME: + case SQL_DESC_TABLE_NAME: + case SQL_DESC_TYPE_NAME: + if (!(value = strW = strnAtoW( value, len ))) return SQL_ERROR; + default: break; + } + + ret = handle->win32_funcs->SQLSetDescFieldW( handle->win32_handle, record, id, value, len ); + free( strW ); + } + + return ret; }
/************************************************************************* @@ -3273,11 +3301,11 @@ SQLRETURN WINAPI SQLSetDescField(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumbe
if (handle->unix_handle) { - ret = set_desc_field_unix( handle, RecNumber, FieldIdentifier, Value, BufferLength ); + ret = set_desc_field_unix_a( handle, RecNumber, FieldIdentifier, Value, BufferLength ); } else if (handle->win32_handle) { - ret = set_desc_field_win32( handle, RecNumber, FieldIdentifier, Value, BufferLength ); + ret = set_desc_field_win32_a( handle, RecNumber, FieldIdentifier, Value, BufferLength ); }
TRACE("Returning %d\n", ret); @@ -6801,6 +6829,22 @@ done: return ret; }
+static SQLRETURN set_desc_field_unix_w( struct handle *handle, SQLSMALLINT record, SQLSMALLINT id, SQLPOINTER value, + SQLINTEGER len ) +{ + struct SQLSetDescFieldW_params params = { handle->unix_handle, record, id, value, len }; + return ODBC_CALL( SQLSetDescFieldW, ¶ms ); +} + +static SQLRETURN set_desc_field_win32_w( struct handle *handle, SQLSMALLINT record, SQLSMALLINT id, SQLPOINTER value, + SQLINTEGER len ) +{ + if (handle->win32_funcs->SQLSetDescFieldW) + return handle->win32_funcs->SQLSetDescFieldW( handle->win32_handle, record, id, value, len ); + if (handle->win32_funcs->SQLSetDescField) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetDescFieldW [ODBC32.173] */ @@ -6817,14 +6861,11 @@ SQLRETURN WINAPI SQLSetDescFieldW(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumb
if (handle->unix_handle) { - struct SQLSetDescFieldW_params params = { handle->unix_handle, RecNumber, FieldIdentifier, Value, - BufferLength }; - ret = ODBC_CALL( SQLSetDescFieldW, ¶ms ); + ret = set_desc_field_unix_w( handle, RecNumber, FieldIdentifier, Value, BufferLength ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetDescFieldW( handle->win32_handle, RecNumber, FieldIdentifier, Value, - BufferLength ); + ret = set_desc_field_win32_w( handle, RecNumber, FieldIdentifier, Value, BufferLength ); }
TRACE("Returning %d\n", ret);
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 64 ++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 17 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 0042d51b09e..868e340f050 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -3533,7 +3533,7 @@ static BOOL resize_result_lengths( struct handle *handle, UINT size ) return TRUE; }
-static SQLRETURN set_stmt_attr_unix( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +static SQLRETURN set_stmt_attr_unix_a( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) { struct SQLSetStmtAttr_params params = { handle->unix_handle, attr, value, len }; SQLRETURN ret; @@ -3551,11 +3551,25 @@ static SQLRETURN set_stmt_attr_unix( struct handle *handle, SQLINTEGER attr, SQL return ret; }
-static SQLRETURN set_stmt_attr_win32( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +static SQLRETURN set_stmt_attr_win32_a( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) { + SQLRETURN ret = SQL_ERROR; + if (handle->win32_funcs->SQLSetStmtAttr) return handle->win32_funcs->SQLSetStmtAttr( handle->win32_handle, attr, value, len ); - return SQL_ERROR; + + if (handle->win32_funcs->SQLSetStmtAttrW) + { + WCHAR *strW; + + if (len == SQL_IS_POINTER || len < SQL_LEN_BINARY_ATTR_OFFSET) + return handle->win32_funcs->SQLSetStmtAttrW( handle->win32_handle, attr, value, len ); + + if (!(strW = strnAtoW( value, len ))) return SQL_ERROR; + ret = handle->win32_funcs->SQLSetStmtAttrW( handle->win32_handle, attr, strW, len ); + free( strW ); + } + return ret; }
/************************************************************************* @@ -3574,11 +3588,11 @@ SQLRETURN WINAPI SQLSetStmtAttr(SQLHSTMT StatementHandle, SQLINTEGER Attribute,
if (handle->unix_handle) { - ret = set_stmt_attr_unix( handle, Attribute, Value, StringLength ); + ret = set_stmt_attr_unix_a( handle, Attribute, Value, StringLength ); } else if (handle->win32_handle) { - ret = set_stmt_attr_win32( handle, Attribute, Value, StringLength ); + ret = set_stmt_attr_win32_a( handle, Attribute, Value, StringLength ); }
TRACE("Returning %d\n", ret); @@ -6872,6 +6886,32 @@ SQLRETURN WINAPI SQLSetDescFieldW(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumb return ret; }
+static SQLRETURN set_stmt_attr_unix_w( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +{ + struct SQLSetStmtAttrW_params params = { handle->unix_handle, attr, value, len }; + SQLRETURN ret; + + if (SUCCESS((ret = ODBC_CALL( SQLSetStmtAttrW, ¶ms )))) + { + SQLULEN row_count = (SQLULEN)value; + if (attr == SQL_ATTR_ROW_ARRAY_SIZE && row_count != handle->row_count) + { + TRACE( "resizing result length array\n" ); + if (!resize_result_lengths( handle, row_count )) ret = SQL_ERROR; + else handle->row_count = row_count; + } + } + return ret; +} + +static SQLRETURN set_stmt_attr_win32_w( struct handle *handle, SQLINTEGER attr, SQLPOINTER value, SQLINTEGER len ) +{ + if (handle->win32_funcs->SQLSetStmtAttrW) + return handle->win32_funcs->SQLSetStmtAttrW( handle->win32_handle, attr, value, len ); + if (handle->win32_funcs->SQLSetStmtAttr) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLSetStmtAttrW [ODBC32.176] */ @@ -6888,21 +6928,11 @@ SQLRETURN WINAPI SQLSetStmtAttrW(SQLHSTMT StatementHandle, SQLINTEGER Attribute,
if (handle->unix_handle) { - struct SQLSetStmtAttrW_params params = { handle->unix_handle, Attribute, Value, StringLength }; - if (SUCCESS((ret = ODBC_CALL( SQLSetStmtAttrW, ¶ms )))) - { - SQLULEN row_count = (SQLULEN)Value; - if (Attribute == SQL_ATTR_ROW_ARRAY_SIZE && row_count != handle->row_count) - { - TRACE( "resizing result length array\n" ); - if (!resize_result_lengths( handle, row_count )) ret = SQL_ERROR; - else handle->row_count = row_count; - } - } + ret = set_stmt_attr_unix_w( handle, Attribute, Value, StringLength ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSetStmtAttrW( handle->win32_handle, Attribute, Value, StringLength ); + ret = set_stmt_attr_win32_w( handle, Attribute, Value, StringLength ); }
TRACE("Returning %d\n", ret);
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 74 +++++++++++++++++++++++++++++++++++------ 1 file changed, 63 insertions(+), 11 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 868e340f050..8e5d9a99c94 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -3637,6 +3637,41 @@ SQLRETURN WINAPI SQLSetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, return ret; }
+static SQLRETURN special_columns_unix_a( struct handle *handle, SQLUSMALLINT id, SQLCHAR *catalog, SQLSMALLINT len1, + SQLCHAR *schema, SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3, + SQLUSMALLINT scope, SQLUSMALLINT nullable ) +{ + struct SQLSpecialColumns_params params = { handle->unix_handle, id, catalog, len1, schema, len2, table, len3, + scope, nullable }; + return ODBC_CALL( SQLSpecialColumns, ¶ms ); +} + +static SQLRETURN special_columns_win32_a( struct handle *handle, SQLUSMALLINT id, SQLCHAR *catalog, SQLSMALLINT len1, + SQLCHAR *schema, SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3, + SQLUSMALLINT scope, SQLUSMALLINT nullable ) +{ + SQLWCHAR *catalogW = NULL, *schemaW = NULL, *tableW = NULL; + SQLRETURN ret = SQL_ERROR; + + if (handle->win32_funcs->SQLSpecialColumns) + return handle->win32_funcs->SQLSpecialColumns( handle->win32_handle, id, catalog, len1, schema, len2, table, + len3, scope, nullable ); + + if (handle->win32_funcs->SQLSpecialColumnsW) + { + if (!(catalogW = strnAtoW( catalog, len1 ))) return SQL_ERROR; + if (!(schemaW = strnAtoW( schema, len2 ))) goto done; + if (!(tableW = strnAtoW( table, len3 ))) goto done; + ret = handle->win32_funcs->SQLSpecialColumnsW( handle->win32_handle, id, catalogW, len1, schemaW, len2, + tableW, len3, scope, nullable ); + } +done: + free( catalogW ); + free( schemaW ); + free( tableW ); + return ret; +} + /************************************************************************* * SQLSpecialColumns [ODBC32.052] */ @@ -3657,14 +3692,13 @@ SQLRETURN WINAPI SQLSpecialColumns(SQLHSTMT StatementHandle, SQLUSMALLINT Identi
if (handle->unix_handle) { - struct SQLSpecialColumns_params params = { handle->unix_handle, IdentifierType, CatalogName, NameLength1, - SchemaName, NameLength2, TableName, NameLength3, Scope, Nullable }; - ret = ODBC_CALL( SQLSpecialColumns, ¶ms ); + ret = special_columns_unix_a( handle, IdentifierType, CatalogName, NameLength1, SchemaName, NameLength2, + TableName, NameLength3, Scope, Nullable ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSpecialColumns( handle->win32_handle, IdentifierType, CatalogName, NameLength1, - SchemaName, NameLength2, TableName, NameLength3, Scope, Nullable ); + ret = special_columns_win32_a( handle, IdentifierType, CatalogName, NameLength1, SchemaName, NameLength2, + TableName, NameLength3, Scope, Nullable ); }
TRACE("Returning %d\n", ret); @@ -6199,6 +6233,26 @@ SQLRETURN WINAPI SQLSetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Opt return ret; }
+static SQLRETURN special_columns_unix_w( struct handle *handle, SQLUSMALLINT id, SQLWCHAR *catalog, SQLSMALLINT len1, + SQLWCHAR *schema, SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3, + SQLUSMALLINT scope, SQLUSMALLINT nullable ) +{ + struct SQLSpecialColumnsW_params params = { handle->unix_handle, id, catalog, len1, schema, len2, table, len3, + scope, nullable }; + return ODBC_CALL( SQLSpecialColumnsW, ¶ms ); +} + +static SQLRETURN special_columns_win32_w( struct handle *handle, SQLUSMALLINT id, SQLWCHAR *catalog, SQLSMALLINT len1, + SQLWCHAR *schema, SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3, + SQLUSMALLINT scope, SQLUSMALLINT nullable ) +{ + if (handle->win32_funcs->SQLSpecialColumnsW) + return handle->win32_funcs->SQLSpecialColumnsW( handle->win32_handle, id, catalog, len1, schema, len2, table, + len3, scope, nullable ); + if (handle->win32_funcs->SQLSpecialColumns) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLSpecialColumnsW [ODBC32.152] */ @@ -6219,15 +6273,13 @@ SQLRETURN WINAPI SQLSpecialColumnsW(SQLHSTMT StatementHandle, SQLUSMALLINT Ident
if (handle->unix_handle) { - struct SQLSpecialColumnsW_params params = { handle->unix_handle, IdentifierType, CatalogName, NameLength1, - SchemaName, NameLength2, TableName, NameLength3, Scope, Nullable }; - ret = ODBC_CALL( SQLSpecialColumnsW, ¶ms ); + ret = special_columns_unix_w( handle, IdentifierType, CatalogName, NameLength1, SchemaName, NameLength2, + TableName, NameLength3, Scope, Nullable ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLSpecialColumnsW( handle->win32_handle, IdentifierType, CatalogName, - NameLength1, SchemaName, NameLength2, TableName, NameLength3, - Scope, Nullable ); + ret = special_columns_win32_w( handle, IdentifierType, CatalogName, NameLength1, SchemaName, NameLength2, + TableName, NameLength3, Scope, Nullable ); }
TRACE("Returning %d\n", ret);
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 73 +++++++++++++++++++++++++++++++++++------ 1 file changed, 63 insertions(+), 10 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 8e5d9a99c94..a14c77e80ad 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -3705,6 +3705,41 @@ SQLRETURN WINAPI SQLSpecialColumns(SQLHSTMT StatementHandle, SQLUSMALLINT Identi return ret; }
+static SQLRETURN statistics_unix_a( struct handle *handle, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, + SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3, SQLUSMALLINT unique, + SQLUSMALLINT reserved ) +{ + struct SQLStatistics_params params = { handle->unix_handle, catalog, len1, schema, len2, table, len3, unique, + reserved }; + return ODBC_CALL( SQLStatistics, ¶ms ); +} + +static SQLRETURN statistics_win32_a( struct handle *handle, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, + SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3, SQLUSMALLINT unique, + SQLUSMALLINT reserved ) +{ + SQLWCHAR *catalogW = NULL, *schemaW = NULL, *tableW = NULL; + SQLRETURN ret = SQL_ERROR; + + if (handle->win32_funcs->SQLStatistics) + return handle->win32_funcs->SQLStatistics( handle->win32_handle, catalog, len1, schema, len2, table, len3, + unique, reserved ); + + if (handle->win32_funcs->SQLStatisticsW) + { + if (!(catalogW = strnAtoW( catalog, len1 ))) return SQL_ERROR; + if (!(schemaW = strnAtoW( schema, len2 ))) goto done; + if (!(tableW = strnAtoW( table, len3 ))) goto done; + ret = handle->win32_funcs->SQLStatisticsW( handle->win32_handle, catalogW, len1, schemaW, len2, tableW, + len3, unique, reserved ); + } +done: + free( catalogW ); + free( schemaW ); + free( tableW ); + return ret; +} + /************************************************************************* * SQLStatistics [ODBC32.053] */ @@ -3724,14 +3759,13 @@ SQLRETURN WINAPI SQLStatistics(SQLHSTMT StatementHandle, SQLCHAR *CatalogName, S
if (handle->unix_handle) { - struct SQLStatistics_params params = { handle->unix_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3, Unique, Reserved }; - ret = ODBC_CALL( SQLStatistics, ¶ms ); + ret = statistics_unix_a( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + Unique, Reserved ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLStatistics( handle->win32_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3, Unique, Reserved ); + ret = statistics_win32_a( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + Unique, Reserved ); }
TRACE("Returning %d\n", ret); @@ -6286,6 +6320,26 @@ SQLRETURN WINAPI SQLSpecialColumnsW(SQLHSTMT StatementHandle, SQLUSMALLINT Ident return ret; }
+static SQLRETURN statistics_unix_w( struct handle *handle, SQLWCHAR *catalog, SQLSMALLINT len1, SQLWCHAR *schema, + SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3, SQLUSMALLINT unique, + SQLUSMALLINT reserved ) +{ + struct SQLStatisticsW_params params = { handle->unix_handle, catalog, len1, schema, len2, table, len3, unique, + reserved }; + return ODBC_CALL( SQLStatisticsW, ¶ms ); +} + +static SQLRETURN statistics_win32_w( struct handle *handle, SQLWCHAR *catalog, SQLSMALLINT len1, SQLWCHAR *schema, + SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3, SQLUSMALLINT unique, + SQLUSMALLINT reserved ) +{ + if (handle->win32_funcs->SQLStatisticsW) + return handle->win32_funcs->SQLStatisticsW( handle->win32_handle, catalog, len1, schema, len2, table, len3, + unique, reserved ); + if (handle->win32_funcs->SQLStatistics) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLStatisticsW [ODBC32.153] */ @@ -6305,14 +6359,13 @@ SQLRETURN WINAPI SQLStatisticsW(SQLHSTMT StatementHandle, SQLWCHAR *CatalogName,
if (handle->unix_handle) { - struct SQLStatisticsW_params params = { handle->unix_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3, Unique, Reserved }; - ret = ODBC_CALL( SQLStatisticsW, ¶ms ); + ret = statistics_unix_w( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + Unique, Reserved ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLStatisticsW( handle->win32_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3, Unique, Reserved ); + ret = statistics_win32_w( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + Unique, Reserved ); }
TRACE("Returning %d\n", ret);
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 66 ++++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 10 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index a14c77e80ad..b4812d000ef 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -4758,6 +4758,37 @@ SQLRETURN WINAPI SQLSetPos(SQLHSTMT StatementHandle, SQLSETPOSIROW RowNumber, SQ return ret; }
+static SQLRETURN table_privileges_unix_a( struct handle *handle, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, + SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3 ) +{ + struct SQLTablePrivileges_params params = { handle->unix_handle, catalog, len1, schema, len2, table, len3 }; + return ODBC_CALL( SQLTablePrivileges, ¶ms ); +} + +static SQLRETURN table_privileges_win32_a( struct handle *handle, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, + SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3 ) +{ + WCHAR *catalogW = NULL, *schemaW = NULL, *tableW = NULL; + SQLRETURN ret = SQL_ERROR; + + if (handle->win32_funcs->SQLTablePrivileges) + return handle->win32_funcs->SQLTablePrivileges( handle->win32_handle, catalog, len1, schema, len2, table, + len3 ); + if (handle->win32_funcs->SQLTablePrivilegesW) + { + if (!(catalogW = strnAtoW( catalog, len1 ))) goto done; + if (!(schemaW = strnAtoW( schema, len2 ))) goto done; + if (!(tableW = strnAtoW( table, len3 ))) goto done; + ret = handle->win32_funcs->SQLTablePrivilegesW( handle->win32_handle, catalogW, len1, schemaW, len2, tableW, + len3 ); + } +done: + free( catalogW ); + free( schemaW ); + free( tableW ); + return ret; +} + /************************************************************************* * SQLTablePrivileges [ODBC32.070] */ @@ -4777,14 +4808,13 @@ SQLRETURN WINAPI SQLTablePrivileges(SQLHSTMT StatementHandle, SQLCHAR *CatalogNa
if (handle->unix_handle) { - struct SQLTablePrivileges_params params = { handle->unix_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3 }; - ret = ODBC_CALL( SQLTablePrivileges, ¶ms ); + ret = table_privileges_unix_a( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, + NameLength3 ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLTablePrivileges( handle->win32_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3 ); + ret = table_privileges_win32_a( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, + NameLength3 ); }
TRACE("Returning %d\n", ret); @@ -6856,6 +6886,23 @@ SQLRETURN WINAPI SQLProceduresW(SQLHSTMT StatementHandle, SQLWCHAR *CatalogName, return ret; }
+static SQLRETURN table_privileges_unix_w( struct handle *handle, SQLWCHAR *catalog, SQLSMALLINT len1, SQLWCHAR *schema, + SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3 ) +{ + struct SQLTablePrivilegesW_params params = { handle->unix_handle, catalog, len1, schema, len2, table, len3 }; + return ODBC_CALL( SQLTablePrivilegesW, ¶ms ); +} + +static SQLRETURN table_privileges_win32_w( struct handle *handle, SQLWCHAR *catalog, SQLSMALLINT len1, + SQLWCHAR *schema, SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3 ) +{ + if (handle->win32_funcs->SQLTablePrivilegesW) + return handle->win32_funcs->SQLTablePrivilegesW( handle->win32_handle, catalog, len1, schema, len2, table, + len3 ); + if (handle->win32_funcs->SQLTablePrivileges) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLTablePrivilegesW [ODBC32.170] */ @@ -6875,14 +6922,13 @@ SQLRETURN WINAPI SQLTablePrivilegesW(SQLHSTMT StatementHandle, SQLWCHAR *Catalog
if (handle->unix_handle) { - struct SQLTablePrivilegesW_params params = { handle->unix_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3 }; - ret = ODBC_CALL( SQLTablePrivilegesW, ¶ms ); + ret = table_privileges_unix_w( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, + NameLength3 ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLTablePrivilegesW( handle->win32_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3 ); + ret = table_privileges_win32_w( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, + NameLength3 ); }
TRACE("Returning %d\n", ret);
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 72 +++++++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 10 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index b4812d000ef..4799ca0a11e 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -3772,6 +3772,41 @@ SQLRETURN WINAPI SQLStatistics(SQLHSTMT StatementHandle, SQLCHAR *CatalogName, S return ret; }
+static SQLRETURN tables_unix_a( struct handle *handle, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, + SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3, SQLCHAR *type, + SQLSMALLINT len4 ) +{ + struct SQLTables_params params = { handle->unix_handle, catalog, len1, schema, len2, table, len3, type, len4 }; + return ODBC_CALL( SQLTables, ¶ms ); +} + +static SQLRETURN tables_win32_a( struct handle *handle, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, + SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3, SQLCHAR *type, + SQLSMALLINT len4 ) +{ + SQLWCHAR *catalogW = NULL, *schemaW = NULL, *tableW = NULL, *typeW = NULL; + SQLRETURN ret = SQL_ERROR; + + if (handle->win32_funcs->SQLTables) + return handle->win32_funcs->SQLTables( handle->win32_handle, catalog, len1, schema, len2, table, len3, type, + len4 ); + if (handle->win32_funcs->SQLTablesW) + { + if (!(catalogW = strnAtoW( catalog, len1 ))) return SQL_ERROR; + if (!(schemaW = strnAtoW( schema, len2 ))) goto done; + if (!(tableW = strnAtoW( table, len3 ))) goto done; + if (!(typeW = strnAtoW( type, len4 ))) goto done; + ret = handle->win32_funcs->SQLTablesW( handle->win32_handle, catalogW, len1, schemaW, len2, tableW, len3, + typeW, len4 ); + } +done: + free( catalogW ); + free( schemaW ); + free( tableW ); + free( typeW ); + return ret; +} + /************************************************************************* * SQLTables [ODBC32.054] */ @@ -3792,14 +3827,13 @@ SQLRETURN WINAPI SQLTables(SQLHSTMT StatementHandle, SQLCHAR *CatalogName, SQLSM
if (handle->unix_handle) { - struct SQLTables_params params = { handle->unix_handle, CatalogName, NameLength1, SchemaName, NameLength2, - TableName, NameLength3, TableType, NameLength4 }; - ret = ODBC_CALL( SQLTables, ¶ms ); + ret = tables_unix_a( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + TableType, NameLength4 ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLTables( handle->win32_handle, CatalogName, NameLength1, SchemaName, NameLength2, - TableName, NameLength3, TableType, NameLength4 ); + ret = tables_win32_a( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + TableType, NameLength4 ); }
TRACE("Returning %d\n", ret); @@ -6402,6 +6436,25 @@ SQLRETURN WINAPI SQLStatisticsW(SQLHSTMT StatementHandle, SQLWCHAR *CatalogName, return ret; }
+static SQLRETURN tables_unix_w( struct handle *handle, SQLWCHAR *catalog, SQLSMALLINT len1, SQLWCHAR *schema, + SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3, SQLWCHAR *type, + SQLSMALLINT len4 ) +{ + struct SQLTablesW_params params = { handle->unix_handle, catalog, len1, schema, len2, table, len3, type, len4 }; + return ODBC_CALL( SQLTablesW, ¶ms ); +} + +static SQLRETURN tables_win32_w( struct handle *handle, SQLWCHAR *catalog, SQLSMALLINT len1, SQLWCHAR *schema, + SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3, SQLWCHAR *type, + SQLSMALLINT len4 ) +{ + if (handle->win32_funcs->SQLTablesW) + return handle->win32_funcs->SQLTablesW( handle->win32_handle, catalog, len1, schema, len2, table, len3, + type, len4 ); + if (handle->win32_funcs->SQLTables) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLTablesW [ODBC32.154] */ @@ -6422,14 +6475,13 @@ SQLRETURN WINAPI SQLTablesW(SQLHSTMT StatementHandle, SQLWCHAR *CatalogName, SQL
if (handle->unix_handle) { - struct SQLTablesW_params params = { handle->unix_handle, CatalogName, NameLength1, SchemaName, NameLength2, - TableName, NameLength3, TableType, NameLength4 }; - ret = ODBC_CALL( SQLTablesW, ¶ms ); + ret = tables_unix_w( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + TableType, NameLength4 ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLTablesW( handle->win32_handle, CatalogName, NameLength1, SchemaName, NameLength2, - TableName, NameLength3, TableType, NameLength4 ); + ret = tables_win32_w( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + TableType, NameLength4 ); }
TRACE("Returning %d\n", ret);