From 42a307df6790bdf84f2fd9095a4a4c169a797782 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Thu, 1 May 2025 06:50:48 +1000 Subject: [PATCH] Updated odbc32-fixes patchset More support for the PostgreSQL ODBC ascii driver. --- ...-SQLColAttributeW-Add-ascii-fallback.patch | 2 +- ...28-SQLGetDiagRecW-Add-ascii-fallback.patch | 56 +++++++++++++++++++ ...c32-SQLNativeSqlW-add-ascii-fallback.patch | 52 +++++++++++++++++ ...dbc32-SQLPrepareW-add-ascii-fallback.patch | 36 ++++++++++++ 4 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 patches/odbc32-fixes/0028-SQLGetDiagRecW-Add-ascii-fallback.patch create mode 100644 patches/odbc32-fixes/0029-odbc32-SQLNativeSqlW-add-ascii-fallback.patch create mode 100644 patches/odbc32-fixes/0030-odbc32-SQLPrepareW-add-ascii-fallback.patch diff --git a/patches/odbc32-fixes/0027-odbc32-SQLColAttributeW-Add-ascii-fallback.patch b/patches/odbc32-fixes/0027-odbc32-SQLColAttributeW-Add-ascii-fallback.patch index dca5e23e..5f1f7f14 100644 --- a/patches/odbc32-fixes/0027-odbc32-SQLColAttributeW-Add-ascii-fallback.patch +++ b/patches/odbc32-fixes/0027-odbc32-SQLColAttributeW-Add-ascii-fallback.patch @@ -37,7 +37,7 @@ index b490da9012f..b17f8a46e0e 100644 + 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) && strA && retlen ) ++ if (ret == SQL_SUCCESS && SQLColAttributes_KnownStringAttribute(field_id) ) + { + if (strA) + { diff --git a/patches/odbc32-fixes/0028-SQLGetDiagRecW-Add-ascii-fallback.patch b/patches/odbc32-fixes/0028-SQLGetDiagRecW-Add-ascii-fallback.patch new file mode 100644 index 00000000..07d2e466 --- /dev/null +++ b/patches/odbc32-fixes/0028-SQLGetDiagRecW-Add-ascii-fallback.patch @@ -0,0 +1,56 @@ +From 2b03235b360575563a2ffee961c9447699edce0d Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Thu, 1 May 2025 07:32:58 +1000 +Subject: [PATCH] SQLGetDiagRecW: Add ascii fallback + +--- + dlls/odbc32/proxyodbc.c | 25 +++++++++++++++++++++++-- + 1 file changed, 23 insertions(+), 2 deletions(-) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index b607c361416..377124653c1 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -6716,8 +6716,9 @@ static SQLRETURN get_diag_rec_win32_w( SQLSMALLINT type, struct object *obj, SQL + return SQL_ERROR; + } + +- if (obj->win32_funcs->SQLErrorW) ++ if (obj->win32_funcs->SQLErrorW || obj->win32_funcs->SQLError) + { ++ SQLRETURN ret = SQL_ERROR; + SQLHENV env = NULL; + SQLHDBC con = NULL; + SQLHSTMT stmt = NULL; +@@ -6742,7 +6743,27 @@ static SQLRETURN get_diag_rec_win32_w( SQLSMALLINT type, struct object *obj, SQL + return SQL_ERROR; + } + +- return obj->win32_funcs->SQLErrorW( env, con, stmt, state, native_err, msg, buflen, retlen ); ++ if (obj->win32_funcs->SQLErrorW) ++ ret = obj->win32_funcs->SQLErrorW( env, con, stmt, state, native_err, msg, buflen, retlen ); ++ else if (obj->win32_funcs->SQLError) ++ { ++ SQLCHAR stateA[6], *msgA = NULL; ++ SQLSMALLINT lenA; ++ ++ if (!(msgA = malloc( buflen ))) return SQL_ERROR; ++ ret = obj->win32_funcs->SQLError( env, con, stmt, stateA, native_err, msgA, buflen, &lenA ); ++ if (SUCCESS( ret )) ++ { ++ WCHAR *p = strnAtoW(msgA, lenA); ++ wcscpy(msg, p); ++ free(p); ++ ++ MultiByteToWideChar( CP_ACP, 0, (const char *)stateA, 6, state, 12 ); ++ } ++ free( msgA ); ++ ++ } ++ return ret; + } + + return SQL_ERROR; +-- +2.47.2 + diff --git a/patches/odbc32-fixes/0029-odbc32-SQLNativeSqlW-add-ascii-fallback.patch b/patches/odbc32-fixes/0029-odbc32-SQLNativeSqlW-add-ascii-fallback.patch new file mode 100644 index 00000000..f44c163a --- /dev/null +++ b/patches/odbc32-fixes/0029-odbc32-SQLNativeSqlW-add-ascii-fallback.patch @@ -0,0 +1,52 @@ +From 7f895746aa93f74933dab0f2e115c4feb2d57556 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Thu, 1 May 2025 08:05:31 +1000 +Subject: [PATCH] odbc32: SQLNativeSqlW add ascii fallback + +--- + dlls/odbc32/proxyodbc.c | 26 ++++++++++++++++++++++++-- + 1 file changed, 24 insertions(+), 2 deletions(-) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index ca2f94cb250..799ea5accf2 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -7819,11 +7819,33 @@ static SQLRETURN native_sql_unix_w( struct connection *con, SQLWCHAR *in_stateme + static SQLRETURN native_sql_win32_w( struct connection *con, SQLWCHAR *in_statement, SQLINTEGER len, + SQLWCHAR *out_statement, SQLINTEGER buflen, SQLINTEGER *retlen ) + { ++ SQLRETURN ret = SQL_ERROR; ++ + if (con->hdr.win32_funcs->SQLNativeSqlW) + return con->hdr.win32_funcs->SQLNativeSqlW( con->hdr.win32_handle, in_statement, len, out_statement, buflen, + retlen ); +- if (con->hdr.win32_funcs->SQLNativeSql) FIXME( "Unicode to ANSI conversion not handled\n" ); +- return SQL_ERROR; ++ if (con->hdr.win32_funcs->SQLNativeSql) ++ { ++ SQLCHAR *statement = (SQLCHAR*)strdupWtoA( (WCHAR*)in_statement ); ++ SQLCHAR *out = NULL; ++ if (buflen) ++ out = malloc( buflen ); ++ ++ ret = con->hdr.win32_funcs->SQLNativeSql( con->hdr.win32_handle, statement, len, out, buflen, retlen ); ++ if(ret == SQL_SUCCESS) ++ { ++ if (out_statement) ++ { ++ MultiByteToWideChar( CP_ACP, 0, (const char *)out, len, out_statement, buflen ); ++ out_statement[buflen] = 0; ++ } ++ } ++ if (retlen) *retlen *= sizeof(WCHAR); ++ ++ free( statement ); ++ free( out ); ++ } ++ return ret; + } + + /************************************************************************* +-- +2.47.2 + diff --git a/patches/odbc32-fixes/0030-odbc32-SQLPrepareW-add-ascii-fallback.patch b/patches/odbc32-fixes/0030-odbc32-SQLPrepareW-add-ascii-fallback.patch new file mode 100644 index 00000000..3c2b5b31 --- /dev/null +++ b/patches/odbc32-fixes/0030-odbc32-SQLPrepareW-add-ascii-fallback.patch @@ -0,0 +1,36 @@ +From fbc17da7bbb48155d2fe1225f159a2b50b7aaf65 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Thu, 1 May 2025 08:10:04 +1000 +Subject: [PATCH] odbc32: SQLPrepareW add ascii fallback + +--- + dlls/odbc32/proxyodbc.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index 799ea5accf2..0fed17640c1 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -6199,10 +6199,17 @@ static SQLRETURN prepare_unix_w( struct statement *stmt, SQLWCHAR *statement, SQ + + static SQLRETURN prepare_win32_w( struct statement *stmt, SQLWCHAR *statement, SQLINTEGER len ) + { ++ SQLRETURN ret = SQL_ERROR; ++ + if (stmt->hdr.win32_funcs->SQLPrepareW) + return stmt->hdr.win32_funcs->SQLPrepareW( stmt->hdr.win32_handle, statement, len ); +- if (stmt->hdr.win32_funcs->SQLPrepare) FIXME( "Unicode to ANSI conversion not handled\n" ); +- return SQL_ERROR; ++ if (stmt->hdr.win32_funcs->SQLPrepare) ++ { ++ SQLCHAR *statementA = (SQLCHAR*)strdupWtoA( statement ); ++ ret = stmt->hdr.win32_funcs->SQLPrepare( stmt->hdr.win32_handle, statementA, len ); ++ free(statementA); ++ } ++ return ret; + } + + /************************************************************************* +-- +2.47.2 +