Updated odbc-remove-unixodbc patchset

Use fallback for SQLColAttributeW for ODBC v2.0 drivers.
Use fallback for SQLGetDiagRecW for ODBC v2.0 drivers
Thanks Steve Fawcett

Use fallback for SQLBindParameter for ODBC v2.0 drivers.
Use fallback for SQLGetConnectAttr/W for ODBC v2.0 drivers.
Use fallback for SQLSetConnectAttr/W for ODBC v2.0 drivers.

Forward SQLSetConnectAttr onto driver.
Forward SQLError/W onto driver (new patch).
This commit is contained in:
Alistair Leslie-Hughes 2024-06-08 14:32:02 +10:00
parent 87a5dcecb7
commit 9e8e2ae892
6 changed files with 212 additions and 39 deletions

View File

@ -1,18 +1,60 @@
From 54744cb90ebf7ebe9ae60e6f4de12586c6d2083f Mon Sep 17 00:00:00 2001
From 827ccc5a0ef8a1b1e1290d7225f25619ca11fcf0 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 08:55:12 +1100
Subject: [PATCH 10/42] odbc32: Foward SQLSetConnectAttr requets onto the
driver
Subject: [PATCH] odbc32: Foward SQLSetConnectAttr requets onto the driver
---
dlls/odbc32/proxyodbc.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
dlls/odbc32/proxyodbc.c | 49 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 44 insertions(+), 5 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 6e4e1a68011..89062e9cadf 100644
index e816caa0daa..00822d9d263 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1812,6 +1812,7 @@ SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribu
@@ -1042,11 +1042,40 @@ SQLRETURN WINAPI SQLRowCount(SQLHSTMT StatementHandle, SQLLEN *RowCount)
SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER Value,
SQLINTEGER StringLength)
{
- SQLRETURN ret = SQL_ERROR;
+ struct SQLHDBC_data *hdbc = ConnectionHandle;
+ SQLRETURN ret = SQL_SUCCESS;
- FIXME("(ConnectionHandle %p, Attribute %d, Value %p, StringLength %d)\n", ConnectionHandle, Attribute, Value,
+ TRACE("(ConnectionHandle %p, Attribute %d, Value %p, StringLength %d)\n", ConnectionHandle, Attribute, Value,
StringLength);
+ if (hdbc->type != SQL_HANDLE_DBC)
+ {
+ WARN("Wrong handle type %d\n", hdbc->type);
+ return SQL_ERROR;
+ }
+
+ switch(Attribute)
+ {
+ case SQL_ATTR_LOGIN_TIMEOUT:
+ if (Value)
+ hdbc->login_timeout = (intptr_t)Value;
+ else
+ hdbc->login_timeout = 0;
+ break;
+ default:
+ if (hdbc->pSQLSetConnectAttr)
+ ret = hdbc->pSQLSetConnectAttr(hdbc->driver_hdbc, Attribute, Value, StringLength);
+ else if(hdbc->pSQLSetConnectOption)
+ ret = hdbc->pSQLSetConnectOption(hdbc->driver_hdbc, Attribute, (SQLULEN)Value);
+ else
+ {
+ FIXME("Unsupported Attribute %d\n", Attribute);
+ ret = SQL_ERROR;
+ }
+ }
+
+ TRACE("ret %d\n", ret);
+
return ret;
}
@@ -1802,6 +1831,7 @@ SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribu
SQLINTEGER StringLength)
{
struct SQLHDBC_data *hdbc = ConnectionHandle;
@ -20,7 +62,7 @@ index 6e4e1a68011..89062e9cadf 100644
TRACE("(ConnectionHandle %p, Attribute %d, Value %p, StringLength %d)\n", ConnectionHandle, Attribute, Value,
StringLength);
@@ -1831,11 +1832,18 @@ SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribu
@@ -1821,11 +1851,20 @@ SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribu
hdbc->login_timeout = 0;
break;
default:
@ -28,6 +70,8 @@ index 6e4e1a68011..89062e9cadf 100644
- return SQL_ERROR;
+ if (hdbc->pSQLSetConnectAttrW)
+ ret = hdbc->pSQLSetConnectAttrW(hdbc->driver_hdbc, Attribute, Value, StringLength);
+ else if(hdbc->pSQLSetConnectOptionW)
+ ret = hdbc->pSQLSetConnectOptionW(hdbc->driver_hdbc, Attribute, (SQLULEN)Value);
+ else
+ {
+ FIXME("Unsupported Attribute %d\n", Attribute);
@ -43,5 +87,5 @@ index 6e4e1a68011..89062e9cadf 100644
/*************************************************************************
--
2.39.1
2.43.0

View File

@ -1,18 +1,17 @@
From f5914eea19b16f6312de43ff72b289c82c08f846 Mon Sep 17 00:00:00 2001
From 618ae30847043d66cc952fd6a58c319a8eee698d Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 09:08:27 +1100
Subject: [PATCH 12/42] odbc32: Forward SQLGetConnectAttr/W requets onto the
driver
Subject: [PATCH] odbc32: Forward SQLGetConnectAttr/W requets onto the driver
---
dlls/odbc32/proxyodbc.c | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
dlls/odbc32/proxyodbc.c | 42 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 7e92b90b10c..96357cd3f1d 100644
index 3a1d8ba1d08..333d040be8c 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -739,11 +739,26 @@ SQLRETURN WINAPI SQLFreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option)
@@ -729,11 +729,30 @@ SQLRETURN WINAPI SQLFreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option)
SQLRETURN WINAPI SQLGetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER Value,
SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
@ -34,13 +33,17 @@ index 7e92b90b10c..96357cd3f1d 100644
+ ret = connection->pSQLGetConnectAttr(connection->driver_hdbc, Attribute, Value,
+ BufferLength, StringLength);
+ }
+ else if (connection->pSQLGetConnectOption)
+ {
+ ret = connection->pSQLGetConnectOption(connection->driver_hdbc, Attribute, Value);
+ }
+
+ TRACE("ret %d\n", ret);
+
return ret;
}
@@ -1721,11 +1736,26 @@ SQLRETURN WINAPI SQLColAttributeW(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnN
@@ -1711,11 +1730,30 @@ SQLRETURN WINAPI SQLColAttributeW(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnN
SQLRETURN WINAPI SQLGetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER Value,
SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
@ -62,6 +65,10 @@ index 7e92b90b10c..96357cd3f1d 100644
+ ret = connection->pSQLGetConnectAttrW(connection->driver_hdbc, Attribute, Value,
+ BufferLength, StringLength);
+ }
+ else if (connection->pSQLGetConnectOptionW)
+ {
+ ret = connection->pSQLGetConnectOptionW(connection->driver_hdbc, Attribute, Value);
+ }
+
+ TRACE("ret %d\n", ret);
+
@ -69,5 +76,5 @@ index 7e92b90b10c..96357cd3f1d 100644
}
--
2.39.1
2.43.0

View File

@ -1,17 +1,17 @@
From 4fe0ad96bddd96ff4eb2b3786765ff7a547974d8 Mon Sep 17 00:00:00 2001
From b6d2054d5cd0787c18631e520594e9442c76781d Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 15:40:24 +1100
Subject: [PATCH 35/42] odbc32: Forward SQLBindParameter request onto driver
Subject: [PATCH] odbc32: Forward SQLBindParameter request onto driver
---
dlls/odbc32/proxyodbc.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
dlls/odbc32/proxyodbc.c | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 7f8cc57e968..f73daad254f 100644
index 40128395b32..4d2f472740c 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1901,12 +1901,26 @@ SQLRETURN WINAPI SQLBindParameter(SQLHSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT
@@ -1893,12 +1893,47 @@ SQLRETURN WINAPI SQLBindParameter(SQLHSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT
SQLSMALLINT ibScale, SQLPOINTER rgbValue, SQLLEN cbValueMax,
SQLLEN *pcbValue)
{
@ -34,11 +34,32 @@ index 7f8cc57e968..f73daad254f 100644
+ ret = statement->connection->pSQLBindParameter(statement->driver_stmt, ipar, fParamType,
+ fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue);
+ }
+ else if(statement->connection->pSQLBindParam)
+ {
+ /* TODO: Make function */
+ if(fCType == SQL_C_TYPE_TIME)
+ fCType = SQL_C_TIME;
+ else if(fCType == SQL_C_TYPE_DATE)
+ fCType = SQL_C_DATE;
+ else if(fCType == SQL_C_TYPE_TIMESTAMP)
+ fCType = SQL_C_TIMESTAMP;
+
+ /* TODO: Make function */
+ if (fSqlType == SQL_TIME)
+ fSqlType = SQL_TYPE_TIME;
+ else if (fSqlType == SQL_DATE)
+ fSqlType = SQL_TYPE_DATE;
+ else if (fSqlType == SQL_TIMESTAMP)
+ fSqlType = SQL_TYPE_TIMESTAMP;
+
+ ret = statement->connection->pSQLBindParam(statement->driver_stmt, ipar, fCType, fSqlType,
+ cbColDef, ibScale, rgbValue, pcbValue);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1
2.43.0

View File

@ -1,17 +1,17 @@
From 5fa88dabafbfb905553310a211a2701ad17f6df6 Mon Sep 17 00:00:00 2001
From 76850074a3e3f4a1de4503eb81748af85e4bdd13 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Tue, 7 Feb 2023 14:18:20 +1100
Subject: [PATCH 37/42] odbc32: Forward SQLGetDiagRecW request onto driver
Subject: [PATCH] odbc32: Forward SQLGetDiagRecW request onto driver
---
dlls/odbc32/proxyodbc.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
dlls/odbc32/proxyodbc.c | 42 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index c73912b38cf..bdd8361d221 100644
index a5a3c0186eb..692324a93a3 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -2286,10 +2286,36 @@ SQLRETURN WINAPI SQLGetDiagRecW(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMA
@@ -2280,10 +2280,50 @@ SQLRETURN WINAPI SQLGetDiagRecW(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMA
{
SQLRETURN ret = SQL_ERROR;
@ -29,16 +29,30 @@ index c73912b38cf..bdd8361d221 100644
+ struct SQLHDBC_data *hdbc = Handle;
+
+ if (hdbc->pSQLGetDiagRecW)
+ {
+ ret = hdbc->pSQLGetDiagRecW(HandleType, hdbc->driver_hdbc, RecNumber, Sqlstate,
+ NativeError, MessageText, BufferLength, TextLength);
+ }
+ else if (hdbc->pSQLErrorW)
+ {
+ ret = hdbc->pSQLErrorW(SQL_NULL_HENV, hdbc->driver_hdbc, SQL_NULL_HSTMT, Sqlstate,
+ NativeError, MessageText, BufferLength, TextLength);
+ }
+ }
+ else if (HandleType == SQL_HANDLE_STMT)
+ {
+ struct SQLHSTMT_data *statement = Handle;
+
+ if (statement->connection->pSQLGetDiagRecW)
+ {
+ ret = statement->connection->pSQLGetDiagRecW(HandleType, statement->driver_stmt, RecNumber,
+ Sqlstate, NativeError, MessageText, BufferLength, TextLength);
+ }
+ else if (statement->connection->pSQLErrorW)
+ {
+ ret = statement->connection->pSQLErrorW(SQL_NULL_HENV, SQL_NULL_HDBC, statement->driver_stmt,
+ Sqlstate, NativeError, MessageText, BufferLength, TextLength);
+ }
+ }
+
+ if (ret != SQL_ERROR)
@ -50,5 +64,5 @@ index c73912b38cf..bdd8361d221 100644
}
--
2.39.1
2.43.0

View File

@ -1,17 +1,17 @@
From 5e0d8ba8d698d404b1b16076a76cbb3e17b616c0 Mon Sep 17 00:00:00 2001
From c6664bce748c7d66f6fa1aecd6c8ae30a7c5784f Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Wed, 8 Feb 2023 20:19:44 +1100
Subject: [PATCH] odbc32: Forward SQLColAttribute/W request onto driver
---
dlls/odbc32/proxyodbc.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
dlls/odbc32/proxyodbc.c | 52 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 50 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 6f6d502e772..d33dbac8b2b 100644
index 7f3221ba124..dc61b2a5540 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -566,12 +566,26 @@ SQLRETURN WINAPI SQLColAttribute(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNu
@@ -556,12 +556,26 @@ SQLRETURN WINAPI SQLColAttribute(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNu
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
SQLLEN *NumericAttribute)
{
@ -39,7 +39,28 @@ index 6f6d502e772..d33dbac8b2b 100644
return ret;
}
@@ -2230,12 +2244,26 @@ SQLRETURN WINAPI SQLColAttributeW(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnN
@@ -2017,6 +2031,20 @@ static SQLINTEGER map_odbc2_to_3(SQLINTEGER fieldid)
return fieldid;
}
}
+static SQLINTEGER map_odbc3_to_2(SQLINTEGER fieldid)
+{
+ switch( fieldid )
+ {
+ case SQL_DESC_COUNT:
+ return SQL_COLUMN_COUNT;
+ case SQL_DESC_NULLABLE:
+ return SQL_COLUMN_NULLABLE;
+ case SQL_DESC_NAME:
+ return SQL_COLUMN_NAME;
+ default:
+ return fieldid;
+ }
+}
/*************************************************************************
* SQLColAttributesW [ODBC32.106]
@@ -2224,12 +2252,32 @@ SQLRETURN WINAPI SQLColAttributeW(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnN
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
SQLLEN *NumericAttribute)
{
@ -62,11 +83,17 @@ index 6f6d502e772..d33dbac8b2b 100644
+ ret = statement->connection->pSQLColAttributeW(statement->driver_stmt, ColumnNumber, FieldIdentifier,
+ CharacterAttribute, BufferLength, StringLength, NumericAttribute);
+ }
+ else if (statement->connection->pSQLColAttributesW)
+ {
+ FieldIdentifier = map_odbc3_to_2(FieldIdentifier);
+ ret = statement->connection->pSQLColAttributesW(statement->driver_stmt, ColumnNumber, FieldIdentifier,
+ CharacterAttribute, BufferLength, StringLength, NumericAttribute);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1
2.43.0

View File

@ -0,0 +1,60 @@
From 0ea6cb924d626265873019518672111b7c0fb963 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 10 Jun 2024 08:40:09 +1000
Subject: [PATCH] odbc32: Forward SQLError/W onto driver
---
dlls/odbc32/proxyodbc.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 89aaf1e8417..19027fdb83e 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -735,12 +735,20 @@ SQLRETURN WINAPI SQLError(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle, S
SQLCHAR *Sqlstate, SQLINTEGER *NativeError, SQLCHAR *MessageText,
SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
{
+ struct SQLHDBC_data *hdbc = ConnectionHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(EnvironmentHandle %p, ConnectionHandle %p, StatementHandle %p, Sqlstate %p, NativeError %p,"
+ TRACE("(EnvironmentHandle %p, ConnectionHandle %p, StatementHandle %p, Sqlstate %p, NativeError %p,"
" MessageText %p, BufferLength %d, TextLength %p)\n", EnvironmentHandle, ConnectionHandle,
StatementHandle, Sqlstate, NativeError, MessageText, BufferLength, TextLength);
+ if (hdbc->pSQLError)
+ {
+ ret = hdbc->pSQLError(hdbc->driver_env, hdbc->driver_hdbc, StatementHandle, Sqlstate,
+ NativeError, MessageText, BufferLength, TextLength);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
@@ -2240,12 +2248,20 @@ SQLRETURN WINAPI SQLErrorW(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle,
WCHAR *Sqlstate, SQLINTEGER *NativeError, WCHAR *MessageText,
SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
{
+ struct SQLHDBC_data *hdbc = ConnectionHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(EnvironmentHandle %p, ConnectionHandle %p, StatementHandle %p, Sqlstate %p, NativeError %p,"
+ TRACE("(EnvironmentHandle %p, ConnectionHandle %p, StatementHandle %p, Sqlstate %p, NativeError %p,"
" MessageText %p, BufferLength %d, TextLength %p)\n", EnvironmentHandle, ConnectionHandle,
StatementHandle, Sqlstate, NativeError, MessageText, BufferLength, TextLength);
+ if (hdbc->pSQLErrorW)
+ {
+ ret = hdbc->pSQLErrorW(hdbc->driver_env, hdbc->driver_hdbc, StatementHandle, Sqlstate,
+ NativeError, MessageText, BufferLength, TextLength);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.43.0