msdasql: Correct default dialect logic.
[wine.git] / dlls / msdasql / session.c
blobe52e8cd18d8b1645a4c38cec01555636c251888f
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;
48 static inline struct msdasql_session *impl_from_IUnknown( IUnknown *iface )
50 return CONTAINING_RECORD( iface, struct msdasql_session, session_iface );
53 static inline struct msdasql_session *impl_from_IGetDataSource( IGetDataSource *iface )
55 return CONTAINING_RECORD( iface, struct msdasql_session, IGetDataSource_iface );
58 static inline struct msdasql_session *impl_from_IOpenRowset( IOpenRowset *iface )
60 return CONTAINING_RECORD( iface, struct msdasql_session, IOpenRowset_iface );
63 static inline struct msdasql_session *impl_from_ISessionProperties( ISessionProperties *iface )
65 return CONTAINING_RECORD( iface, struct msdasql_session, ISessionProperties_iface );
68 static inline struct msdasql_session *impl_from_IDBCreateCommand( IDBCreateCommand *iface )
70 return CONTAINING_RECORD( iface, struct msdasql_session, IDBCreateCommand_iface );
73 static HRESULT WINAPI session_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
75 struct msdasql_session *session = impl_from_IUnknown( iface );
77 TRACE( "%p, %s, %p\n", iface, debugstr_guid(riid), ppv );
78 *ppv = NULL;
80 if(IsEqualGUID(&IID_IUnknown, riid))
82 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
83 *ppv = &session->session_iface;
85 else if(IsEqualGUID(&IID_IGetDataSource, riid))
87 TRACE("(%p)->(IID_IGetDataSource %p)\n", iface, ppv);
88 *ppv = &session->IGetDataSource_iface;
90 else if(IsEqualGUID(&IID_IOpenRowset, riid))
92 TRACE("(%p)->(IID_IOpenRowset %p)\n", iface, ppv);
93 *ppv = &session->IOpenRowset_iface;
95 else if(IsEqualGUID(&IID_ISessionProperties, riid))
97 TRACE("(%p)->(IID_ISessionProperties %p)\n", iface, ppv);
98 *ppv = &session->ISessionProperties_iface;
100 else if(IsEqualGUID(&IID_IDBCreateCommand, riid))
102 TRACE("(%p)->(IDBCreateCommand_iface %p)\n", iface, ppv);
103 *ppv = &session->IDBCreateCommand_iface;
105 else if(IsEqualGUID(&IID_IBindResource, riid))
107 TRACE("(%p)->(IID_IBindResource not support)\n", iface);
108 return E_NOINTERFACE;
110 else if(IsEqualGUID(&IID_ICreateRow, riid))
112 TRACE("(%p)->(IID_ICreateRow not support)\n", iface);
113 return E_NOINTERFACE;
116 if(*ppv)
118 IUnknown_AddRef((IUnknown*)*ppv);
119 return S_OK;
122 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
123 return E_NOINTERFACE;
126 static ULONG WINAPI session_AddRef(IUnknown *iface)
128 struct msdasql_session *session = impl_from_IUnknown( iface );
129 LONG refs = InterlockedIncrement( &session->refs );
130 TRACE( "%p new refcount %d\n", session, refs );
131 return refs;
134 static ULONG WINAPI session_Release(IUnknown *iface)
136 struct msdasql_session *session = impl_from_IUnknown( iface );
137 LONG refs = InterlockedDecrement( &session->refs );
138 TRACE( "%p new refcount %d\n", session, refs );
139 if (!refs)
141 TRACE( "destroying %p\n", session );
142 heap_free( session );
144 return refs;
147 static const IUnknownVtbl unkfactoryVtbl =
149 session_QueryInterface,
150 session_AddRef,
151 session_Release,
155 HRESULT WINAPI datasource_QueryInterface(IGetDataSource *iface, REFIID riid, void **out)
157 struct msdasql_session *session = impl_from_IGetDataSource( iface );
158 return IUnknown_QueryInterface(&session->session_iface, riid, out);
161 ULONG WINAPI datasource_AddRef(IGetDataSource *iface)
163 struct msdasql_session *session = impl_from_IGetDataSource( iface );
164 return IUnknown_AddRef(&session->session_iface);
167 ULONG WINAPI datasource_Release(IGetDataSource *iface)
169 struct msdasql_session *session = impl_from_IGetDataSource( iface );
170 return IUnknown_Release(&session->session_iface);
173 HRESULT WINAPI datasource_GetDataSource(IGetDataSource *iface, REFIID riid, IUnknown **datasource)
175 struct msdasql_session *session = impl_from_IGetDataSource( iface );
176 FIXME("%p, %s, %p stub\n", session, debugstr_guid(riid), datasource);
178 return E_NOTIMPL;
181 static const IGetDataSourceVtbl datasourceVtbl =
183 datasource_QueryInterface,
184 datasource_AddRef,
185 datasource_Release,
186 datasource_GetDataSource
189 HRESULT WINAPI openrowset_QueryInterface(IOpenRowset *iface, REFIID riid, void **out)
191 struct msdasql_session *session = impl_from_IOpenRowset( iface );
192 return IUnknown_QueryInterface(&session->session_iface, riid, out);
195 ULONG WINAPI openrowset_AddRef(IOpenRowset *iface)
197 struct msdasql_session *session = impl_from_IOpenRowset( iface );
198 return IUnknown_AddRef(&session->session_iface);
201 ULONG WINAPI openrowset_Release(IOpenRowset *iface)
203 struct msdasql_session *session = impl_from_IOpenRowset( iface );
204 return IUnknown_Release(&session->session_iface);
207 HRESULT WINAPI openrowset_OpenRowset(IOpenRowset *iface, IUnknown *pUnkOuter, DBID *table,
208 DBID *index, REFIID riid, ULONG count, DBPROPSET propertysets[], IUnknown **rowset)
210 struct msdasql_session *session = impl_from_IOpenRowset( iface );
211 FIXME("%p, %p, %p %p %s, %d %p %p stub\n", session, pUnkOuter, table, index, debugstr_guid(riid),
212 count, propertysets, rowset);
214 return E_NOTIMPL;
217 static const IOpenRowsetVtbl openrowsetVtbl =
219 openrowset_QueryInterface,
220 openrowset_AddRef,
221 openrowset_Release,
222 openrowset_OpenRowset
225 static HRESULT WINAPI properties_QueryInterface(ISessionProperties *iface, REFIID riid, void **out)
227 struct msdasql_session *session = impl_from_ISessionProperties( iface );
228 return IUnknown_QueryInterface(&session->session_iface, riid, out);
231 static ULONG WINAPI properties_AddRef(ISessionProperties *iface)
233 struct msdasql_session *session = impl_from_ISessionProperties( iface );
234 return IUnknown_AddRef(&session->session_iface);
237 static ULONG WINAPI properties_Release(ISessionProperties *iface)
239 struct msdasql_session *session = impl_from_ISessionProperties( iface );
240 return IUnknown_Release(&session->session_iface);
244 static HRESULT WINAPI properties_GetProperties(ISessionProperties *iface, ULONG set_count,
245 const DBPROPIDSET id_sets[], ULONG *count, DBPROPSET **sets)
247 struct msdasql_session *session = impl_from_ISessionProperties( iface );
248 FIXME("%p %d %p %p %p\n", session, set_count, id_sets, count, sets);
250 return E_NOTIMPL;
253 static HRESULT WINAPI properties_SetProperties(ISessionProperties *iface, ULONG count,
254 DBPROPSET sets[])
256 struct msdasql_session *session = impl_from_ISessionProperties( iface );
257 FIXME("%p %d %p\n", session, count, sets);
259 return S_OK;
262 static const ISessionPropertiesVtbl propertiesVtbl =
264 properties_QueryInterface,
265 properties_AddRef,
266 properties_Release,
267 properties_GetProperties,
268 properties_SetProperties
271 static HRESULT WINAPI createcommand_QueryInterface(IDBCreateCommand *iface, REFIID riid, void **out)
273 struct msdasql_session *session = impl_from_IDBCreateCommand( iface );
274 return IUnknown_QueryInterface(&session->session_iface, riid, out);
277 static ULONG WINAPI createcommand_AddRef(IDBCreateCommand *iface)
279 struct msdasql_session *session = impl_from_IDBCreateCommand( iface );
280 return IUnknown_AddRef(&session->session_iface);
283 static ULONG WINAPI createcommand_Release(IDBCreateCommand *iface)
285 struct msdasql_session *session = impl_from_IDBCreateCommand( iface );
286 return IUnknown_Release(&session->session_iface);
289 struct command
291 ICommandText ICommandText_iface;
292 ICommandProperties ICommandProperties_iface;
293 IColumnsInfo IColumnsInfo_iface;
294 IConvertType IConvertType_iface;
295 ICommandPrepare ICommandPrepare_iface;
296 LONG refs;
297 WCHAR *query;
298 IUnknown *session;
301 static inline struct command *impl_from_ICommandText( ICommandText *iface )
303 return CONTAINING_RECORD( iface, struct command, ICommandText_iface );
306 static inline struct command *impl_from_ICommandProperties( ICommandProperties *iface )
308 return CONTAINING_RECORD( iface, struct command, ICommandProperties_iface );
311 static inline struct command *impl_from_IColumnsInfo( IColumnsInfo *iface )
313 return CONTAINING_RECORD( iface, struct command, IColumnsInfo_iface );
316 static inline struct command *impl_from_IConvertType( IConvertType *iface )
318 return CONTAINING_RECORD( iface, struct command, IConvertType_iface );
321 static inline struct command *impl_from_ICommandPrepare( ICommandPrepare *iface )
323 return CONTAINING_RECORD( iface, struct command, ICommandPrepare_iface );
326 static HRESULT WINAPI command_QueryInterface(ICommandText *iface, REFIID riid, void **ppv)
328 struct command *command = impl_from_ICommandText( iface );
330 TRACE( "%p, %s, %p\n", command, debugstr_guid(riid), ppv );
331 *ppv = NULL;
333 if(IsEqualGUID(&IID_IUnknown, riid) ||
334 IsEqualGUID(&IID_ICommand, riid) ||
335 IsEqualGUID(&IID_ICommandText, riid))
337 *ppv = &command->ICommandText_iface;
339 else if(IsEqualGUID(&IID_ICommandProperties, riid))
341 *ppv = &command->ICommandProperties_iface;
343 else if(IsEqualGUID(&IID_IColumnsInfo, riid))
345 *ppv = &command->IColumnsInfo_iface;
347 else if(IsEqualGUID(&IID_IConvertType, riid))
349 *ppv = &command->IConvertType_iface;
351 else if(IsEqualGUID(&IID_ICommandPrepare, riid))
353 *ppv = &command->ICommandPrepare_iface;
356 if(*ppv)
358 IUnknown_AddRef((IUnknown*)*ppv);
359 return S_OK;
361 else if (IsEqualGUID(&IID_IMultipleResults, riid))
363 TRACE("IID_IMultipleResults not supported\n");
364 return E_NOINTERFACE;
366 else if(IsEqualGUID(&IID_ICommandStream, riid))
368 TRACE("ICommandStream not support\n");
369 return E_NOINTERFACE;
371 else if (IsEqualGUID(&IID_IRowsetChange, riid))
373 TRACE("IID_IRowsetChange not supported\n");
374 return E_NOINTERFACE;
376 else if (IsEqualGUID(&IID_IRowsetUpdate, riid))
378 TRACE("IID_IRowsetUpdate not supported\n");
379 return E_NOINTERFACE;
381 else if (IsEqualGUID(&IID_IRowsetLocate, riid))
383 TRACE("IID_IRowsetLocate not supported\n");
384 return E_NOINTERFACE;
387 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
388 return E_NOINTERFACE;
391 static ULONG WINAPI command_AddRef(ICommandText *iface)
393 struct command *command = impl_from_ICommandText( iface );
394 LONG refs = InterlockedIncrement( &command->refs );
395 TRACE( "%p new refcount %d\n", command, refs );
396 return refs;
399 static ULONG WINAPI command_Release(ICommandText *iface)
401 struct command *command = impl_from_ICommandText( iface );
402 LONG refs = InterlockedDecrement( &command->refs );
403 TRACE( "%p new refcount %d\n", command, refs );
404 if (!refs)
406 TRACE( "destroying %p\n", command );
407 if (command->session)
408 IUnknown_Release(command->session);
409 heap_free( command->query );
410 heap_free( command );
412 return refs;
415 static HRESULT WINAPI command_Cancel(ICommandText *iface)
417 struct command *command = impl_from_ICommandText( iface );
418 FIXME("%p\n", command);
419 return E_NOTIMPL;
422 struct msdasql_rowset
424 IRowset IRowset_iface;
425 IRowsetInfo IRowsetInfo_iface;
426 IColumnsInfo IColumnsInfo_iface;
427 IAccessor IAccessor_iface;
428 IColumnsRowset IColumnsRowset_iface;
429 LONG refs;
432 static inline struct msdasql_rowset *impl_from_IRowset( IRowset *iface )
434 return CONTAINING_RECORD( iface, struct msdasql_rowset, IRowset_iface );
437 static inline struct msdasql_rowset *impl_from_IRowsetInfo( IRowsetInfo *iface )
439 return CONTAINING_RECORD( iface, struct msdasql_rowset, IRowsetInfo_iface );
442 static inline struct msdasql_rowset *rowset_impl_from_IColumnsInfo( IColumnsInfo *iface )
444 return CONTAINING_RECORD( iface, struct msdasql_rowset, IColumnsInfo_iface );
447 static inline struct msdasql_rowset *impl_from_IAccessor ( IAccessor *iface )
449 return CONTAINING_RECORD( iface, struct msdasql_rowset, IAccessor_iface );
452 static inline struct msdasql_rowset *impl_from_IColumnsRowset ( IColumnsRowset *iface )
454 return CONTAINING_RECORD( iface, struct msdasql_rowset, IColumnsRowset_iface );
457 static HRESULT WINAPI msdasql_rowset_QueryInterface(IRowset *iface, REFIID riid, void **ppv)
459 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
461 TRACE( "%p, %s, %p\n", rowset, debugstr_guid(riid), ppv );
463 *ppv = NULL;
464 if(IsEqualGUID(&IID_IUnknown, riid) ||
465 IsEqualGUID(&IID_IRowset, riid))
467 *ppv = &rowset->IRowset_iface;
469 else if (IsEqualGUID(&IID_IRowsetInfo, riid))
471 *ppv = &rowset->IRowsetInfo_iface;
473 else if (IsEqualGUID(&IID_IColumnsInfo, riid))
475 *ppv = &rowset->IColumnsInfo_iface;
477 else if(IsEqualGUID(&IID_IAccessor, riid))
479 *ppv = &rowset->IAccessor_iface;
481 else if(IsEqualGUID(&IID_IColumnsRowset, riid))
483 *ppv = &rowset->IColumnsRowset_iface;
485 else if (IsEqualGUID(&IID_IRowsetChange, riid))
487 TRACE("IID_IRowsetChange not supported\n");
488 return E_NOINTERFACE;
490 else if (IsEqualGUID(&IID_IRowsetUpdate, riid))
492 TRACE("IID_IRowsetUpdate not supported\n");
493 return E_NOINTERFACE;
495 else if (IsEqualGUID(&IID_IRowsetLocate, riid))
497 TRACE("IID_IRowsetLocate not supported\n");
498 return E_NOINTERFACE;
501 if(*ppv)
503 IUnknown_AddRef((IUnknown*)*ppv);
504 return S_OK;
507 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
508 return E_NOINTERFACE;
511 static ULONG WINAPI msdasql_rowset_AddRef(IRowset *iface)
513 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
514 LONG refs = InterlockedIncrement( &rowset->refs );
515 TRACE( "%p new refcount %d\n", rowset, refs );
516 return refs;
519 static ULONG WINAPI msdasql_rowset_Release(IRowset *iface)
521 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
522 LONG refs = InterlockedDecrement( &rowset->refs );
523 TRACE( "%p new refcount %d\n", rowset, refs );
524 if (!refs)
526 TRACE( "destroying %p\n", rowset );
527 heap_free( rowset );
529 return refs;
532 static HRESULT WINAPI msdasql_rowset_AddRefRows(IRowset *iface, DBCOUNTITEM count,
533 const HROW rows[], DBREFCOUNT ref_counts[], DBROWSTATUS status[])
535 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
536 FIXME("%p, %ld, %p, %p, %p\n", rowset, count, rows, ref_counts, status);
537 return E_NOTIMPL;
540 static HRESULT WINAPI msdasql_rowset_GetData(IRowset *iface, HROW row, HACCESSOR accessor, void *data)
542 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
543 FIXME("%p, %ld, %ld, %p\n", rowset, row, accessor, data);
544 return E_NOTIMPL;
547 static HRESULT WINAPI msdasql_rowset_GetNextRows(IRowset *iface, HCHAPTER reserved, DBROWOFFSET offset,
548 DBROWCOUNT count, DBCOUNTITEM *obtained, HROW **rows)
550 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
551 FIXME("%p, %ld, %ld, %ld, %p, %p\n", rowset, reserved, offset, count, obtained, rows);
552 return E_NOTIMPL;
555 static HRESULT WINAPI msdasql_rowset_ReleaseRows(IRowset *iface, DBCOUNTITEM count,
556 const HROW rows[], DBROWOPTIONS options[], DBREFCOUNT ref_counts[], DBROWSTATUS status[])
558 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
560 FIXME("%p, %ld, %p, %p, %p, %p\n", rowset, count, rows, options, ref_counts, status);
561 return E_NOTIMPL;
564 static HRESULT WINAPI msdasql_rowset_RestartPosition(IRowset *iface, HCHAPTER reserved)
566 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
567 FIXME("%p, %ld\n", rowset, reserved);
568 return E_NOTIMPL;
571 static const struct IRowsetVtbl msdasql_rowset_vtbl =
573 msdasql_rowset_QueryInterface,
574 msdasql_rowset_AddRef,
575 msdasql_rowset_Release,
576 msdasql_rowset_AddRefRows,
577 msdasql_rowset_GetData,
578 msdasql_rowset_GetNextRows,
579 msdasql_rowset_ReleaseRows,
580 msdasql_rowset_RestartPosition
583 static HRESULT WINAPI rowset_info_QueryInterface(IRowsetInfo *iface, REFIID riid, void **ppv)
585 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
586 return IRowset_QueryInterface(&rowset->IRowset_iface, riid, ppv);
589 static ULONG WINAPI rowset_info_AddRef(IRowsetInfo *iface)
591 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
592 return IRowset_AddRef(&rowset->IRowset_iface);
595 static ULONG WINAPI rowset_info_Release(IRowsetInfo *iface)
597 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
598 return IRowset_Release(&rowset->IRowset_iface);
601 static HRESULT WINAPI rowset_info_GetProperties(IRowsetInfo *iface, const ULONG count,
602 const DBPROPIDSET propertyidsets[], ULONG *out_count, DBPROPSET **propertysets)
604 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
605 FIXME("%p, %d, %p, %p, %p\n", rowset, count, propertyidsets, out_count, propertysets);
606 return E_NOTIMPL;
609 static HRESULT WINAPI rowset_info_GetReferencedRowset(IRowsetInfo *iface, DBORDINAL ordinal,
610 REFIID riid, IUnknown **unk)
612 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
613 FIXME("%p, %ld, %s, %p\n", rowset, ordinal, debugstr_guid(riid), unk);
614 return E_NOTIMPL;
617 static HRESULT WINAPI rowset_info_GetSpecification(IRowsetInfo *iface, REFIID riid,
618 IUnknown **specification)
620 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
621 FIXME("%p, %s, %p\n", rowset, debugstr_guid(riid), specification);
622 return E_NOTIMPL;
625 struct IRowsetInfoVtbl rowset_info_vtbl =
627 rowset_info_QueryInterface,
628 rowset_info_AddRef,
629 rowset_info_Release,
630 rowset_info_GetProperties,
631 rowset_info_GetReferencedRowset,
632 rowset_info_GetSpecification
635 static HRESULT WINAPI rowset_colsinfo_QueryInterface(IColumnsInfo *iface, REFIID riid, void **out)
637 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
638 return IRowset_QueryInterface(&rowset->IRowset_iface, riid, out);
641 static ULONG WINAPI rowset_colsinfo_AddRef(IColumnsInfo *iface)
643 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
644 return IRowset_AddRef(&rowset->IRowset_iface);
647 static ULONG WINAPI rowset_colsinfo_Release(IColumnsInfo *iface)
649 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
650 return IRowset_Release(&rowset->IRowset_iface);
653 static HRESULT WINAPI rowset_colsinfo_GetColumnInfo(IColumnsInfo *iface, DBORDINAL *columns,
654 DBCOLUMNINFO **colinfo, OLECHAR **stringsbuffer)
656 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
657 FIXME("%p, %p, %p, %p\n", rowset, columns, colinfo, stringsbuffer);
658 return E_NOTIMPL;
661 static HRESULT WINAPI rowset_colsinfo_MapColumnIDs(IColumnsInfo *iface, DBORDINAL column_ids,
662 const DBID *dbids, DBORDINAL *columns)
664 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
665 FIXME("%p, %lu, %p, %p\n", rowset, column_ids, dbids, columns);
666 return E_NOTIMPL;
669 static struct IColumnsInfoVtbl rowset_columninfo_vtbll =
671 rowset_colsinfo_QueryInterface,
672 rowset_colsinfo_AddRef,
673 rowset_colsinfo_Release,
674 rowset_colsinfo_GetColumnInfo,
675 rowset_colsinfo_MapColumnIDs
678 static HRESULT WINAPI rowset_accessor_QueryInterface(IAccessor *iface, REFIID riid, void **out)
680 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
681 return IRowset_QueryInterface(&rowset->IRowset_iface, riid, out);
684 static ULONG WINAPI rowset_accessor_AddRef(IAccessor *iface)
686 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
687 return IRowset_AddRef(&rowset->IRowset_iface);
690 static ULONG WINAPI rowset_accessor_Release(IAccessor *iface)
692 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
693 return IRowset_Release(&rowset->IRowset_iface);
696 static HRESULT WINAPI rowset_accessor_AddRefAccessor(IAccessor *iface, HACCESSOR accessor, DBREFCOUNT *count)
698 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
699 FIXME("%p, %lu, %p\n", rowset, accessor, count);
700 return E_NOTIMPL;
703 static HRESULT WINAPI rowset_accessor_CreateAccessor(IAccessor *iface, DBACCESSORFLAGS flags,
704 DBCOUNTITEM count, const DBBINDING bindings[], DBLENGTH row_size, HACCESSOR *accessor,
705 DBBINDSTATUS status[])
707 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
708 FIXME("%p 0x%08x, %lu, %p, %lu, %p, %p\n", rowset, flags, count, bindings, row_size, accessor, status);
709 return E_NOTIMPL;
712 static HRESULT WINAPI rowset_accessor_GetBindings(IAccessor *iface, HACCESSOR accessor,
713 DBACCESSORFLAGS *flags, DBCOUNTITEM *count, DBBINDING **bindings)
715 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
716 FIXME("%p %lu, %p, %p, %p\n", rowset, accessor, flags, count, bindings);
717 return E_NOTIMPL;
720 static HRESULT WINAPI rowset_accessor_ReleaseAccessor(IAccessor *iface, HACCESSOR accessor, DBREFCOUNT *count)
722 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
723 FIXME("%p, %lu, %p\n", rowset, accessor, count);
724 return E_NOTIMPL;
727 struct IAccessorVtbl accessor_vtbl =
729 rowset_accessor_QueryInterface,
730 rowset_accessor_AddRef,
731 rowset_accessor_Release,
732 rowset_accessor_AddRefAccessor,
733 rowset_accessor_CreateAccessor,
734 rowset_accessor_GetBindings,
735 rowset_accessor_ReleaseAccessor
738 static HRESULT WINAPI column_rs_QueryInterface(IColumnsRowset *iface, REFIID riid, void **out)
740 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
741 return IRowset_QueryInterface(&rowset->IRowset_iface, riid, out);
744 static ULONG WINAPI column_rs_AddRef(IColumnsRowset *iface)
746 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
747 return IRowset_AddRef(&rowset->IRowset_iface);
750 static ULONG WINAPI column_rs_Release(IColumnsRowset *iface)
752 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
753 return IRowset_Release(&rowset->IRowset_iface);
756 static HRESULT WINAPI column_rs_GetAvailableColumns(IColumnsRowset *iface, DBORDINAL *count, DBID **columns)
758 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
759 FIXME("%p, %p, %p\n", rowset, count, columns);
760 return E_NOTIMPL;
763 static HRESULT WINAPI column_rs_GetColumnsRowset(IColumnsRowset *iface, IUnknown *outer, DBORDINAL count,
764 const DBID columns[], REFIID riid, ULONG property_cnt, DBPROPSET property_sets[], IUnknown **unk_rs)
766 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
767 FIXME("(%p)->(%p %ld %p %s %u, %p %p): stub\n", rowset, outer, count, columns, debugstr_guid(riid),
768 property_cnt, property_sets, unk_rs);
769 return E_NOTIMPL;
772 struct IColumnsRowsetVtbl columnrs_rs_vtbl =
774 column_rs_QueryInterface,
775 column_rs_AddRef,
776 column_rs_Release,
777 column_rs_GetAvailableColumns,
778 column_rs_GetColumnsRowset
782 static HRESULT WINAPI command_Execute(ICommandText *iface, IUnknown *outer, REFIID riid,
783 DBPARAMS *params, DBROWCOUNT *affected, IUnknown **rowset)
785 struct command *command = impl_from_ICommandText( iface );
786 struct msdasql_rowset *msrowset;
787 HRESULT hr;
789 FIXME("%p, %p, %s, %p %p %p Semi Stub\n", command, outer, debugstr_guid(riid), params, affected, rowset);
791 msrowset = heap_alloc(sizeof(*msrowset));
792 if (!msrowset)
793 return E_OUTOFMEMORY;
795 msrowset->IRowset_iface.lpVtbl = &msdasql_rowset_vtbl;
796 msrowset->IRowsetInfo_iface.lpVtbl = &rowset_info_vtbl;
797 msrowset->IColumnsInfo_iface.lpVtbl = &rowset_columninfo_vtbll;
798 msrowset->IAccessor_iface.lpVtbl = &accessor_vtbl;
799 msrowset->IColumnsRowset_iface.lpVtbl = &columnrs_rs_vtbl;
800 msrowset->refs = 1;
802 if (affected)
803 *affected = 0; /* FIXME */
805 hr = IRowset_QueryInterface(&msrowset->IRowset_iface, riid, (void**)rowset);
806 IRowset_Release(&msrowset->IRowset_iface);
808 return hr;
811 static HRESULT WINAPI command_GetDBSession(ICommandText *iface, REFIID riid, IUnknown **session)
813 struct command *command = impl_from_ICommandText( iface );
815 TRACE("%p, %s, %p\n", command, debugstr_guid(riid), session);
817 if (!session)
818 return E_INVALIDARG;
820 *session = NULL;
822 if (!command->session)
823 return S_FALSE;
825 return IUnknown_QueryInterface(command->session, riid, (void**)session);
828 static HRESULT WINAPI command_GetCommandText(ICommandText *iface, GUID *dialect, LPOLESTR *commandstr)
830 struct command *command = impl_from_ICommandText( iface );
831 HRESULT hr = S_OK;
832 TRACE("%p, %p, %p\n", command, dialect, commandstr);
834 if (!command->query)
835 return DB_E_NOCOMMAND;
837 if (IsEqualGUID(&DBGUID_DEFAULT, dialect))
838 hr = DB_S_DIALECTIGNORED;
840 *commandstr = heap_alloc((lstrlenW(command->query)+1)*sizeof(WCHAR));
841 wcscpy(*commandstr, command->query);
842 return hr;
845 static HRESULT WINAPI command_SetCommandText(ICommandText *iface, REFGUID dialect, LPCOLESTR commandstr)
847 struct command *command = impl_from_ICommandText( iface );
848 TRACE("%p, %s, %s\n", command, debugstr_guid(dialect), debugstr_w(commandstr));
850 if (!IsEqualGUID(&DBGUID_DEFAULT, dialect))
851 FIXME("Currently non Default Dialect isn't supported\n");
853 heap_free(command->query);
855 if (commandstr)
857 command->query = heap_alloc((lstrlenW(commandstr)+1)*sizeof(WCHAR));
858 if (!command->query)
859 return E_OUTOFMEMORY;
861 wcscpy(command->query, commandstr);
863 else
864 command->query = NULL;
865 return S_OK;
868 static const ICommandTextVtbl commandVtbl =
870 command_QueryInterface,
871 command_AddRef,
872 command_Release,
873 command_Cancel,
874 command_Execute,
875 command_GetDBSession,
876 command_GetCommandText,
877 command_SetCommandText
880 static HRESULT WINAPI command_prop_QueryInterface(ICommandProperties *iface, REFIID riid, void **out)
882 struct command *command = impl_from_ICommandProperties( iface );
883 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
886 static ULONG WINAPI command_prop_AddRef(ICommandProperties *iface)
888 struct command *command = impl_from_ICommandProperties( iface );
889 return ICommandText_AddRef(&command->ICommandText_iface);
892 static ULONG WINAPI command_prop_Release(ICommandProperties *iface)
894 struct command *command = impl_from_ICommandProperties( iface );
895 return ICommandText_Release(&command->ICommandText_iface);
898 static HRESULT WINAPI command_prop_GetProperties(ICommandProperties *iface, ULONG count,
899 const DBPROPIDSET propertyidsets[], ULONG *sets_cnt, DBPROPSET **propertyset)
901 struct command *command = impl_from_ICommandProperties( iface );
902 FIXME("%p %d %p %p %p\n", command, count, propertyidsets, sets_cnt, propertyset);
903 return E_NOTIMPL;
906 static HRESULT WINAPI command_prop_SetProperties(ICommandProperties *iface, ULONG count,
907 DBPROPSET propertyset[])
909 struct command *command = impl_from_ICommandProperties( iface );
910 FIXME("%p %p\n", command, propertyset);
911 return S_OK;
914 static const ICommandPropertiesVtbl commonpropsVtbl =
916 command_prop_QueryInterface,
917 command_prop_AddRef,
918 command_prop_Release,
919 command_prop_GetProperties,
920 command_prop_SetProperties
923 static HRESULT WINAPI colsinfo_QueryInterface(IColumnsInfo *iface, REFIID riid, void **out)
925 struct command *command = impl_from_IColumnsInfo( iface );
926 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
929 static ULONG WINAPI colsinfo_AddRef(IColumnsInfo *iface)
931 struct command *command = impl_from_IColumnsInfo( iface );
932 return ICommandText_AddRef(&command->ICommandText_iface);
935 static ULONG WINAPI colsinfo_Release(IColumnsInfo *iface)
937 struct command *command = impl_from_IColumnsInfo( iface );
938 return ICommandText_Release(&command->ICommandText_iface);
941 static HRESULT WINAPI colsinfo_GetColumnInfo(IColumnsInfo *iface, DBORDINAL *columns,
942 DBCOLUMNINFO **colinfo, OLECHAR **stringsbuffer)
944 struct command *command = impl_from_IColumnsInfo( iface );
945 FIXME("%p, %p, %p, %p\n", command, columns, colinfo, stringsbuffer);
946 return E_NOTIMPL;
949 static HRESULT WINAPI colsinfo_MapColumnIDs(IColumnsInfo *iface, DBORDINAL column_ids,
950 const DBID *dbids, DBORDINAL *columns)
952 struct command *command = impl_from_IColumnsInfo( iface );
953 FIXME("%p, %lu, %p, %p\n", command, column_ids, dbids, columns);
954 return E_NOTIMPL;
957 static struct IColumnsInfoVtbl columninfoVtbl =
959 colsinfo_QueryInterface,
960 colsinfo_AddRef,
961 colsinfo_Release,
962 colsinfo_GetColumnInfo,
963 colsinfo_MapColumnIDs
966 static HRESULT WINAPI converttype_QueryInterface(IConvertType *iface, REFIID riid, void **out)
968 struct command *command = impl_from_IConvertType( iface );
969 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
972 static ULONG WINAPI converttype_AddRef(IConvertType *iface)
974 struct command *command = impl_from_IConvertType( iface );
975 return ICommandText_AddRef(&command->ICommandText_iface);
978 static ULONG WINAPI converttype_Release(IConvertType *iface)
980 struct command *command = impl_from_IConvertType( iface );
981 return ICommandText_Release(&command->ICommandText_iface);
984 static HRESULT WINAPI converttype_CanConvert(IConvertType *iface, DBTYPE from, DBTYPE to, DBCONVERTFLAGS flags)
986 struct command *command = impl_from_IConvertType( iface );
987 FIXME("%p, %u, %d, 0x%08x\n", command, from, to, flags);
988 return E_NOTIMPL;
991 static struct IConvertTypeVtbl converttypeVtbl =
993 converttype_QueryInterface,
994 converttype_AddRef,
995 converttype_Release,
996 converttype_CanConvert
999 static HRESULT WINAPI commandprepare_QueryInterface(ICommandPrepare *iface, REFIID riid, void **out)
1001 struct command *command = impl_from_ICommandPrepare( iface );
1002 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
1005 static ULONG WINAPI commandprepare_AddRef(ICommandPrepare *iface)
1007 struct command *command = impl_from_ICommandPrepare( iface );
1008 return ICommandText_AddRef(&command->ICommandText_iface);
1011 static ULONG WINAPI commandprepare_Release(ICommandPrepare *iface)
1013 struct command *command = impl_from_ICommandPrepare( iface );
1014 return ICommandText_Release(&command->ICommandText_iface);
1017 static HRESULT WINAPI commandprepare_Prepare(ICommandPrepare *iface, ULONG runs)
1019 struct command *command = impl_from_ICommandPrepare( iface );
1020 FIXME("%p, %u\n", command, runs);
1021 return E_NOTIMPL;
1024 static HRESULT WINAPI commandprepare_Unprepare(ICommandPrepare *iface)
1026 struct command *command = impl_from_ICommandPrepare( iface );
1027 FIXME("%p\n", command);
1028 return E_NOTIMPL;
1031 struct ICommandPrepareVtbl commandprepareVtbl =
1033 commandprepare_QueryInterface,
1034 commandprepare_AddRef,
1035 commandprepare_Release,
1036 commandprepare_Prepare,
1037 commandprepare_Unprepare
1040 static HRESULT WINAPI createcommand_CreateCommand(IDBCreateCommand *iface, IUnknown *outer, REFIID riid,
1041 IUnknown **out)
1043 struct msdasql_session *session = impl_from_IDBCreateCommand( iface );
1044 struct command *command;
1045 HRESULT hr;
1047 TRACE("%p, %p, %s, %p\n", session, outer, debugstr_guid(riid), out);
1049 if (outer)
1050 FIXME("Outer not currently supported\n");
1052 command = heap_alloc(sizeof(*command));
1053 if (!command)
1054 return E_OUTOFMEMORY;
1056 command->ICommandText_iface.lpVtbl = &commandVtbl;
1057 command->ICommandProperties_iface.lpVtbl = &commonpropsVtbl;
1058 command->IColumnsInfo_iface.lpVtbl = &columninfoVtbl;
1059 command->IConvertType_iface.lpVtbl = &converttypeVtbl;
1060 command->ICommandPrepare_iface.lpVtbl = &commandprepareVtbl;
1061 command->refs = 1;
1063 IUnknown_QueryInterface(&session->session_iface, &IID_IUnknown, (void**)&command->session);
1065 hr = ICommandText_QueryInterface(&command->ICommandText_iface, riid, (void**)out);
1066 ICommandText_Release(&command->ICommandText_iface);
1067 return hr;
1070 static const IDBCreateCommandVtbl createcommandVtbl =
1072 createcommand_QueryInterface,
1073 createcommand_AddRef,
1074 createcommand_Release,
1075 createcommand_CreateCommand
1078 HRESULT create_db_session(REFIID riid, void **unk)
1080 struct msdasql_session *session;
1081 HRESULT hr;
1083 session = heap_alloc(sizeof(*session));
1084 if (!session)
1085 return E_OUTOFMEMORY;
1087 session->session_iface.lpVtbl = &unkfactoryVtbl;
1088 session->IGetDataSource_iface.lpVtbl = &datasourceVtbl;
1089 session->IOpenRowset_iface.lpVtbl = &openrowsetVtbl;
1090 session->ISessionProperties_iface.lpVtbl = &propertiesVtbl;
1091 session->IDBCreateCommand_iface.lpVtbl = &createcommandVtbl;
1092 session->refs = 1;
1094 hr = IUnknown_QueryInterface(&session->session_iface, riid, unk);
1095 IUnknown_Release(&session->session_iface);
1096 return hr;