msdasql: Fix printf format warnings with long types.
[wine.git] / dlls / msdasql / session.c
blobabd8252218de5af19a991cd2af316d4b12cbc1df
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"
33 #include "sqlucode.h"
35 #include "msdasql_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msdasql);
39 struct msdasql_session
41 IUnknown session_iface;
42 IGetDataSource IGetDataSource_iface;
43 IOpenRowset IOpenRowset_iface;
44 ISessionProperties ISessionProperties_iface;
45 IDBCreateCommand IDBCreateCommand_iface;
46 ITransactionJoin ITransactionJoin_iface;
47 LONG refs;
49 IUnknown *datasource;
51 HDBC hdbc;
54 static inline struct msdasql_session *impl_from_IUnknown( IUnknown *iface )
56 return CONTAINING_RECORD( iface, struct msdasql_session, session_iface );
59 static inline struct msdasql_session *impl_from_IGetDataSource( IGetDataSource *iface )
61 return CONTAINING_RECORD( iface, struct msdasql_session, IGetDataSource_iface );
64 static inline struct msdasql_session *impl_from_IOpenRowset( IOpenRowset *iface )
66 return CONTAINING_RECORD( iface, struct msdasql_session, IOpenRowset_iface );
69 static inline struct msdasql_session *impl_from_ISessionProperties( ISessionProperties *iface )
71 return CONTAINING_RECORD( iface, struct msdasql_session, ISessionProperties_iface );
74 static inline struct msdasql_session *impl_from_IDBCreateCommand( IDBCreateCommand *iface )
76 return CONTAINING_RECORD( iface, struct msdasql_session, IDBCreateCommand_iface );
79 static inline struct msdasql_session *impl_from_ITransactionJoin( ITransactionJoin *iface )
81 return CONTAINING_RECORD( iface, struct msdasql_session, ITransactionJoin_iface );
84 static HRESULT WINAPI session_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
86 struct msdasql_session *session = impl_from_IUnknown( iface );
88 TRACE( "%p, %s, %p\n", iface, debugstr_guid(riid), ppv );
89 *ppv = NULL;
91 if(IsEqualGUID(&IID_IUnknown, riid))
93 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
94 *ppv = &session->session_iface;
96 else if(IsEqualGUID(&IID_IGetDataSource, riid))
98 TRACE("(%p)->(IID_IGetDataSource %p)\n", iface, ppv);
99 *ppv = &session->IGetDataSource_iface;
101 else if(IsEqualGUID(&IID_IOpenRowset, riid))
103 TRACE("(%p)->(IID_IOpenRowset %p)\n", iface, ppv);
104 *ppv = &session->IOpenRowset_iface;
106 else if(IsEqualGUID(&IID_ISessionProperties, riid))
108 TRACE("(%p)->(IID_ISessionProperties %p)\n", iface, ppv);
109 *ppv = &session->ISessionProperties_iface;
111 else if(IsEqualGUID(&IID_IDBCreateCommand, riid))
113 TRACE("(%p)->(IDBCreateCommand_iface %p)\n", iface, ppv);
114 *ppv = &session->IDBCreateCommand_iface;
116 else if(IsEqualGUID(&IID_ITransactionJoin, riid))
118 TRACE("(%p)->(ITransactionJoin %p)\n", iface, ppv);
119 *ppv = &session->ITransactionJoin_iface;
121 else if(IsEqualGUID(&IID_IBindResource, riid))
123 TRACE("(%p)->(IID_IBindResource not support)\n", iface);
124 return E_NOINTERFACE;
126 else if(IsEqualGUID(&IID_ICreateRow, riid))
128 TRACE("(%p)->(IID_ICreateRow not support)\n", iface);
129 return E_NOINTERFACE;
132 if(*ppv)
134 IUnknown_AddRef((IUnknown*)*ppv);
135 return S_OK;
138 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
139 return E_NOINTERFACE;
142 static ULONG WINAPI session_AddRef(IUnknown *iface)
144 struct msdasql_session *session = impl_from_IUnknown( iface );
145 LONG refs = InterlockedIncrement( &session->refs );
146 TRACE( "%p new refcount %ld\n", session, refs );
147 return refs;
150 static ULONG WINAPI session_Release(IUnknown *iface)
152 struct msdasql_session *session = impl_from_IUnknown( iface );
153 LONG refs = InterlockedDecrement( &session->refs );
154 TRACE( "%p new refcount %ld\n", session, refs );
155 if (!refs)
157 TRACE( "destroying %p\n", session );
159 IUnknown_Release(session->datasource);
160 heap_free( session );
162 return refs;
165 static const IUnknownVtbl unkfactoryVtbl =
167 session_QueryInterface,
168 session_AddRef,
169 session_Release,
173 HRESULT WINAPI datasource_QueryInterface(IGetDataSource *iface, REFIID riid, void **out)
175 struct msdasql_session *session = impl_from_IGetDataSource( iface );
176 return IUnknown_QueryInterface(&session->session_iface, riid, out);
179 ULONG WINAPI datasource_AddRef(IGetDataSource *iface)
181 struct msdasql_session *session = impl_from_IGetDataSource( iface );
182 return IUnknown_AddRef(&session->session_iface);
185 ULONG WINAPI datasource_Release(IGetDataSource *iface)
187 struct msdasql_session *session = impl_from_IGetDataSource( iface );
188 return IUnknown_Release(&session->session_iface);
191 HRESULT WINAPI datasource_GetDataSource(IGetDataSource *iface, REFIID riid, IUnknown **datasource)
193 struct msdasql_session *session = impl_from_IGetDataSource( iface );
195 TRACE("%p, %s, %p stub\n", session, debugstr_guid(riid), datasource);
197 if (!datasource)
198 return E_INVALIDARG;
200 return IUnknown_QueryInterface(session->datasource, riid, (void**)datasource);
203 static const IGetDataSourceVtbl datasourceVtbl =
205 datasource_QueryInterface,
206 datasource_AddRef,
207 datasource_Release,
208 datasource_GetDataSource
211 HRESULT WINAPI openrowset_QueryInterface(IOpenRowset *iface, REFIID riid, void **out)
213 struct msdasql_session *session = impl_from_IOpenRowset( iface );
214 return IUnknown_QueryInterface(&session->session_iface, riid, out);
217 ULONG WINAPI openrowset_AddRef(IOpenRowset *iface)
219 struct msdasql_session *session = impl_from_IOpenRowset( iface );
220 return IUnknown_AddRef(&session->session_iface);
223 ULONG WINAPI openrowset_Release(IOpenRowset *iface)
225 struct msdasql_session *session = impl_from_IOpenRowset( iface );
226 return IUnknown_Release(&session->session_iface);
229 HRESULT WINAPI openrowset_OpenRowset(IOpenRowset *iface, IUnknown *pUnkOuter, DBID *table,
230 DBID *index, REFIID riid, ULONG count, DBPROPSET propertysets[], IUnknown **rowset)
232 struct msdasql_session *session = impl_from_IOpenRowset( iface );
233 FIXME("%p, %p, %p %p %s, %ld %p %p stub\n", session, pUnkOuter, table, index, debugstr_guid(riid),
234 count, propertysets, rowset);
236 return E_NOTIMPL;
239 static const IOpenRowsetVtbl openrowsetVtbl =
241 openrowset_QueryInterface,
242 openrowset_AddRef,
243 openrowset_Release,
244 openrowset_OpenRowset
247 static HRESULT WINAPI properties_QueryInterface(ISessionProperties *iface, REFIID riid, void **out)
249 struct msdasql_session *session = impl_from_ISessionProperties( iface );
250 return IUnknown_QueryInterface(&session->session_iface, riid, out);
253 static ULONG WINAPI properties_AddRef(ISessionProperties *iface)
255 struct msdasql_session *session = impl_from_ISessionProperties( iface );
256 return IUnknown_AddRef(&session->session_iface);
259 static ULONG WINAPI properties_Release(ISessionProperties *iface)
261 struct msdasql_session *session = impl_from_ISessionProperties( iface );
262 return IUnknown_Release(&session->session_iface);
266 static HRESULT WINAPI properties_GetProperties(ISessionProperties *iface, ULONG set_count,
267 const DBPROPIDSET id_sets[], ULONG *count, DBPROPSET **sets)
269 struct msdasql_session *session = impl_from_ISessionProperties( iface );
270 FIXME("%p %lu %p %p %p\n", session, set_count, id_sets, count, sets);
272 return E_NOTIMPL;
275 static HRESULT WINAPI properties_SetProperties(ISessionProperties *iface, ULONG count,
276 DBPROPSET sets[])
278 struct msdasql_session *session = impl_from_ISessionProperties( iface );
279 FIXME("%p %lu %p\n", session, count, sets);
281 return S_OK;
284 static const ISessionPropertiesVtbl propertiesVtbl =
286 properties_QueryInterface,
287 properties_AddRef,
288 properties_Release,
289 properties_GetProperties,
290 properties_SetProperties
293 static HRESULT WINAPI createcommand_QueryInterface(IDBCreateCommand *iface, REFIID riid, void **out)
295 struct msdasql_session *session = impl_from_IDBCreateCommand( iface );
296 return IUnknown_QueryInterface(&session->session_iface, riid, out);
299 static ULONG WINAPI createcommand_AddRef(IDBCreateCommand *iface)
301 struct msdasql_session *session = impl_from_IDBCreateCommand( iface );
302 return IUnknown_AddRef(&session->session_iface);
305 static ULONG WINAPI createcommand_Release(IDBCreateCommand *iface)
307 struct msdasql_session *session = impl_from_IDBCreateCommand( iface );
308 return IUnknown_Release(&session->session_iface);
311 struct command
313 ICommandText ICommandText_iface;
314 ICommandProperties ICommandProperties_iface;
315 IColumnsInfo IColumnsInfo_iface;
316 IConvertType IConvertType_iface;
317 ICommandPrepare ICommandPrepare_iface;
318 ICommandWithParameters ICommandWithParameters_iface;
319 LONG refs;
320 WCHAR *query;
321 IUnknown *session;
322 HDBC hdbc;
323 SQLHSTMT hstmt;
326 static inline struct command *impl_from_ICommandText( ICommandText *iface )
328 return CONTAINING_RECORD( iface, struct command, ICommandText_iface );
331 static inline struct command *impl_from_ICommandProperties( ICommandProperties *iface )
333 return CONTAINING_RECORD( iface, struct command, ICommandProperties_iface );
336 static inline struct command *impl_from_IColumnsInfo( IColumnsInfo *iface )
338 return CONTAINING_RECORD( iface, struct command, IColumnsInfo_iface );
341 static inline struct command *impl_from_IConvertType( IConvertType *iface )
343 return CONTAINING_RECORD( iface, struct command, IConvertType_iface );
346 static inline struct command *impl_from_ICommandPrepare( ICommandPrepare *iface )
348 return CONTAINING_RECORD( iface, struct command, ICommandPrepare_iface );
351 static inline struct command *impl_from_ICommandWithParameters( ICommandWithParameters *iface )
353 return CONTAINING_RECORD( iface, struct command, ICommandWithParameters_iface );
356 static HRESULT WINAPI command_QueryInterface(ICommandText *iface, REFIID riid, void **ppv)
358 struct command *command = impl_from_ICommandText( iface );
360 TRACE( "%p, %s, %p\n", command, debugstr_guid(riid), ppv );
361 *ppv = NULL;
363 if(IsEqualGUID(&IID_IUnknown, riid) ||
364 IsEqualGUID(&IID_ICommand, riid) ||
365 IsEqualGUID(&IID_ICommandText, riid))
367 *ppv = &command->ICommandText_iface;
369 else if(IsEqualGUID(&IID_ICommandProperties, riid))
371 *ppv = &command->ICommandProperties_iface;
373 else if(IsEqualGUID(&IID_IColumnsInfo, riid))
375 *ppv = &command->IColumnsInfo_iface;
377 else if(IsEqualGUID(&IID_IConvertType, riid))
379 *ppv = &command->IConvertType_iface;
381 else if(IsEqualGUID(&IID_ICommandPrepare, riid))
383 *ppv = &command->ICommandPrepare_iface;
385 else if(IsEqualGUID(&IID_ICommandWithParameters, riid))
387 *ppv = &command->ICommandWithParameters_iface;
390 if(*ppv)
392 IUnknown_AddRef((IUnknown*)*ppv);
393 return S_OK;
395 else if (IsEqualGUID(&IID_IMultipleResults, riid))
397 TRACE("IID_IMultipleResults not supported\n");
398 return E_NOINTERFACE;
400 else if(IsEqualGUID(&IID_ICommandStream, riid))
402 TRACE("ICommandStream not support\n");
403 return E_NOINTERFACE;
405 else if (IsEqualGUID(&IID_IRowsetChange, riid))
407 TRACE("IID_IRowsetChange not supported\n");
408 return E_NOINTERFACE;
410 else if (IsEqualGUID(&IID_IRowsetUpdate, riid))
412 TRACE("IID_IRowsetUpdate not supported\n");
413 return E_NOINTERFACE;
415 else if (IsEqualGUID(&IID_IRowsetLocate, riid))
417 TRACE("IID_IRowsetLocate not supported\n");
418 return E_NOINTERFACE;
421 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
422 return E_NOINTERFACE;
425 static ULONG WINAPI command_AddRef(ICommandText *iface)
427 struct command *command = impl_from_ICommandText( iface );
428 LONG refs = InterlockedIncrement( &command->refs );
429 TRACE( "%p new refcount %ld\n", command, refs );
430 return refs;
433 static ULONG WINAPI command_Release(ICommandText *iface)
435 struct command *command = impl_from_ICommandText( iface );
436 LONG refs = InterlockedDecrement( &command->refs );
437 TRACE( "%p new refcount %ld\n", command, refs );
438 if (!refs)
440 TRACE( "destroying %p\n", command );
441 if (command->session)
442 IUnknown_Release(command->session);
444 if (command->hstmt)
445 SQLFreeHandle(SQL_HANDLE_STMT, command->hstmt);
447 heap_free( command->query );
448 heap_free( command );
450 return refs;
453 static HRESULT WINAPI command_Cancel(ICommandText *iface)
455 struct command *command = impl_from_ICommandText( iface );
456 FIXME("%p\n", command);
457 return E_NOTIMPL;
460 struct msdasql_rowset
462 IRowset IRowset_iface;
463 IRowsetInfo IRowsetInfo_iface;
464 IColumnsInfo IColumnsInfo_iface;
465 IAccessor IAccessor_iface;
466 IColumnsRowset IColumnsRowset_iface;
467 IUnknown *caller;
468 LONG refs;
471 static inline struct msdasql_rowset *impl_from_IRowset( IRowset *iface )
473 return CONTAINING_RECORD( iface, struct msdasql_rowset, IRowset_iface );
476 static inline struct msdasql_rowset *impl_from_IRowsetInfo( IRowsetInfo *iface )
478 return CONTAINING_RECORD( iface, struct msdasql_rowset, IRowsetInfo_iface );
481 static inline struct msdasql_rowset *rowset_impl_from_IColumnsInfo( IColumnsInfo *iface )
483 return CONTAINING_RECORD( iface, struct msdasql_rowset, IColumnsInfo_iface );
486 static inline struct msdasql_rowset *impl_from_IAccessor ( IAccessor *iface )
488 return CONTAINING_RECORD( iface, struct msdasql_rowset, IAccessor_iface );
491 static inline struct msdasql_rowset *impl_from_IColumnsRowset ( IColumnsRowset *iface )
493 return CONTAINING_RECORD( iface, struct msdasql_rowset, IColumnsRowset_iface );
496 static HRESULT WINAPI msdasql_rowset_QueryInterface(IRowset *iface, REFIID riid, void **ppv)
498 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
500 TRACE( "%p, %s, %p\n", rowset, debugstr_guid(riid), ppv );
502 *ppv = NULL;
503 if(IsEqualGUID(&IID_IUnknown, riid) ||
504 IsEqualGUID(&IID_IRowset, riid))
506 *ppv = &rowset->IRowset_iface;
508 else if (IsEqualGUID(&IID_IRowsetInfo, riid))
510 *ppv = &rowset->IRowsetInfo_iface;
512 else if (IsEqualGUID(&IID_IColumnsInfo, riid))
514 *ppv = &rowset->IColumnsInfo_iface;
516 else if(IsEqualGUID(&IID_IAccessor, riid))
518 *ppv = &rowset->IAccessor_iface;
520 else if(IsEqualGUID(&IID_IColumnsRowset, riid))
522 *ppv = &rowset->IColumnsRowset_iface;
524 else if (IsEqualGUID(&IID_IRowsetChange, riid))
526 TRACE("IID_IRowsetChange not supported\n");
527 return E_NOINTERFACE;
529 else if (IsEqualGUID(&IID_IRowsetUpdate, riid))
531 TRACE("IID_IRowsetUpdate not supported\n");
532 return E_NOINTERFACE;
534 else if (IsEqualGUID(&IID_IRowsetLocate, riid))
536 TRACE("IID_IRowsetLocate not supported\n");
537 return E_NOINTERFACE;
540 if(*ppv)
542 IUnknown_AddRef((IUnknown*)*ppv);
543 return S_OK;
546 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
547 return E_NOINTERFACE;
550 static ULONG WINAPI msdasql_rowset_AddRef(IRowset *iface)
552 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
553 LONG refs = InterlockedIncrement( &rowset->refs );
554 TRACE( "%p new refcount %ld\n", rowset, refs );
555 return refs;
558 static ULONG WINAPI msdasql_rowset_Release(IRowset *iface)
560 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
561 LONG refs = InterlockedDecrement( &rowset->refs );
562 TRACE( "%p new refcount %ld\n", rowset, refs );
563 if (!refs)
565 TRACE( "destroying %p\n", rowset );
567 if (rowset->caller)
568 IUnknown_Release(rowset->caller);
570 heap_free( rowset );
572 return refs;
575 static HRESULT WINAPI msdasql_rowset_AddRefRows(IRowset *iface, DBCOUNTITEM count,
576 const HROW rows[], DBREFCOUNT ref_counts[], DBROWSTATUS status[])
578 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
579 FIXME("%p, %Id, %p, %p, %p\n", rowset, count, rows, ref_counts, status);
580 return E_NOTIMPL;
583 static HRESULT WINAPI msdasql_rowset_GetData(IRowset *iface, HROW row, HACCESSOR accessor, void *data)
585 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
586 FIXME("%p, %Id, %Id, %p\n", rowset, row, accessor, data);
587 return E_NOTIMPL;
590 static HRESULT WINAPI msdasql_rowset_GetNextRows(IRowset *iface, HCHAPTER reserved, DBROWOFFSET offset,
591 DBROWCOUNT count, DBCOUNTITEM *obtained, HROW **rows)
593 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
594 FIXME("%p, %Id, %Id, %Id, %p, %p\n", rowset, reserved, offset, count, obtained, rows);
595 return E_NOTIMPL;
598 static HRESULT WINAPI msdasql_rowset_ReleaseRows(IRowset *iface, DBCOUNTITEM count,
599 const HROW rows[], DBROWOPTIONS options[], DBREFCOUNT ref_counts[], DBROWSTATUS status[])
601 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
603 FIXME("%p, %Id, %p, %p, %p, %p\n", rowset, count, rows, options, ref_counts, status);
604 return E_NOTIMPL;
607 static HRESULT WINAPI msdasql_rowset_RestartPosition(IRowset *iface, HCHAPTER reserved)
609 struct msdasql_rowset *rowset = impl_from_IRowset( iface );
610 FIXME("%p, %Id\n", rowset, reserved);
611 return E_NOTIMPL;
614 static const struct IRowsetVtbl msdasql_rowset_vtbl =
616 msdasql_rowset_QueryInterface,
617 msdasql_rowset_AddRef,
618 msdasql_rowset_Release,
619 msdasql_rowset_AddRefRows,
620 msdasql_rowset_GetData,
621 msdasql_rowset_GetNextRows,
622 msdasql_rowset_ReleaseRows,
623 msdasql_rowset_RestartPosition
626 static HRESULT WINAPI rowset_info_QueryInterface(IRowsetInfo *iface, REFIID riid, void **ppv)
628 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
629 return IRowset_QueryInterface(&rowset->IRowset_iface, riid, ppv);
632 static ULONG WINAPI rowset_info_AddRef(IRowsetInfo *iface)
634 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
635 return IRowset_AddRef(&rowset->IRowset_iface);
638 static ULONG WINAPI rowset_info_Release(IRowsetInfo *iface)
640 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
641 return IRowset_Release(&rowset->IRowset_iface);
644 static HRESULT WINAPI rowset_info_GetProperties(IRowsetInfo *iface, const ULONG count,
645 const DBPROPIDSET propertyidsets[], ULONG *out_count, DBPROPSET **propertysets)
647 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
648 FIXME("%p, %lu, %p, %p, %p\n", rowset, count, propertyidsets, out_count, propertysets);
649 return E_NOTIMPL;
652 static HRESULT WINAPI rowset_info_GetReferencedRowset(IRowsetInfo *iface, DBORDINAL ordinal,
653 REFIID riid, IUnknown **unk)
655 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
656 FIXME("%p, %Id, %s, %p\n", rowset, ordinal, debugstr_guid(riid), unk);
657 return E_NOTIMPL;
660 static HRESULT WINAPI rowset_info_GetSpecification(IRowsetInfo *iface, REFIID riid,
661 IUnknown **specification)
663 struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
665 TRACE("%p, %s, %p\n", rowset, debugstr_guid(riid), specification);
667 if (!specification)
668 return E_INVALIDARG;
670 if (!rowset->caller)
671 return S_FALSE;
673 return IUnknown_QueryInterface(rowset->caller, riid, (void**)specification);
676 struct IRowsetInfoVtbl rowset_info_vtbl =
678 rowset_info_QueryInterface,
679 rowset_info_AddRef,
680 rowset_info_Release,
681 rowset_info_GetProperties,
682 rowset_info_GetReferencedRowset,
683 rowset_info_GetSpecification
686 static HRESULT WINAPI rowset_colsinfo_QueryInterface(IColumnsInfo *iface, REFIID riid, void **out)
688 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
689 return IRowset_QueryInterface(&rowset->IRowset_iface, riid, out);
692 static ULONG WINAPI rowset_colsinfo_AddRef(IColumnsInfo *iface)
694 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
695 return IRowset_AddRef(&rowset->IRowset_iface);
698 static ULONG WINAPI rowset_colsinfo_Release(IColumnsInfo *iface)
700 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
701 return IRowset_Release(&rowset->IRowset_iface);
704 static HRESULT WINAPI rowset_colsinfo_GetColumnInfo(IColumnsInfo *iface, DBORDINAL *columns,
705 DBCOLUMNINFO **colinfo, OLECHAR **stringsbuffer)
707 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
708 FIXME("%p, %p, %p, %p\n", rowset, columns, colinfo, stringsbuffer);
709 return E_NOTIMPL;
712 static HRESULT WINAPI rowset_colsinfo_MapColumnIDs(IColumnsInfo *iface, DBORDINAL column_ids,
713 const DBID *dbids, DBORDINAL *columns)
715 struct msdasql_rowset *rowset = rowset_impl_from_IColumnsInfo( iface );
716 FIXME("%p, %Id, %p, %p\n", rowset, column_ids, dbids, columns);
717 return E_NOTIMPL;
720 static struct IColumnsInfoVtbl rowset_columninfo_vtbll =
722 rowset_colsinfo_QueryInterface,
723 rowset_colsinfo_AddRef,
724 rowset_colsinfo_Release,
725 rowset_colsinfo_GetColumnInfo,
726 rowset_colsinfo_MapColumnIDs
729 static HRESULT WINAPI rowset_accessor_QueryInterface(IAccessor *iface, REFIID riid, void **out)
731 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
732 return IRowset_QueryInterface(&rowset->IRowset_iface, riid, out);
735 static ULONG WINAPI rowset_accessor_AddRef(IAccessor *iface)
737 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
738 return IRowset_AddRef(&rowset->IRowset_iface);
741 static ULONG WINAPI rowset_accessor_Release(IAccessor *iface)
743 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
744 return IRowset_Release(&rowset->IRowset_iface);
747 static HRESULT WINAPI rowset_accessor_AddRefAccessor(IAccessor *iface, HACCESSOR accessor, DBREFCOUNT *count)
749 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
750 FIXME("%p, %Id, %p\n", rowset, accessor, count);
751 return E_NOTIMPL;
754 static HRESULT WINAPI rowset_accessor_CreateAccessor(IAccessor *iface, DBACCESSORFLAGS flags,
755 DBCOUNTITEM count, const DBBINDING bindings[], DBLENGTH row_size, HACCESSOR *accessor,
756 DBBINDSTATUS status[])
758 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
759 FIXME("%p, 0x%08lx, %Id, %p, %Id, %p, %p\n", rowset, flags, count, bindings, row_size, accessor, status);
760 return E_NOTIMPL;
763 static HRESULT WINAPI rowset_accessor_GetBindings(IAccessor *iface, HACCESSOR accessor,
764 DBACCESSORFLAGS *flags, DBCOUNTITEM *count, DBBINDING **bindings)
766 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
767 FIXME("%p, %Id, %p, %p, %p\n", rowset, accessor, flags, count, bindings);
768 return E_NOTIMPL;
771 static HRESULT WINAPI rowset_accessor_ReleaseAccessor(IAccessor *iface, HACCESSOR accessor, DBREFCOUNT *count)
773 struct msdasql_rowset *rowset = impl_from_IAccessor( iface );
774 FIXME("%p, %Id, %p\n", rowset, accessor, count);
775 return E_NOTIMPL;
778 struct IAccessorVtbl accessor_vtbl =
780 rowset_accessor_QueryInterface,
781 rowset_accessor_AddRef,
782 rowset_accessor_Release,
783 rowset_accessor_AddRefAccessor,
784 rowset_accessor_CreateAccessor,
785 rowset_accessor_GetBindings,
786 rowset_accessor_ReleaseAccessor
789 static HRESULT WINAPI column_rs_QueryInterface(IColumnsRowset *iface, REFIID riid, void **out)
791 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
792 return IRowset_QueryInterface(&rowset->IRowset_iface, riid, out);
795 static ULONG WINAPI column_rs_AddRef(IColumnsRowset *iface)
797 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
798 return IRowset_AddRef(&rowset->IRowset_iface);
801 static ULONG WINAPI column_rs_Release(IColumnsRowset *iface)
803 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
804 return IRowset_Release(&rowset->IRowset_iface);
807 static HRESULT WINAPI column_rs_GetAvailableColumns(IColumnsRowset *iface, DBORDINAL *count, DBID **columns)
809 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
810 FIXME("%p, %p, %p\n", rowset, count, columns);
811 return E_NOTIMPL;
814 static HRESULT WINAPI column_rs_GetColumnsRowset(IColumnsRowset *iface, IUnknown *outer, DBORDINAL count,
815 const DBID columns[], REFIID riid, ULONG property_cnt, DBPROPSET property_sets[], IUnknown **unk_rs)
817 struct msdasql_rowset *rowset = impl_from_IColumnsRowset( iface );
818 FIXME("(%p)->(%p, %Id, %p, %s, %lu, %p, %p): stub\n", rowset, outer, count, columns, debugstr_guid(riid),
819 property_cnt, property_sets, unk_rs);
820 return E_NOTIMPL;
823 struct IColumnsRowsetVtbl columnrs_rs_vtbl =
825 column_rs_QueryInterface,
826 column_rs_AddRef,
827 column_rs_Release,
828 column_rs_GetAvailableColumns,
829 column_rs_GetColumnsRowset
832 static HRESULT WINAPI command_Execute(ICommandText *iface, IUnknown *outer, REFIID riid,
833 DBPARAMS *params, DBROWCOUNT *affected, IUnknown **rowset)
835 struct command *command = impl_from_ICommandText( iface );
836 struct msdasql_rowset *msrowset;
837 HRESULT hr;
839 FIXME("%p, %p, %s, %p %p %p Semi Stub\n", command, outer, debugstr_guid(riid), params, affected, rowset);
841 msrowset = heap_alloc(sizeof(*msrowset));
842 if (!msrowset)
843 return E_OUTOFMEMORY;
845 msrowset->IRowset_iface.lpVtbl = &msdasql_rowset_vtbl;
846 msrowset->IRowsetInfo_iface.lpVtbl = &rowset_info_vtbl;
847 msrowset->IColumnsInfo_iface.lpVtbl = &rowset_columninfo_vtbll;
848 msrowset->IAccessor_iface.lpVtbl = &accessor_vtbl;
849 msrowset->IColumnsRowset_iface.lpVtbl = &columnrs_rs_vtbl;
850 msrowset->refs = 1;
851 ICommandText_QueryInterface(iface, &IID_IUnknown, (void**)&msrowset->caller);
853 if (affected)
854 *affected = 0; /* FIXME */
856 hr = IRowset_QueryInterface(&msrowset->IRowset_iface, riid, (void**)rowset);
857 IRowset_Release(&msrowset->IRowset_iface);
859 return hr;
862 static HRESULT WINAPI command_GetDBSession(ICommandText *iface, REFIID riid, IUnknown **session)
864 struct command *command = impl_from_ICommandText( iface );
866 TRACE("%p, %s, %p\n", command, debugstr_guid(riid), session);
868 if (!session)
869 return E_INVALIDARG;
871 *session = NULL;
873 if (!command->session)
874 return S_FALSE;
876 return IUnknown_QueryInterface(command->session, riid, (void**)session);
879 static HRESULT WINAPI command_GetCommandText(ICommandText *iface, GUID *dialect, LPOLESTR *commandstr)
881 struct command *command = impl_from_ICommandText( iface );
882 HRESULT hr = S_OK;
883 TRACE("%p, %p, %p\n", command, dialect, commandstr);
885 if (!command->query)
886 return DB_E_NOCOMMAND;
888 if (dialect && !IsEqualGUID(&DBGUID_DEFAULT, dialect))
890 *dialect = DBGUID_DEFAULT;
891 hr = DB_S_DIALECTIGNORED;
894 *commandstr = heap_alloc((lstrlenW(command->query)+1)*sizeof(WCHAR));
895 wcscpy(*commandstr, command->query);
896 return hr;
899 static HRESULT WINAPI command_SetCommandText(ICommandText *iface, REFGUID dialect, LPCOLESTR commandstr)
901 struct command *command = impl_from_ICommandText( iface );
902 TRACE("%p, %s, %s\n", command, debugstr_guid(dialect), debugstr_w(commandstr));
904 if (!IsEqualGUID(&DBGUID_DEFAULT, dialect))
905 FIXME("Currently non Default Dialect isn't supported\n");
907 heap_free(command->query);
909 if (commandstr)
911 command->query = heap_alloc((lstrlenW(commandstr)+1)*sizeof(WCHAR));
912 if (!command->query)
913 return E_OUTOFMEMORY;
915 wcscpy(command->query, commandstr);
917 else
918 command->query = NULL;
919 return S_OK;
922 static const ICommandTextVtbl commandVtbl =
924 command_QueryInterface,
925 command_AddRef,
926 command_Release,
927 command_Cancel,
928 command_Execute,
929 command_GetDBSession,
930 command_GetCommandText,
931 command_SetCommandText
934 static HRESULT WINAPI command_prop_QueryInterface(ICommandProperties *iface, REFIID riid, void **out)
936 struct command *command = impl_from_ICommandProperties( iface );
937 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
940 static ULONG WINAPI command_prop_AddRef(ICommandProperties *iface)
942 struct command *command = impl_from_ICommandProperties( iface );
943 return ICommandText_AddRef(&command->ICommandText_iface);
946 static ULONG WINAPI command_prop_Release(ICommandProperties *iface)
948 struct command *command = impl_from_ICommandProperties( iface );
949 return ICommandText_Release(&command->ICommandText_iface);
952 static HRESULT WINAPI command_prop_GetProperties(ICommandProperties *iface, ULONG count,
953 const DBPROPIDSET propertyidsets[], ULONG *sets_cnt, DBPROPSET **propertyset)
955 struct command *command = impl_from_ICommandProperties( iface );
956 FIXME("%p %lu %p %p %p\n", command, count, propertyidsets, sets_cnt, propertyset);
957 return E_NOTIMPL;
960 static HRESULT WINAPI command_prop_SetProperties(ICommandProperties *iface, ULONG count,
961 DBPROPSET propertyset[])
963 struct command *command = impl_from_ICommandProperties( iface );
964 FIXME("%p, %lu, %p\n", command, count, propertyset);
965 return S_OK;
968 static const ICommandPropertiesVtbl commonpropsVtbl =
970 command_prop_QueryInterface,
971 command_prop_AddRef,
972 command_prop_Release,
973 command_prop_GetProperties,
974 command_prop_SetProperties
977 static HRESULT WINAPI colsinfo_QueryInterface(IColumnsInfo *iface, REFIID riid, void **out)
979 struct command *command = impl_from_IColumnsInfo( iface );
980 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
983 static ULONG WINAPI colsinfo_AddRef(IColumnsInfo *iface)
985 struct command *command = impl_from_IColumnsInfo( iface );
986 return ICommandText_AddRef(&command->ICommandText_iface);
989 static ULONG WINAPI colsinfo_Release(IColumnsInfo *iface)
991 struct command *command = impl_from_IColumnsInfo( iface );
992 return ICommandText_Release(&command->ICommandText_iface);
995 static HRESULT WINAPI colsinfo_GetColumnInfo(IColumnsInfo *iface, DBORDINAL *columns,
996 DBCOLUMNINFO **colinfo, OLECHAR **stringsbuffer)
998 struct command *command = impl_from_IColumnsInfo( iface );
999 FIXME("%p, %p, %p, %p\n", command, columns, colinfo, stringsbuffer);
1000 return E_NOTIMPL;
1003 static HRESULT WINAPI colsinfo_MapColumnIDs(IColumnsInfo *iface, DBORDINAL column_ids,
1004 const DBID *dbids, DBORDINAL *columns)
1006 struct command *command = impl_from_IColumnsInfo( iface );
1007 FIXME("%p, %Iu, %p, %p\n", command, column_ids, dbids, columns);
1008 return E_NOTIMPL;
1011 static struct IColumnsInfoVtbl columninfoVtbl =
1013 colsinfo_QueryInterface,
1014 colsinfo_AddRef,
1015 colsinfo_Release,
1016 colsinfo_GetColumnInfo,
1017 colsinfo_MapColumnIDs
1020 static HRESULT WINAPI converttype_QueryInterface(IConvertType *iface, REFIID riid, void **out)
1022 struct command *command = impl_from_IConvertType( iface );
1023 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
1026 static ULONG WINAPI converttype_AddRef(IConvertType *iface)
1028 struct command *command = impl_from_IConvertType( iface );
1029 return ICommandText_AddRef(&command->ICommandText_iface);
1032 static ULONG WINAPI converttype_Release(IConvertType *iface)
1034 struct command *command = impl_from_IConvertType( iface );
1035 return ICommandText_Release(&command->ICommandText_iface);
1038 static HRESULT WINAPI converttype_CanConvert(IConvertType *iface, DBTYPE from, DBTYPE to, DBCONVERTFLAGS flags)
1040 struct command *command = impl_from_IConvertType( iface );
1041 FIXME("%p, %u, %d, 0x%08lx\n", command, from, to, flags);
1042 return E_NOTIMPL;
1045 static struct IConvertTypeVtbl converttypeVtbl =
1047 converttype_QueryInterface,
1048 converttype_AddRef,
1049 converttype_Release,
1050 converttype_CanConvert
1053 static HRESULT WINAPI commandprepare_QueryInterface(ICommandPrepare *iface, REFIID riid, void **out)
1055 struct command *command = impl_from_ICommandPrepare( iface );
1056 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
1059 static ULONG WINAPI commandprepare_AddRef(ICommandPrepare *iface)
1061 struct command *command = impl_from_ICommandPrepare( iface );
1062 return ICommandText_AddRef(&command->ICommandText_iface);
1065 static ULONG WINAPI commandprepare_Release(ICommandPrepare *iface)
1067 struct command *command = impl_from_ICommandPrepare( iface );
1068 return ICommandText_Release(&command->ICommandText_iface);
1071 static HRESULT WINAPI commandprepare_Prepare(ICommandPrepare *iface, ULONG runs)
1073 struct command *command = impl_from_ICommandPrepare( iface );
1074 RETCODE ret;
1076 TRACE("%p, %lu\n", command, runs);
1078 if (!command->query)
1079 return DB_E_NOCOMMAND;
1081 if (command->hstmt)
1082 SQLFreeHandle(SQL_HANDLE_STMT, command->hstmt);
1084 SQLAllocHandle(SQL_HANDLE_STMT, command->hdbc, &command->hstmt);
1086 ret = SQLPrepareW(command->hstmt, command->query, SQL_NTS);
1087 if (ret != SQL_SUCCESS)
1089 dump_sql_diag_records(SQL_HANDLE_STMT, command->hstmt);
1090 return E_FAIL;
1092 return S_OK;
1095 static HRESULT WINAPI commandprepare_Unprepare(ICommandPrepare *iface)
1097 struct command *command = impl_from_ICommandPrepare( iface );
1098 TRACE("%p\n", command);
1099 return S_OK;
1102 struct ICommandPrepareVtbl commandprepareVtbl =
1104 commandprepare_QueryInterface,
1105 commandprepare_AddRef,
1106 commandprepare_Release,
1107 commandprepare_Prepare,
1108 commandprepare_Unprepare
1111 static HRESULT WINAPI cmd_with_params_QueryInterface(ICommandWithParameters *iface, REFIID riid, void **out)
1113 struct command *command = impl_from_ICommandWithParameters( iface );
1114 return ICommandText_QueryInterface(&command->ICommandText_iface, riid, out);
1117 static ULONG WINAPI cmd_with_params_AddRef(ICommandWithParameters *iface)
1119 struct command *command = impl_from_ICommandWithParameters( iface );
1120 return ICommandText_AddRef(&command->ICommandText_iface);
1123 static ULONG WINAPI cmd_with_params_Release(ICommandWithParameters *iface)
1125 struct command *command = impl_from_ICommandWithParameters( iface );
1126 return ICommandText_Release(&command->ICommandText_iface);
1129 static HRESULT WINAPI cmd_with_params_GetParameterInfo(ICommandWithParameters *iface, DB_UPARAMS *uparams,
1130 DBPARAMINFO **info, OLECHAR **buffer)
1132 struct command *command = impl_from_ICommandWithParameters( iface );
1133 FIXME("%p, %p, %p, %p\n", command, uparams, info, buffer);
1134 return E_NOTIMPL;
1137 static HRESULT WINAPI cmd_with_params_MapParameterNames(ICommandWithParameters *iface, DB_UPARAMS uparams,
1138 LPCWSTR names[], DB_LPARAMS ordinals[])
1140 struct command *command = impl_from_ICommandWithParameters( iface );
1141 FIXME("%p, %Iu, %p, %p\n", command, uparams, names, ordinals);
1142 return E_NOTIMPL;
1145 static HRESULT WINAPI cmd_with_params_SetParameterInfo(ICommandWithParameters *iface, DB_UPARAMS uparams,
1146 const DB_UPARAMS ordinals[], const DBPARAMBINDINFO bindinfo[])
1148 struct command *command = impl_from_ICommandWithParameters( iface );
1149 FIXME("%p, %Iu, %p, %p\n", command, uparams, ordinals, bindinfo);
1150 return E_NOTIMPL;
1153 struct ICommandWithParametersVtbl command_with_params_vtbl =
1155 cmd_with_params_QueryInterface,
1156 cmd_with_params_AddRef,
1157 cmd_with_params_Release,
1158 cmd_with_params_GetParameterInfo,
1159 cmd_with_params_MapParameterNames,
1160 cmd_with_params_SetParameterInfo
1163 static HRESULT WINAPI createcommand_CreateCommand(IDBCreateCommand *iface, IUnknown *outer, REFIID riid,
1164 IUnknown **out)
1166 struct msdasql_session *session = impl_from_IDBCreateCommand( iface );
1167 struct command *command;
1168 HRESULT hr;
1170 TRACE("%p, %p, %s, %p\n", session, outer, debugstr_guid(riid), out);
1172 if (outer)
1173 FIXME("Outer not currently supported\n");
1175 command = heap_alloc(sizeof(*command));
1176 if (!command)
1177 return E_OUTOFMEMORY;
1179 command->ICommandText_iface.lpVtbl = &commandVtbl;
1180 command->ICommandProperties_iface.lpVtbl = &commonpropsVtbl;
1181 command->IColumnsInfo_iface.lpVtbl = &columninfoVtbl;
1182 command->IConvertType_iface.lpVtbl = &converttypeVtbl;
1183 command->ICommandPrepare_iface.lpVtbl = &commandprepareVtbl;
1184 command->ICommandWithParameters_iface.lpVtbl = &command_with_params_vtbl;
1185 command->refs = 1;
1186 command->query = NULL;
1187 command->hdbc = session->hdbc;
1188 command->hstmt = NULL;
1190 IUnknown_QueryInterface(&session->session_iface, &IID_IUnknown, (void**)&command->session);
1192 hr = ICommandText_QueryInterface(&command->ICommandText_iface, riid, (void**)out);
1193 ICommandText_Release(&command->ICommandText_iface);
1194 return hr;
1197 static const IDBCreateCommandVtbl createcommandVtbl =
1199 createcommand_QueryInterface,
1200 createcommand_AddRef,
1201 createcommand_Release,
1202 createcommand_CreateCommand
1205 static HRESULT WINAPI transjoin_QueryInterface(ITransactionJoin *iface, REFIID riid, void **out)
1207 struct msdasql_session *session = impl_from_ITransactionJoin( iface );
1208 return IUnknown_QueryInterface(&session->session_iface, riid, out);
1211 static ULONG WINAPI transjoin_AddRef(ITransactionJoin *iface)
1213 struct msdasql_session *session = impl_from_ITransactionJoin( iface );
1214 return IUnknown_AddRef(&session->session_iface);
1217 static ULONG WINAPI transjoin_Release(ITransactionJoin *iface)
1219 struct msdasql_session *session = impl_from_ITransactionJoin( iface );
1220 return IUnknown_Release(&session->session_iface);
1223 static HRESULT WINAPI transjoin_GetOptionsObject(ITransactionJoin *iface, ITransactionOptions **options)
1225 struct msdasql_session *session = impl_from_ITransactionJoin( iface );
1227 FIXME("%p, %p\n", session, options);
1229 return E_NOTIMPL;
1232 static HRESULT WINAPI transjoin_JoinTransaction(ITransactionJoin *iface, IUnknown *unk, ISOLEVEL level,
1233 ULONG flags, ITransactionOptions *options)
1235 struct msdasql_session *session = impl_from_ITransactionJoin( iface );
1237 FIXME("%p, %p, %lu, 0x%08lx, %p\n", session, unk, level, flags, options);
1239 return E_NOTIMPL;
1242 static const ITransactionJoinVtbl transactionjoinVtbl =
1244 transjoin_QueryInterface,
1245 transjoin_AddRef,
1246 transjoin_Release,
1247 transjoin_GetOptionsObject,
1248 transjoin_JoinTransaction
1251 HRESULT create_db_session(REFIID riid, IUnknown *datasource, HDBC hdbc, void **unk)
1253 struct msdasql_session *session;
1254 HRESULT hr;
1256 session = heap_alloc(sizeof(*session));
1257 if (!session)
1258 return E_OUTOFMEMORY;
1260 session->session_iface.lpVtbl = &unkfactoryVtbl;
1261 session->IGetDataSource_iface.lpVtbl = &datasourceVtbl;
1262 session->IOpenRowset_iface.lpVtbl = &openrowsetVtbl;
1263 session->ISessionProperties_iface.lpVtbl = &propertiesVtbl;
1264 session->IDBCreateCommand_iface.lpVtbl = &createcommandVtbl;
1265 session->ITransactionJoin_iface.lpVtbl = &transactionjoinVtbl;
1266 IUnknown_QueryInterface(datasource, &IID_IUnknown, (void**)&session->datasource);
1267 session->refs = 1;
1268 session->hdbc = hdbc;
1270 hr = IUnknown_QueryInterface(&session->session_iface, riid, unk);
1271 IUnknown_Release(&session->session_iface);
1272 return hr;