Alistair Leslie-Hughes : msado15: Add helper function to create CommandText interface.

Alexandre Julliard julliard at winehq.org
Tue Feb 23 15:54:46 CST 2021


Module: wine
Branch: master
Commit: 0949cb4552bb9435211fff5b6404d9bcae5d2358
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=0949cb4552bb9435211fff5b6404d9bcae5d2358

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Tue Feb 23 07:58:34 2021 +1100

msado15: Add helper function to create CommandText interface.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msado15/command.c         |  1 +
 dlls/msado15/connection.c      | 83 +++++++++++++++++++++++++++---------------
 dlls/msado15/main.c            |  1 +
 dlls/msado15/msado15_private.h |  2 +
 dlls/msado15/stream.c          |  1 +
 5 files changed, 58 insertions(+), 30 deletions(-)

diff --git a/dlls/msado15/command.c b/dlls/msado15/command.c
index d19108a1a25..9a56ced25ac 100644
--- a/dlls/msado15/command.c
+++ b/dlls/msado15/command.c
@@ -20,6 +20,7 @@
 #include "winbase.h"
 #define COBJMACROS
 #include "objbase.h"
+#include "msdasc.h"
 #include "msado15_backcompat.h"
 
 #include "wine/debug.h"
diff --git a/dlls/msado15/connection.c b/dlls/msado15/connection.c
index 500be033199..d55c0d18a35 100644
--- a/dlls/msado15/connection.c
+++ b/dlls/msado15/connection.c
@@ -264,61 +264,90 @@ static HRESULT WINAPI connection_Close( _Connection *iface )
     return S_OK;
 }
 
-static HRESULT WINAPI connection_Execute( _Connection *iface, BSTR command, VARIANT *records_affected,
-                                          LONG options, _Recordset **record_set )
+HRESULT create_command_text(IUnknown *session, BSTR command, ICommandText **cmd_text)
 {
-    struct connection *connection = impl_from_Connection( iface );
     HRESULT hr;
     IOpenRowset *openrowset;
-    IDBCreateCommand *create_command = NULL;
-    ICommand *cmd = NULL;
-    ICommandText *comand_text = NULL;
-    DBROWCOUNT affected;
-    IUnknown *rowset = NULL;
-    _Recordset *recordset = NULL;
-    ADORecordsetConstruction *construct;
+    ICommandText *command_text;
+    ICommand *cmd;
+    IDBCreateCommand *create_command;
 
-    FIXME( "%p, %s, %p, 0x%08x, %p Semi-stub\n", iface, debugstr_w(command), records_affected, options, record_set );
-
-    if (connection->state == adStateClosed) return MAKE_ADO_HRESULT( adErrObjectClosed );
-
-    hr = IUnknown_QueryInterface(connection->session, &IID_IOpenRowset, (void**)&openrowset);
+    hr = IUnknown_QueryInterface(session, &IID_IOpenRowset, (void**)&openrowset);
     if (FAILED(hr))
         return hr;
 
     hr = IOpenRowset_QueryInterface(openrowset, &IID_IDBCreateCommand, (void**)&create_command);
+    IOpenRowset_Release(openrowset);
     if (FAILED(hr))
-        goto done;
+        return hr;
 
     hr = IDBCreateCommand_CreateCommand(create_command, NULL, &IID_IUnknown, (IUnknown **)&cmd);
+    IDBCreateCommand_Release(create_command);
     if (FAILED(hr))
-        goto done;
+        return hr;
 
-    hr = ICommand_QueryInterface(cmd, &IID_ICommandText, (void**)&comand_text);
+    hr = ICommand_QueryInterface(cmd, &IID_ICommandText, (void**)&command_text);
+    ICommand_Release(cmd);
     if (FAILED(hr))
     {
         FIXME("Currently only ICommandText interface is support\n");
-        goto done;
+        return hr;
+    }
+
+    hr = ICommandText_SetCommandText(command_text, &DBGUID_DEFAULT, command);
+    if (FAILED(hr))
+    {
+        ICommandText_Release(command_text);
+        return hr;
     }
 
-    hr = ICommandText_SetCommandText(comand_text, &DBGUID_DEFAULT, command);
+    *cmd_text = command_text;
+
+    return S_OK;
+}
+
+static HRESULT WINAPI connection_Execute( _Connection *iface, BSTR command, VARIANT *records_affected,
+                                          LONG options, _Recordset **record_set )
+{
+    struct connection *connection = impl_from_Connection( iface );
+    HRESULT hr;
+    ICommandText *comand_text;
+    DBROWCOUNT affected;
+    IUnknown *rowset;
+    _Recordset *recordset;
+    ADORecordsetConstruction *construct;
+
+    FIXME( "%p, %s, %p, 0x%08x, %p Semi-stub\n", iface, debugstr_w(command), records_affected, options, record_set );
+
+    if (connection->state == adStateClosed) return MAKE_ADO_HRESULT( adErrObjectClosed );
+
+    hr = create_command_text(connection->session, command, &comand_text);
     if (FAILED(hr))
-        goto done;
+        return hr;
 
     hr = ICommandText_Execute(comand_text, NULL, &IID_IUnknown, NULL, &affected, &rowset);
+    ICommandText_Release(comand_text);
     if (FAILED(hr))
-        goto done;
+        return hr;
 
     hr = Recordset_create( (void**)&recordset);
     if (FAILED(hr))
-        goto done;
+    {
+        IUnknown_Release(rowset);
+        return hr;
+    }
 
     hr = _Recordset_QueryInterface(recordset, &IID_ADORecordsetConstruction, (void**)&construct);
     if (FAILED(hr))
-        goto done;
+    {
+        IUnknown_Release(rowset);
+        _Recordset_Release(recordset);
+        return hr;
+    }
 
     ADORecordsetConstruction_put_Rowset(construct, rowset);
     ADORecordsetConstruction_Release(construct);
+    IUnknown_Release(rowset);
 
     if (records_affected)
     {
@@ -329,12 +358,6 @@ static HRESULT WINAPI connection_Execute( _Connection *iface, BSTR command, VARI
     _Recordset_put_CursorLocation(recordset, connection->location);
     *record_set = recordset;
 
-done:
-    if (rowset) IUnknown_Release(rowset);
-    if (comand_text) ICommandText_Release(comand_text);
-    if (cmd) ICommand_Release(cmd);
-    if (create_command) IDBCreateCommand_Release(create_command);
-    if (openrowset) IOpenRowset_Release(openrowset);
     return hr;
 }
 
diff --git a/dlls/msado15/main.c b/dlls/msado15/main.c
index 770a02fc59d..0b8de1f9117 100644
--- a/dlls/msado15/main.c
+++ b/dlls/msado15/main.c
@@ -22,6 +22,7 @@
 #define COBJMACROS
 #include "objbase.h"
 #include "rpcproxy.h"
+#include "msdasc.h"
 #include "msado15_backcompat.h"
 
 #include "wine/debug.h"
diff --git a/dlls/msado15/msado15_private.h b/dlls/msado15/msado15_private.h
index f6c60f0304c..dd98c382e2b 100644
--- a/dlls/msado15/msado15_private.h
+++ b/dlls/msado15/msado15_private.h
@@ -26,6 +26,8 @@ HRESULT Connection_create( void ** ) DECLSPEC_HIDDEN;
 HRESULT Recordset_create( void ** ) DECLSPEC_HIDDEN;
 HRESULT Stream_create( void ** ) DECLSPEC_HIDDEN;
 
+HRESULT create_command_text(IUnknown *session, BSTR command, ICommandText **cmd_text) DECLSPEC_HIDDEN;
+
 static inline void *heap_realloc_zero( void *mem, SIZE_T len )
 {
     if (!mem) return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
diff --git a/dlls/msado15/stream.c b/dlls/msado15/stream.c
index c6add70b1bc..b40f664dcf1 100644
--- a/dlls/msado15/stream.c
+++ b/dlls/msado15/stream.c
@@ -21,6 +21,7 @@
 #include "winbase.h"
 #define COBJMACROS
 #include "objbase.h"
+#include "msdasc.h"
 #include "msado15_backcompat.h"
 
 #include "wine/debug.h"




More information about the wine-cvs mailing list