wine-staging/patches/odbc-remove-unixodbc/0014-odbc32-Implement-SQLAllocStmt.patch

74 lines
2.1 KiB
Diff
Raw Normal View History

2023-02-16 15:44:46 -08:00
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