[PATCH] msado15: Semi-stub _Recordset Open

Hans Leidekker hans at codeweavers.com
Fri Feb 19 03:40:41 CST 2021


On Fri, 2021-02-19 at 19:58 +1100, Alistair Leslie-Hughes wrote:
> Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
> ---
>  dlls/msado15/recordset.c | 65 ++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 62 insertions(+), 3 deletions(-)
> 
> diff --git a/dlls/msado15/recordset.c b/dlls/msado15/recordset.c
> index 12bb9680258..8dab455fb67 100644
> --- a/dlls/msado15/recordset.c
> +++ b/dlls/msado15/recordset.c
> @@ -1182,15 +1182,74 @@ static HRESULT WINAPI recordset_Open( _Recordset *iface, VARIANT source, VARIANT
>                                        CursorTypeEnum cursor_type, LockTypeEnum lock_type, LONG options )
>  {
>      struct recordset *recordset = impl_from_Recordset( iface );
> +    ADOConnectionConstruction15 *construct;
> +    IUnknown *session = NULL;
> +    IOpenRowset *openrowset = NULL;
> +    IDBCreateCommand *create_command = NULL;
> +    ICommand *cmd = NULL;
> +    ICommandText *command_text = NULL;
> +    DBROWCOUNT affected;
> +    IUnknown *rowset = NULL;
> +    HRESULT hr;
>  
> 
> -    FIXME( "%p, %s, %s, %d, %d, %d\n", recordset, debugstr_variant(&source), debugstr_variant(&active_connection),
> +    FIXME( "%p, %s, %s, %d, %d, %d Semi-stub\n", recordset, debugstr_variant(&source), debugstr_variant(&active_connection),
>             cursor_type, lock_type, options );
>  
> 
> -    if (!recordset->fields) return MAKE_ADO_HRESULT( adErrInvalidConnection );
>      if (recordset->state == adStateOpen) return MAKE_ADO_HRESULT( adErrObjectOpen );
>  
> 
> +    if (V_VT(&active_connection) != VT_DISPATCH)
> +    {
> +        FIXME("Unsupported Active connection type %d\n", V_VT(&active_connection));
> +        return E_FAIL;
> +    }
> +
> +    hr = IDispatch_QueryInterface(V_DISPATCH(&active_connection), &IID_ADOConnectionConstruction15, (void**)&construct);
> +    if (FAILED(hr))
> +        return E_FAIL;
> +
> +    hr = ADOConnectionConstruction15_get_Session(construct, &session);
> +    ADOConnectionConstruction15_Release(construct);
> +    if (FAILED(hr))
> +        return E_FAIL;
> +
> +    hr = IUnknown_QueryInterface(session, &IID_IOpenRowset, (void**)&openrowset);
> +    if (FAILED(hr)) return hr;
> +
> +    hr = IOpenRowset_QueryInterface(openrowset, &IID_IDBCreateCommand, (void**)&create_command);
> +    if (FAILED(hr))
> +        goto done;
> +
> +    hr = IDBCreateCommand_CreateCommand(create_command, NULL, &IID_IUnknown, (IUnknown **)&cmd);
> +    if (FAILED(hr))
> +        goto done;
> +
> +    hr = ICommand_QueryInterface(cmd, &IID_ICommandText, (void**)&command_text);
> +    if (FAILED(hr))
> +    {
> +        FIXME("Currently only ICommandText interface is support\n");
> +        goto done;
> +    }
> +
> +    hr = ICommandText_SetCommandText(command_text, &DBGUID_DEFAULT, V_BSTR(&source));
> +    if (FAILED(hr))
> +        goto done;
> +
> +    hr = ICommandText_Execute(command_text, NULL, &IID_IUnknown, NULL, &affected, &rowset);
> +    if (FAILED(hr))
> +        goto done;
> +
> +    ADORecordsetConstruction_put_Rowset(&recordset->ADORecordsetConstruction_iface, rowset);
> +    recordset->cursor_type = cursor_type;
>      recordset->state = adStateOpen;
> -    return S_OK;
> +
> +done:
> +    if (session) IUnknown_Release(session);
> +    if (rowset) IUnknown_Release(rowset);
> +    if (command_text) ICommandText_Release(command_text);
> +    if (cmd) ICommand_Release(cmd);
> +    if (create_command) IDBCreateCommand_Release(create_command);
> +    if (openrowset) IOpenRowset_Release(openrowset);
> +    return hr;
>  }

This shares a lot of code with connection_Execute. I'd suggest to add a
helper to execute a command with IOpenRowset.





More information about the wine-devel mailing list