Added odbc-remove-unixodbc patchset

This commit is contained in:
Alistair Leslie-Hughes 2023-02-17 10:44:46 +11:00
parent 996b5b4cea
commit 53e545fe79
44 changed files with 7238 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,74 @@
From b866665b60bc2c29105d45a0e071db8e259ac229 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 3 Feb 2023 11:44:19 +1100
Subject: [PATCH 02/42] odbc32: Implement SQLAllocEnv/SQLFreeEnv
---
dlls/odbc32/proxyodbc.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index e8574430e74..24e84883aa5 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -43,6 +43,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(odbc);
+struct SQLHENV_data
+{
+ int type;
+};
+
/*************************************************************************
* SQLAllocConnect [ODBC32.001]
@@ -61,13 +66,23 @@ SQLRETURN WINAPI SQLAllocConnect(SQLHENV EnvironmentHandle, SQLHDBC *ConnectionH
*/
SQLRETURN WINAPI SQLAllocEnv(SQLHENV *EnvironmentHandle)
{
- SQLRETURN ret = SQL_ERROR;
+ struct SQLHENV_data *henv;
- FIXME("(EnvironmentHandle %p)\n", EnvironmentHandle);
+ TRACE("(EnvironmentHandle %p)\n", EnvironmentHandle);
+
+ if (!EnvironmentHandle)
+ return SQL_ERROR;
*EnvironmentHandle = SQL_NULL_HENV;
+ henv = calloc(1, sizeof(*henv));
+ if (!henv)
+ return SQL_ERROR;
- return ret;
+ henv->type = SQL_HANDLE_ENV;
+
+ *EnvironmentHandle = henv;
+
+ return SQL_SUCCESS;
}
/*************************************************************************
@@ -399,11 +414,15 @@ SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle)
*/
SQLRETURN WINAPI SQLFreeEnv(SQLHENV EnvironmentHandle)
{
- SQLRETURN ret = SQL_ERROR;
+ struct SQLHENV_data *data = EnvironmentHandle;
+ TRACE("(EnvironmentHandle %p)\n", EnvironmentHandle);
- FIXME("(EnvironmentHandle %p)\n", EnvironmentHandle);
+ if (data && data->type != SQL_HANDLE_ENV)
+ WARN("EnvironmentHandle isn't of type SQL_HANDLE_ENV\n");
+ else
+ free(data);
- return ret;
+ return SQL_SUCCESS;
}
/*************************************************************************
--
2.39.1

View File

@ -0,0 +1,114 @@
From cd4b544dc92159ca8c80e790c25a36e93b848145 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 3 Feb 2023 13:41:20 +1100
Subject: [PATCH 03/42] odbc32: Support SQL_ATTR_CONNECTION_POOLING in
SQLGetEnvAttr/SQLSetEnvAttr
---
dlls/odbc32/proxyodbc.c | 63 +++++++++++++++++++++++++++++++++++++----
1 file changed, 57 insertions(+), 6 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 24e84883aa5..1330c4c33fe 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -46,6 +46,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(odbc);
struct SQLHENV_data
{
int type;
+ SQLUINTEGER pooling;
};
@@ -79,6 +80,7 @@ SQLRETURN WINAPI SQLAllocEnv(SQLHENV *EnvironmentHandle)
return SQL_ERROR;
henv->type = SQL_HANDLE_ENV;
+ henv->pooling = SQL_CP_OFF;
*EnvironmentHandle = henv;
@@ -571,12 +573,42 @@ SQLRETURN WINAPI SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMAL
SQLRETURN WINAPI SQLGetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute, SQLPOINTER Value,
SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
- SQLRETURN ret = SQL_ERROR;
+ struct SQLHENV_data *data = EnvironmentHandle;
- FIXME("(EnvironmentHandle %p, Attribute %d, Value %p, BufferLength %d, StringLength %p)\n",
+ TRACE("(EnvironmentHandle %p, Attribute %d, Value %p, BufferLength %d, StringLength %p)\n",
EnvironmentHandle, Attribute, Value, BufferLength, StringLength);
- return ret;
+ if (EnvironmentHandle == SQL_NULL_HENV)
+ {
+ if (StringLength)
+ *StringLength = 0;
+ if (Value)
+ *(SQLINTEGER*)Value = 0;
+ return SQL_SUCCESS;
+ }
+
+ if (data->type != SQL_HANDLE_ENV)
+ {
+ WARN("Wrong handle type %d\n", data->type);
+ return SQL_ERROR;
+ }
+
+ switch (Attribute)
+ {
+ case SQL_ATTR_CONNECTION_POOLING:
+ if (BufferLength != sizeof(data->pooling))
+ {
+ WARN("Invalid buffer size\n");
+ return SQL_ERROR;
+ }
+ *(SQLUINTEGER*)Value = data->pooling;
+ break;
+ default:
+ FIXME("Unhandle attribute %d\n", Attribute);
+ return SQL_ERROR;
+ }
+
+ return SQL_SUCCESS;
}
/*************************************************************************
@@ -785,12 +817,31 @@ SQLRETURN WINAPI SQLSetDescRec(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber,
SQLRETURN WINAPI SQLSetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute, SQLPOINTER Value,
SQLINTEGER StringLength)
{
- SQLRETURN ret = SQL_ERROR;
+ struct SQLHENV_data *data = EnvironmentHandle;
- FIXME("(EnvironmentHandle %p, Attribute %d, Value %p, StringLength %d)\n", EnvironmentHandle, Attribute, Value,
+ TRACE("(EnvironmentHandle %p, Attribute %d, Value %p, StringLength %d)\n", EnvironmentHandle, Attribute, Value,
StringLength);
- return ret;
+ if(!data || data->type != SQL_HANDLE_ENV)
+ {
+ WARN("Wrong handle type %d\n", data->type);
+ return SQL_ERROR;
+ }
+
+ switch(Attribute)
+ {
+ case SQL_ATTR_CONNECTION_POOLING:
+ if (Value)
+ data->pooling = (uintptr_t)Value;
+ else
+ data->pooling = SQL_CP_OFF;
+ break;
+ default:
+ FIXME("Unhandle attribute %d\n", Attribute);
+ return SQL_ERROR;
+ }
+
+ return SQL_SUCCESS;
}
/*************************************************************************
--
2.39.1

View File

@ -0,0 +1,222 @@
From 648d4f13e26a076feca219b76111c03262504d95 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 3 Feb 2023 14:16:21 +1100
Subject: [PATCH 04/42] odbc32: Add initial tests
---
configure | 1 +
configure.ac | 1 +
dlls/odbc32/tests/Makefile.in | 4 +
dlls/odbc32/tests/connection.c | 165 +++++++++++++++++++++++++++++++++
4 files changed, 171 insertions(+)
create mode 100644 dlls/odbc32/tests/Makefile.in
create mode 100644 dlls/odbc32/tests/connection.c
diff --git a/configure b/configure
index 66e607337db..40b93ce0490 100755
--- a/configure
+++ b/configure
@@ -21634,6 +21634,7 @@ wine_fn_config_makefile dlls/ntprint enable_ntprint
wine_fn_config_makefile dlls/ntprint/tests enable_tests
wine_fn_config_makefile dlls/objsel enable_objsel
wine_fn_config_makefile dlls/odbc32 enable_odbc32
+wine_fn_config_makefile dlls/odbc32/tests enable_tests
wine_fn_config_makefile dlls/odbcbcp enable_odbcbcp
wine_fn_config_makefile dlls/odbccp32 enable_odbccp32
wine_fn_config_makefile dlls/odbccp32/tests enable_tests
diff --git a/configure.ac b/configure.ac
index 1033af2e613..249ea8b3f05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2898,6 +2898,7 @@ WINE_CONFIG_MAKEFILE(dlls/ntprint)
WINE_CONFIG_MAKEFILE(dlls/ntprint/tests)
WINE_CONFIG_MAKEFILE(dlls/objsel)
WINE_CONFIG_MAKEFILE(dlls/odbc32)
+WINE_CONFIG_MAKEFILE(dlls/odbc32/tests)
WINE_CONFIG_MAKEFILE(dlls/odbcbcp)
WINE_CONFIG_MAKEFILE(dlls/odbccp32)
WINE_CONFIG_MAKEFILE(dlls/odbccp32/tests)
diff --git a/dlls/odbc32/tests/Makefile.in b/dlls/odbc32/tests/Makefile.in
new file mode 100644
index 00000000000..4d8716ed2ed
--- /dev/null
+++ b/dlls/odbc32/tests/Makefile.in
@@ -0,0 +1,4 @@
+TESTDLL = odbc32.dll
+IMPORTS = odbc32
+
+C_SRCS = connection.c
diff --git a/dlls/odbc32/tests/connection.c b/dlls/odbc32/tests/connection.c
new file mode 100644
index 00000000000..b04d93c42c5
--- /dev/null
+++ b/dlls/odbc32/tests/connection.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2018 Alistair Leslie-Hughes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <wine/test.h>
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "sqlext.h"
+#include "sqlucode.h"
+#include "odbcinst.h"
+
+static void test_SQLAllocEnv(void)
+{
+ SQLRETURN ret;
+ SQLHENV sqlenv, sqlenv2;
+
+ ret = SQLAllocEnv(NULL);
+ ok(ret == SQL_ERROR, "got %d\n", ret);
+
+ ret = SQLAllocEnv(&sqlenv);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+
+ ret = SQLAllocEnv(&sqlenv2);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+ ok(sqlenv != sqlenv2, "got %d\n", ret);
+
+ ret = SQLFreeEnv(sqlenv2);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+
+ ret = SQLFreeEnv(sqlenv);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+
+ ret = SQLFreeEnv(sqlenv);
+ todo_wine ok(ret == SQL_INVALID_HANDLE, "got %d\n", ret);
+
+ ret = SQLFreeEnv(SQL_NULL_HENV);
+ todo_wine ok(ret == SQL_INVALID_HANDLE, "got %d\n", ret);
+}
+
+void test_SQLGetEnvAttr(void)
+{
+ SQLRETURN ret;
+ SQLHENV sqlenv;
+ SQLINTEGER value, length;
+
+ ret = SQLAllocEnv(&sqlenv);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+
+ value = 5;
+ length = 12;
+ ret = SQLGetEnvAttr(SQL_NULL_HENV, SQL_ATTR_CONNECTION_POOLING, &value, sizeof(SQLINTEGER), &length);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+ ok(value == 0, "got %d\n", value);
+ todo_wine ok(length == 12, "got %d\n", length);
+
+ value = 5;
+ length = 13;
+ ret = SQLGetEnvAttr(SQL_NULL_HENV, SQL_ATTR_CONNECTION_POOLING, &value, 0, &length);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+ ok(value == 0, "got %d\n", value);
+ todo_wine ok(length == 13, "got %d\n", length);
+
+ value = 5;
+ length = 12;
+ ret = SQLGetEnvAttr(sqlenv, SQL_ATTR_CONNECTION_POOLING, &value, sizeof(SQLINTEGER), &length);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+ ok(value == 0, "got %d\n", value);
+ ok(length == 12, "got %d\n", length);
+
+ value = 5;
+ length = 12;
+ ret = SQLGetEnvAttr(sqlenv, SQL_ATTR_CONNECTION_POOLING, &value, 2, &length);
+ todo_wine ok(ret == SQL_SUCCESS, "got %d\n", ret);
+ todo_wine ok(value == 0, "got %d\n", value);
+ ok(length == 12, "got %d\n", length);
+
+ ret = SQLFreeEnv(sqlenv);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+}
+
+static void test_SQLDriver(void)
+{
+ SQLHENV henv = SQL_NULL_HENV;
+ SQLRETURN ret;
+ SQLCHAR driver[256];
+ SQLCHAR attr[256];
+ SQLSMALLINT driver_ret;
+ SQLSMALLINT attr_ret;
+ SQLUSMALLINT direction;
+
+ ret = SQLAllocEnv(&henv);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+ ok(henv != SQL_NULL_HENV, "NULL handle\n");
+
+ direction = SQL_FETCH_FIRST;
+
+ while(SQL_SUCCEEDED(ret = SQLDrivers(henv, direction, driver, sizeof(driver),
+ &driver_ret, attr, sizeof(attr), &attr_ret)))
+ {
+ direction = SQL_FETCH_NEXT;
+
+ trace("%s - %s\n", driver, attr);
+ }
+ todo_wine ok(ret == SQL_NO_DATA, "got %d\n", ret);
+
+ ret = SQLFreeEnv(henv);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+}
+
+static void test_SQLGetDiagRec(void)
+{
+ SQLHENV henv = SQL_NULL_HENV;
+ SQLHDBC connection;
+ SQLRETURN ret;
+ WCHAR version[11];
+ WCHAR SqlState[6], Msg[SQL_MAX_MESSAGE_LENGTH];
+ SQLINTEGER NativeError;
+ SQLSMALLINT MsgLen;
+
+ ret = SQLAllocEnv(&henv);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+ ok(henv != SQL_NULL_HENV, "NULL handle\n");
+
+ ret = SQLAllocConnect(henv, &connection);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+
+ ret = SQLGetInfoW(connection, SQL_ODBC_VER, version, 22, NULL);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+ trace("ODBC_VER=%s\n", wine_dbgstr_w(version));
+
+ ret = SQLFreeConnect(connection);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+
+ NativeError = 88;
+ ret = SQLGetDiagRecW( SQL_HANDLE_ENV, henv, 1, SqlState, &NativeError, Msg, sizeof(Msg), &MsgLen);
+ todo_wine ok(ret == SQL_NO_DATA, "got %d\n", ret);
+ ok(NativeError == 88, "got %d\n", NativeError);
+
+ ret = SQLFreeEnv(henv);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+}
+
+START_TEST(connection)
+{
+ test_SQLAllocEnv();
+ test_SQLGetEnvAttr();
+ test_SQLDriver();
+ test_SQLGetDiagRec();
+}
--
2.39.1

View File

@ -0,0 +1,81 @@
From 8d5b34c895f776ed4944fa5aeed0df3ddc847015 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 3 Feb 2023 14:40:03 +1100
Subject: [PATCH 05/42] odbc32: Implement SQLAllocConnect
---
dlls/odbc32/proxyodbc.c | 41 +++++++++++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 1330c4c33fe..b3680b7759d 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -49,17 +49,35 @@ struct SQLHENV_data
SQLUINTEGER pooling;
};
+struct SQLHDBC_data
+{
+ int type;
+ struct SQLHENV_data *environment;
+};
/*************************************************************************
* SQLAllocConnect [ODBC32.001]
*/
SQLRETURN WINAPI SQLAllocConnect(SQLHENV EnvironmentHandle, SQLHDBC *ConnectionHandle)
{
- SQLRETURN ret = SQL_ERROR;
+ struct SQLHDBC_data *hdbc;
+
+ TRACE("(EnvironmentHandle %p, ConnectionHandle %p)\n", EnvironmentHandle, ConnectionHandle);
- FIXME("(EnvironmentHandle %p, ConnectionHandle %p)\n", EnvironmentHandle, ConnectionHandle);
+ if(!ConnectionHandle)
+ return SQL_ERROR;
*ConnectionHandle = SQL_NULL_HDBC;
- return ret;
+
+ hdbc = calloc(1, sizeof(*hdbc));
+ if (!hdbc)
+ return SQL_ERROR;
+
+ hdbc->type = SQL_HANDLE_DBC;
+ hdbc->environment = EnvironmentHandle;
+
+ *ConnectionHandle = hdbc;
+
+ return SQL_SUCCESS;
}
/*************************************************************************
@@ -404,11 +422,22 @@ SQLRETURN WINAPI SQLFetchScroll(SQLHSTMT StatementHandle, SQLSMALLINT FetchOrien
*/
SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle)
{
- SQLRETURN ret = SQL_ERROR;
+ struct SQLHDBC_data *hdbc = ConnectionHandle;
- FIXME("(ConnectionHandle %p)\n", ConnectionHandle);
+ TRACE("(ConnectionHandle %p)\n", ConnectionHandle);
- return ret;
+ if (!hdbc)
+ return SQL_ERROR;
+
+ if (hdbc->type != SQL_HANDLE_DBC)
+ {
+ WARN("Wrong handle type %d\n", hdbc->type);
+ return SQL_ERROR;
+ }
+
+ free(hdbc);
+
+ return SQL_SUCCESS;
}
/*************************************************************************
--
2.39.1

View File

@ -0,0 +1,72 @@
From c4739858fb4397522f5e09e88400c5433a7cecf2 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 3 Feb 2023 14:46:44 +1100
Subject: [PATCH 06/42] odbc32: SQLGetInfo/W support InfoType SQL_ODBC_VER
---
dlls/odbc32/proxyodbc.c | 36 ++++++++++++++++++++++++++++++------
1 file changed, 30 insertions(+), 6 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index b3680b7759d..c19f0248ef8 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -658,12 +658,24 @@ SQLRETURN WINAPI SQLGetFunctions(SQLHDBC ConnectionHandle, SQLUSMALLINT Function
SQLRETURN WINAPI SQLGetInfo(SQLHDBC ConnectionHandle, SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
{
- SQLRETURN ret = SQL_ERROR;
+ char *ptr = InfoValue;
- FIXME("(ConnectionHandle, %p, InfoType %d, InfoValue %p, BufferLength %d, StringLength %p)\n", ConnectionHandle,
+ TRACE("(ConnectionHandle, %p, InfoType %d, InfoValue %p, BufferLength %d, StringLength %p)\n", ConnectionHandle,
InfoType, InfoValue, BufferLength, StringLength);
- return ret;
+ switch(InfoType)
+ {
+ case SQL_ODBC_VER:
+ lstrcpynA(ptr, "03.80.0000", BufferLength);
+ if (StringLength)
+ *StringLength = strlen(ptr);
+ break;
+ default:
+ FIXME("Unsupported type %d\n", InfoType);
+ return SQL_ERROR;
+ }
+
+ return SQL_SUCCESS;
}
/*************************************************************************
@@ -1597,12 +1609,24 @@ SQLRETURN WINAPI SQLGetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Opt
SQLRETURN WINAPI SQLGetInfoW(SQLHDBC ConnectionHandle, SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
{
- SQLRETURN ret = SQL_ERROR;
+ WCHAR *ptr = InfoValue;
- FIXME("(ConnectionHandle, %p, InfoType %d, InfoValue %p, BufferLength %d, StringLength %p)\n", ConnectionHandle,
+ TRACE("(ConnectionHandle, %p, InfoType %d, InfoValue %p, BufferLength %d, StringLength %p)\n", ConnectionHandle,
InfoType, InfoValue, BufferLength, StringLength);
- return ret;
+ switch(InfoType)
+ {
+ case SQL_ODBC_VER:
+ lstrcpynW(ptr, L"03.80.0000", BufferLength);
+ if (StringLength)
+ *StringLength = wcslen(ptr);
+ break;
+ default:
+ FIXME("Unsupported type %d\n", InfoType);
+ return SQL_ERROR;
+ }
+
+ return SQL_SUCCESS;
}
/*************************************************************************
--
2.39.1

View File

@ -0,0 +1,69 @@
From a6061eab04f7b9432acf1eb86eb47d3286d97f0e Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 3 Feb 2023 15:18:21 +1100
Subject: [PATCH 07/42] odbc32: Support SQL_ATTR_LOGIN_TIMEOUT in
SQLSetConnectAttrW
---
dlls/odbc32/proxyodbc.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index c19f0248ef8..b4ec548b09c 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -53,6 +53,8 @@ struct SQLHDBC_data
{
int type;
struct SQLHENV_data *environment;
+
+ SQLUINTEGER login_timeout;
};
/*************************************************************************
@@ -74,6 +76,7 @@ SQLRETURN WINAPI SQLAllocConnect(SQLHENV EnvironmentHandle, SQLHDBC *ConnectionH
hdbc->type = SQL_HANDLE_DBC;
hdbc->environment = EnvironmentHandle;
+ hdbc->login_timeout = 0;
*ConnectionHandle = hdbc;
@@ -1548,12 +1551,31 @@ SQLRETURN WINAPI SQLGetStmtAttrW(SQLHSTMT StatementHandle, SQLINTEGER Attribute,
SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER Value,
SQLINTEGER StringLength)
{
- SQLRETURN ret = SQL_ERROR;
+ struct SQLHDBC_data *hdbc = ConnectionHandle;
- 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);
- return ret;
+ 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:
+ FIXME("Unhandle attribute %d\n", Attribute);
+ return SQL_ERROR;
+ }
+
+ return SQL_SUCCESS;
}
/*************************************************************************
--
2.39.1

View File

@ -0,0 +1,405 @@
From 258bc40f574604e6d27cf3fb75e682f463dcde99 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Sat, 4 Feb 2023 09:16:29 +1100
Subject: [PATCH 08/42] odbc32: Implement SQLDriverConnectW
---
dlls/odbc32/proxyodbc.c | 344 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 343 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index b4ec548b09c..ebb6b53d62d 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -53,10 +53,257 @@ struct SQLHDBC_data
{
int type;
struct SQLHENV_data *environment;
+ HMODULE module;
+ SQLHENV driver_env;
+ SQLHDBC driver_hdbc;
+
+ SQLRETURN (WINAPI *pSQLAllocConnect)(SQLHENV,SQLHDBC*);
+ SQLRETURN (WINAPI *pSQLAllocEnv)(SQLHENV*);
+ SQLRETURN (WINAPI *pSQLAllocHandle)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*);
+ SQLRETURN (WINAPI *pSQLAllocHandleStd)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*);
+ SQLRETURN (WINAPI *pSQLAllocStmt)(SQLHDBC,SQLHSTMT*);
+ SQLRETURN (WINAPI *pSQLBindCol)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*);
+ SQLRETURN (WINAPI *pSQLBindParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN*);
+ SQLRETURN (WINAPI *pSQLBindParameter)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*);
+ SQLRETURN (WINAPI *pSQLBrowseConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLBrowseConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLBulkOperations)(SQLHSTMT,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLCancel)(SQLHSTMT);
+ SQLRETURN (WINAPI *pSQLCloseCursor)(SQLHSTMT);
+ SQLRETURN (WINAPI *pSQLColAttribute)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLLEN*);
+ SQLRETURN (WINAPI *pSQLColAttributeW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLLEN*);
+ SQLRETURN (WINAPI *pSQLColAttributes)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLLEN*);
+ SQLRETURN (WINAPI *pSQLColAttributesW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLLEN*);
+ SQLRETURN (WINAPI *pSQLColumnPrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLColumnPrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLCopyDesc)(SQLHDESC,SQLHDESC);
+ SQLRETURN (WINAPI *pSQLDataSources)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLDataSourcesA)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLDataSourcesW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLDescribeCol)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLDescribeColW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLDescribeParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLDisconnect)(SQLHDBC);
+ SQLRETURN (WINAPI *pSQLDriverConnect)(SQLHDBC,SQLHWND,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
+ SQLRETURN (WINAPI *pSQLDriverConnectW)(SQLHDBC,SQLHWND,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
+ SQLRETURN (WINAPI *pSQLDrivers)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLDriversW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLEndTran)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLError)(SQLHENV,SQLHDBC,SQLHSTMT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLErrorW)(SQLHENV,SQLHDBC,SQLHSTMT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLExecDirect)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
+ SQLRETURN (WINAPI *pSQLExecDirectW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
+ SQLRETURN (WINAPI *pSQLExecute)(SQLHSTMT);
+ SQLRETURN (WINAPI *pSQLExtendedFetch)(SQLHSTMT,SQLUSMALLINT,SQLLEN,SQLULEN*,SQLUSMALLINT*);
+ SQLRETURN (WINAPI *pSQLFetch)(SQLHSTMT);
+ SQLRETURN (WINAPI *pSQLFetchScroll)(SQLHSTMT,SQLSMALLINT,SQLLEN);
+ SQLRETURN (WINAPI *pSQLForeignKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLForeignKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLFreeConnect)(SQLHDBC);
+ SQLRETURN (WINAPI *pSQLFreeEnv)(SQLHENV);
+ SQLRETURN (WINAPI *pSQLFreeHandle)(SQLSMALLINT,SQLHANDLE);
+ SQLRETURN (WINAPI *pSQLFreeStmt)(SQLHSTMT,SQLUSMALLINT);
+ SQLRETURN (WINAPI *pSQLGetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
+ SQLRETURN (WINAPI *pSQLGetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
+ SQLRETURN (WINAPI *pSQLGetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
+ SQLRETURN (WINAPI *pSQLGetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
+ SQLRETURN (WINAPI *pSQLGetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLGetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLGetData)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*);
+ SQLRETURN (WINAPI *pSQLGetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
+ SQLRETURN (WINAPI *pSQLGetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
+ SQLRETURN (WINAPI *pSQLGetDescRec)(SQLHDESC,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLGetDescRecW)(SQLHDESC,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLGetDiagField)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLGetDiagFieldW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLGetDiagRec)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLGetDiagRecA)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLCHAR*,SQLINTEGER*, SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLGetDiagRecW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLGetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
+ SQLRETURN (WINAPI *pSQLGetFunctions)(SQLHDBC,SQLUSMALLINT,SQLUSMALLINT*);
+ SQLRETURN (WINAPI *pSQLGetInfo)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLGetInfoW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLGetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
+ SQLRETURN (WINAPI *pSQLGetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
+ SQLRETURN (WINAPI *pSQLGetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLPOINTER);
+ SQLRETURN (WINAPI *pSQLGetTypeInfo)(SQLHSTMT,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLGetTypeInfoW)(SQLHSTMT,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLMoreResults)(SQLHSTMT);
+ SQLRETURN (WINAPI *pSQLNativeSql)(SQLHDBC,SQLCHAR*,SQLINTEGER,SQLCHAR*,SQLINTEGER,SQLINTEGER*);
+ SQLRETURN (WINAPI *pSQLNativeSqlW)(SQLHDBC,SQLWCHAR*,SQLINTEGER,SQLWCHAR*,SQLINTEGER,SQLINTEGER*);
+ SQLRETURN (WINAPI *pSQLNumParams)(SQLHSTMT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLNumResultCols)(SQLHSTMT,SQLSMALLINT*);
+ SQLRETURN (WINAPI *pSQLParamData)(SQLHSTMT,SQLPOINTER*);
+ SQLRETURN (WINAPI *pSQLParamOptions)(SQLHSTMT,SQLULEN,SQLULEN*);
+ SQLRETURN (WINAPI *pSQLPrepare)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
+ SQLRETURN (WINAPI *pSQLPrepareW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
+ SQLRETURN (WINAPI *pSQLPrimaryKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLPrimaryKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLProcedureColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLProcedureColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLProcedures)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLProceduresW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLPutData)(SQLHSTMT,SQLPOINTER,SQLLEN);
+ SQLRETURN (WINAPI *pSQLRowCount)(SQLHSTMT,SQLLEN*);
+ SQLRETURN (WINAPI *pSQLSetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
+ SQLRETURN (WINAPI *pSQLSetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
+ SQLRETURN (WINAPI *pSQLSetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLULEN);
+ SQLRETURN (WINAPI *pSQLSetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLULEN);
+ SQLRETURN (WINAPI *pSQLSetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLSetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLSetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
+ SQLRETURN (WINAPI *pSQLSetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
+ SQLRETURN (WINAPI *pSQLSetDescRec)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLLEN,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLLEN*,SQLLEN*);
+ SQLRETURN (WINAPI *pSQLSetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER);
+ SQLRETURN (WINAPI *pSQLSetParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN*);
+ SQLRETURN (WINAPI *pSQLSetPos)(SQLHSTMT,SQLSETPOSIROW,SQLUSMALLINT,SQLUSMALLINT);
+ SQLRETURN (WINAPI *pSQLSetScrollOptions)(SQLHSTMT,SQLUSMALLINT,SQLLEN,SQLUSMALLINT);
+ SQLRETURN (WINAPI *pSQLSetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
+ SQLRETURN (WINAPI *pSQLSetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
+ SQLRETURN (WINAPI *pSQLSetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLULEN);
+ SQLRETURN (WINAPI *pSQLSpecialColumns)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
+ SQLRETURN (WINAPI *pSQLSpecialColumnsW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
+ SQLRETURN (WINAPI *pSQLStatistics)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
+ SQLRETURN (WINAPI *pSQLStatisticsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
+ SQLRETURN (WINAPI *pSQLTablePrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLTablePrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLTables)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLTablesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
+ SQLRETURN (WINAPI *pSQLTransact)(SQLHENV,SQLHDBC,SQLUSMALLINT);
SQLUINTEGER login_timeout;
};
+static void connection_bind_sql_funcs(struct SQLHDBC_data *connection)
+{
+#define LOAD_FUNCPTR(f) if((connection->p##f = (void*)GetProcAddress(connection->module, #f)) == NULL) \
+ { \
+ WARN( "function '%s' not found in driver.\n", #f ); \
+ }
+
+ LOAD_FUNCPTR(SQLAllocConnect);
+ LOAD_FUNCPTR(SQLAllocEnv);
+ LOAD_FUNCPTR(SQLAllocHandle);
+ LOAD_FUNCPTR(SQLAllocHandleStd)
+ LOAD_FUNCPTR(SQLAllocStmt);
+ LOAD_FUNCPTR(SQLBindCol);
+ LOAD_FUNCPTR(SQLBindParam);
+ LOAD_FUNCPTR(SQLBindParameter);
+ LOAD_FUNCPTR(SQLBrowseConnect);
+ LOAD_FUNCPTR(SQLBrowseConnectW);
+ LOAD_FUNCPTR(SQLBulkOperations);
+ LOAD_FUNCPTR(SQLCancel);
+ LOAD_FUNCPTR(SQLCloseCursor);
+ LOAD_FUNCPTR(SQLColAttribute);
+ LOAD_FUNCPTR(SQLColAttributeW);
+ LOAD_FUNCPTR(SQLColAttributes);
+ LOAD_FUNCPTR(SQLColAttributesW);
+ LOAD_FUNCPTR(SQLColumnPrivileges);
+ LOAD_FUNCPTR(SQLColumnPrivilegesW)
+ LOAD_FUNCPTR(SQLColumns);
+ LOAD_FUNCPTR(SQLColumnsW);
+ LOAD_FUNCPTR(SQLConnect);
+ LOAD_FUNCPTR(SQLConnectW);
+ LOAD_FUNCPTR(SQLCopyDesc);
+ LOAD_FUNCPTR(SQLDataSources);
+ LOAD_FUNCPTR(SQLDataSourcesA);
+ LOAD_FUNCPTR(SQLDataSourcesW);
+ LOAD_FUNCPTR(SQLDescribeCol);
+ LOAD_FUNCPTR(SQLDescribeColW);
+ LOAD_FUNCPTR(SQLDescribeParam);
+ LOAD_FUNCPTR(SQLDisconnect);
+ LOAD_FUNCPTR(SQLDriverConnect);
+ LOAD_FUNCPTR(SQLDriverConnectW);
+ LOAD_FUNCPTR(SQLDrivers);
+ LOAD_FUNCPTR(SQLDriversW);
+ LOAD_FUNCPTR(SQLEndTran);
+ LOAD_FUNCPTR(SQLError);
+ LOAD_FUNCPTR(SQLErrorW);
+ LOAD_FUNCPTR(SQLExecDirect);
+ LOAD_FUNCPTR(SQLExecDirectW);
+ LOAD_FUNCPTR(SQLExecute);
+ LOAD_FUNCPTR(SQLExtendedFetch);
+ LOAD_FUNCPTR(SQLFetch);
+ LOAD_FUNCPTR(SQLFetchScroll);
+ LOAD_FUNCPTR(SQLForeignKeys);
+ LOAD_FUNCPTR(SQLForeignKeysW);
+ LOAD_FUNCPTR(SQLFreeConnect);
+ LOAD_FUNCPTR(SQLFreeEnv);
+ LOAD_FUNCPTR(SQLFreeHandle);
+ LOAD_FUNCPTR(SQLFreeStmt);
+ LOAD_FUNCPTR(SQLGetConnectAttr);
+ LOAD_FUNCPTR(SQLGetConnectAttrW);
+ LOAD_FUNCPTR(SQLGetConnectOption);
+ LOAD_FUNCPTR(SQLGetConnectOptionW);
+ LOAD_FUNCPTR(SQLGetCursorName);
+ LOAD_FUNCPTR(SQLGetCursorNameW);
+ LOAD_FUNCPTR(SQLGetData);
+ LOAD_FUNCPTR(SQLGetDescField);
+ LOAD_FUNCPTR(SQLGetDescFieldW);
+ LOAD_FUNCPTR(SQLGetDescRec);
+ LOAD_FUNCPTR(SQLGetDescRecW);
+ LOAD_FUNCPTR(SQLGetDiagField);
+ LOAD_FUNCPTR(SQLGetDiagFieldW);
+ LOAD_FUNCPTR(SQLGetDiagRec);
+ LOAD_FUNCPTR(SQLGetDiagRecA);
+ LOAD_FUNCPTR(SQLGetDiagRecW);
+ LOAD_FUNCPTR(SQLGetEnvAttr);
+ LOAD_FUNCPTR(SQLGetFunctions);
+ LOAD_FUNCPTR(SQLGetInfo);
+ LOAD_FUNCPTR(SQLGetInfoW);
+ LOAD_FUNCPTR(SQLGetStmtAttr);
+ LOAD_FUNCPTR(SQLGetStmtAttrW);
+ LOAD_FUNCPTR(SQLGetStmtOption);
+ LOAD_FUNCPTR(SQLGetTypeInfo);
+ LOAD_FUNCPTR(SQLGetTypeInfoW);
+ LOAD_FUNCPTR(SQLMoreResults);
+ LOAD_FUNCPTR(SQLNativeSql);
+ LOAD_FUNCPTR(SQLNativeSqlW);
+ LOAD_FUNCPTR(SQLNumParams);
+ LOAD_FUNCPTR(SQLNumResultCols);
+ LOAD_FUNCPTR(SQLParamData);
+ LOAD_FUNCPTR(SQLParamOptions);
+ LOAD_FUNCPTR(SQLPrepare);
+ LOAD_FUNCPTR(SQLPrepareW);
+ LOAD_FUNCPTR(SQLPrimaryKeys);
+ LOAD_FUNCPTR(SQLPrimaryKeysW);
+ LOAD_FUNCPTR(SQLProcedureColumns);
+ LOAD_FUNCPTR(SQLProcedureColumnsW);
+ LOAD_FUNCPTR(SQLProcedures);
+ LOAD_FUNCPTR(SQLProceduresW);
+ LOAD_FUNCPTR(SQLPutData);
+ LOAD_FUNCPTR(SQLRowCount);
+ LOAD_FUNCPTR(SQLSetConnectAttr);
+ LOAD_FUNCPTR(SQLSetConnectAttrW);
+ LOAD_FUNCPTR(SQLSetConnectOption);
+ LOAD_FUNCPTR(SQLSetConnectOptionW);
+ LOAD_FUNCPTR(SQLSetCursorName);
+ LOAD_FUNCPTR(SQLSetCursorNameW);
+ LOAD_FUNCPTR(SQLSetDescField);
+ LOAD_FUNCPTR(SQLSetDescFieldW);
+ LOAD_FUNCPTR(SQLSetDescRec);
+ LOAD_FUNCPTR(SQLSetEnvAttr);
+ LOAD_FUNCPTR(SQLSetParam);
+ LOAD_FUNCPTR(SQLSetPos);
+ LOAD_FUNCPTR(SQLSetScrollOptions);
+ LOAD_FUNCPTR(SQLSetStmtAttr);
+ LOAD_FUNCPTR(SQLSetStmtAttrW);
+ LOAD_FUNCPTR(SQLSetStmtOption);
+ LOAD_FUNCPTR(SQLSpecialColumns);
+ LOAD_FUNCPTR(SQLSpecialColumnsW);
+ LOAD_FUNCPTR(SQLStatistics);
+ LOAD_FUNCPTR(SQLStatisticsW);
+ LOAD_FUNCPTR(SQLTablePrivileges);
+ LOAD_FUNCPTR(SQLTablePrivilegesW);
+ LOAD_FUNCPTR(SQLTables);
+ LOAD_FUNCPTR(SQLTablesW);
+ LOAD_FUNCPTR(SQLTransact);
+}
+
/*************************************************************************
* SQLAllocConnect [ODBC32.001]
*/
@@ -77,6 +324,7 @@ SQLRETURN WINAPI SQLAllocConnect(SQLHENV EnvironmentHandle, SQLHDBC *ConnectionH
hdbc->type = SQL_HANDLE_DBC;
hdbc->environment = EnvironmentHandle;
hdbc->login_timeout = 0;
+ hdbc->module = NULL;
*ConnectionHandle = hdbc;
@@ -438,6 +686,8 @@ SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle)
return SQL_ERROR;
}
+ FreeLibrary(hdbc->module);
+
free(hdbc);
return SQL_SUCCESS;
@@ -1596,6 +1846,62 @@ SQLRETURN WINAPI SQLColumnsW(SQLHSTMT StatementHandle, WCHAR *CatalogName, SQLSM
return ret;
}
+static HMODULE load_odbc_driver(const WCHAR *driver)
+{
+ long ret;
+ HMODULE hmod;
+ WCHAR *filename = NULL;
+ HKEY hkey;
+ WCHAR regpath[256];
+
+ wcscpy(regpath, L"Software\\ODBC\\ODBC.INI\\");
+ wcscat(regpath, driver);
+
+ if ((ret = RegOpenKeyW(HKEY_CURRENT_USER, regpath, &hkey)) != ERROR_SUCCESS)
+ {
+ ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, regpath, &hkey);
+ }
+
+ if (ret == ERROR_SUCCESS)
+ {
+ DWORD size = 0, type;
+ ret = RegGetValueW(hkey, NULL, L"Driver", RRF_RT_REG_SZ, &type, NULL, &size);
+ if(ret != ERROR_SUCCESS || type != REG_SZ)
+ {
+ RegCloseKey(hkey);
+ WARN("Invalid DSN %s\n", debugstr_w(driver));
+
+ return NULL;
+ }
+
+ filename = malloc(size);
+ if(!filename)
+ {
+ RegCloseKey(hkey);
+ ERR("Out of memory\n");
+
+ return NULL;
+ }
+ ret = RegGetValueW(hkey, NULL, L"Driver", RRF_RT_REG_SZ, &type, filename, &size);
+
+ RegCloseKey(hkey);
+ }
+
+ if(ret != ERROR_SUCCESS)
+ {
+ free(filename);
+ ERR("Failed to open Registry Key\n");
+ return NULL;
+ }
+
+ hmod = LoadLibraryExW(filename, NULL, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
+ free(filename);
+
+ if(!hmod)
+ ERR("Failed to load driver\n");
+
+ return hmod;
+}
/*************************************************************************
* SQLDriverConnectW [ODBC32.141]
*/
@@ -1603,13 +1909,49 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl
SQLSMALLINT Length, WCHAR *OutConnectionString, SQLSMALLINT BufferLength,
SQLSMALLINT *Length2, SQLUSMALLINT DriverCompletion)
{
+ struct SQLHDBC_data *connection = ConnectionHandle;
+ HMODULE driver;
SQLRETURN ret = SQL_ERROR;
+ WCHAR dsn[128];
+ WCHAR *p;
- FIXME("(ConnectionHandle %p, WindowHandle %p, InConnectionString %s, Length %d, OutConnectionString %p,"
+ TRACE("(ConnectionHandle %p, WindowHandle %p, InConnectionString %s, Length %d, OutConnectionString %p,"
" BufferLength %d, Length2 %p, DriverCompletion %d)\n", ConnectionHandle, WindowHandle,
debugstr_wn(InConnectionString, Length), Length, OutConnectionString, BufferLength, Length2,
DriverCompletion);
+ p = wcsstr(InConnectionString, L"DSN=");
+ if (p)
+ {
+ WCHAR *end = wcsstr(p, L";");
+
+ lstrcpynW(dsn, p+4, end - (p + 3));
+ }
+
+ driver = load_odbc_driver(dsn);
+ if (!driver)
+ return SQL_ERROR;
+
+ connection->module = driver;
+ connection_bind_sql_funcs(connection);
+
+ if (connection->pSQLAllocHandle)
+ {
+ connection->pSQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &connection->driver_env);
+ connection->pSQLAllocHandle(SQL_HANDLE_DBC, connection->driver_env, &connection->driver_hdbc);
+ }
+
+ if(!connection->pSQLDriverConnectW)
+ {
+ ERR("Failed to find pSQLDriverConnectW\n");
+ return SQL_ERROR;
+ }
+
+ ret = connection->pSQLDriverConnectW(connection->driver_hdbc, WindowHandle, InConnectionString, Length,
+ OutConnectionString, BufferLength, Length2, DriverCompletion);
+
+ TRACE("Driver returned %d\n", ret);
+
return ret;
}
--
2.39.1

View File

@ -0,0 +1,82 @@
From 721fddbb419b2bdaf710c023b9d33851b77e1684 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 08:47:46 +1100
Subject: [PATCH 09/42] odbc32: Foward SQLGetInfo/W requests onto the driver
---
dlls/odbc32/proxyodbc.c | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index ebb6b53d62d..6e4e1a68011 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -911,7 +911,9 @@ SQLRETURN WINAPI SQLGetFunctions(SQLHDBC ConnectionHandle, SQLUSMALLINT Function
SQLRETURN WINAPI SQLGetInfo(SQLHDBC ConnectionHandle, SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
{
+ struct SQLHDBC_data *connection = ConnectionHandle;
char *ptr = InfoValue;
+ SQLRETURN ret = SQL_SUCCESS;
TRACE("(ConnectionHandle, %p, InfoType %d, InfoValue %p, BufferLength %d, StringLength %p)\n", ConnectionHandle,
InfoType, InfoValue, BufferLength, StringLength);
@@ -924,11 +926,19 @@ SQLRETURN WINAPI SQLGetInfo(SQLHDBC ConnectionHandle, SQLUSMALLINT InfoType, SQL
*StringLength = strlen(ptr);
break;
default:
- FIXME("Unsupported type %d\n", InfoType);
- return SQL_ERROR;
+ if (connection->pSQLGetInfo)
+ ret = connection->pSQLGetInfo(connection->driver_hdbc, InfoType, InfoValue,
+ BufferLength, StringLength);
+ else
+ {
+ FIXME("Unsupported type %d\n", InfoType);
+ ret = SQL_ERROR;
+ }
}
- return SQL_SUCCESS;
+ TRACE("ret %d\n", ret);
+
+ return ret;
}
/*************************************************************************
@@ -1973,7 +1983,9 @@ SQLRETURN WINAPI SQLGetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Opt
SQLRETURN WINAPI SQLGetInfoW(SQLHDBC ConnectionHandle, SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
{
+ struct SQLHDBC_data *connection = ConnectionHandle;
WCHAR *ptr = InfoValue;
+ SQLRETURN ret = SQL_SUCCESS;
TRACE("(ConnectionHandle, %p, InfoType %d, InfoValue %p, BufferLength %d, StringLength %p)\n", ConnectionHandle,
InfoType, InfoValue, BufferLength, StringLength);
@@ -1986,11 +1998,19 @@ SQLRETURN WINAPI SQLGetInfoW(SQLHDBC ConnectionHandle, SQLUSMALLINT InfoType, SQ
*StringLength = wcslen(ptr);
break;
default:
- FIXME("Unsupported type %d\n", InfoType);
- return SQL_ERROR;
+ if (connection->pSQLGetInfoW)
+ ret = connection->pSQLGetInfoW(connection->driver_hdbc, InfoType, InfoValue,
+ BufferLength, StringLength);
+ else
+ {
+ FIXME("Unsupported type %d\n", InfoType);
+ ret = SQL_ERROR;
+ }
}
- return SQL_SUCCESS;
+ TRACE("ret %d\n", ret);
+
+ return ret;
}
/*************************************************************************
--
2.39.1

View File

@ -0,0 +1,47 @@
From 54744cb90ebf7ebe9ae60e6f4de12586c6d2083f 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
---
dlls/odbc32/proxyodbc.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 6e4e1a68011..89062e9cadf 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1812,6 +1812,7 @@ SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribu
SQLINTEGER StringLength)
{
struct SQLHDBC_data *hdbc = ConnectionHandle;
+ SQLRETURN ret = SQL_SUCCESS;
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
hdbc->login_timeout = 0;
break;
default:
- FIXME("Unhandle attribute %d\n", Attribute);
- return SQL_ERROR;
+ if (hdbc->pSQLSetConnectAttrW)
+ ret = hdbc->pSQLSetConnectAttrW(hdbc->driver_hdbc, Attribute, Value, StringLength);
+ else
+ {
+ FIXME("Unsupported Attribute %d\n", Attribute);
+ ret = SQL_ERROR;
+ }
}
- return SQL_SUCCESS;
+ TRACE("ret %d\n", ret);
+
+ return ret;
}
/*************************************************************************
--
2.39.1

View File

@ -0,0 +1,33 @@
From 8b3bcc595990b84b8632397707a3ba756f1b2892 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 09:02:34 +1100
Subject: [PATCH 11/42] odbc32: Forward SQLGetFunctions requets onto the driver
---
dlls/odbc32/proxyodbc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 89062e9cadf..7e92b90b10c 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -898,9 +898,15 @@ SQLRETURN WINAPI SQLGetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute,
*/
SQLRETURN WINAPI SQLGetFunctions(SQLHDBC ConnectionHandle, SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported)
{
+ struct SQLHDBC_data *connection = ConnectionHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(ConnectionHandle %p, FunctionId %d, Supported %p)\n", ConnectionHandle, FunctionId, Supported);
+ TRACE("(ConnectionHandle %p, FunctionId %d, Supported %p)\n", ConnectionHandle, FunctionId, Supported);
+
+ if (connection->pSQLGetFunctions)
+ {
+ ret = connection->pSQLGetFunctions(connection->driver_hdbc, FunctionId, Supported);
+ }
return ret;
}
--
2.39.1

View File

@ -0,0 +1,73 @@
From f5914eea19b16f6312de43ff72b289c82c08f846 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
---
dlls/odbc32/proxyodbc.c | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 7e92b90b10c..96357cd3f1d 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -739,11 +739,26 @@ SQLRETURN WINAPI SQLFreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option)
SQLRETURN WINAPI SQLGetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER Value,
SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
+ struct SQLHDBC_data *connection = ConnectionHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(ConnectionHandle %p, Attribute %d, Value %p, BufferLength %d, StringLength %p)\n", ConnectionHandle,
+ TRACE("(ConnectionHandle %p, Attribute %d, Value %p, BufferLength %d, StringLength %p)\n", ConnectionHandle,
Attribute, Value, BufferLength, StringLength);
+ if (connection->type != SQL_HANDLE_DBC)
+ {
+ WARN("Wrong handle type %d\n", connection->type);
+ return SQL_ERROR;
+ }
+
+ if (connection->pSQLGetConnectAttr)
+ {
+ ret = connection->pSQLGetConnectAttr(connection->driver_hdbc, Attribute, Value,
+ BufferLength, StringLength);
+ }
+
+ TRACE("ret %d\n", ret);
+
return ret;
}
@@ -1721,11 +1736,26 @@ SQLRETURN WINAPI SQLColAttributeW(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnN
SQLRETURN WINAPI SQLGetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER Value,
SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
+ struct SQLHDBC_data *connection = ConnectionHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(ConnectionHandle %p, Attribute %d, Value %p, BufferLength %d, StringLength %p)\n", ConnectionHandle,
+ TRACE("(ConnectionHandle %p, Attribute %d, Value %p, BufferLength %d, StringLength %p)\n", ConnectionHandle,
Attribute, Value, BufferLength, StringLength);
+ if (connection->type != SQL_HANDLE_DBC)
+ {
+ WARN("Wrong handle type %d\n", connection->type);
+ return SQL_ERROR;
+ }
+
+ if (connection->pSQLGetConnectAttrW)
+ {
+ ret = connection->pSQLGetConnectAttrW(connection->driver_hdbc, Attribute, Value,
+ BufferLength, StringLength);
+ }
+
+ TRACE("ret %d\n", ret);
+
return ret;
}
--
2.39.1

View File

@ -0,0 +1,41 @@
From 3a815fdc2731ffe21a617668e7cd4570196e02c5 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 09:26:57 +1100
Subject: [PATCH 13/42] odbc32: Foward SQLDisconnect request onto driver
---
dlls/odbc32/proxyodbc.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 96357cd3f1d..65f882968c6 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -583,9 +583,23 @@ SQLRETURN WINAPI SQLDescribeCol(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNum
*/
SQLRETURN WINAPI SQLDisconnect(SQLHDBC ConnectionHandle)
{
+ struct SQLHDBC_data *connection = ConnectionHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(ConnectionHandle %p)\n", ConnectionHandle);
+ TRACE("(ConnectionHandle %p)\n", ConnectionHandle);
+
+ if (connection->type != SQL_HANDLE_DBC)
+ {
+ WARN("Wrong handle type %d\n", connection->type);
+ return SQL_ERROR;
+ }
+
+ if (connection->pSQLDisconnect)
+ {
+ ret = connection->pSQLDisconnect(connection->driver_hdbc);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,73 @@
From 2bda5feb6297ec6c01a022a3c13338c2c6f6ff27 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 09:53:34 +1100
Subject: [PATCH 14/42] odbc32: Implement SQLAllocStmt
---
dlls/odbc32/proxyodbc.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 65f882968c6..4ec5ecfcb83 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -178,6 +178,13 @@ struct SQLHDBC_data
SQLUINTEGER login_timeout;
};
+struct SQLHSTMT_data
+{
+ int type;
+ struct SQLHDBC_data *connection;
+ SQLHSTMT driver_stmt;
+};
+
static void connection_bind_sql_funcs(struct SQLHDBC_data *connection)
{
#define LOAD_FUNCPTR(f) if((connection->p##f = (void*)GetProcAddress(connection->module, #f)) == NULL) \
@@ -374,11 +381,41 @@ SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, S
*/
SQLRETURN WINAPI SQLAllocStmt(SQLHDBC ConnectionHandle, SQLHSTMT *StatementHandle)
{
+ struct SQLHDBC_data *connection = ConnectionHandle;
+ struct SQLHSTMT_data *stmt;
SQLRETURN ret = SQL_ERROR;
- FIXME("(ConnectionHandle %p, StatementHandle %p)\n", ConnectionHandle, StatementHandle);
+ TRACE("(ConnectionHandle %p, StatementHandle %p)\n", ConnectionHandle, StatementHandle);
*StatementHandle = SQL_NULL_HSTMT;
+ if (connection->type != SQL_HANDLE_DBC)
+ {
+ WARN("Wrong handle type %d\n", connection->type);
+ return SQL_ERROR;
+ }
+
+ stmt = malloc(sizeof(*stmt));
+ if (!stmt)
+ {
+ return SQL_ERROR;
+ }
+
+ stmt->type = SQL_HANDLE_STMT;
+ stmt->connection = connection;
+
+ /* Default to ODBC v3 function */
+ if(connection->pSQLAllocHandle)
+ {
+ ret = connection->pSQLAllocHandle(SQL_HANDLE_STMT, connection->driver_hdbc, &stmt->driver_stmt);
+ }
+ else if (connection->pSQLAllocStmt)
+ {
+ ret = connection->pSQLAllocStmt(connection->driver_hdbc, &stmt->driver_stmt);
+ }
+
+ *StatementHandle = stmt;
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,68 @@
From eeab9933053871380bac92db0a9e7444be7f9374 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 09:59:14 +1100
Subject: [PATCH 15/42] odbc32: Forward SQLSetStmtAttr/W request to driver
---
dlls/odbc32/proxyodbc.c | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 4ec5ecfcb83..d0be7b600bf 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1242,11 +1242,24 @@ SQLRETURN WINAPI SQLSetParam(SQLHSTMT StatementHandle, SQLUSMALLINT ParameterNum
SQLRETURN WINAPI SQLSetStmtAttr(SQLHSTMT StatementHandle, SQLINTEGER Attribute, SQLPOINTER Value,
SQLINTEGER StringLength)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, Attribute %d, Value %p, StringLength %d)\n", StatementHandle, Attribute, Value,
+ TRACE("(StatementHandle %p, Attribute %d, Value %p, StringLength %d)\n", StatementHandle, Attribute, Value,
StringLength);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLSetStmtAttr)
+ {
+ ret = statement->connection->pSQLSetStmtAttr(statement->driver_stmt, Attribute, Value, StringLength);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
@@ -2378,11 +2391,24 @@ SQLRETURN WINAPI SQLSetDescFieldW(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumb
SQLRETURN WINAPI SQLSetStmtAttrW(SQLHSTMT StatementHandle, SQLINTEGER Attribute, SQLPOINTER Value,
SQLINTEGER StringLength)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, Attribute %d, Value %p, StringLength %d)\n", StatementHandle, Attribute, Value,
+ TRACE("(StatementHandle %p, Attribute %d, Value %p, StringLength %d)\n", StatementHandle, Attribute, Value,
StringLength);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLSetStmtAttrW)
+ {
+ ret = statement->connection->pSQLSetStmtAttrW(statement->driver_stmt, Attribute, Value, StringLength);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,41 @@
From e93822d6974d17a4f649228222fb6cd2f513d2a4 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 10:50:26 +1100
Subject: [PATCH 16/42] odbc32: Forward SQLParamOptions request onto driver
---
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 d0be7b600bf..10de992e83e 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1501,10 +1501,23 @@ SQLRETURN WINAPI SQLNumParams(SQLHSTMT hstmt, SQLSMALLINT *pcpar)
*/
SQLRETURN WINAPI SQLParamOptions(SQLHSTMT hstmt, SQLULEN crow, SQLULEN *pirow)
{
+ struct SQLHSTMT_data *statement = hstmt;
SQLRETURN ret = SQL_ERROR;
- FIXME("(hstmt %p, crow %s, pirow %p)\n", hstmt, debugstr_sqlulen(crow), pirow);
+ TRACE("(hstmt %p, crow %s, pirow %p)\n", hstmt, debugstr_sqlulen(crow), pirow);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLParamOptions)
+ {
+ ret = statement->connection->pSQLParamOptions(statement->driver_stmt, crow, pirow);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,66 @@
From 7b0b4f665836d2008dd679d27c9995c25895f1bb Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 10:53:29 +1100
Subject: odbc32: Forward SQLExecDirect/W request onto driver
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 10de992e83e..bbcaa2487db 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -674,11 +674,25 @@ SQLRETURN WINAPI SQLError(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle, S
*/
SQLRETURN WINAPI SQLExecDirect(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, StatementText %s, TextLength %d)\n", StatementHandle,
- debugstr_an((const char *)StatementText, TextLength), TextLength);
+ TRACE("(StatementHandle %p, StatementText %s, TextLength %d)\n", StatementHandle,
+ TextLength > 0 ? debugstr_wn(StatementText, TextLength) : debugstr_w(StatementText),
+ TextLength);
+
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+ if (statement->connection->pSQLExecDirect)
+ {
+ ret = statement->connection->pSQLExecDirect(statement->driver_stmt, StatementText, TextLength);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
@@ -1742,11 +1756,25 @@ SQLRETURN WINAPI SQLErrorW(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle,
*/
SQLRETURN WINAPI SQLExecDirectW(SQLHSTMT StatementHandle, WCHAR *StatementText, SQLINTEGER TextLength)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, StatementText %s, TextLength %d)\n", StatementHandle,
- debugstr_wn(StatementText, TextLength), TextLength);
+ TRACE("(StatementHandle %p, StatementText %s, TextLength %d)\n", StatementHandle,
+ TextLength > 0 ? debugstr_wn(StatementText, TextLength) : debugstr_w(StatementText),
+ TextLength);
+
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+ if (statement->connection->pSQLExecDirectW)
+ {
+ ret = statement->connection->pSQLExecDirectW(statement->driver_stmt, StatementText, TextLength);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}

View File

@ -0,0 +1,82 @@
From e1399a4847627be9772aa411c24f3c9a7269c18d Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 11:04:32 +1100
Subject: [PATCH 18/42] odbc32: Forward SQLGetStmtAttr/W onto driver
---
dlls/odbc32/proxyodbc.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index b43f2a0f876..ae790cd3651 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1032,17 +1032,31 @@ SQLRETURN WINAPI SQLGetInfo(SQLHDBC ConnectionHandle, SQLUSMALLINT InfoType, SQL
SQLRETURN WINAPI SQLGetStmtAttr(SQLHSTMT StatementHandle, SQLINTEGER Attribute, SQLPOINTER Value,
SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, Attribute %d, Value %p, BufferLength %d, StringLength %p)\n", StatementHandle,
+ TRACE("(StatementHandle %p, Attribute %d, Value %p, BufferLength %d, StringLength %p)\n", StatementHandle,
Attribute, Value, BufferLength, StringLength);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
if (!Value)
{
WARN("Unexpected NULL Value return address\n");
return SQL_ERROR;
}
+ if (statement->connection->pSQLGetStmtAttr)
+ {
+ ret = statement->connection->pSQLGetStmtAttr(statement->driver_stmt, Attribute, Value,
+ BufferLength, StringLength);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
@@ -1930,17 +1944,31 @@ SQLRETURN WINAPI SQLGetDiagRecW(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMA
SQLRETURN WINAPI SQLGetStmtAttrW(SQLHSTMT StatementHandle, SQLINTEGER Attribute, SQLPOINTER Value,
SQLINTEGER BufferLength, SQLINTEGER *StringLength)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, Attribute %d, Value %p, BufferLength %d, StringLength %p)\n", StatementHandle,
+ TRACE("(StatementHandle %p, Attribute %d, Value %p, BufferLength %d, StringLength %p)\n", StatementHandle,
Attribute, Value, BufferLength, StringLength);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
if (!Value)
{
WARN("Unexpected NULL Value return address\n");
return SQL_ERROR;
}
+ if (statement->connection->pSQLGetStmtAttrW)
+ {
+ ret = statement->connection->pSQLGetStmtAttrW(statement->driver_stmt, Attribute, Value,
+ BufferLength, StringLength);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,41 @@
From 31d7dbc51491735cfadd4732d1a8cc64be18de14 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 11:08:41 +1100
Subject: [PATCH 19/42] odbc32: Forward SQLRowCount onto driver
---
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 ae790cd3651..32c61eea427 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1138,10 +1138,23 @@ SQLRETURN WINAPI SQLPutData(SQLHSTMT StatementHandle, SQLPOINTER Data, SQLLEN St
*/
SQLRETURN WINAPI SQLRowCount(SQLHSTMT StatementHandle, SQLLEN *RowCount)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, RowCount %p)\n", StatementHandle, RowCount);
+ TRACE("(StatementHandle %p, RowCount %p)\n", StatementHandle, RowCount);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLRowCount)
+ {
+ ret = statement->connection->pSQLRowCount(statement->driver_stmt, RowCount);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,41 @@
From 7359117d8a80ac80ca0602ca81a3b2b3ce2d26c1 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 11:10:54 +1100
Subject: [PATCH 20/42] odbc32: Forward SQLNumResultCols onto driver
---
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 32c61eea427..1d1c575ca11 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1089,10 +1089,23 @@ SQLRETURN WINAPI SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
*/
SQLRETURN WINAPI SQLNumResultCols(SQLHSTMT StatementHandle, SQLSMALLINT *ColumnCount)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, ColumnCount %p)\n", StatementHandle, ColumnCount);
+ TRACE("(StatementHandle %p, ColumnCount %p)\n", StatementHandle, ColumnCount);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLNumResultCols)
+ {
+ ret = statement->connection->pSQLNumResultCols(statement->driver_stmt, ColumnCount);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,41 @@
From 7c1897a48423d319430c3bea7252d2335a1148d5 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 11:12:20 +1100
Subject: [PATCH 21/42] odbc32: Forward SQLMoreResults request onto driver
---
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 1d1c575ca11..e5b0ae63afb 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1516,10 +1516,23 @@ SQLRETURN WINAPI SQLForeignKeys(SQLHSTMT hstmt, SQLCHAR *szPkCatalogName, SQLSMA
*/
SQLRETURN WINAPI SQLMoreResults(SQLHSTMT StatementHandle)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(%p)\n", StatementHandle);
+ TRACE("(%p)\n", StatementHandle);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLMoreResults)
+ {
+ ret = statement->connection->pSQLMoreResults(statement->driver_stmt);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,78 @@
From 4f1d0d9509469e410e151671da2a8baf53df09b3 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 11:17:59 +1100
Subject: [PATCH 22/42] odbc32: Forward SQLDescribeCol/w request onto driver
---
dlls/odbc32/proxyodbc.c | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index e5b0ae63afb..318aba1cc48 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -606,12 +606,29 @@ SQLRETURN WINAPI SQLDescribeCol(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNum
SQLSMALLINT BufferLength, SQLSMALLINT *NameLength, SQLSMALLINT *DataType,
SQLULEN *ColumnSize, SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
+ SQLSMALLINT dummy;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, ColumnNumber %d, ColumnName %p, BufferLength %d, NameLength %p, DataType %p,"
+ TRACE("(StatementHandle %p, ColumnNumber %d, ColumnName %p, BufferLength %d, NameLength %p, DataType %p,"
" ColumnSize %p, DecimalDigits %p, Nullable %p)\n", StatementHandle, ColumnNumber, ColumnName,
BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable);
+ if (!NameLength) NameLength = &dummy; /* workaround for drivers that don't accept NULL NameLength */
+
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLDescribeCol)
+ {
+ ret = statement->connection->pSQLDescribeCol(statement->driver_stmt, ColumnNumber, ColumnName,
+ BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
@@ -1775,15 +1792,29 @@ SQLRETURN WINAPI SQLDescribeColW(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNu
SQLSMALLINT BufferLength, SQLSMALLINT *NameLength, SQLSMALLINT *DataType,
SQLULEN *ColumnSize, SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLSMALLINT dummy;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, ColumnNumber %d, ColumnName %p, BufferLength %d, NameLength %p, DataType %p,"
+ TRACE("(StatementHandle %p, ColumnNumber %d, ColumnName %p, BufferLength %d, NameLength %p, DataType %p,"
" ColumnSize %p, DecimalDigits %p, Nullable %p)\n", StatementHandle, ColumnNumber, ColumnName,
BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable);
if (!NameLength) NameLength = &dummy; /* workaround for drivers that don't accept NULL NameLength */
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLDescribeColW)
+ {
+ ret = statement->connection->pSQLDescribeColW(statement->driver_stmt, ColumnNumber, ColumnName,
+ BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,100 @@
From 85be83ac84dea5b5e5aa43770d1c7e78ad07dbd5 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 11:30:58 +1100
Subject: [PATCH 23/42] odbc32: Forward SQLColAttributes/W request onto driver
---
dlls/odbc32/proxyodbc.c | 55 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 53 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 318aba1cc48..8360cd0684f 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1449,11 +1449,26 @@ SQLRETURN WINAPI SQLColAttributes(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLUSMALLIN
SQLPOINTER rgbDesc, SQLSMALLINT cbDescMax, SQLSMALLINT *pcbDesc,
SQLLEN *pfDesc)
{
+ struct SQLHSTMT_data *statement = hstmt;
SQLRETURN ret = SQL_ERROR;
- FIXME("(hstmt %p, icol %d, fDescType %d, rgbDesc %p, cbDescMax %d, pcbDesc %p, pfDesc %p)\n", hstmt, icol,
+ TRACE("(hstmt %p, icol %d, fDescType %d, rgbDesc %p, cbDescMax %d, pcbDesc %p, pfDesc %p)\n", hstmt, icol,
fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLColAttributes)
+ {
+ ret = statement->connection->pSQLColAttributes(statement->driver_stmt, icol, fDescType,
+ rgbDesc, cbDescMax, pcbDesc, pfDesc);
+ }
+
+ TRACE("ret %d\n", ret);
+
return ret;
}
@@ -1754,6 +1769,21 @@ SQLRETURN WINAPI SQLSetScrollOptions(SQLHSTMT statement_handle, SQLUSMALLINT f_c
return ret;
}
+static SQLINTEGER map_odbc2_to_3(SQLINTEGER fieldid)
+{
+ switch( fieldid )
+ {
+ case SQL_COLUMN_COUNT:
+ return SQL_DESC_COUNT;
+ case SQL_COLUMN_NULLABLE:
+ return SQL_DESC_NULLABLE;
+ case SQL_COLUMN_NAME:
+ return SQL_DESC_NAME;
+ default:
+ return fieldid;
+ }
+}
+
/*************************************************************************
* SQLColAttributesW [ODBC32.106]
*/
@@ -1761,11 +1791,32 @@ SQLRETURN WINAPI SQLColAttributesW(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLUSMALLI
SQLPOINTER rgbDesc, SQLSMALLINT cbDescMax, SQLSMALLINT *pcbDesc,
SQLLEN *pfDesc)
{
+ struct SQLHSTMT_data *statement = hstmt;
SQLRETURN ret = SQL_ERROR;
- FIXME("(hstmt %p, icol %d, fDescType %d, rgbDesc %p, cbDescMax %d, pcbDesc %p, pfDesc %p)\n", hstmt, icol,
+ TRACE("(hstmt %p, icol %d, fDescType %d, rgbDesc %p, cbDescMax %d, pcbDesc %p, pfDesc %p)\n", hstmt, icol,
fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ /* Default to ODBC 3.x */
+ if (statement->connection->pSQLColAttributeW)
+ {
+ fDescType = map_odbc2_to_3(fDescType);
+ ret = statement->connection->pSQLColAttributeW(statement->driver_stmt, icol, fDescType,
+ rgbDesc, cbDescMax, pcbDesc, pfDesc);
+ }
+ else if (statement->connection->pSQLColAttributesW)
+ {
+ ret = statement->connection->pSQLColAttributesW(statement->driver_stmt, icol, fDescType,
+ rgbDesc, cbDescMax, pcbDesc, pfDesc);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,70 @@
From 04b5940c19de8c92269f9da73e6d98d9777a3020 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 11:36:33 +1100
Subject: [PATCH 24/42] odbc32: Forward SQLNativeSql/W request onto driver
---
dlls/odbc32/proxyodbc.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 8360cd0684f..5b63fded654 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1574,11 +1574,25 @@ SQLRETURN WINAPI SQLMoreResults(SQLHSTMT StatementHandle)
SQLRETURN WINAPI SQLNativeSql(SQLHDBC hdbc, SQLCHAR *szSqlStrIn, SQLINTEGER cbSqlStrIn, SQLCHAR *szSqlStr,
SQLINTEGER cbSqlStrMax, SQLINTEGER *pcbSqlStr)
{
+ struct SQLHDBC_data *connection = hdbc;
SQLRETURN ret = SQL_ERROR;
- FIXME("(hdbc %p, szSqlStrIn %s, cbSqlStrIn %d, szSqlStr %p, cbSqlStrMax %d, pcbSqlStr %p)\n", hdbc,
+ TRACE("(hdbc %p, szSqlStrIn %s, cbSqlStrIn %d, szSqlStr %p, cbSqlStrMax %d, pcbSqlStr %p)\n", hdbc,
debugstr_an((const char *)szSqlStrIn, cbSqlStrIn), cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
+ if (connection->type != SQL_HANDLE_DBC)
+ {
+ WARN("Wrong handle type %d\n", connection->type);
+ return SQL_ERROR;
+ }
+
+ if (connection->pSQLNativeSql)
+ {
+ ret = connection->pSQLNativeSql(connection->driver_hdbc, szSqlStrIn, cbSqlStrIn,
+ szSqlStr, cbSqlStrMax, pcbSqlStr);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
@@ -2465,11 +2479,25 @@ SQLRETURN WINAPI SQLForeignKeysW(SQLHSTMT hstmt, SQLWCHAR *szPkCatalogName, SQLS
SQLRETURN WINAPI SQLNativeSqlW(SQLHDBC hdbc, SQLWCHAR *szSqlStrIn, SQLINTEGER cbSqlStrIn, SQLWCHAR *szSqlStr,
SQLINTEGER cbSqlStrMax, SQLINTEGER *pcbSqlStr)
{
+ struct SQLHDBC_data *connection = hdbc;
SQLRETURN ret = SQL_ERROR;
- FIXME("(hdbc %p, szSqlStrIn %s, cbSqlStrIn %d, szSqlStr %p, cbSqlStrMax %d, pcbSqlStr %p)\n", hdbc,
+ TRACE("(hdbc %p, szSqlStrIn %s, cbSqlStrIn %d, szSqlStr %p, cbSqlStrMax %d, pcbSqlStr %p)\n", hdbc,
debugstr_wn(szSqlStrIn, cbSqlStrIn), cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
+ if (connection->type != SQL_HANDLE_DBC)
+ {
+ WARN("Wrong handle type %d\n", connection->type);
+ return SQL_ERROR;
+ }
+
+ if (connection->pSQLNativeSqlW)
+ {
+ ret = connection->pSQLNativeSqlW(connection->driver_hdbc, szSqlStrIn, cbSqlStrIn,
+ szSqlStr, cbSqlStrMax, pcbSqlStr);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,65 @@
From 95d92cec6ceebb2f3fc7624180f89e7764e2430f Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 11:44:00 +1100
Subject: odbc32: Forward SQLPrepare/W request onto driver
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 5b63fded654..fae384ca411 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1143,11 +1143,25 @@ SQLRETURN WINAPI SQLParamData(SQLHSTMT StatementHandle, SQLPOINTER *Value)
*/
SQLRETURN WINAPI SQLPrepare(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
FIXME("(StatementHandle %p, StatementText %s, TextLength %d)\n", StatementHandle,
- debugstr_an((const char *)StatementText, TextLength), TextLength);
+ TextLength > 0 ? debugstr_an((const char *)StatementText, TextLength) : debugstr_a((const char *)StatementText),
+ TextLength);
+
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+ if (statement->connection->pSQLPrepare)
+ {
+ ret = statement->connection->pSQLPrepare(statement->driver_stmt, StatementText, TextLength);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
@@ -1944,11 +1958,25 @@ SQLRETURN WINAPI SQLGetCursorNameW(SQLHSTMT StatementHandle, WCHAR *CursorName,
*/
SQLRETURN WINAPI SQLPrepareW(SQLHSTMT StatementHandle, WCHAR *StatementText, SQLINTEGER TextLength)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, StatementText %s, TextLength %d)\n", StatementHandle,
- debugstr_wn(StatementText, TextLength), TextLength);
+ TRACE("(StatementHandle %p, StatementText %s, TextLength %d)\n", StatementHandle,
+ TextLength > 0 ? debugstr_wn(StatementText, TextLength) : debugstr_w(StatementText),
+ TextLength);
+
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+ if (statement->connection->pSQLPrepareW)
+ {
+ ret = statement->connection->pSQLPrepareW(statement->driver_stmt, StatementText, TextLength);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}

View File

@ -0,0 +1,41 @@
From 20e5843387fd2daf28414b529dddd83dafa23cae Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 11:47:40 +1100
Subject: [PATCH 26/42] odbc32: Implement SQLFreeStmt
---
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 821c769c865..18efa222945 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -807,10 +807,23 @@ SQLRETURN WINAPI SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
*/
SQLRETURN WINAPI SQLFreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, Option %d)\n", StatementHandle, Option);
+ TRACE("(StatementHandle %p, Option %d)\n", StatementHandle, Option);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLFreeStmt)
+ {
+ ret = statement->connection->pSQLFreeStmt(statement->driver_stmt, Option);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,43 @@
From 2eed70f4cf636fc2f3e6549d480e8be80b8fcaca Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 11:57:00 +1100
Subject: [PATCH 27/42] odbc32: Forward SQLBindCol requets onto driver
---
dlls/odbc32/proxyodbc.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 18efa222945..48b89731ed0 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -447,11 +447,25 @@ static const char *debugstr_sqllen( SQLLEN len )
SQLRETURN WINAPI SQLBindCol(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
SQLPOINTER TargetValue, SQLLEN BufferLength, SQLLEN *StrLen_or_Ind)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, ColumnNumber %d, TargetType %d, TargetValue %p, BufferLength %s, StrLen_or_Ind %p)\n",
+ TRACE("(StatementHandle %p, ColumnNumber %d, TargetType %d, TargetValue %p, BufferLength %s, StrLen_or_Ind %p)\n",
StatementHandle, ColumnNumber, TargetType, TargetValue, debugstr_sqllen(BufferLength), StrLen_or_Ind);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLBindCol)
+ {
+ ret = statement->connection->pSQLBindCol(statement->driver_stmt, ColumnNumber, TargetType,
+ TargetValue, BufferLength, StrLen_or_Ind);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,43 @@
From 2ad199088b8f666c3d7418eac6ec35e639f8260b Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 12:35:26 +1100
Subject: [PATCH 28/42] odbc32: Forward SQLExtendedFetch request onto driver
---
dlls/odbc32/proxyodbc.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 48b89731ed0..5a03ea3d757 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1551,11 +1551,25 @@ SQLRETURN WINAPI SQLDescribeParam(SQLHSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT
SQLRETURN WINAPI SQLExtendedFetch(SQLHSTMT hstmt, SQLUSMALLINT fFetchType, SQLLEN irow, SQLULEN *pcrow,
SQLUSMALLINT *rgfRowStatus)
{
+ struct SQLHSTMT_data *statement = hstmt;
SQLRETURN ret = SQL_ERROR;
- FIXME("(hstmt %p, fFetchType %d, irow %s, pcrow %p, rgfRowStatus %p)\n", hstmt, fFetchType, debugstr_sqllen(irow),
+ TRACE("(hstmt %p, fFetchType %d, irow %s, pcrow %p, rgfRowStatus %p)\n", hstmt, fFetchType, debugstr_sqllen(irow),
pcrow, rgfRowStatus);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLExtendedFetch)
+ {
+ ret = statement->connection->pSQLExtendedFetch(statement->driver_stmt, fFetchType, irow,
+ pcrow, rgfRowStatus);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,41 @@
From 04ef2a6e51678a60daac117cec90ed48d5fb3fa6 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 13:14:19 +1100
Subject: [PATCH 29/42] odbc32: Forward SQLExecute request onto driver
---
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 5a03ea3d757..846b788b76b 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -743,10 +743,23 @@ SQLRETURN WINAPI SQLExecute(SQLHSTMT StatementHandle)
*/
SQLRETURN WINAPI SQLFetch(SQLHSTMT StatementHandle)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p)\n", StatementHandle);
+ TRACE("(StatementHandle %p)\n", StatementHandle);
+
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLFetch)
+ {
+ ret = statement->connection->pSQLFetch(statement->driver_stmt);
+ }
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,80 @@
From 89c345e13d530c284be111076b5b17abb7d3487b Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 13:15:48 +1100
Subject: [PATCH 30/42] odbc32: Forward SQLGetDiagField/W request onto driver
---
dlls/odbc32/proxyodbc.c | 46 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 846b788b76b..74e5d70cfef 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -963,9 +963,30 @@ SQLRETURN WINAPI SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSM
{
SQLRETURN ret = SQL_ERROR;
- FIXME("(HandleType %d, Handle %p, RecNumber %d, DiagIdentifier %d, DiagInfo %p, BufferLength %d,"
+ TRACE("(HandleType %d, Handle %p, RecNumber %d, DiagIdentifier %d, DiagInfo %p, BufferLength %d,"
" StringLength %p)\n", HandleType, Handle, RecNumber, DiagIdentifier, DiagInfo, BufferLength, StringLength);
+ if (HandleType == SQL_HANDLE_ENV)
+ {
+ FIXME("Unhandled SQL_HANDLE_ENV records\n");
+ }
+ else if (HandleType == SQL_HANDLE_DBC)
+ {
+ struct SQLHDBC_data *hdbc = Handle;
+
+ if (hdbc->pSQLGetDiagField)
+ ret = hdbc->pSQLGetDiagField(HandleType, hdbc->driver_hdbc, RecNumber, DiagIdentifier,
+ DiagInfo, BufferLength, StringLength);
+ }
+ else if (HandleType == SQL_HANDLE_STMT)
+ {
+ struct SQLHSTMT_data *statement = Handle;
+
+ if (statement->connection->pSQLGetDiagField)
+ ret = statement->connection->pSQLGetDiagField(HandleType, statement->driver_stmt, RecNumber,
+ DiagIdentifier, DiagInfo, BufferLength, StringLength);
+ }
+
return ret;
}
@@ -2131,9 +2152,30 @@ SQLRETURN WINAPI SQLGetDiagFieldW(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLS
{
SQLRETURN ret = SQL_ERROR;
- FIXME("(HandleType %d, Handle %p, RecNumber %d, DiagIdentifier %d, DiagInfo %p, BufferLength %d,"
+ TRACE("(HandleType %d, Handle %p, RecNumber %d, DiagIdentifier %d, DiagInfo %p, BufferLength %d,"
" StringLength %p)\n", HandleType, Handle, RecNumber, DiagIdentifier, DiagInfo, BufferLength, StringLength);
+ if (HandleType == SQL_HANDLE_ENV)
+ {
+ FIXME("Unhandled SQL_HANDLE_ENV records\n");
+ }
+ else if (HandleType == SQL_HANDLE_DBC)
+ {
+ struct SQLHDBC_data *hdbc = Handle;
+
+ if (hdbc->pSQLGetDiagFieldW)
+ ret = hdbc->pSQLGetDiagFieldW(HandleType, hdbc->driver_hdbc, RecNumber, DiagIdentifier,
+ DiagInfo, BufferLength, StringLength);
+ }
+ else if (HandleType == SQL_HANDLE_STMT)
+ {
+ struct SQLHSTMT_data *statement = Handle;
+
+ if (statement->connection->pSQLGetDiagFieldW)
+ ret = statement->connection->pSQLGetDiagFieldW(HandleType, statement->driver_stmt, RecNumber,
+ DiagIdentifier, DiagInfo, BufferLength, StringLength);
+ }
+
return ret;
}
--
2.39.1

View File

@ -0,0 +1,124 @@
From a3e0c12cbbdc7a8a81b5d7278659104d6b4d325a Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 14:00:41 +1100
Subject: [PATCH 31/42] odbc32: SQLGetStmtAttr store some driver HDESC values
---
dlls/odbc32/proxyodbc.c | 81 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 78 insertions(+), 3 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 74e5d70cfef..27e4f1a4baa 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -178,11 +178,22 @@ struct SQLHDBC_data
SQLUINTEGER login_timeout;
};
+struct SQLHDESC_data
+{
+ struct SQLHSTMT_data *parent;
+ SQLHDESC driver_hdesc;
+};
+
struct SQLHSTMT_data
{
int type;
struct SQLHDBC_data *connection;
SQLHSTMT driver_stmt;
+
+ struct SQLHDESC_data app_row_desc;
+ struct SQLHDESC_data imp_row_desc;
+ struct SQLHDESC_data app_param_desc;
+ struct SQLHDESC_data imp_param_desc;
};
static void connection_bind_sql_funcs(struct SQLHDBC_data *connection)
@@ -1130,8 +1141,40 @@ SQLRETURN WINAPI SQLGetStmtAttr(SQLHSTMT StatementHandle, SQLINTEGER Attribute,
if (statement->connection->pSQLGetStmtAttr)
{
- ret = statement->connection->pSQLGetStmtAttr(statement->driver_stmt, Attribute, Value,
+ switch(Attribute)
+ {
+ case SQL_ATTR_APP_ROW_DESC:
+ statement->app_row_desc.parent = statement;
+ ret = statement->connection->pSQLGetStmtAttr(statement->driver_stmt, Attribute,
+ &statement->app_row_desc.driver_hdesc,
+ BufferLength, StringLength);
+ *((SQLHDESC*)Value) = &statement->app_row_desc;
+ break;
+ case SQL_ATTR_IMP_ROW_DESC:
+ statement->imp_row_desc.parent = statement;
+ ret = statement->connection->pSQLGetStmtAttr(statement->driver_stmt, Attribute,
+ &statement->imp_row_desc.driver_hdesc,
+ BufferLength, StringLength);
+ *((SQLHDESC*)Value) = &statement->imp_row_desc;
+ break;
+ case SQL_ATTR_APP_PARAM_DESC:
+ statement->app_param_desc.parent = statement;
+ ret = statement->connection->pSQLGetStmtAttr(statement->driver_stmt, Attribute,
+ &statement->app_param_desc.driver_hdesc,
+ BufferLength, StringLength);
+ *((SQLHDESC*)Value) = &statement->app_param_desc;
+ break;
+ case SQL_ATTR_IMP_PARAM_DESC:
+ statement->imp_param_desc.parent = statement;
+ ret = statement->connection->pSQLGetStmtAttr(statement->driver_stmt, Attribute,
+ &statement->imp_param_desc.driver_hdesc,
+ BufferLength, StringLength);
+ *((SQLHDESC*)Value) = &statement->imp_param_desc;
+ break;
+ default:
+ ret = statement->connection->pSQLGetStmtAttr(statement->driver_stmt, Attribute, Value,
BufferLength, StringLength);
+ }
}
TRACE("ret %d\n", ret);
@@ -2221,8 +2264,40 @@ SQLRETURN WINAPI SQLGetStmtAttrW(SQLHSTMT StatementHandle, SQLINTEGER Attribute,
if (statement->connection->pSQLGetStmtAttrW)
{
- ret = statement->connection->pSQLGetStmtAttrW(statement->driver_stmt, Attribute, Value,
- BufferLength, StringLength);
+ switch(Attribute)
+ {
+ case SQL_ATTR_APP_ROW_DESC:
+ statement->app_row_desc.parent = statement;
+ ret = statement->connection->pSQLGetStmtAttrW(statement->driver_stmt, Attribute,
+ &statement->app_row_desc.driver_hdesc,
+ BufferLength, StringLength);
+ *((SQLHDESC*)Value) = &statement->app_row_desc;
+ break;
+ case SQL_ATTR_IMP_ROW_DESC:
+ statement->imp_row_desc.parent = statement;
+ ret = statement->connection->pSQLGetStmtAttrW(statement->driver_stmt, Attribute,
+ &statement->imp_row_desc.driver_hdesc,
+ BufferLength, StringLength);
+ *((SQLHDESC*)Value) = &statement->imp_row_desc;
+ break;
+ case SQL_ATTR_APP_PARAM_DESC:
+ statement->app_param_desc.parent = statement;
+ ret = statement->connection->pSQLGetStmtAttrW(statement->driver_stmt, Attribute,
+ &statement->app_param_desc.driver_hdesc,
+ BufferLength, StringLength);
+ *((SQLHDESC*)Value) = &statement->app_param_desc;
+ break;
+ case SQL_ATTR_IMP_PARAM_DESC:
+ statement->imp_param_desc.parent = statement;
+ ret = statement->connection->pSQLGetStmtAttrW(statement->driver_stmt, Attribute,
+ &statement->imp_param_desc.driver_hdesc,
+ BufferLength, StringLength);
+ *((SQLHDESC*)Value) = &statement->imp_param_desc;
+ break;
+ default:
+ ret = statement->connection->pSQLGetStmtAttrW(statement->driver_stmt, Attribute, Value,
+ BufferLength, StringLength);
+ }
}
TRACE("ret %d\n", ret);
--
2.39.1

View File

@ -0,0 +1,43 @@
From d2d566575b786ccaa223e582260a0b33038a8153 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 14:11:44 +1100
Subject: [PATCH 32/42] odbc32: Forward SQLSetDescFieldW request onto driver
---
dlls/odbc32/proxyodbc.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 27e4f1a4baa..7589ba7d9d4 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -2218,6 +2218,7 @@ SQLRETURN WINAPI SQLGetDiagFieldW(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLS
ret = statement->connection->pSQLGetDiagFieldW(HandleType, statement->driver_stmt, RecNumber,
DiagIdentifier, DiagInfo, BufferLength, StringLength);
}
+ TRACE("ret %d\n", ret);
return ret;
}
@@ -2790,11 +2791,17 @@ SQLRETURN WINAPI SQLDriversW(SQLHENV EnvironmentHandle, SQLUSMALLINT fDirection,
SQLRETURN WINAPI SQLSetDescFieldW(SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
SQLPOINTER Value, SQLINTEGER BufferLength)
{
+ struct SQLHDESC_data *hdesc = DescriptorHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(DescriptorHandle %p, RecNumber %d, FieldIdentifier %d, Value %p, BufferLength %d)\n", DescriptorHandle,
+ TRACE("(DescriptorHandle %p, RecNumber %d, FieldIdentifier %d, Value %p, BufferLength %d)\n", DescriptorHandle,
RecNumber, FieldIdentifier, Value, BufferLength);
+ if (hdesc->parent->connection->pSQLSetDescFieldW)
+ ret = hdesc->parent->connection->pSQLSetDescFieldW(hdesc->driver_hdesc, RecNumber, FieldIdentifier,
+ Value, BufferLength);
+ TRACE("ret %d\n", ret);
+
return ret;
}
--
2.39.1

View File

@ -0,0 +1,43 @@
From 8d90ba32bbd212d36cbdd47c595c76b4f324d4f8 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 15:13:09 +1100
Subject: [PATCH 33/42] odbc32: Forward SQLGetData request onto driver
---
dlls/odbc32/proxyodbc.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 7589ba7d9d4..4e98c8c7caa 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -926,11 +926,25 @@ SQLRETURN WINAPI SQLGetCursorName(SQLHSTMT StatementHandle, SQLCHAR *CursorName,
SQLRETURN WINAPI SQLGetData(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
SQLPOINTER TargetValue, SQLLEN BufferLength, SQLLEN *StrLen_or_Ind)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, ColumnNumber %d, TargetType %d, TargetValue %p, BufferLength %s, StrLen_or_Ind %p)\n",
+ TRACE("(StatementHandle %p, ColumnNumber %d, TargetType %d, TargetValue %p, BufferLength %s, StrLen_or_Ind %p)\n",
StatementHandle, ColumnNumber, TargetType, TargetValue, debugstr_sqllen(BufferLength), StrLen_or_Ind);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLGetData)
+ {
+ ret = statement->connection->pSQLGetData(statement->driver_stmt, ColumnNumber, TargetType,
+ TargetValue, BufferLength, StrLen_or_Ind);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,66 @@
From edf0a873027a3b95e1bf84750efbb29939aee60e Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 15:23:30 +1100
Subject: [PATCH 34/42] odbc32: Forward SQLGetTypeInfo/W request onto driver
---
dlls/odbc32/proxyodbc.c | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 4e98c8c7caa..7f8cc57e968 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1212,10 +1212,23 @@ SQLRETURN WINAPI SQLGetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option,
*/
SQLRETURN WINAPI SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, DataType %d)\n", StatementHandle, DataType);
+ TRACE("(StatementHandle %p, DataType %d)\n", StatementHandle, DataType);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLGetTypeInfo)
+ {
+ ret = statement->connection->pSQLGetTypeInfo(statement->driver_stmt, DataType);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
@@ -2540,10 +2553,23 @@ SQLRETURN WINAPI SQLGetInfoW(SQLHDBC ConnectionHandle, SQLUSMALLINT InfoType, SQ
*/
SQLRETURN WINAPI SQLGetTypeInfoW(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, DataType %d)\n", StatementHandle, DataType);
+ TRACE("(StatementHandle %p, DataType %d)\n", StatementHandle, DataType);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLGetTypeInfoW)
+ {
+ ret = statement->connection->pSQLGetTypeInfoW(statement->driver_stmt, DataType);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,44 @@
From 4fe0ad96bddd96ff4eb2b3786765ff7a547974d8 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
---
dlls/odbc32/proxyodbc.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 7f8cc57e968..f73daad254f 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1901,12 +1901,26 @@ SQLRETURN WINAPI SQLBindParameter(SQLHSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT
SQLSMALLINT ibScale, SQLPOINTER rgbValue, SQLLEN cbValueMax,
SQLLEN *pcbValue)
{
+ struct SQLHSTMT_data *statement = hstmt;
SQLRETURN ret = SQL_ERROR;
- FIXME("(hstmt %p, ipar %d, fParamType %d, fCType %d, fSqlType %d, cbColDef %s, ibScale %d, rgbValue %p,"
+ TRACE("(hstmt %p, ipar %d, fParamType %d, fCType %d, fSqlType %d, cbColDef %s, ibScale %d, rgbValue %p,"
" cbValueMax %s, pcbValue %p)\n", hstmt, ipar, fParamType, fCType, fSqlType, debugstr_sqlulen(cbColDef),
ibScale, rgbValue, debugstr_sqllen(cbValueMax), pcbValue);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLBindParameter)
+ {
+ ret = statement->connection->pSQLBindParameter(statement->driver_stmt, ipar, fParamType,
+ fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,42 @@
From 0930c5f0fe4e4608957cc5c16c2d8e63d805d5e4 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 6 Feb 2023 16:03:58 +1100
Subject: [PATCH 36/42] odbc32: Forward SQLTransact request onto driver
---
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 f73daad254f..c73912b38cf 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -1550,11 +1550,24 @@ SQLRETURN WINAPI SQLTables(SQLHSTMT StatementHandle, SQLCHAR *CatalogName, SQLSM
*/
SQLRETURN WINAPI SQLTransact(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle, SQLUSMALLINT CompletionType)
{
+ struct SQLHDBC_data *connection = ConnectionHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(EnvironmentHandle %p, ConnectionHandle %p, CompletionType %d)\n", EnvironmentHandle, ConnectionHandle,
+ TRACE("(EnvironmentHandle %p, ConnectionHandle %p, CompletionType %d)\n", EnvironmentHandle, ConnectionHandle,
CompletionType);
+ if (connection->type != SQL_HANDLE_DBC)
+ {
+ WARN("Wrong connection handle type %d\n", connection->type);
+ return SQL_ERROR;
+ }
+
+ if (connection->pSQLTransact)
+ {
+ ret = connection->pSQLTransact(connection->driver_env, connection->driver_hdbc, CompletionType);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,54 @@
From 5fa88dabafbfb905553310a211a2701ad17f6df6 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
---
dlls/odbc32/proxyodbc.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index c73912b38cf..bdd8361d221 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -2286,10 +2286,36 @@ SQLRETURN WINAPI SQLGetDiagRecW(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMA
{
SQLRETURN ret = SQL_ERROR;
- FIXME("(HandleType %d, Handle %p, RecNumber %d, Sqlstate %p, NativeError %p, MessageText %p, BufferLength %d,"
+ TRACE("(HandleType %d, Handle %p, RecNumber %d, Sqlstate %p, NativeError %p, MessageText %p, BufferLength %d,"
" TextLength %p)\n", HandleType, Handle, RecNumber, Sqlstate, NativeError, MessageText, BufferLength,
TextLength);
+ if (HandleType == SQL_HANDLE_ENV)
+ {
+ FIXME("Unhandled SQL_HANDLE_ENV records\n");
+ }
+ else if (HandleType == SQL_HANDLE_DBC)
+ {
+ struct SQLHDBC_data *hdbc = Handle;
+
+ if (hdbc->pSQLGetDiagRecW)
+ ret = hdbc->pSQLGetDiagRecW(HandleType, hdbc->driver_hdbc, RecNumber, 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);
+ }
+
+ if (ret != SQL_ERROR)
+ {
+ TRACE("%d: %s %s\n", RecNumber, debugstr_w(Sqlstate), debugstr_w(MessageText));
+ }
+
return ret;
}
--
2.39.1

View File

@ -0,0 +1,61 @@
From 99696a933b6393903df0aa314190a220cea635ac Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Wed, 8 Feb 2023 08:39:26 +1100
Subject: [PATCH 38/42] odbc32: SQLGetEnvAttr: Support SQL_ATTR_ODBC_VERSION
attribute
---
dlls/odbc32/proxyodbc.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index bdd8361d221..46872add8b0 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -47,6 +47,7 @@ struct SQLHENV_data
{
int type;
SQLUINTEGER pooling;
+ SQLUINTEGER version;
};
struct SQLHDBC_data
@@ -368,6 +369,7 @@ SQLRETURN WINAPI SQLAllocEnv(SQLHENV *EnvironmentHandle)
henv->type = SQL_HANDLE_ENV;
henv->pooling = SQL_CP_OFF;
+ henv->version = SQL_OV_ODBC2;
*EnvironmentHandle = henv;
@@ -1067,6 +1069,14 @@ SQLRETURN WINAPI SQLGetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute,
}
*(SQLUINTEGER*)Value = data->pooling;
break;
+ case SQL_ATTR_ODBC_VERSION:
+ if (BufferLength != sizeof(data->version))
+ {
+ WARN("Invalid buffer size\n");
+ return SQL_ERROR;
+ }
+ *(SQLUINTEGER*)Value = data->version;
+ break;
default:
FIXME("Unhandle attribute %d\n", Attribute);
return SQL_ERROR;
@@ -1426,6 +1436,12 @@ SQLRETURN WINAPI SQLSetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute,
else
data->pooling = SQL_CP_OFF;
break;
+ case SQL_ATTR_ODBC_VERSION:
+ if (Value)
+ data->version = (uintptr_t)Value;
+ else
+ data->version = SQL_OV_ODBC2;
+ break;
default:
FIXME("Unhandle attribute %d\n", Attribute);
return SQL_ERROR;
--
2.39.1

View File

@ -0,0 +1,29 @@
From 51a3447adf38839ab44b8b7e91baf5de66055125 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Wed, 8 Feb 2023 09:03:40 +1100
Subject: [PATCH 39/42] odbc32: Pass ODBC version when creating driver
environment
---
dlls/odbc32/proxyodbc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 46872add8b0..851d2535ca1 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -2552,6 +2552,11 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl
if (connection->pSQLAllocHandle)
{
connection->pSQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &connection->driver_env);
+
+ if (connection->pSQLSetEnvAttr)
+ connection->pSQLSetEnvAttr(connection->driver_env, SQL_ATTR_ODBC_VERSION,
+ (SQLPOINTER)connection->environment->version, 0);
+
connection->pSQLAllocHandle(SQL_HANDLE_DBC, connection->driver_env, &connection->driver_hdbc);
}
--
2.39.1

View File

@ -0,0 +1,37 @@
From e73aae5f26b1af29ce14f3edaa84569bd3c86bc4 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Wed, 8 Feb 2023 14:16:24 +1100
Subject: [PATCH 40/42] odbc32: SQLBindCol convert to ODBC2 types if required
---
dlls/odbc32/proxyodbc.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 851d2535ca1..c6d19b58e1c 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -474,6 +474,20 @@ SQLRETURN WINAPI SQLBindCol(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber,
if (statement->connection->pSQLBindCol)
{
+ /*
+ * Map ODBC3 Datatype back to ODBC2 types when the application has asked for SQL_OV_ODBC2.
+ * Some drivers rely on this (PostgreSQL odbc driver).
+ */
+ if (statement->connection->environment->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 = statement->connection->pSQLBindCol(statement->driver_stmt, ColumnNumber, TargetType,
TargetValue, BufferLength, StrLen_or_Ind);
}
--
2.39.1

View File

@ -0,0 +1,40 @@
From dca052a02225fb151237d0ba36dbf35d3fdab4fe Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Wed, 8 Feb 2023 15:22:00 +1100
Subject: [PATCH 41/42] odbc32: Implement SQLAllocHandle
---
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 c6d19b58e1c..15171a0d028 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -383,9 +383,22 @@ SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, S
{
SQLRETURN ret = SQL_ERROR;
- FIXME("(HandleType %d, InputHandle %p, OutputHandle %p)\n", HandleType, InputHandle, OutputHandle);
+ TRACE("(HandleType %d, InputHandle %p, OutputHandle %p)\n", HandleType, InputHandle, OutputHandle);
*OutputHandle = 0;
+ if (HandleType == SQL_HANDLE_ENV)
+ {
+ ret = SQLAllocEnv(OutputHandle);
+ }
+ else if (HandleType == SQL_HANDLE_DBC)
+ {
+ ret = SQLAllocConnect(InputHandle, OutputHandle);
+ }
+ else if (HandleType == SQL_HANDLE_STMT)
+ {
+ ret = SQLAllocStmt(InputHandle, OutputHandle);
+ }
+
return ret;
}
--
2.39.1

View File

@ -0,0 +1,48 @@
From ec35258befb2b050e2cd2087dc6ea9ea66155403 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Wed, 8 Feb 2023 15:34:18 +1100
Subject: [PATCH 42/42] odbc32: Forward SQLConnectW request onto driver
---
dlls/odbc32/proxyodbc.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 15171a0d028..6f6d502e772 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -2069,12 +2069,28 @@ SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle, WCHAR *ServerName, SQLSMA
WCHAR *UserName, SQLSMALLINT NameLength2, WCHAR *Authentication,
SQLSMALLINT NameLength3)
{
+ struct SQLHDBC_data *connection = ConnectionHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(ConnectionHandle %p, ServerName %s, NameLength1 %d, UserName %s, NameLength2 %d, Authentication %s,"
- " NameLength3 %d)\n", ConnectionHandle, debugstr_wn(ServerName, NameLength1), NameLength1,
- debugstr_wn(UserName, NameLength2), NameLength2, debugstr_wn(Authentication, NameLength3), NameLength3);
+ TRACE("(ConnectionHandle %p, ServerName %s, NameLength1 %d, UserName %s, NameLength2 %d, Authentication %s,"
+ " NameLength3 %d)\n", ConnectionHandle,
+ NameLength1 > 0 ? debugstr_wn(ServerName, NameLength1) : debugstr_w(ServerName), NameLength1,
+ NameLength2 > 0 ? debugstr_wn(UserName, NameLength2) : debugstr_w(UserName), NameLength2,
+ NameLength3 > 0 ? debugstr_wn(Authentication, NameLength3) : debugstr_w(Authentication), NameLength3);
+ if (!connection || connection->type != SQL_HANDLE_DBC)
+ {
+ WARN("Wrong handle type %d\n", connection ? connection->type : 0);
+ return SQL_ERROR;
+ }
+
+ if (connection->pSQLConnectW)
+ {
+ ret = connection->pSQLConnectW(connection->driver_hdbc, ServerName, NameLength1,
+ UserName, NameLength2, Authentication, NameLength3);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1,72 @@
From 5e0d8ba8d698d404b1b16076a76cbb3e17b616c0 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(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 6f6d502e772..d33dbac8b2b 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -566,12 +566,26 @@ SQLRETURN WINAPI SQLColAttribute(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNu
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
SQLLEN *NumericAttribute)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("(StatementHandle %p, ColumnNumber %d, FieldIdentifier %d, CharacterAttribute %p, BufferLength %d,"
+ TRACE("(StatementHandle %p, ColumnNumber %d, FieldIdentifier %d, CharacterAttribute %p, BufferLength %d,"
" StringLength %p, NumericAttribute %p)\n", StatementHandle, ColumnNumber, FieldIdentifier,
CharacterAttribute, BufferLength, StringLength, NumericAttribute);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLColAttribute)
+ {
+ ret = statement->connection->pSQLColAttribute(statement->driver_stmt, ColumnNumber, FieldIdentifier,
+ CharacterAttribute, BufferLength, StringLength, NumericAttribute);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
@@ -2230,12 +2244,26 @@ SQLRETURN WINAPI SQLColAttributeW(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnN
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
SQLLEN *NumericAttribute)
{
+ struct SQLHSTMT_data *statement = StatementHandle;
SQLRETURN ret = SQL_ERROR;
- FIXME("StatementHandle %p ColumnNumber %d FieldIdentifier %d CharacterAttribute %p BufferLength %d"
+ TRACE("StatementHandle %p ColumnNumber %d FieldIdentifier %d CharacterAttribute %p BufferLength %d"
" StringLength %p NumericAttribute %p\n", StatementHandle, ColumnNumber, FieldIdentifier,
CharacterAttribute, BufferLength, StringLength, NumericAttribute);
+ if (statement->type != SQL_HANDLE_STMT)
+ {
+ WARN("Wrong handle type %d\n", statement->type);
+ return SQL_ERROR;
+ }
+
+ if (statement->connection->pSQLColAttributeW)
+ {
+ ret = statement->connection->pSQLColAttributeW(statement->driver_stmt, ColumnNumber, FieldIdentifier,
+ CharacterAttribute, BufferLength, StringLength, NumericAttribute);
+ }
+
+ TRACE("ret %d\n", ret);
return ret;
}
--
2.39.1

View File

@ -0,0 +1 @@
Fixes: [54499] Support native ODBC drivers.