From 5adaf024fbb6afb2a0f9f1db51df61105cdc3c17 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Tue, 29 Apr 2025 13:08:38 +1000 Subject: [PATCH] odbc32: SQLColAttributeW - Add ANSI fallback --- dlls/odbc32/proxyodbc.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 8b74c2b3d5f..84a099bd4a0 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -6544,7 +6544,7 @@ static SQLRETURN col_attribute_win32_w( struct statement *stmt, SQLUSMALLINT col return ret; } - if (stmt->hdr.win32_funcs->SQLColAttributesW) + if (stmt->hdr.win32_funcs->SQLColAttributesW || stmt->hdr.win32_funcs->SQLColAttributes) { if (buflen < 0) return SQL_ERROR; if (!col) @@ -6593,8 +6593,43 @@ static SQLRETURN col_attribute_win32_w( struct statement *stmt, SQLUSMALLINT col FIXME( "field id %u not handled\n", field_id ); } - ret = stmt->hdr.win32_funcs->SQLColAttributesW( stmt->hdr.win32_handle, col, field_id, char_attr, buflen, + if (stmt->hdr.win32_funcs->SQLColAttributes) + { + SQLCHAR *strA = char_attr; + + if (char_attr && buflen && SQLColAttributes_KnownStringAttribute(field_id)) + { + strA = malloc( buflen ); + } + + ret = stmt->hdr.win32_funcs->SQLColAttributes( stmt->hdr.win32_handle, col, field_id, strA, buflen, + retlen, num_attr ); + + if (ret == SQL_SUCCESS && SQLColAttributes_KnownStringAttribute(field_id) ) + { + if (strA) + { + WCHAR *p = strnAtoW(strA, -1); + wcscpy(char_attr, p); + free(p); + + if (retlen) + *retlen = wcslen( char_attr ) * sizeof(WCHAR); + } + else if (retlen) + *retlen = *retlen * sizeof(WCHAR); + } + + if (strA != char_attr) + free(strA); + + } + else + { + ret = stmt->hdr.win32_funcs->SQLColAttributesW( stmt->hdr.win32_handle, col, field_id, char_attr, buflen, retlen, num_attr ); + } + /* Convert back for ODBC2 drivers */ env = (struct environment *)find_object_type(SQL_HANDLE_ENV, stmt->hdr.parent); conn = (struct connection *)find_object_type(SQL_HANDLE_DBC, stmt->hdr.parent); -- 2.51.0