From c72487ac8ae2279f43da906df6ac430fa55e2ae9 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Fri, 12 Jul 2024 14:29:17 +1000 Subject: [PATCH 06/15] 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 1f51ac2a27e..c4e1c046edc 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1915,7 +1915,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 ); } @@ -4285,6 +4299,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