Commit 5b9496ad authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

msdasql: Always return affected rows if required.

When using msadosql it always returns the number of records affected or records returned by a SELECT statement. The access database, which is what the defaults tests are using doesn't return the number of records for a SELECT. It's a known issue that you have to MoveLast/MoveFirst before the correct RecordCount value is return for an Access DB.
parent a40d67e0
......@@ -1242,6 +1242,7 @@ static HRESULT WINAPI command_Execute(ICommandText *iface, IUnknown *outer, REFI
RETCODE ret;
SQLHSTMT hstmt = command->hstmt;
SQLLEN results = -1;
BOOL free_hstmt = TRUE;
TRACE("%p, %p, %s, %p %p %p\n", command, outer, debugstr_guid(riid), params, affected, rowset);
......@@ -1272,21 +1273,23 @@ static HRESULT WINAPI command_Execute(ICommandText *iface, IUnknown *outer, REFI
msrowset->refs = 1;
ICommandText_QueryInterface(iface, &IID_IUnknown, (void**)&msrowset->caller);
msrowset->hstmt = hstmt;
free_hstmt = FALSE;
hr = IRowset_QueryInterface(&msrowset->IRowset_iface, riid, (void**)rowset);
IRowset_Release(&msrowset->IRowset_iface);
}
else
if (affected)
{
ret = SQLRowCount(hstmt, &results);
if (ret != SQL_SUCCESS)
ERR("SQLRowCount failed (%d)\n", ret);
SQLFreeStmt(hstmt, SQL_CLOSE);
*affected = results;
}
if (affected)
*affected = results;
if (free_hstmt)
SQLFreeStmt(hstmt, SQL_CLOSE);
return hr;
}
......
......@@ -569,6 +569,13 @@ static void test_command_rowset(IUnknown *cmd)
if (unk)
IUnknown_Release(unk);
/* Ensure all rows are deleted - Interactive Test */
hr = ICommandText_SetCommandText(command_text, &DBGUID_DEFAULT, L"delete from testing");
ok(hr == S_OK, "got 0x%08lx\n", hr);
hr = ICommandText_Execute(command_text, NULL, &IID_NULL, NULL, NULL, NULL);
ok(hr == S_OK, "got 0x%08lx\n", hr);
hr = ICommandText_SetCommandText(command_text, &DBGUID_DEFAULT, L"insert into testing values(1, 'red', 1.0)");
ok(hr == S_OK, "got 0x%08lx\n", hr);
......@@ -594,7 +601,7 @@ static void test_command_rowset(IUnknown *cmd)
DBCOLUMNINFO *dbcolinfo;
OLECHAR *stringsbuffer;
todo_wine ok(affected == -1, "got %Id\n", affected);
ok(affected == -1 || affected == 1, "got %Iu\n", affected);
hr = IUnknown_QueryInterface(unk, &IID_IRowset, (void**)&rowset);
ok(hr == S_OK, "got 0x%08lx\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment