From 353a8681368713270c60ad8e191519737983e585 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Sat, 26 Apr 2025 12:34:21 +1000 Subject: [PATCH] Updated odbc32-fixes patchset Attempt to get PostgreSQL ascii ODBC driver working. --- ...ConnectW-fallback-to-SQLDriverConnec.patch | 64 +++++++++++++ ...2-SQLGetInfoW-support-ascii-fallback.patch | 59 ++++++++++++ ...cDirectW-call-fallback-SQLExecDirect.patch | 57 ++++++++++++ ...2-SQLDescribeColW-add-ascii-fallback.patch | 40 +++++++++ ...2-SQLGetStmtAttrW-add-ascii-fallback.patch | 26 ++++++ ...2-SQLSetStmtAttrW-add-ascii-fallback.patch | 29 ++++++ .../0025-odbc32-Various-ascii-fallback.patch | 89 +++++++++++++++++++ 7 files changed, 364 insertions(+) create mode 100644 patches/odbc32-fixes/0019-odbc32-SQLDriverConnectW-fallback-to-SQLDriverConnec.patch create mode 100644 patches/odbc32-fixes/0020-odbc32-SQLGetInfoW-support-ascii-fallback.patch create mode 100644 patches/odbc32-fixes/0021-odbc32-SQLExecDirectW-call-fallback-SQLExecDirect.patch create mode 100644 patches/odbc32-fixes/0022-odbc32-SQLDescribeColW-add-ascii-fallback.patch create mode 100644 patches/odbc32-fixes/0023-odbc32-SQLGetStmtAttrW-add-ascii-fallback.patch create mode 100644 patches/odbc32-fixes/0024-odbc32-SQLSetStmtAttrW-add-ascii-fallback.patch create mode 100644 patches/odbc32-fixes/0025-odbc32-Various-ascii-fallback.patch diff --git a/patches/odbc32-fixes/0019-odbc32-SQLDriverConnectW-fallback-to-SQLDriverConnec.patch b/patches/odbc32-fixes/0019-odbc32-SQLDriverConnectW-fallback-to-SQLDriverConnec.patch new file mode 100644 index 00000000..461171d1 --- /dev/null +++ b/patches/odbc32-fixes/0019-odbc32-SQLDriverConnectW-fallback-to-SQLDriverConnec.patch @@ -0,0 +1,64 @@ +From 518a165d51be822ae34c89146cd6a0d75e41852b Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Sat, 26 Apr 2025 12:33:23 +1000 +Subject: [PATCH] odbc32: SQLDriverConnectW fallback to SQLDriverConnect when + required. + +--- + dlls/odbc32/proxyodbc.c | 37 +++++++++++++++++++++++++++++++++++-- + 1 file changed, 35 insertions(+), 2 deletions(-) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index cf9d72e8452..e26fdcb8620 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -6861,11 +6861,44 @@ static SQLRETURN driver_connect_win32_w( struct connection *con, SQLHWND window, + SQLSMALLINT len, SQLWCHAR *out_conn_str, SQLSMALLINT buflen, SQLSMALLINT *len2, + SQLUSMALLINT completion ) + { ++ SQLRETURN ret = SQL_ERROR; ++ + if (con->hdr.win32_funcs->SQLDriverConnectW) + return con->hdr.win32_funcs->SQLDriverConnectW( con->hdr.win32_handle, window, in_conn_str, len, out_conn_str, + buflen, len2, completion ); +- if (con->hdr.win32_funcs->SQLDriverConnect) FIXME( "Unicode to ANSI conversion not handled\n" ); +- return SQL_ERROR; ++ if (con->hdr.win32_funcs->SQLDriverConnect) ++ { ++ SQLCHAR *in = NULL, *out = NULL; ++ SQLSMALLINT in_len = 0, out_len = 0; ++ ++ in_len = WideCharToMultiByte(CP_ACP, 0, in_conn_str, len, NULL, 0, NULL, NULL); ++ if (!(in = malloc(in_len + 1))) return SQL_ERROR; ++ ++ WideCharToMultiByte(CP_ACP, 0, in_conn_str, len, (char *)in, in_len, NULL, NULL); ++ in[in_len] = 0; ++ ++ if (out_conn_str && buflen > 0) ++ { ++ if (!(out = malloc(buflen))) ++ { ++ free(in); ++ return SQL_ERROR; ++ } ++ } ++ ++ ret = con->hdr.win32_funcs->SQLDriverConnect( con->hdr.win32_handle, window, in, in_len, out, buflen, &out_len, completion ); ++ ++ if (SQL_SUCCEEDED(ret) && out_conn_str && out) ++ { ++ MultiByteToWideChar(CP_ACP, 0, (char *)out, out_len, out_conn_str, buflen); ++ if (len2) *len2 = out_len; ++ } ++ ++ free(in); ++ free(out); ++ } ++ ++ return ret; + } + + static SQLRETURN driver_connect_unix_w( struct connection *con, SQLHWND window, SQLWCHAR *in_conn_str, SQLSMALLINT len, +-- +2.47.2 + diff --git a/patches/odbc32-fixes/0020-odbc32-SQLGetInfoW-support-ascii-fallback.patch b/patches/odbc32-fixes/0020-odbc32-SQLGetInfoW-support-ascii-fallback.patch new file mode 100644 index 00000000..8a16d678 --- /dev/null +++ b/patches/odbc32-fixes/0020-odbc32-SQLGetInfoW-support-ascii-fallback.patch @@ -0,0 +1,59 @@ +From 9b36b65dd25db374f53f51cc24b36637e80de2c2 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Sat, 26 Apr 2025 16:27:58 +1000 +Subject: [PATCH] odbc32: SQLGetInfoW support ascii fallback. + +--- + dlls/odbc32/proxyodbc.c | 31 +++++++++++++++++++++++++++++-- + 1 file changed, 29 insertions(+), 2 deletions(-) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index 7025a141bb6..495bf2ff446 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -6924,13 +6924,40 @@ static SQLRETURN get_info_unix_w( struct connection *con, SQLUSMALLINT type, SQL + return ODBC_CALL( SQLGetInfoW, ¶ms ); + } + ++static BOOL typeinfo_is_string( SQLSMALLINT type ) ++{ ++ switch (type) ++ { ++ case SQL_DRIVER_ODBC_VER: ++ case SQL_DRIVER_NAME: ++ return TRUE; ++ default: ++ { ++ FIXME("Type %d not handled\n", type); ++ return FALSE; ++ } ++ } ++} ++ + static SQLRETURN get_info_win32_w( struct connection *con, SQLUSMALLINT type, SQLPOINTER value, SQLSMALLINT buflen, + SQLSMALLINT *retlen ) + { ++ SQLRETURN ret = SQL_ERROR; ++ + if (con->hdr.win32_funcs->SQLGetInfoW) + return con->hdr.win32_funcs->SQLGetInfoW( con->hdr.win32_handle, type, value, buflen, retlen ); +- if (con->hdr.win32_funcs->SQLGetInfo) FIXME( "Unicode to ANSI conversion not handled\n" ); +- return SQL_ERROR; ++ if (con->hdr.win32_funcs->SQLGetInfo) ++ { ++ ret = con->hdr.win32_funcs->SQLGetInfo( con->hdr.win32_handle, type, value, buflen, retlen ); ++ FIXME("st %s\n", debugstr_a(value)); ++ if (SQL_SUCCEEDED(ret) && typeinfo_is_string(type)) ++ { ++ WCHAR *p = strnAtoW(value, buflen); ++ wcscpy(value, p); ++ free(p); ++ } ++ } ++ return ret; + } + + /************************************************************************* +-- +2.47.2 + diff --git a/patches/odbc32-fixes/0021-odbc32-SQLExecDirectW-call-fallback-SQLExecDirect.patch b/patches/odbc32-fixes/0021-odbc32-SQLExecDirectW-call-fallback-SQLExecDirect.patch new file mode 100644 index 00000000..d0129180 --- /dev/null +++ b/patches/odbc32-fixes/0021-odbc32-SQLExecDirectW-call-fallback-SQLExecDirect.patch @@ -0,0 +1,57 @@ +From 6beecab75df0c60ccde26fe8571172166efd5d72 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Sat, 26 Apr 2025 17:07:21 +1000 +Subject: [PATCH] odbc32: SQLExecDirectW call fallback SQLExecDirect + +--- + 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 e8b05a7b9ec..b792fcbe603 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -1099,6 +1099,20 @@ static SQLWCHAR *strnAtoW( const SQLCHAR *str, int len ) + return ret; + } + ++static inline char *strdupWtoA(const WCHAR *str) ++{ ++ char *ret = NULL; ++ ++ if(str) { ++ DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL); ++ ret = malloc(size); ++ if(ret) ++ WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL); ++ } ++ ++ return ret; ++} ++ + static SQLRETURN columns_unix_a( struct statement *stmt, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, + SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3, SQLCHAR *column, + SQLSMALLINT len4 ) +@@ -6073,10 +6087,17 @@ static SQLRETURN exec_direct_unix_w( struct statement *stmt, SQLWCHAR *text, SQL + + static SQLRETURN exec_direct_win32_w( struct statement *stmt, SQLWCHAR *text, SQLINTEGER len ) + { ++ SQLRETURN ret = SQL_ERROR; ++ + if (stmt->hdr.win32_funcs->SQLExecDirectW) + return stmt->hdr.win32_funcs->SQLExecDirectW( stmt->hdr.win32_handle, text, len ); +- if (stmt->hdr.win32_funcs->SQLExecDirect) FIXME( "Unicode to ANSI conversion not handled\n" ); +- return SQL_ERROR; ++ if (stmt->hdr.win32_funcs->SQLExecDirect) ++ { ++ SQLCHAR *textA = (SQLCHAR*)strdupWtoA( text ); ++ ret = stmt->hdr.win32_funcs->SQLExecDirect( stmt->hdr.win32_handle, textA, len ); ++ free(textA); ++ } ++ return ret; + } + + /************************************************************************* +-- +2.47.2 + diff --git a/patches/odbc32-fixes/0022-odbc32-SQLDescribeColW-add-ascii-fallback.patch b/patches/odbc32-fixes/0022-odbc32-SQLDescribeColW-add-ascii-fallback.patch new file mode 100644 index 00000000..f1769a66 --- /dev/null +++ b/patches/odbc32-fixes/0022-odbc32-SQLDescribeColW-add-ascii-fallback.patch @@ -0,0 +1,40 @@ +From ff127c9da0bcfe90fbf2c9d6bcbd63e11366b43c Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Sat, 26 Apr 2025 17:32:49 +1000 +Subject: [PATCH] odbc32: SQLDescribeColW add ascii fallback + +--- + dlls/odbc32/proxyodbc.c | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index b792fcbe603..c81ab1f39d3 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -5975,11 +5975,21 @@ static SQLRETURN describe_col_win32_w( struct statement *stmt, SQLUSMALLINT col_ + SQLSMALLINT buf_len, SQLSMALLINT *name_len, SQLSMALLINT *data_type, + SQLULEN *col_size, SQLSMALLINT *decimal_digits, SQLSMALLINT *nullable ) + { ++ SQLRETURN ret = SQL_ERROR; ++ + if (stmt->hdr.win32_funcs->SQLDescribeColW) + return stmt->hdr.win32_funcs->SQLDescribeColW( stmt->hdr.win32_handle, col_number, col_name, buf_len, + name_len, data_type, col_size, decimal_digits, nullable ); +- if (stmt->hdr.win32_funcs->SQLDescribeCol) FIXME( "Unicode to ANSI conversion not handled\n" ); +- return SQL_ERROR; ++ if (stmt->hdr.win32_funcs->SQLDescribeCol) ++ { ++ SQLCHAR *name = (SQLCHAR*)strdupWtoA( (WCHAR*)col_name ); ++ ++ ret = stmt->hdr.win32_funcs->SQLDescribeCol( stmt->hdr.win32_handle, col_number, name, buf_len, name_len, ++ data_type, col_size, decimal_digits, nullable); ++ ++ free(name); ++ } ++ return ret; + } + + /************************************************************************* +-- +2.47.2 + diff --git a/patches/odbc32-fixes/0023-odbc32-SQLGetStmtAttrW-add-ascii-fallback.patch b/patches/odbc32-fixes/0023-odbc32-SQLGetStmtAttrW-add-ascii-fallback.patch new file mode 100644 index 00000000..5a901c95 --- /dev/null +++ b/patches/odbc32-fixes/0023-odbc32-SQLGetStmtAttrW-add-ascii-fallback.patch @@ -0,0 +1,26 @@ +From a559a392ee8ff765c9784e9fe5f05c899e38c76e Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Sat, 26 Apr 2025 17:35:38 +1000 +Subject: [PATCH] odbc32: SQLGetStmtAttrW add ascii fallback + +--- + dlls/odbc32/proxyodbc.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index c81ab1f39d3..1036e6cfa96 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -6709,7 +6709,8 @@ static SQLRETURN get_stmt_attr_win32_w( struct statement *stmt, SQLINTEGER attr, + { + if (stmt->hdr.win32_funcs->SQLGetStmtAttrW) + return stmt->hdr.win32_funcs->SQLGetStmtAttrW( stmt->hdr.win32_handle, attr, value, buflen, retlen ); +- if (stmt->hdr.win32_funcs->SQLGetStmtAttr) FIXME( "Unicode to ANSI conversion not handled\n" ); ++ if (stmt->hdr.win32_funcs->SQLGetStmtAttr) ++ return stmt->hdr.win32_funcs->SQLGetStmtAttr( stmt->hdr.win32_handle, attr, value, buflen, retlen ); + return SQL_ERROR; + } + +-- +2.47.2 + diff --git a/patches/odbc32-fixes/0024-odbc32-SQLSetStmtAttrW-add-ascii-fallback.patch b/patches/odbc32-fixes/0024-odbc32-SQLSetStmtAttrW-add-ascii-fallback.patch new file mode 100644 index 00000000..347696ad --- /dev/null +++ b/patches/odbc32-fixes/0024-odbc32-SQLSetStmtAttrW-add-ascii-fallback.patch @@ -0,0 +1,29 @@ +From b69941179da4ae6c1d5db0b6b883fe8442e511c3 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Sat, 26 Apr 2025 17:51:54 +1000 +Subject: [PATCH] odbc32: SQLSetStmtAttrW add ascii fallback + +--- + dlls/odbc32/proxyodbc.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index 1036e6cfa96..cc638b63ddd 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -8031,7 +8031,11 @@ static SQLRETURN set_stmt_attr_win32_w( struct statement *stmt, SQLINTEGER attr, + { + if (stmt->hdr.win32_funcs->SQLSetStmtAttrW) + return stmt->hdr.win32_funcs->SQLSetStmtAttrW( stmt->hdr.win32_handle, attr, value, len ); +- if (stmt->hdr.win32_funcs->SQLSetStmtAttr) FIXME( "Unicode to ANSI conversion not handled\n" ); ++ if (stmt->hdr.win32_funcs->SQLSetStmtAttr) ++ { ++ FIXME( "Unicode to ANSI conversion not handled\n" ); ++ return stmt->hdr.win32_funcs->SQLSetStmtAttr( stmt->hdr.win32_handle, attr, value, len ); ++ } + else if (stmt->hdr.win32_funcs->SQLSetStmtOption) + { + /* ODBC v2.0 */ +-- +2.47.2 + diff --git a/patches/odbc32-fixes/0025-odbc32-Various-ascii-fallback.patch b/patches/odbc32-fixes/0025-odbc32-Various-ascii-fallback.patch new file mode 100644 index 00000000..effaf93f --- /dev/null +++ b/patches/odbc32-fixes/0025-odbc32-Various-ascii-fallback.patch @@ -0,0 +1,89 @@ +From 7020fa486aeaffb34399dd882cb817feb6a15adc Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Sat, 26 Apr 2025 19:18:17 +1000 +Subject: [PATCH] odbc32: Various ascii fallback + +Needs spliting. +--- + dlls/odbc32/proxyodbc.c | 34 +++++++++++++++++++++++++++++----- + 1 file changed, 29 insertions(+), 5 deletions(-) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index 81f5cb9a799..8d8448657ee 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -6411,7 +6411,11 @@ static SQLRETURN get_connect_attr_win32_w( struct connection *con, SQLINTEGER at + { + if (con->hdr.win32_funcs->SQLGetConnectAttrW) + return con->hdr.win32_funcs->SQLGetConnectAttrW( con->hdr.win32_handle, attr, value, buflen, retlen ); +- if (con->hdr.win32_funcs->SQLGetConnectAttr) FIXME( "Unicode to ANSI conversion not handled\n" ); ++ if (con->hdr.win32_funcs->SQLGetConnectAttr) ++ { ++ FIXME( "Unicode to ANSI conversion not handled\n" ); ++ return con->hdr.win32_funcs->SQLGetConnectAttr( con->hdr.win32_handle, attr, value, buflen, retlen ); ++ } + return SQL_ERROR; + } + +@@ -6577,7 +6581,12 @@ static SQLRETURN get_diag_field_win32_w( SQLSMALLINT type, struct object *obj, S + if (obj->win32_funcs->SQLGetDiagFieldW) + return obj->win32_funcs->SQLGetDiagFieldW( type, obj->win32_handle, rec_num, diag_id, diag_info, buflen, + retlen ); +- if (obj->win32_funcs->SQLGetDiagField) FIXME( "Unicode to ANSI conversion not handled\n" ); ++ if (obj->win32_funcs->SQLGetDiagField) ++ { ++ FIXME( "Unicode to ANSI conversion not handled\n" ); ++ return obj->win32_funcs->SQLGetDiagField( type, obj->win32_handle, rec_num, diag_id, diag_info, buflen, ++ retlen ); ++ } + return SQL_ERROR; + } + +@@ -6780,7 +6789,11 @@ static SQLRETURN set_connect_attr_win32_w( struct connection *con, SQLINTEGER at + { + if (con->hdr.win32_funcs->SQLSetConnectAttrW) + return con->hdr.win32_funcs->SQLSetConnectAttrW( con->hdr.win32_handle, attr, value, len ); +- if (con->hdr.win32_funcs->SQLSetConnectAttr) FIXME( "Unicode to ANSI conversion not handled\n" ); ++ if (con->hdr.win32_funcs->SQLSetConnectAttr) ++ { ++ FIXME( "Unicode to ANSI conversion not handled\n" ); ++ return con->hdr.win32_funcs->SQLSetConnectAttr( con->hdr.win32_handle, attr, value, len ); ++ } + else if(con->hdr.win32_funcs->SQLSetConnectOptionW) + { + /* ODBC v2 */ +@@ -7066,10 +7079,17 @@ static BOOL typeinfo_is_string( SQLSMALLINT type ) + { + case SQL_DRIVER_ODBC_VER: + case SQL_DRIVER_NAME: ++ case SQL_MULT_RESULT_SETS: ++ case SQL_NEED_LONG_DATA_LEN: + return TRUE; + default: +- { + FIXME("Type %d not handled\n", type); ++ case SQL_BOOKMARK_PERSISTENCE: ++ case SQL_LOCK_TYPES: ++ case SQL_POS_OPERATIONS: ++ case SQL_SCROLL_OPTIONS: ++ case SQL_STATIC_SENSITIVITY: ++ { + return FALSE; + } + } +@@ -7978,7 +7998,11 @@ static SQLRETURN set_desc_field_win32_w( struct descriptor *desc, SQLSMALLINT re + { + if (desc->hdr.win32_funcs->SQLSetDescFieldW) + return desc->hdr.win32_funcs->SQLSetDescFieldW( desc->hdr.win32_handle, record, id, value, len ); +- if (desc->hdr.win32_funcs->SQLSetDescField) FIXME( "Unicode to ANSI conversion not handled\n" ); ++ if (desc->hdr.win32_funcs->SQLSetDescField) ++ { ++ FIXME( "Unicode to ANSI conversion not handled\n" ); ++ return desc->hdr.win32_funcs->SQLSetDescField( desc->hdr.win32_handle, record, id, value, len ); ++ } + return SQL_ERROR; + } + +-- +2.47.2 +