Files
wine-staging/patches/odbc32-fixes/0018-odbc32-SQLGetDiagRecW-add-ANSI-fallback.patch
Alistair Leslie-Hughes f95009bb3e Updated odbc32-fixes patchset
Corrected Commit ascii to ANSI.
Reset patch numbers.
Convert SQL_C_WCHAR to SQL_CHAR when required for ANSI driver.
2025-05-05 11:54:43 +10:00

57 lines
1.9 KiB
Diff

From 1d2d97060b72cc99498fa440ae603f7db8ea74da Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Thu, 1 May 2025 07:32:58 +1000
Subject: [PATCH] odbc32: SQLGetDiagRecW add ANSI fallback.
---
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 be4908e258a..393eefc9791 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -6720,8 +6720,9 @@ static SQLRETURN get_diag_rec_win32_w( SQLSMALLINT type, struct object *obj, SQL
return SQL_ERROR;
}
- if (obj->win32_funcs->SQLErrorW)
+ if (obj->win32_funcs->SQLErrorW || obj->win32_funcs->SQLError)
{
+ SQLRETURN ret = SQL_ERROR;
SQLHENV env = NULL;
SQLHDBC con = NULL;
SQLHSTMT stmt = NULL;
@@ -6746,7 +6747,27 @@ static SQLRETURN get_diag_rec_win32_w( SQLSMALLINT type, struct object *obj, SQL
return SQL_ERROR;
}
- return obj->win32_funcs->SQLErrorW( env, con, stmt, state, native_err, msg, buflen, retlen );
+ if (obj->win32_funcs->SQLErrorW)
+ ret = obj->win32_funcs->SQLErrorW( env, con, stmt, state, native_err, msg, buflen, retlen );
+ else if (obj->win32_funcs->SQLError)
+ {
+ SQLCHAR stateA[6], *msgA = NULL;
+ SQLSMALLINT lenA;
+
+ if (!(msgA = malloc( buflen ))) return SQL_ERROR;
+ ret = obj->win32_funcs->SQLError( env, con, stmt, stateA, native_err, msgA, buflen, &lenA );
+ if (SUCCESS( ret ))
+ {
+ WCHAR *p = strnAtoW(msgA, lenA);
+ wcscpy(msg, p);
+ free(p);
+
+ MultiByteToWideChar( CP_ACP, 0, (const char *)stateA, 6, state, 12 );
+ }
+ free( msgA );
+
+ }
+ return ret;
}
return SQL_ERROR;
--
2.47.2