d2d1: Create feature level 10.0 device context state objects.
[wine.git] / dlls / msdasql / session.c
blobb4239c59037efde5e64274be8b08346a41ff5594
1 /*
2 * Copyright 2020 Alistair Leslie-Hughes
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "objbase.h"
26 #include "rpcproxy.h"
27 #include "msdasc.h"
28 #include "wine/heap.h"
29 #include "wine/debug.h"
31 #include "msdasql.h"
32 #include "oledberr.h"
34 #include "msdasql_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msdasql);
38 struct msdasql_session
40 IUnknown session_iface;
41 IGetDataSource IGetDataSource_iface;
42 IOpenRowset IOpenRowset_iface;
43 ISessionProperties ISessionProperties_iface;
44 IDBCreateCommand IDBCreateCommand_iface;
45 LONG refs;
47 IUnknown *datasource;
50 static inline struct msdasql_session *impl_from_IUnknown( IUnknown *iface )
52 return CONTAINING_RECORD( iface, struct msdasql_session, session_iface );
55 static inline struct msdasql_session *impl_from_IGetDataSource( IGetDataSource *iface )
57 return CONTAINING_RECORD( iface, struct msdasql_session, IGetDataSource_iface );
60 static inline struct msdasql_session *impl_from_IOpenRowset( IOpenRowset *iface )
62 return CONTAINING_RECORD( iface, struct msdasql_session, IOpenRowset_iface );
65 static inline struct msdasql_session *impl_from_ISessionProperties( ISessionProperties *iface )
67 return CONTAINING_RECORD( iface, struct msdasql_session, ISessionProperties_iface );
70 static inline struct msdasql_session *impl_from_IDBCreateCommand( IDBCreateCommand *iface )
72 return CONTAINING_RECORD( iface, struct msdasql_session, IDBCreateCommand_iface );
75 static HRESULT WINAPI session_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
77 struct msdasql_session *session = impl_from_IUnknown( iface );
79 TRACE( "%p, %s, %p\n", iface, debugstr_guid(riid), ppv );
80 *ppv = NULL;
82 if(IsEqualGUID(&IID_IUnknown, riid))
84 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
85 *ppv = &session->session_iface;
87 else if(IsEqualGUID(&IID_IGetDataSource, riid))
89 TRACE("(%p)->(IID_IGetDataSource %p)\n", iface, ppv);
90 *ppv = &session->IGetDataSource_iface;
92 else if(IsEqualGUID(&IID_IOpenRowset, riid))
94 TRACE("(%p)->(IID_IOpenRowset %p)\n", iface, ppv);
95 *ppv = &session->IOpenRowset_iface;
97 else if(IsEqualGUID(&IID_ISessionProperties, riid))
99 TRACE("(%p)->(IID_ISessionProperties %p)\n", iface, ppv);
100 *ppv = &session->ISessionProperties_iface;
102 else if(IsEqualGUID(&IID_IDBCreateCommand, riid))
104 TRACE("(%p)->(IDBCreateCommand_iface %p)\n", iface, ppv);
105 *ppv = &session->IDBCreateCommand_iface;
107 else if(IsEqualGUID(&IID_IBindResource, riid))
109 TRACE("(%p)->(IID_IBindResource not support)\n", iface);
110 return E_NOINTERFACE;
112 else if(IsEqualGUID(&IID_ICreateRow, riid))
114 TRACE("(%p)->(IID_ICreateRow not support)\n", iface);
115 return E_NOINTERFACE;
118 if(*ppv)
120 IUnknown_AddRef((IUnknown*)*ppv);
121 return S_OK;
124 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
125 return E_NOINTERFACE;
128 static ULONG WINAPI session_AddRef(IUnknown *iface)
130 struct msdasql_session *session = impl_from_IUnknown( iface );
131 LONG refs = InterlockedIncrement( &session->refs );
132 TRACE( "%p new refcount %d\n", session, refs );
133 return refs;
136 static ULONG WINAPI session_Release(IUnknown *iface)
138 struct msdasql_session *session = impl_from_IUnknown( iface );
139 LONG refs = InterlockedDecrement( &session->refs );
140 TRACE( "%p new refcount %d\n", session, refs );
141 if (!refs)
143 TRACE( "destroying %p\n", session );
145 IUnknown_Release(session->datasource);
146 heap_free( session );
148 return refs;
151 static const IUnknownVtbl unkfactoryVtbl =
153 session_QueryInterface,
154 session_AddRef,
155 session_Release,
159 HRESULT WINAPI datasource_QueryInterface(IGetDataSource *iface, REFIID riid, void **out)
161 struct msdasql_session *session = impl_from_IGetDataSource( iface );
162 return IUnknown_QueryInterface(&session->session_iface, riid, out);
165 ULONG WINAPI datasource_AddRef(IGetDataSource *iface)
167 struct msdasql_session *session = impl_from_IGetDataSource( iface );
168 return IUnknown_AddRef(&session->session_iface);
171 ULONG WINAPI datasource_Release(IGetDataSource *iface)
173 struct msdasql_session *session = impl_from_IGetDataSource( iface );
174 return IUnknown_Release(&session->session_iface);
177 HRESULT WINAPI datasource_GetDataSource(IGetDataSource *iface, REFIID riid, IUnknown **datasource)
179 struct msdasql_session *session = impl_from_IGetDataSource( iface );
181 TRACE("%p, %s, %p stub\n", session, debugstr_guid(riid), datasource);
183 if (!datasource)
184 return E_INVALIDARG;
186 return IUnknown_QueryInterface(session->datasource, riid, (void**)datasource);
189 static const IGetDataSourceVtbl datasourceVtbl =
191 datasource_QueryInterface,
192 datasource_AddRef,
193 datasource_Release,
194 datasource_GetDataSource
197 HRESULT WINAPI openrowset_QueryInterface(IOpenRowset *iface, REFIID riid, void **out)
199 struct msdasql_session *session = impl_from_IOpenRowset( iface );
200 return IUnknown_QueryInterface(&session->session_iface, riid, out);
203 ULONG WINAPI openrowset_AddRef(IOpenRowset *iface)
205 struct msdasql_session *session = impl_from_IOpenRowset( iface );
206 return IUnknown_AddRef(&session->session_iface);
209 ULONG WINAPI openrowset_Release(IOpenRowset *iface)
211 struct msdasql_session *session = impl_from_IOpenRowset( iface );
212 return IUnknown_Release(&session->session_iface);
215 HRESULT WINAPI openrowset_OpenRowset(IOpenRowset *iface, IUnknown *pUnkOuter, DBID *table,
216 DBID *index, REFIID riid, ULONG count, DBPROPSET propertysets[], IUnknown **rowset)
218 struct msdasql_session *session = impl_from_IOpenRowset( iface );
219 FIXME("%p, %p, %p %p %s, %d %p %p stub\n", session, pUnkOuter, table, index, debugstr_guid(riid),
220 count, propertysets, rowset);
222 return E_NOTIMPL;
225 static const IOpenRowsetVtbl openrowsetVtbl =
227 openrowset_QueryInterface,
228 openrowset_AddRef,
229 openrowset_Release,
230 openrowset_OpenRowset
233 static HRESULT WINAPI properties_QueryInterface(ISessionProperties *iface, REFIID riid, void **out)
235 struct msdasql_session *session = impl_from_ISessionProperties( iface );
236 return IUnknown_QueryInterface(&session->session_iface, riid, out);
239 static ULONG WINAPI properties_AddRef(ISessionProperties *iface)
241 struct msdasql_session *session = impl_from_ISessionProperties( iface );
242 return IUnknown_AddRef(&session->session_iface);
245 static ULONG WINAPI properties_Release(ISessionProperties *iface)
247 struct msdasql_session *session = impl_from_ISessionProperties( iface );
248 return IUnknown_Release(&session->session_iface);
252 static HRESULT WINAPI properties_GetProperties(ISessionProperties *iface, ULONG set_count,
253 const DBPROPIDSET id_sets[], ULONG *count, DBPROPSET **sets)
255 struct msdasql_session *session = impl_from_ISessionProperties( iface );
256 FIXME("%p %d %p %p %p\n", session, set_count, id_sets, count, sets);
258 return E_NOTIMPL;
261 static HRESULT WINAPI properties_SetProperties(ISessionProperties *iface, ULONG count,
262 DBPROPSET sets[])
264 struct msdasql_session *session = impl_from_ISessionProperties( iface );
265 FIXME("%p %d %p\n", session, count, sets);
267 return S_OK;
270 static const ISessionPropertiesVtbl propertiesVtbl =
272 properties_QueryInterface,
273 properties_AddRef,
274 properties_Release,
275 properties_GetProperties,
276 properties_SetProperties
279 static HRESULT WINAPI createcommand_QueryInterface(IDBCreateCommand *iface, REFIID riid, void **out)
281 struct msdasql_session *session = impl_from_IDBCreateCommand( iface );
282 return IUnknown_QueryInterface(&session->session_iface, riid, out);
285 static ULONG WINAPI createcommand_AddRef(IDBCreateCommand *iface)
287 struct msdasql_session *session = impl_from_IDBCreateCommand( iface );
288 return IUnknown_AddRef(&session->session_iface);
291 static ULONG WINAPI createcommand_Release(IDBCreateCommand *iface)
293 struct msdasql_session *session = impl_from_IDBCreateCommand( iface );
294 return IUnknown_Release(&session->session_iface);
297 struct command
299 ICommandText ICommandText_iface;
300 ICommandProperties ICommandProperties_iface;
301 IColumnsInfo IColumnsInfo_iface;
302 IConvertType IConvertType_iface;
303 ICommandPrepare ICommandPrepare_iface;
304 ICommandWithParameters ICommandWithParameters_iface;
305 LONG refs;
306 WCHAR *query;
307 IUnknown *session;
310 static inline struct command *impl_from_ICommandText( ICommandText *iface )
312 return CONTAINING_RECORD( iface, struct command, ICommandText_iface );
315 static inline struct command *impl_from_ICommandProperties( ICommandProperties *iface )
317 return CONTAINING_RECORD( iface, struct command, ICommandProperties_iface );
320 static inline struct command *impl_from_IColumnsInfo( IColumnsInfo *iface )
322 return CONTAINING_RECORD( iface, struct command, IColumnsInfo_iface );
325 static inline struct command *impl_from_IConvertType( IConvertType *iface )
327 return CONTAINING_RECORD( iface, struct command, IConvertType_iface );
330 static inline struct command *impl_from_ICommandPrepare( ICommandPrepare *iface )
332 return CONTAINING_RECORD( iface, struct command, ICommandPrepare_iface );
335 static inline struct command *impl_from_ICommandWithParameters( ICommandWithParameters *iface )
337 return CONTAINING_RECORD( iface, struct command, ICommandWithParameters_iface );
340 static HRESULT WINAPI command_QueryInterface(ICommandText *iface, REFIID riid, void **ppv)
342 struct command *command = impl_from_ICommandText( iface );
344 TRACE( "%p, %s, %p\n", command, debugstr_guid(riid), ppv );
345 *ppv = NULL;
347 if(IsEqualGUID(&IID_IUnknown, riid) ||
348 IsEqualGUID(&IID_ICommand, riid) ||
349 IsEqualGUID(&IID_ICommandText, riid))
351 *ppv = &command->ICommandText_iface;
353 else if(IsEqualGUID(&IID_ICommandProperties, riid))
355 *ppv = &command->ICommandProperties_iface;
357 else if(IsEqualGUID(&IID_IColumnsInfo, riid))
359 *ppv = &command->IColumnsInfo_iface;
361 else if(IsEqualGUID(&IID_IConvertType, riid))
363 *ppv = &command->IConvertType_iface;
365 else if(IsEqualGUID(&IID_ICommandPrepare, riid))
367 *ppv = &command->ICommandPrepare_iface;
369 else if(IsEqualGUID(&IID_ICommandWithParameters, riid))
371 *ppv = &command->ICommandWithParameters_iface;
374 if(*ppv)
376 IUnknown_AddRef((IUnknown*)*ppv);
377 return S_OK;
379 else if (IsEqualGUID(&IID_IMultipleResults, riid))
381 TRACE("IID_IMultipleResults not supported\n");
382 return E_NOINTERFACE;
384 else if(IsEqualGUID(&IID_ICommandStream, riid))
386 TRACE("ICommandStream not support\n");
387 return E_NOINTERFACE;
389 else if (IsEqualGUID(&IID_IRowsetChange, riid))
391 TRACE("IID_IRowsetChange not supported\n");
392 return E_NOINTERFACE;
394 else if (IsEqualGUID(&IID_IRowsetUpdate, riid))
396 TRACE("IID_IRowsetUpdate not supported\n");
397 return E_NOINTERFACE;
399 else if (IsEqualGUID(&IID_IRowsetLocate, riid))
401 TRACE("IID_IRowsetLocate not supported\n");
402 return E_NOINTERFACE;
405 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
406 return E_NOINTERFACE;
409 static ULONG WINAPI command_AddRef(ICommandText *iface)
411 struct command *command = impl_from_ICommandText( iface );
412 LONG refs = InterlockedIncrement( &command->refs );
413 TRACE( "%p new refcount %d\n", command, refs );
414 return refs;
417 static ULONG WINAPI command_Release(ICommandText *iface)
419 struct command *command = impl_from_ICommandText( iface );
420 LONG refs = InterlockedDecrement( &command->refs );
421 TRACE( "%p new refcount %d\n", command, refs );
422 if (!refs)
424 TRACE( "destroying %p\n", command );
425 if (command->session)
426 IUnknown_Release(command->session);
427 heap_free( command->query );
428 heap_free( command );
430 return refs;
433 static HRESULT WINAPI command_Cancel(ICommandText *iface)
435 struct command *command = impl_from_ICommandText( iface );
436 FIXME("%p\n", command);
437 return E_NOTIMPL;
440 struct msdasql_rowset
442 IRowset IRowset_iface;
443 IRowsetInfo IRowsetInfo_iface;
444 IColumnsInfo IColumnsInfo_iface;
445 IAccessor IAccessor_iface;
446 IColumnsRowset IColumnsRowset_iface;
447 IUnknown *caller;
448 LONG refs;
451 static inline struct msdasql_rowset *impl_from_IRowset( IRowset *iface )
453 return CONTAINING_RECORD( iface, struct msdasql_rowset, IRowset_iface );
456 static inline struct msdasql_rowset *impl_from_IRowsetInfo( IRowsetInfo *iface )
458 return CONTAINING_RECORD( iface, struct msdasql_rowset, IRowsetInfo_iface );
461 static inline struct msdasql_rowset *rowset_impl_from_IColumnsInfo( IColumnsInfo *iface )
463 return CONTAINING_RECORD( iface, struct msdasql_rowset, IColumnsInfo_iface );
466 static inline struct msdasql_rowset *impl_from_IAccessor ( IAccessor *iface )
468 return CONTAINING_RECORD( iface, struct msdasql_rowset, IAccessor_iface );
471 static inline struct msdasql_rowset *impl_from_IColumnsRowset ( IColumnsRowset *iface )
473 return CONTAINING_RECORD( iface, struct msdasql_rowset, IColumnsRowset_iface );
476 static HRESULT WINAPI msdasql_rowset_QueryInterface(IRowset *iface, REFIID riid, void **ppv)
478 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
480 TRACE( "%p, %s, %p\n", rowset, debugstr_guid(riid), ppv );
482 *ppv = NULL;
483 if(IsEqualGUID(&IID_IUnknown, riid) ||
484 IsEqualGUID(&IID_IRowset, riid))
486 *ppv = &rowset->IRowset_iface;
488 else if (IsEqualGUID(&IID_IRowsetInfo, riid))
490 *ppv = &rowset->IRowsetInfo_iface;
492 else if (IsEqualGUID(&IID_IColumnsInfo, riid))
494 *ppv = &rowset->IColumnsInfo_iface;
496 else if(IsEqualGUID(&IID_IAccessor, riid))
498 *ppv = &rowset->IAccessor_iface;
500 else if(IsEqualGUID(&IID_IColumnsRowset, riid))
502 *ppv = &rowset->IColumnsRowset_iface;
504 else if (IsEqualGUID(&IID_IRowsetChange, riid))
506 TRACE("IID_IRowsetChange not supported\n");
507 return E_NOINTERFACE;
509 else if (IsEqualGUID(&IID_IRowsetUpdate, riid))
511 TRACE("IID_IRowsetUpdate not supported\n");
512 return E_NOINTERFACE;
514 else if (IsEqualGUID(&IID_IRowsetLocate, riid))
516 TRACE("IID_IRowsetLocate not supported\n");
517 return E_NOINTERFACE;
520 if(*ppv)
522 IUnknown_AddRef((IUnknown*)*ppv);
523 return S_OK;
526 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
527 return E_NOINTERFACE;
530 static ULONG WINAPI msdasql_rowset_AddRef(IRowset *iface)
532 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
533 LONG refs = InterlockedIncrement( &rowset->refs );
534 TRACE( "%p new refcount %d\n", rowset, refs );
535 return refs;
538 static ULONG WINAPI msdasql_rowset_Release(IRowset *iface)
540 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
541 LONG refs = InterlockedDecrement( &rowset->refs );
542 TRACE( "%p new refcount %d\n", rowset, refs );
543 if (!refs)
545 TRACE( "destroying %p\n", rowset );
547 if (rowset->caller)
548 IUnknown_Release(rowset->caller);
550 heap_free( rowset );
552 return refs;
555 static HRESULT WINAPI msdasql_rowset_AddRefRows(IRowset *iface, DBCOUNTITEM count,
556 const HROW rows[], DBREFCOUNT ref_counts[], DBROWSTATUS status[])
558 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
559 FIXME("%p, %ld, %p, %p, %p\n", rowset, count, rows, ref_counts, status);
560 return E_NOTIMPL;
563 static HRESULT WINAPI msdasql_rowset_GetData(IRowset *iface, HROW row, HACCESSOR accessor, void *data)
565 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
566 FIXME("%p, %ld, %ld, %p\n", rowset, row, accessor, data);
567 return E_NOTIMPL;
570 static HRESULT WINAPI msdasql_rowset_GetNextRows(IRowset *iface, HCHAPTER reserved, DBROWOFFSET offset,
571 DBROWCOUNT count, DBCOUNTITEM *obtained, HROW **rows)
573 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
574 FIXME("%p, %ld, %ld, %ld, %p, %p\n", rowset, reserved, offset, count, obtained, rows);
575 return E_NOTIMPL;
578 static HRESULT WINAPI msdasql_rowset_ReleaseRows(IRowset *iface, DBCOUNTITEM count,
579 const HROW rows[], DBROWOPTIONS options[], DBREFCOUNT ref_counts[], DBROWSTATUS status[])
581 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
583 FIXME("%p, %ld, %p, %p, %p, %p\n", rowset, count, rows, options, ref_counts, status);
584 return E_NOTIMPL;
587 static HRESULT WINAPI msdasql_rowset_RestartPosition(IRowset *iface, HCHAPTER reserved)
589 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
590 FIXME("%p, %ld\n", rowset, reserved);
591 return E_NOTIMPL;
594 static const struct IRowsetVtbl msdasql_rowset_vtbl =
596 msdasql_rowset_QueryInterface,
597 msdasql_rowset_AddRef,
598 msdasql_rowset_Release,
599 msdasql_rowset_AddRefRows,
600 msdasql_rowset_GetData,
601 msdasql_rowset_GetNextRows,
602 msdasql_rowset_ReleaseRows,
603 msdasql_rowset_RestartPosition
606 static HRESULT WINAPI rowset_info_QueryInterface(IRowsetInfo *iface, REFIID riid, void **ppv)
608 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
609 return IRowset_QueryInterface(&rowset->IRowset_iface, riid, ppv);
612 static ULONG WINAPI rowset_info_AddRef(IRowsetInfo *iface)
614 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
615 return IRowset_AddRef(&rowset->IRowset_iface);
618 static ULONG WINAPI rowset_info_Release(IRowsetInfo *iface)
620 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
621 return IRowset_Release(&rowset->IRowset_iface);
624 static HRESULT WINAPI rowset_info_GetProperties(IRowsetInfo *iface, const ULONG count,
625 const DBPROPIDSET propertyidsets[], ULONG *out_count, DBPROPSET **propertysets)
627 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
628 FIXME("%p, %d, %p, %p, %p\n", rowset, count, propertyidsets, out_count, propertysets);
629 return E_NOTIMPL;
632 static HRESULT WINAPI rowset_info_GetReferencedRowset(IRowsetInfo *iface, DBORDINAL ordinal,
633 REFIID riid, IUnknown **unk)
635 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
636 FIXME("%p, %ld, %s, %p\n", rowset, ordinal, debugstr_guid(riid), unk);
637 return E_NOTIMPL;
640 static HRESULT WINAPI rowset_info_GetSpecification(IRowsetInfo *iface, REFIID riid,
641 IUnknown **specification)
643 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
645 TRACE("%p, %s, %p\n", rowset, debugstr_guid(riid), specification);
647 if (!specification)
648 return E_INVALIDARG;
650 if (!rowset->caller)
651 return S_FALSE;
653 return IUnknown_QueryInterface(rowset->caller, riid, (void**)specification);
656 struct IRowsetInfoVtbl rowset_info_vtbl =
658 rowset_info_QueryInterface,
659 rowset_info_AddRef,
660 rowset_info_Release,
661 rowset_info_GetProperties,
662 rowset_info_GetReferencedRowset,
663 rowset_info_GetSpecification
666 static HRESULT WINAPI rowset_colsinfo_QueryInterface(IColumnsInfo *iface, REFIID riid, void **out)
668 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
669 return IRowset_QueryInterface(&rowset->IRowset_iface, riid, out);
672 static ULONG WINAPI rowset_colsinfo_AddRef(IColumnsInfo *iface)
674 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
675 return IRowset_AddRef(&rowset->IRowset_iface);
678 static ULONG WINAPI rowset_colsinfo_Release(IColumnsInfo *iface)
680 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
681 return IRowset_Release(&rowset->IRowset_iface);
684 static HRESULT WINAPI rowset_colsinfo_GetColumnInfo(IColumnsInfo *iface, DBORDINAL *columns,
685 DBCOLUMNINFO **colinfo, OLECHAR **stringsbuffer)
687 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
688 FIXME("%p, %p, %p, %p\n", rowset, columns, colinfo, stringsbuffer);
689 return E_NOTIMPL;
692 static HRESULT WINAPI rowset_colsinfo_MapColumnIDs(IColumnsInfo *iface, DBORDINAL column_ids,
693 const DBID *dbids, DBORDINAL *columns)
695 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
696 FIXME("%p, %lu, %p, %p\n", rowset, column_ids, dbids, columns);
697 return E_NOTIMPL;
700 static struct IColumnsInfoVtbl rowset_columninfo_vtbll =
702 rowset_colsinfo_QueryInterface,
703 rowset_colsinfo_AddRef,
704 rowset_colsinfo_Release,
705 rowset_colsinfo_GetColumnInfo,
706 rowset_colsinfo_MapColumnIDs
709 static HRESULT WINAPI rowset_accessor_QueryInterface(IAccessor *iface, REFIID riid, void **out)
711 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
712 return IRowset_QueryInterface(&rowset->IRowset_iface, riid, out);
715 static ULONG WINAPI rowset_accessor_AddRef(IAccessor *iface)
717 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
718 return IRowset_AddRef(&rowset->IRowset_iface);
721 static ULONG WINAPI rowset_accessor_Release(IAccessor *iface)
723 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
724 return IRowset_Release(&rowset->IRowset_iface);
727 static HRESULT WINAPI rowset_accessor_AddRefAccessor(IAccessor *iface, HACCESSOR accessor, DBREFCOUNT *count)
729 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
730 FIXME("%p, %lu, %p\n", rowset, accessor, count);
731 return E_NOTIMPL;
734 static HRESULT WINAPI rowset_accessor_CreateAccessor(IAccessor *iface, DBACCESSORFLAGS flags,
735 DBCOUNTITEM count, const DBBINDING bindings[], DBLENGTH row_size, HACCESSOR *accessor,
736 DBBINDSTATUS status[])
738 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
739 FIXME("%p 0x%08x, %lu, %p, %lu, %p, %p\n", rowset, flags, count, bindings, row_size, accessor, status);
740 return E_NOTIMPL;
743 static HRESULT WINAPI rowset_accessor_GetBindings(IAccessor *iface, HACCESSOR accessor,
744 DBACCESSORFLAGS *flags, DBCOUNTITEM *count, DBBINDING **bindings)
746 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
747 FIXME("%p %lu, %p, %p, %p\n", rowset, accessor, flags, count, bindings);
748 return E_NOTIMPL;
751 static HRESULT WINAPI rowset_accessor_ReleaseAccessor(IAccessor *iface, HACCESSOR accessor, DBREFCOUNT *count)
753 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
754 FIXME("%p, %lu, %p\n", rowset, accessor, count);
755 return E_NOTIMPL;
758 struct IAccessorVtbl accessor_vtbl =
760 rowset_accessor_QueryInterface,
761 rowset_accessor_AddRef,
762 rowset_accessor_Release,
763 rowset_accessor_AddRefAccessor,
764 rowset_accessor_CreateAccessor,
765 rowset_accessor_GetBindings,
766 rowset_accessor_ReleaseAccessor
769 static HRESULT WINAPI column_rs_QueryInterface(IColumnsRowset *iface, REFIID riid, void **out)
771 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
772 return IRowset_QueryInterface(&rowset->IRowset_iface, riid, out);
775 static ULONG WINAPI column_rs_AddRef(IColumnsRowset *iface)
777 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
778 return IRowset_AddRef(&rowset->IRowset_iface);
781 static ULONG WINAPI column_rs_Release(IColumnsRowset *iface)
783 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
784 return IRowset_Release(&rowset->IRowset_iface);
787 static HRESULT WINAPI column_rs_GetAvailableColumns(IColumnsRowset *iface, DBORDINAL *count, DBID **columns)
789 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
790 FIXME("%p, %p, %p\n", rowset, count, columns);
791 return E_NOTIMPL;
794 static HRESULT WINAPI column_rs_GetColumnsRowset(IColumnsRowset *iface, IUnknown *outer, DBORDINAL count,
795 const DBID columns[], REFIID riid, ULONG property_cnt, DBPROPSET property_sets[], IUnknown **unk_rs)
797 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
798 FIXME("(%p)->(%p %ld %p %s %u, %p %p): stub\n", rowset, outer, count, columns, debugstr_guid(riid),
799 property_cnt, property_sets, unk_rs);
800 return E_NOTIMPL;
803 struct IColumnsRowsetVtbl columnrs_rs_vtbl =
805 column_rs_QueryInterface,
806 column_rs_AddRef,
807 column_rs_Release,
808 column_rs_GetAvailableColumns,
809 column_rs_GetColumnsRowset
812 static HRESULT WINAPI command_Execute(ICommandText *iface, IUnknown *outer, REFIID riid,
813 DBPARAMS *params, DBROWCOUNT *affected, IUnknown **rowset)
815 struct command *command = impl_from_ICommandText( iface );
816 struct msdasql_rowset *msrowset;
817 HRESULT hr;
819 FIXME("%p, %p, %s, %p %p %p Semi Stub\n", command, outer, debugstr_guid(riid), params, affected, rowset);
821 msrowset = heap_alloc(sizeof(*msrowset));
822 if (!msrowset)
823 return E_OUTOFMEMORY;
825 msrowset->IRowset_iface.lpVtbl = &msdasql_rowset_vtbl;
826 msrowset->IRowsetInfo_iface.lpVtbl = &rowset_info_vtbl;
827 msrowset->IColumnsInfo_iface.lpVtbl = &rowset_columninfo_vtbll;
828 msrowset->IAccessor_iface.lpVtbl = &accessor_vtbl;
829 msrowset->IColumnsRowset_iface.lpVtbl = &columnrs_rs_vtbl;
830 msrowset->refs = 1;
831 ICommandText_QueryInterface(iface, &IID_IUnknown, (void**)&msrowset->caller);
833 if (affected)
834 *affected = 0; /* FIXME */
836 hr = IRowset_QueryInterface(&msrowset->IRowset_iface, riid, (void**)rowset);
837 IRowset_Release(&msrowset->IRowset_iface);
839 return hr;
842 static HRESULT WINAPI command_GetDBSession(ICommandText *iface, REFIID riid, IUnknown **session)
844 struct command *command = impl_from_ICommandText( iface );
846 TRACE("%p, %s, %p\n", command, debugstr_guid(riid), session);
848 if (!session)
849 return E_INVALIDARG;
851 *session = NULL;
853 if (!command->session)
854 return S_FALSE;
856 return IUnknown_QueryInterface(command->session, riid, (void**)session);
859 static HRESULT WINAPI command_GetCommandText(ICommandText *iface, GUID *dialect, LPOLESTR *commandstr)
861 struct command *command = impl_from_ICommandText( iface );
862 HRESULT hr = S_OK;
863 TRACE("%p, %p, %p\n", command, dialect, commandstr);
865 if (!command->query)
866 return DB_E_NOCOMMAND;
868 if (dialect && !IsEqualGUID(&DBGUID_DEFAULT, dialect))
870 *dialect = DBGUID_DEFAULT;
871 hr = DB_S_DIALECTIGNORED;
874 *commandstr = heap_alloc((lstrlenW(command->query)+1)*sizeof(WCHAR));
875 wcscpy(*commandstr, command->query);
876 return hr;
879 static HRESULT WINAPI command_SetCommandText(ICommandText *iface, REFGUID dialect, LPCOLESTR commandstr)
881 struct command *command = impl_from_ICommandText( iface );
882 TRACE("%p, %s, %s\n", command, debugstr_guid(dialect), debugstr_w(commandstr));
884 if (!IsEqualGUID(&DBGUID_DEFAULT, dialect))
885 FIXME("Currently non Default Dialect isn't supported\n");
887 heap_free(command->query);
889 if (commandstr)
891 command->query = heap_alloc((lstrlenW(commandstr)+1)*sizeof(WCHAR));
892 if (!command->query)
893 return E_OUTOFMEMORY;
895 wcscpy(command->query, commandstr);
897 else
898 command->query = NULL;
899 return S_OK;
902 static const ICommandTextVtbl commandVtbl =
904 command_QueryInterface,
905 command_AddRef,
906 command_Release,
907 command_Cancel,
908 command_Execute,
909 command_GetDBSession,
910 command_GetCommandText,
911 command_SetCommandText
914 static HRESULT WINAPI command_prop_QueryInterface(ICommandProperties *iface, REFIID riid, void **out)
916 struct command *command = impl_from_ICommandProperties( iface );
917 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
920 static ULONG WINAPI command_prop_AddRef(ICommandProperties *iface)
922 struct command *command = impl_from_ICommandProperties( iface );
923 return ICommandText_AddRef(&command->ICommandText_iface);
926 static ULONG WINAPI command_prop_Release(ICommandProperties *iface)
928 struct command *command = impl_from_ICommandProperties( iface );
929 return ICommandText_Release(&command->ICommandText_iface);
932 static HRESULT WINAPI command_prop_GetProperties(ICommandProperties *iface, ULONG count,
933 const DBPROPIDSET propertyidsets[], ULONG *sets_cnt, DBPROPSET **propertyset)
935 struct command *command = impl_from_ICommandProperties( iface );
936 FIXME("%p %d %p %p %p\n", command, count, propertyidsets, sets_cnt, propertyset);
937 return E_NOTIMPL;
940 static HRESULT WINAPI command_prop_SetProperties(ICommandProperties *iface, ULONG count,
941 DBPROPSET propertyset[])
943 struct command *command = impl_from_ICommandProperties( iface );
944 FIXME("%p %p\n", command, propertyset);
945 return S_OK;
948 static const ICommandPropertiesVtbl commonpropsVtbl =
950 command_prop_QueryInterface,
951 command_prop_AddRef,
952 command_prop_Release,
953 command_prop_GetProperties,
954 command_prop_SetProperties
957 static HRESULT WINAPI colsinfo_QueryInterface(IColumnsInfo *iface, REFIID riid, void **out)
959 struct command *command = impl_from_IColumnsInfo( iface );
960 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
963 static ULONG WINAPI colsinfo_AddRef(IColumnsInfo *iface)
965 struct command *command = impl_from_IColumnsInfo( iface );
966 return ICommandText_AddRef(&command->ICommandText_iface);
969 static ULONG WINAPI colsinfo_Release(IColumnsInfo *iface)
971 struct command *command = impl_from_IColumnsInfo( iface );
972 return ICommandText_Release(&command->ICommandText_iface);
975 static HRESULT WINAPI colsinfo_GetColumnInfo(IColumnsInfo *iface, DBORDINAL *columns,
976 DBCOLUMNINFO **colinfo, OLECHAR **stringsbuffer)
978 struct command *command = impl_from_IColumnsInfo( iface );
979 FIXME("%p, %p, %p, %p\n", command, columns, colinfo, stringsbuffer);
980 return E_NOTIMPL;
983 static HRESULT WINAPI colsinfo_MapColumnIDs(IColumnsInfo *iface, DBORDINAL column_ids,
984 const DBID *dbids, DBORDINAL *columns)
986 struct command *command = impl_from_IColumnsInfo( iface );
987 FIXME("%p, %lu, %p, %p\n", command, column_ids, dbids, columns);
988 return E_NOTIMPL;
991 static struct IColumnsInfoVtbl columninfoVtbl =
993 colsinfo_QueryInterface,
994 colsinfo_AddRef,
995 colsinfo_Release,
996 colsinfo_GetColumnInfo,
997 colsinfo_MapColumnIDs
1000 static HRESULT WINAPI converttype_QueryInterface(IConvertType *iface, REFIID riid, void **out)
1002 struct command *command = impl_from_IConvertType( iface );
1003 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
1006 static ULONG WINAPI converttype_AddRef(IConvertType *iface)
1008 struct command *command = impl_from_IConvertType( iface );
1009 return ICommandText_AddRef(&command->ICommandText_iface);
1012 static ULONG WINAPI converttype_Release(IConvertType *iface)
1014 struct command *command = impl_from_IConvertType( iface );
1015 return ICommandText_Release(&command->ICommandText_iface);
1018 static HRESULT WINAPI converttype_CanConvert(IConvertType *iface, DBTYPE from, DBTYPE to, DBCONVERTFLAGS flags)
1020 struct command *command = impl_from_IConvertType( iface );
1021 FIXME("%p, %u, %d, 0x%08x\n", command, from, to, flags);
1022 return E_NOTIMPL;
1025 static struct IConvertTypeVtbl converttypeVtbl =
1027 converttype_QueryInterface,
1028 converttype_AddRef,
1029 converttype_Release,
1030 converttype_CanConvert
1033 static HRESULT WINAPI commandprepare_QueryInterface(ICommandPrepare *iface, REFIID riid, void **out)
1035 struct command *command = impl_from_ICommandPrepare( iface );
1036 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
1039 static ULONG WINAPI commandprepare_AddRef(ICommandPrepare *iface)
1041 struct command *command = impl_from_ICommandPrepare( iface );
1042 return ICommandText_AddRef(&command->ICommandText_iface);
1045 static ULONG WINAPI commandprepare_Release(ICommandPrepare *iface)
1047 struct command *command = impl_from_ICommandPrepare( iface );
1048 return ICommandText_Release(&command->ICommandText_iface);
1051 static HRESULT WINAPI commandprepare_Prepare(ICommandPrepare *iface, ULONG runs)
1053 struct command *command = impl_from_ICommandPrepare( iface );
1054 TRACE("%p, %u\n", command, runs);
1055 return S_OK;
1058 static HRESULT WINAPI commandprepare_Unprepare(ICommandPrepare *iface)
1060 struct command *command = impl_from_ICommandPrepare( iface );
1061 TRACE("%p\n", command);
1062 return S_OK;
1065 struct ICommandPrepareVtbl commandprepareVtbl =
1067 commandprepare_QueryInterface,
1068 commandprepare_AddRef,
1069 commandprepare_Release,
1070 commandprepare_Prepare,
1071 commandprepare_Unprepare
1074 static HRESULT WINAPI cmd_with_params_QueryInterface(ICommandWithParameters *iface, REFIID riid, void **out)
1076 struct command *command = impl_from_ICommandWithParameters( iface );
1077 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
1080 static ULONG WINAPI cmd_with_params_AddRef(ICommandWithParameters *iface)
1082 struct command *command = impl_from_ICommandWithParameters( iface );
1083 return ICommandText_AddRef(&command->ICommandText_iface);
1086 static ULONG WINAPI cmd_with_params_Release(ICommandWithParameters *iface)
1088 struct command *command = impl_from_ICommandWithParameters( iface );
1089 return ICommandText_Release(&command->ICommandText_iface);
1092 static HRESULT WINAPI cmd_with_params_GetParameterInfo(ICommandWithParameters *iface, DB_UPARAMS *uparams,
1093 DBPARAMINFO **info, OLECHAR **buffer)
1095 struct command *command = impl_from_ICommandWithParameters( iface );
1096 FIXME("%p, %p, %p, %p\n", command, uparams, info, buffer);
1097 return E_NOTIMPL;
1100 static HRESULT WINAPI cmd_with_params_MapParameterNames(ICommandWithParameters *iface, DB_UPARAMS uparams,
1101 LPCWSTR names[], DB_LPARAMS ordinals[])
1103 struct command *command = impl_from_ICommandWithParameters( iface );
1104 FIXME("%p, %ld, %p, %p\n", command, uparams, names, ordinals);
1105 return E_NOTIMPL;
1108 static HRESULT WINAPI cmd_with_params_SetParameterInfo(ICommandWithParameters *iface, DB_UPARAMS uparams,
1109 const DB_UPARAMS ordinals[], const DBPARAMBINDINFO bindinfo[])
1111 struct command *command = impl_from_ICommandWithParameters( iface );
1112 FIXME("%p, %ld, %p, %p\n", command, uparams, ordinals, bindinfo);
1113 return E_NOTIMPL;
1116 struct ICommandWithParametersVtbl command_with_params_vtbl =
1118 cmd_with_params_QueryInterface,
1119 cmd_with_params_AddRef,
1120 cmd_with_params_Release,
1121 cmd_with_params_GetParameterInfo,
1122 cmd_with_params_MapParameterNames,
1123 cmd_with_params_SetParameterInfo
1126 static HRESULT WINAPI createcommand_CreateCommand(IDBCreateCommand *iface, IUnknown *outer, REFIID riid,
1127 IUnknown **out)
1129 struct msdasql_session *session = impl_from_IDBCreateCommand( iface );
1130 struct command *command;
1131 HRESULT hr;
1133 TRACE("%p, %p, %s, %p\n", session, outer, debugstr_guid(riid), out);
1135 if (outer)
1136 FIXME("Outer not currently supported\n");
1138 command = heap_alloc(sizeof(*command));
1139 if (!command)
1140 return E_OUTOFMEMORY;
1142 command->ICommandText_iface.lpVtbl = &commandVtbl;
1143 command->ICommandProperties_iface.lpVtbl = &commonpropsVtbl;
1144 command->IColumnsInfo_iface.lpVtbl = &columninfoVtbl;
1145 command->IConvertType_iface.lpVtbl = &converttypeVtbl;
1146 command->ICommandPrepare_iface.lpVtbl = &commandprepareVtbl;
1147 command->ICommandWithParameters_iface.lpVtbl = &command_with_params_vtbl;
1148 command->refs = 1;
1149 command->query = NULL;
1151 IUnknown_QueryInterface(&session->session_iface, &IID_IUnknown, (void**)&command->session);
1153 hr = ICommandText_QueryInterface(&command->ICommandText_iface, riid, (void**)out);
1154 ICommandText_Release(&command->ICommandText_iface);
1155 return hr;
1158 static const IDBCreateCommandVtbl createcommandVtbl =
1160 createcommand_QueryInterface,
1161 createcommand_AddRef,
1162 createcommand_Release,
1163 createcommand_CreateCommand
1166 HRESULT create_db_session(REFIID riid, IUnknown *datasource, void **unk)
1168 struct msdasql_session *session;
1169 HRESULT hr;
1171 session = heap_alloc(sizeof(*session));
1172 if (!session)
1173 return E_OUTOFMEMORY;
1175 session->session_iface.lpVtbl = &unkfactoryVtbl;
1176 session->IGetDataSource_iface.lpVtbl = &datasourceVtbl;
1177 session->IOpenRowset_iface.lpVtbl = &openrowsetVtbl;
1178 session->ISessionProperties_iface.lpVtbl = &propertiesVtbl;
1179 session->IDBCreateCommand_iface.lpVtbl = &createcommandVtbl;
1180 IUnknown_QueryInterface(datasource, &IID_IUnknown, (void**)&session->datasource);
1181 session->refs = 1;
1183 hr = IUnknown_QueryInterface(&session->session_iface, riid, unk);
1184 IUnknown_Release(&session->session_iface);
1185 return hr;