From c78b5e8e4749612b72f2c838ba124c9469ed39e9 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Sat, 26 Apr 2025 17:07:21 +1000 Subject: [PATCH] odbc32: SQLExecDirectW call fallback SQLExecDirect --- 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 63539882a61..25a76c8d111 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1099,6 +1099,20 @@ static SQLWCHAR *strnAtoW( const SQLCHAR *str, int len ) return ret; } +static inline char *strdupWtoA(const WCHAR *str) +{ + char *ret = NULL; + + if(str) { + DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL); + ret = malloc(size); + if(ret) + WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL); + } + + return ret; +} + static SQLRETURN columns_unix_a( struct statement *stmt, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3, SQLCHAR *column, SQLSMALLINT len4 ) @@ -6078,10 +6092,17 @@ static SQLRETURN exec_direct_unix_w( struct statement *stmt, SQLWCHAR *text, SQL static SQLRETURN exec_direct_win32_w( struct statement *stmt, SQLWCHAR *text, SQLINTEGER len ) { + SQLRETURN ret = SQL_ERROR; + if (stmt->hdr.win32_funcs->SQLExecDirectW) return stmt->hdr.win32_funcs->SQLExecDirectW( stmt->hdr.win32_handle, text, len ); - if (stmt->hdr.win32_funcs->SQLExecDirect) FIXME( "Unicode to ANSI conversion not handled\n" ); - return SQL_ERROR; + if (stmt->hdr.win32_funcs->SQLExecDirect) + { + SQLCHAR *textA = (SQLCHAR*)strdupWtoA( text ); + ret = stmt->hdr.win32_funcs->SQLExecDirect( stmt->hdr.win32_handle, textA, len ); + free(textA); + } + return ret; } /************************************************************************* -- 2.47.2