Alistair Leslie-Hughes : msdasql: Implement ICommandText GetDBSession.
Alexandre Julliard
julliard at winehq.org
Mon Nov 1 16:38:02 CDT 2021
Module: wine
Branch: master
Commit: dd279bd0150549dbd4703aa5e84e25177ec24398
URL: https://source.winehq.org/git/wine.git/?a=commit;h=dd279bd0150549dbd4703aa5e84e25177ec24398
Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Sun Oct 31 19:51:17 2021 +1100
msdasql: Implement ICommandText GetDBSession.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msdasql/session.c | 19 +++++++++++++++++--
dlls/msdasql/tests/provider.c | 17 +++++++++++++++++
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/dlls/msdasql/session.c b/dlls/msdasql/session.c
index c0deb32d8ad..4949d6d47e5 100644
--- a/dlls/msdasql/session.c
+++ b/dlls/msdasql/session.c
@@ -285,6 +285,7 @@ struct command
ICommandPrepare ICommandPrepare_iface;
LONG refs;
WCHAR *query;
+ IUnknown *session;
};
static inline struct command *impl_from_ICommandText( ICommandText *iface )
@@ -393,6 +394,8 @@ static ULONG WINAPI command_Release(ICommandText *iface)
if (!refs)
{
TRACE( "destroying %p\n", command );
+ if (command->session)
+ IUnknown_Release(command->session);
heap_free( command->query );
heap_free( command );
}
@@ -417,8 +420,18 @@ static HRESULT WINAPI command_Execute(ICommandText *iface, IUnknown *outer, REFI
static HRESULT WINAPI command_GetDBSession(ICommandText *iface, REFIID riid, IUnknown **session)
{
struct command *command = impl_from_ICommandText( iface );
- FIXME("%p, %s, %p\n", command, debugstr_guid(riid), session);
- return E_NOTIMPL;
+
+ TRACE("%p, %s, %p\n", command, debugstr_guid(riid), session);
+
+ if (!session)
+ return E_INVALIDARG;
+
+ *session = NULL;
+
+ if (!command->session)
+ return S_FALSE;
+
+ return IUnknown_QueryInterface(command->session, riid, (void**)session);
}
static HRESULT WINAPI command_GetCommandText(ICommandText *iface, GUID *dialect, LPOLESTR *commandstr)
@@ -656,6 +669,8 @@ static HRESULT WINAPI createcommand_CreateCommand(IDBCreateCommand *iface, IUnkn
command->ICommandPrepare_iface.lpVtbl = &commandprepareVtbl;
command->refs = 1;
+ IUnknown_QueryInterface(&session->session_iface, &IID_IUnknown, (void**)&command->session);
+
hr = ICommandText_QueryInterface(&command->ICommandText_iface, riid, (void**)out);
ICommandText_Release(&command->ICommandText_iface);
return hr;
diff --git a/dlls/msdasql/tests/provider.c b/dlls/msdasql/tests/provider.c
index 09a4b69c31d..35dfeb10d3d 100644
--- a/dlls/msdasql/tests/provider.c
+++ b/dlls/msdasql/tests/provider.c
@@ -206,6 +206,22 @@ if (0)
ICommandText_Release(comand_text);
}
+static void test_command_dbsession(IUnknown *cmd, IUnknown *session)
+{
+ ICommandText *comand_text;
+ HRESULT hr;
+ IUnknown *sess;
+
+ hr = IUnknown_QueryInterface(cmd, &IID_ICommandText, (void**)&comand_text);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = ICommandText_GetDBSession(comand_text, &IID_IUnknown, &sess);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(session == sess, "different session pointers\n");
+
+ ICommandText_Release(comand_text);
+}
+
static void test_sessions(void)
{
IDBProperties *props;
@@ -281,6 +297,7 @@ static void test_sessions(void)
{
test_command_interfaces(cmd);
test_command_text(cmd);
+ test_command_dbsession(cmd, session);
IUnknown_Release(cmd);
}
More information about the wine-cvs
mailing list