wine-staging/patches/odbc32-fixes/0006-odbc32-SQLGetDiagRec-W-handle-fallback-function.patch

66 lines
3.1 KiB
Diff
Raw Normal View History

From 397d95d8e50299f949ac73b0cc245f5fe66cacae Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 12 Jul 2024 14:29:17 +1000
Subject: [PATCH] odbc32: SQLGetDiagRec/W handle fallback function
---
dlls/odbc32/proxyodbc.c | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 5ead68700df..97c4cac8e31 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -2672,7 +2672,21 @@ SQLRETURN WINAPI SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMAL
}
else if (obj->win32_handle)
{
- ret = get_diag_rec_win32_a( HandleType, obj, RecNumber, SqlState, NativeError, MessageText, BufferLength,
+ /* ODBC v2.0 */
+ if (obj->win32_funcs->SQLError)
+ {
+ if (HandleType == SQL_HANDLE_ENV)
+ ret = obj->win32_funcs->SQLError(obj->win32_handle, SQL_NULL_HDBC, SQL_NULL_HSTMT,
+ SqlState, NativeError, MessageText, BufferLength, TextLength);
+ else if (HandleType == SQL_HANDLE_DBC)
+ ret = obj->win32_funcs->SQLError(SQL_NULL_HENV, obj->win32_handle, SQL_NULL_HSTMT,
+ SqlState, NativeError, MessageText, BufferLength, TextLength);
+ else if (HandleType == SQL_HANDLE_STMT)
+ ret = obj->win32_funcs->SQLError(SQL_NULL_HENV, SQL_NULL_HDBC, obj->win32_handle,
+ SqlState, NativeError, MessageText, BufferLength, TextLength);
+ }
+ else
+ ret = get_diag_rec_win32_a( HandleType, obj, RecNumber, SqlState, NativeError, MessageText, BufferLength,
TextLength );
}
@@ -6187,9 +6201,23 @@ static SQLRETURN get_diag_rec_win32_w( SQLSMALLINT type, struct object *obj, SQL
SQLSMALLINT *retlen )
{
if (obj->win32_funcs->SQLGetDiagRecW)
- return obj->win32_funcs->SQLGetDiagRecW( type, obj->win32_handle, rec_num, state, native_err, msg, buflen,
- retlen );
+ return obj->win32_funcs->SQLGetDiagRecW( type, obj->win32_handle, rec_num, state, native_err,
+ msg, buflen, retlen );
+ else if (obj->win32_funcs->SQLErrorW)
+ {
+ /* ODBC v2 */
+ if (type == SQL_HANDLE_ENV)
+ return obj->win32_funcs->SQLErrorW(obj->win32_handle, SQL_NULL_HDBC, SQL_NULL_HSTMT,
+ state, native_err, msg, buflen, retlen);
+ else if (type == SQL_HANDLE_DBC)
+ return obj->win32_funcs->SQLErrorW(SQL_NULL_HENV, obj->win32_handle, SQL_NULL_HSTMT,
+ state, native_err, msg, buflen, retlen);
+ else if (type == SQL_HANDLE_STMT)
+ return obj->win32_funcs->SQLErrorW(SQL_NULL_HENV, SQL_NULL_HDBC, obj->win32_handle,
+ state, native_err, msg, buflen, retlen);
+ }
if (obj->win32_funcs->SQLGetDiagRec) FIXME( "Unicode to ANSI conversion not handled\n" );
+
return SQL_ERROR;
}
--
2.43.0