wine-staging/patches/odbc32-fixes/0005-odbc32-SQLGetDiagRec-W-handle-fallback-function.patch
2024-07-16 09:23:21 +10:00

60 lines
3.0 KiB
Diff

From aef32555c4c66db02760335f30ca060f83c7df9c 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 | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 7c34d905154..53c2cdb4362 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1872,7 +1872,21 @@ SQLRETURN WINAPI SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMAL
}
else if (handle->win32_handle)
{
- ret = get_diag_rec_win32_a( HandleType, handle, RecNumber, SqlState, NativeError, MessageText, BufferLength,
+ /* ODBC v2.0 */
+ if (handle->win32_funcs->SQLError)
+ {
+ if (HandleType == SQL_HANDLE_ENV)
+ ret = handle->win32_funcs->SQLError(handle->win32_handle, SQL_NULL_HDBC, SQL_NULL_HSTMT,
+ SqlState, NativeError, MessageText, BufferLength, TextLength);
+ else if (HandleType == SQL_HANDLE_DBC)
+ ret = handle->win32_funcs->SQLError(SQL_NULL_HENV, handle->win32_handle, SQL_NULL_HSTMT,
+ SqlState, NativeError, MessageText, BufferLength, TextLength);
+ else if (HandleType == SQL_HANDLE_STMT)
+ ret = handle->win32_funcs->SQLError(SQL_NULL_HENV, SQL_NULL_HDBC, handle->win32_handle,
+ SqlState, NativeError, MessageText, BufferLength, TextLength);
+ }
+ else
+ ret = get_diag_rec_win32_a( HandleType, handle, RecNumber, SqlState, NativeError, MessageText, BufferLength,
TextLength );
}
@@ -4228,6 +4242,19 @@ static SQLRETURN get_diag_rec_win32_w( SQLSMALLINT handle_type, struct handle *h
if (handle->win32_funcs->SQLGetDiagRecW)
return handle->win32_funcs->SQLGetDiagRecW( handle_type, handle->win32_handle, rec_num, state, native_err,
msg, buflen, retlen );
+ else if (handle->win32_funcs->SQLErrorW)
+ {
+ /* ODBC v2 */
+ if (handle_type == SQL_HANDLE_ENV)
+ return handle->win32_funcs->SQLErrorW(handle->win32_handle, SQL_NULL_HDBC, SQL_NULL_HSTMT,
+ state, native_err, msg, buflen, retlen);
+ else if (handle_type == SQL_HANDLE_DBC)
+ return handle->win32_funcs->SQLErrorW(SQL_NULL_HENV, handle->win32_handle, SQL_NULL_HSTMT,
+ state, native_err, msg, buflen, retlen);
+ else if (handle_type == SQL_HANDLE_STMT)
+ return handle->win32_funcs->SQLErrorW(SQL_NULL_HENV, SQL_NULL_HDBC, handle->win32_handle,
+ state, native_err, msg, buflen, retlen);
+ }
if (handle->win32_funcs->SQLGetDiagRec) FIXME( "Unicode to ANSI conversion not handled\n" );
return SQL_ERROR;
}
--
2.43.0