diff --git a/patches/odbc32-fixes/0015-odbc32-SQLAllocHandle-use-fallback-for-ODBC-2.0.patch b/patches/odbc32-fixes/0015-odbc32-SQLAllocHandle-use-fallback-for-ODBC-2.0.patch new file mode 100644 index 00000000..340d662f --- /dev/null +++ b/patches/odbc32-fixes/0015-odbc32-SQLAllocHandle-use-fallback-for-ODBC-2.0.patch @@ -0,0 +1,38 @@ +From 0f53e844d9fba3ff36f340d989f7d16223a62dfd Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Wed, 17 Jul 2024 16:58:44 +1000 +Subject: [PATCH] odbc32: SQLAllocHandle use fallback for ODBC 2.0 + +--- + dlls/odbc32/proxyodbc.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index dd68872743e..e6ffd4d6fc7 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -440,7 +440,20 @@ SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, S + } + else if (input->win32_handle) + { +- ret = input->win32_funcs->SQLAllocHandle( HandleType, input->win32_handle, &output->win32_handle ); ++ if(input->win32_funcs->SQLAllocHandle) ++ ret = input->win32_funcs->SQLAllocHandle( HandleType, input->win32_handle, &output->win32_handle ); ++ else ++ { ++ /* ODBC v2.0 */ ++ if (HandleType == SQL_HANDLE_STMT) ++ { ++ if (input->win32_funcs->SQLAllocStmt) ++ { ++ ret = input->win32_funcs->SQLAllocStmt( input->win32_handle, &output->win32_handle ); ++ } ++ } ++ } ++ + if (SUCCESS( ret )) output->win32_funcs = input->win32_funcs; + } + +-- +2.43.0 + diff --git a/patches/odbc32-fixes/0016-odbc32-Record-loaded-driver-SQL_ATTR_ODBC_VERSION.patch b/patches/odbc32-fixes/0016-odbc32-Record-loaded-driver-SQL_ATTR_ODBC_VERSION.patch new file mode 100644 index 00000000..f9558495 --- /dev/null +++ b/patches/odbc32-fixes/0016-odbc32-Record-loaded-driver-SQL_ATTR_ODBC_VERSION.patch @@ -0,0 +1,47 @@ +From 3472c0211aa199df18e0d328d31d9efc290b89b4 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Thu, 18 Jul 2024 07:13:48 +1000 +Subject: [PATCH] odbc32: Record loaded driver SQL_ATTR_ODBC_VERSION + +--- + dlls/odbc32/proxyodbc.c | 4 ++++ + dlls/odbc32/unixlib.h | 1 + + 2 files changed, 5 insertions(+) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index e6ffd4d6fc7..611362dbd7c 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -376,6 +376,7 @@ static struct handle *create_handle( struct handle *parent ) + if (!(ret = calloc( 1, sizeof(*ret) ))) return NULL; + ret->parent = parent; + ret->env_attr_version = SQL_OV_ODBC2; ++ ret->driver_ver = SQL_OV_ODBC2; + ret->row_count = 1; + return ret; + } +@@ -872,6 +873,9 @@ static SQLRETURN set_env_attr( struct handle *handle, SQLINTEGER attr, SQLPOINTE + } + else if (handle->win32_handle) + { ++ if (handle->win32_funcs->SQLGetEnvAttr) ++ ret = handle->win32_funcs->SQLGetEnvAttr( handle->win32_handle, SQL_ATTR_ODBC_VERSION, &handle->driver_ver, 0, NULL ); ++ + if (handle->win32_funcs->SQLSetEnvAttr) + ret = handle->win32_funcs->SQLSetEnvAttr( handle->win32_handle, attr, value, len ); + } +diff --git a/dlls/odbc32/unixlib.h b/dlls/odbc32/unixlib.h +index fc69857c8b7..61b8429768d 100644 +--- a/dlls/odbc32/unixlib.h ++++ b/dlls/odbc32/unixlib.h +@@ -211,6 +211,7 @@ struct handle + UINT32 sources_idx; + void *sources_key; + BOOL sources_system; ++ UINT32 driver_ver; + /* parameter bindings */ + struct param_binding bind_col; + struct param_binding bind_parameter; +-- +2.43.0 + diff --git a/patches/odbc32-fixes/0017-odbc32-SQLGetData-support-ODBC-v2.0.patch b/patches/odbc32-fixes/0017-odbc32-SQLGetData-support-ODBC-v2.0.patch new file mode 100644 index 00000000..1ce7e4ef --- /dev/null +++ b/patches/odbc32-fixes/0017-odbc32-SQLGetData-support-ODBC-v2.0.patch @@ -0,0 +1,32 @@ +From 610fdcdfc1a63432a6476adc46050fbe30db4f81 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Wed, 17 Jul 2024 21:55:20 +1000 +Subject: [PATCH] odbc32: SQLGetData support ODBC v2.0 + +--- + dlls/odbc32/proxyodbc.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index 611362dbd7c..9ca4f35c332 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -1750,6 +1750,15 @@ SQLRETURN WINAPI SQLGetData(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, + } + else if (handle->win32_handle) + { ++ if (handle->env_attr_version == SQL_OV_ODBC2) ++ { ++ if (TargetType == SQL_C_TYPE_TIME) ++ TargetType = SQL_C_TIME; ++ else if (TargetType == SQL_C_TYPE_DATE) ++ TargetType = SQL_C_DATE; ++ else if (TargetType == SQL_C_TYPE_TIMESTAMP) ++ TargetType = SQL_C_TIMESTAMP; ++ } + ret = handle->win32_funcs->SQLGetData( handle->win32_handle, ColumnNumber, TargetType, TargetValue, + BufferLength, StrLen_or_Ind ); + } +-- +2.43.0 + diff --git a/patches/odbc32-fixes/0018-odbc32-SQLColAttributesW-support-ODBC-v2.0.patch b/patches/odbc32-fixes/0018-odbc32-SQLColAttributesW-support-ODBC-v2.0.patch new file mode 100644 index 00000000..60209a2e --- /dev/null +++ b/patches/odbc32-fixes/0018-odbc32-SQLColAttributesW-support-ODBC-v2.0.patch @@ -0,0 +1,87 @@ +From bd50499e151d9bb56254dcc8d3f745dd3e7828d6 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Wed, 17 Jul 2024 22:03:03 +1000 +Subject: [PATCH] odbc32: SQLColAttributesW support ODBC v2.0 + +--- + dlls/odbc32/proxyodbc.c | 39 +++++++++++++++++++++++++++++++++++---- + 1 file changed, 35 insertions(+), 4 deletions(-) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index 9ca4f35c332..91881635cab 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -455,7 +455,12 @@ SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, S + } + } + +- if (SUCCESS( ret )) output->win32_funcs = input->win32_funcs; ++ if (SUCCESS( ret )) ++ { ++ output->win32_funcs = input->win32_funcs; ++ output->env_attr_version = input->env_attr_version; ++ output->driver_ver = input->driver_ver; ++ } + } + + if (SUCCESS( ret )) *OutputHandle = output; +@@ -486,7 +491,12 @@ SQLRETURN WINAPI SQLAllocStmt(SQLHDBC ConnectionHandle, SQLHSTMT *StatementHandl + else if (con->win32_handle) + { + ret = con->win32_funcs->SQLAllocStmt( con->win32_handle, &stmt->win32_handle ); +- if (SUCCESS( ret )) stmt->win32_funcs = con->win32_funcs; ++ if (SUCCESS( ret )) ++ { ++ stmt->win32_funcs = con->win32_funcs; ++ stmt->env_attr_version = con->env_attr_version; ++ stmt->driver_ver = con->driver_ver; ++ } + } + + if (SUCCESS( ret )) *StatementHandle = stmt; +@@ -525,7 +535,12 @@ SQLRETURN WINAPI SQLAllocHandleStd(SQLSMALLINT HandleType, SQLHANDLE InputHandle + else if (input->win32_handle) + { + ret = input->win32_funcs->SQLAllocHandleStd( HandleType, input->win32_handle, &output->win32_handle ); +- if (SUCCESS( ret )) output->win32_funcs = input->win32_funcs; ++ if (SUCCESS( ret )) ++ { ++ output->win32_funcs = input->win32_funcs; ++ output->env_attr_version = input->env_attr_version; ++ output->driver_ver = input->driver_ver; ++ } + } + + if (SUCCESS( ret )) *OutputHandle = output; +@@ -4130,11 +4145,27 @@ static SQLRETURN col_attribute_win32_w( struct handle *handle, SQLUSMALLINT col, + retlen, num_attr ); + else if(handle->win32_funcs->SQLColAttributesW) + { ++ SQLRETURN ret; ++ + /* ODBC v2 */ + field_id = map_odbc3_to_2(field_id); +- return handle->win32_funcs->SQLColAttributesW( handle->win32_handle, col, field_id, ++ ret = handle->win32_funcs->SQLColAttributesW( handle->win32_handle, col, field_id, + char_attr, buflen, retlen, + num_attr ); ++ /* Convert back for ODBC3 drivers */ ++ if (num_attr && field_id == SQL_COLUMN_TYPE && ++ handle->env_attr_version == SQL_OV_ODBC2 && ++ handle->driver_ver == SQL_OV_ODBC3) ++ { ++ if (*num_attr == SQL_TIME) ++ *num_attr = SQL_TYPE_TIME; ++ else if (*num_attr == SQL_DATETIME) ++ *num_attr = SQL_TYPE_DATE; ++ else if (*num_attr == SQL_TIMESTAMP) ++ *num_attr = SQL_TYPE_TIMESTAMP; ++ } ++ ++ return ret; + } + if (handle->win32_funcs->SQLColAttribute) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +-- +2.43.0 + diff --git a/patches/odbc32-fixes/0019-odbc32-SQLSetStmtAttrW-support-fallback-for-ODBC-v2..patch b/patches/odbc32-fixes/0019-odbc32-SQLSetStmtAttrW-support-fallback-for-ODBC-v2..patch new file mode 100644 index 00000000..a47a3ff9 --- /dev/null +++ b/patches/odbc32-fixes/0019-odbc32-SQLSetStmtAttrW-support-fallback-for-ODBC-v2..patch @@ -0,0 +1,35 @@ +From fa52f2afdfb554e43ca32a137378e9aaa052a097 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Wed, 17 Jul 2024 22:04:39 +1000 +Subject: [PATCH] odbc32: SQLSetStmtAttrW support fallback for ODBC v2.0 + +--- + dlls/odbc32/proxyodbc.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c +index 91881635cab..f6e2cd61436 100644 +--- a/dlls/odbc32/proxyodbc.c ++++ b/dlls/odbc32/proxyodbc.c +@@ -5388,7 +5388,17 @@ SQLRETURN WINAPI SQLSetStmtAttrW(SQLHSTMT StatementHandle, SQLINTEGER Attribute, + } + else if (handle->win32_handle) + { +- ret = handle->win32_funcs->SQLSetStmtAttrW( handle->win32_handle, Attribute, Value, StringLength ); ++ if(handle->win32_funcs->SQLSetStmtAttrW) ++ ret = handle->win32_funcs->SQLSetStmtAttrW( handle->win32_handle, Attribute, Value, StringLength ); ++ else ++ { ++ /* ODBC v2.0 */ ++ if (handle->win32_funcs->SQLSetStmtOption) ++ { ++ ret = handle->win32_funcs->SQLSetStmtOption( handle->win32_handle, Attribute, (SQLULEN)Value ); ++ } ++ } ++ + } + + TRACE("Returning %d\n", ret); +-- +2.43.0 +