Files
wine-staging/patches/odbc32-fixes/0018-odbc32-SQLGetDiagRecW-add-ANSI-fallback.patch
Alistair Leslie-Hughes 3714d05e91 Updated odbc32-fixes patchset
2025-09-08 09:54:01 +10:00

57 lines
1.9 KiB
Diff

From a5f46ebf71b1ae10a8af5224157532639b5cd2b4 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 d6946e1c66d..4ff20236cce 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -6791,8 +6791,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;
@@ -6817,7 +6818,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.50.1