From 644fc34023107225a278abc7a41249c98ab1126b 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 cc8a718a754..be4908e258a 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -6340,7 +6340,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) @@ -6388,8 +6388,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); if (SQL_SUCCEEDED(ret) && num_attr && field_id == SQL_COLUMN_TYPE && -- 2.47.2