Commit 109db990 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

msdasql: Implement IGetDataSource GetDataSource.

parent fbca1266
......@@ -559,7 +559,7 @@ static HRESULT WINAPI dbsess_CreateSession(IDBCreateSession *iface, IUnknown *ou
if (outer)
FIXME("outer currently not supported.\n");
hr = create_db_session(riid, (void**)session);
hr = create_db_session(riid, &provider->MSDASQL_iface, (void**)session);
return hr;
}
......
......@@ -16,4 +16,4 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
HRESULT create_db_session(REFIID riid, void **unk) DECLSPEC_HIDDEN;
HRESULT create_db_session(REFIID riid, IUnknown *datasource, void **unk) DECLSPEC_HIDDEN;
......@@ -43,6 +43,8 @@ struct msdasql_session
ISessionProperties ISessionProperties_iface;
IDBCreateCommand IDBCreateCommand_iface;
LONG refs;
IUnknown *datasource;
};
static inline struct msdasql_session *impl_from_IUnknown( IUnknown *iface )
......@@ -139,6 +141,8 @@ static ULONG WINAPI session_Release(IUnknown *iface)
if (!refs)
{
TRACE( "destroying %p\n", session );
IUnknown_Release(session->datasource);
heap_free( session );
}
return refs;
......@@ -173,9 +177,13 @@ ULONG WINAPI datasource_Release(IGetDataSource *iface)
HRESULT WINAPI datasource_GetDataSource(IGetDataSource *iface, REFIID riid, IUnknown **datasource)
{
struct msdasql_session *session = impl_from_IGetDataSource( iface );
FIXME("%p, %s, %p stub\n", session, debugstr_guid(riid), datasource);
return E_NOTIMPL;
TRACE("%p, %s, %p stub\n", session, debugstr_guid(riid), datasource);
if (!datasource)
return E_INVALIDARG;
return IUnknown_QueryInterface(session->datasource, riid, (void**)datasource);
}
static const IGetDataSourceVtbl datasourceVtbl =
......@@ -1155,7 +1163,7 @@ static const IDBCreateCommandVtbl createcommandVtbl =
createcommand_CreateCommand
};
HRESULT create_db_session(REFIID riid, void **unk)
HRESULT create_db_session(REFIID riid, IUnknown *datasource, void **unk)
{
struct msdasql_session *session;
HRESULT hr;
......@@ -1169,6 +1177,7 @@ HRESULT create_db_session(REFIID riid, void **unk)
session->IOpenRowset_iface.lpVtbl = &openrowsetVtbl;
session->ISessionProperties_iface.lpVtbl = &propertiesVtbl;
session->IDBCreateCommand_iface.lpVtbl = &createcommandVtbl;
IUnknown_QueryInterface(datasource, &IID_IUnknown, (void**)&session->datasource);
session->refs = 1;
hr = IUnknown_QueryInterface(&session->session_iface, riid, unk);
......
......@@ -399,7 +399,7 @@ static void test_command_rowset(IUnknown *cmd)
static void test_sessions(void)
{
IDBProperties *props;
IDBProperties *props, *dsource = NULL;
IDBInitialize *dbinit = NULL;
IDataInitialize *datainit;
IDBCreateSession *dbsession = NULL;
......@@ -456,6 +456,11 @@ static void test_sessions(void)
hr = IUnknown_QueryInterface(session, &IID_IGetDataSource, (void**)&datasource);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IGetDataSource_GetDataSource(datasource, &IID_IDBProperties, (IUnknown**)&dsource);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(dsource == props, "different pointers\n");
IDBProperties_Release(dsource);
IGetDataSource_Release(datasource);
hr = IUnknown_QueryInterface(session, &IID_ITransactionJoin, (void**)&join);
......
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