msdasql: ICommandText Execute use ODBC to fetch results.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
111c87f444
commit
50fc9d7ddc
|
@ -477,6 +477,7 @@ struct msdasql_rowset
|
||||||
IColumnsRowset IColumnsRowset_iface;
|
IColumnsRowset IColumnsRowset_iface;
|
||||||
IUnknown *caller;
|
IUnknown *caller;
|
||||||
LONG refs;
|
LONG refs;
|
||||||
|
SQLHSTMT hstmt;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct msdasql_rowset *impl_from_IRowset( IRowset *iface )
|
static inline struct msdasql_rowset *impl_from_IRowset( IRowset *iface )
|
||||||
|
@ -575,6 +576,8 @@ static ULONG WINAPI msdasql_rowset_Release(IRowset *iface)
|
||||||
{
|
{
|
||||||
TRACE( "destroying %p\n", rowset );
|
TRACE( "destroying %p\n", rowset );
|
||||||
|
|
||||||
|
SQLFreeHandle(SQL_HANDLE_STMT, rowset->hstmt);
|
||||||
|
|
||||||
if (rowset->caller)
|
if (rowset->caller)
|
||||||
IUnknown_Release(rowset->caller);
|
IUnknown_Release(rowset->caller);
|
||||||
|
|
||||||
|
@ -845,27 +848,53 @@ static HRESULT WINAPI command_Execute(ICommandText *iface, IUnknown *outer, REFI
|
||||||
{
|
{
|
||||||
struct command *command = impl_from_ICommandText( iface );
|
struct command *command = impl_from_ICommandText( iface );
|
||||||
struct msdasql_rowset *msrowset;
|
struct msdasql_rowset *msrowset;
|
||||||
HRESULT hr;
|
HRESULT hr = S_OK;
|
||||||
|
RETCODE ret;
|
||||||
|
SQLHSTMT hstmt = command->hstmt;
|
||||||
|
SQLLEN results = -1;
|
||||||
|
|
||||||
FIXME("%p, %p, %s, %p %p %p Semi Stub\n", command, outer, debugstr_guid(riid), params, affected, rowset);
|
TRACE("%p, %p, %s, %p %p %p\n", command, outer, debugstr_guid(riid), params, affected, rowset);
|
||||||
|
|
||||||
msrowset = heap_alloc(sizeof(*msrowset));
|
if (!hstmt)
|
||||||
if (!msrowset)
|
SQLAllocHandle(SQL_HANDLE_STMT, command->hdbc, &hstmt);
|
||||||
return E_OUTOFMEMORY;
|
|
||||||
|
|
||||||
msrowset->IRowset_iface.lpVtbl = &msdasql_rowset_vtbl;
|
ret = SQLExecDirectW(hstmt, command->query, SQL_NTS);
|
||||||
msrowset->IRowsetInfo_iface.lpVtbl = &rowset_info_vtbl;
|
if (ret != SQL_SUCCESS)
|
||||||
msrowset->IColumnsInfo_iface.lpVtbl = &rowset_columninfo_vtbll;
|
{
|
||||||
msrowset->IAccessor_iface.lpVtbl = &accessor_vtbl;
|
dump_sql_diag_records(SQL_HANDLE_STMT, hstmt);
|
||||||
msrowset->IColumnsRowset_iface.lpVtbl = &columnrs_rs_vtbl;
|
return E_FAIL;
|
||||||
msrowset->refs = 1;
|
}
|
||||||
ICommandText_QueryInterface(iface, &IID_IUnknown, (void**)&msrowset->caller);
|
|
||||||
|
ret = SQLRowCount(hstmt, &results);
|
||||||
|
if (ret != SQL_SUCCESS)
|
||||||
|
ERR("SQLRowCount failed (%d)\n", ret);
|
||||||
|
|
||||||
if (affected)
|
if (affected)
|
||||||
*affected = 0; /* FIXME */
|
*affected = results;
|
||||||
|
|
||||||
hr = IRowset_QueryInterface(&msrowset->IRowset_iface, riid, (void**)rowset);
|
*rowset = NULL;
|
||||||
IRowset_Release(&msrowset->IRowset_iface);
|
if (!wcsnicmp( command->query, L"select ", 7 ))
|
||||||
|
{
|
||||||
|
msrowset = heap_alloc(sizeof(*msrowset));
|
||||||
|
if (!msrowset)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
command->hstmt = NULL;
|
||||||
|
|
||||||
|
msrowset->IRowset_iface.lpVtbl = &msdasql_rowset_vtbl;
|
||||||
|
msrowset->IRowsetInfo_iface.lpVtbl = &rowset_info_vtbl;
|
||||||
|
msrowset->IColumnsInfo_iface.lpVtbl = &rowset_columninfo_vtbll;
|
||||||
|
msrowset->IAccessor_iface.lpVtbl = &accessor_vtbl;
|
||||||
|
msrowset->IColumnsRowset_iface.lpVtbl = &columnrs_rs_vtbl;
|
||||||
|
msrowset->refs = 1;
|
||||||
|
ICommandText_QueryInterface(iface, &IID_IUnknown, (void**)&msrowset->caller);
|
||||||
|
msrowset->hstmt = hstmt;
|
||||||
|
|
||||||
|
hr = IRowset_QueryInterface(&msrowset->IRowset_iface, riid, (void**)rowset);
|
||||||
|
IRowset_Release(&msrowset->IRowset_iface);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SQLFreeStmt(hstmt, SQL_CLOSE);
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -382,11 +382,20 @@ static void test_command_rowset(IUnknown *cmd)
|
||||||
affected = 9999;
|
affected = 9999;
|
||||||
hr = ICommandText_Execute(command_text, NULL, &IID_IRowset, NULL, &affected, &unk);
|
hr = ICommandText_Execute(command_text, NULL, &IID_IRowset, NULL, &affected, &unk);
|
||||||
ok(hr == S_OK, "got 0x%08lx\n", hr);
|
ok(hr == S_OK, "got 0x%08lx\n", hr);
|
||||||
todo_wine ok(unk == NULL, "Unexpected value\n");
|
ok(unk == NULL, "Unexpected value\n");
|
||||||
todo_wine ok(affected == -1, "got %Id\n", affected);
|
ok(affected == -1, "got %Id\n", affected);
|
||||||
if (unk)
|
if (unk)
|
||||||
IUnknown_Release(unk);
|
IUnknown_Release(unk);
|
||||||
|
|
||||||
|
hr = ICommandText_SetCommandText(command_text, &DBGUID_DEFAULT, L"insert into testing values(1, 0)");
|
||||||
|
ok(hr == S_OK, "got 0x%08lx\n", hr);
|
||||||
|
|
||||||
|
affected = 9999;
|
||||||
|
hr = ICommandText_Execute(command_text, NULL, &IID_IRowset, NULL, &affected, &unk);
|
||||||
|
ok(hr == S_OK, "got 0x%08lx\n", hr);
|
||||||
|
ok(affected == 1, "got %Id\n", affected);
|
||||||
|
ok(unk == NULL, "Unexpected value\n");
|
||||||
|
|
||||||
hr = ICommandText_SetCommandText(command_text, &DBGUID_DEFAULT, L"select * from testing");
|
hr = ICommandText_SetCommandText(command_text, &DBGUID_DEFAULT, L"select * from testing");
|
||||||
ok(hr == S_OK, "got 0x%08lx\n", hr);
|
ok(hr == S_OK, "got 0x%08lx\n", hr);
|
||||||
|
|
||||||
|
@ -396,7 +405,7 @@ static void test_command_rowset(IUnknown *cmd)
|
||||||
ok(unk != NULL, "Unexpected value\n");
|
ok(unk != NULL, "Unexpected value\n");
|
||||||
if (hr == S_OK)
|
if (hr == S_OK)
|
||||||
{
|
{
|
||||||
ok(affected == -1, "wrong affected value\n");
|
ok(affected == -1, "got %Id\n", affected);
|
||||||
|
|
||||||
hr = IUnknown_QueryInterface(unk, &IID_IRowset, (void**)&rowset);
|
hr = IUnknown_QueryInterface(unk, &IID_IRowset, (void**)&rowset);
|
||||||
ok(hr == S_OK, "got 0x%08lx\n", hr);
|
ok(hr == S_OK, "got 0x%08lx\n", hr);
|
||||||
|
|
Loading…
Reference in New Issue