-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcommand.cpp
More file actions
118 lines (97 loc) · 4.02 KB
/
command.cpp
File metadata and controls
118 lines (97 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
ODBO provider for XMLA data stores
Copyright (C) 2014-2015 ARquery LTD
http://www.arquery.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@description
command methods
*/
#include "stdafx.h"
#include "rowset.h"
#include "tabular_rowset.h"
#include "session.h"
#include "connection_handler.h"
#include "axis_rowset.h"
int (*connection_handler::fparsehdr)(struct soap*, const char*, const char*) = nullptr;
STDMETHODIMP command::Execute(IUnknown * pUnkOuter, REFIID riid, DBPARAMS * pParams, DBROWCOUNT * pcRowsAffected, IUnknown ** ppRowset)
{
IUnknown* pSessUnk = NULL;
GetSite( __uuidof( IUnknown ), ( void** ) &pSessUnk );
mConnectionHandler.reset( new connection_handler( pSessUnk ) );
pSessUnk->Release();
int result = mConnectionHandler->execute( CW2A( m_strCommandText.m_str, CP_UTF8 ) );
if ( mConnectionHandler->no_session() ) {
result = mConnectionHandler->execute( CW2A( m_strCommandText.m_str, CP_UTF8 ) );
}
if ( S_OK != result ) {
make_error( FROM_STRING( mConnectionHandler->fault_string(), CP_UTF8 ) );
return E_FAIL;
}
//RIA: this is to corect a "contradiction" in the curent ATL implementation.
//atldb.h has (line 6195)
//if (InlineIsEqualGUID(IID_NULL, riid))
// {
// ATLTRACE(atlTraceDBProvider, 2, _T("IID_NULL was specified in Execute, returning S_OK"));
// return S_OK;
// }
//the same method goes on as accepting IID_NULL and has toward the end (line 6306)
//if (InlineIsEqualGUID(riid, IID_NULL) || ppRowset == NULL)
//{
// if (ppRowset != NULL)
// *ppRowset = NULL;
// return hrExecute;
//}
//line 6306 is consistent to the documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/ms718095(v=vs.85).aspx thas states:
//If this is IID_NULL, ppRowset is ignored and no rowset is returned, even if the command would otherwise generate a rowset. Specifying IID_NULL
//is useful in the case of text commands that do not generate rowsets, such as data definition commands, as a hint to the provider that no rowset
//properties need to be verified.
//I would interpret line 6195 as a bug in ATL because the documentation sugests the command is to be executed but no rowset should be returned.
//The construct on 6195 prevents the command execution. I think the code on line 6306 aims to the functionality but it is never reached.
//The following code is workaround this problem.
if ( InlineIsEqualGUID(IID_NULL, riid) ) {
IUnknown* dummy;
HRESULT hr;
if ( mConnectionHandler->has_tabular_data() )
{
tabular_rowset* pRowset;
hr = CreateRowset(pUnkOuter, riid, pParams, pcRowsAffected, &dummy, pRowset);
} else
{
rowset* pRowset;
hr = CreateRowset(pUnkOuter, riid, pParams, pcRowsAffected, &dummy, pRowset);
}
if ( SUCCEEDED( hr ) ) {
dummy->Release();
}
*ppRowset = NULL;
return hr;
}
if ( mConnectionHandler->has_tabular_data() )
{
tabular_rowset* pRowset;
return CreateRowset(pUnkOuter, riid, pParams, pcRowsAffected, ppRowset, pRowset);
} else
{
rowset* pRowset;
return CreateRowset(pUnkOuter, riid, pParams, pcRowsAffected, ppRowset, pRowset);
}
}
STDMETHODIMP command::GetAxisRowset(IUnknown * pUnkOuter, REFIID riid, void * pParams, DBROWCOUNT * pcRowsAffected, IUnknown ** ppRowset)
{
CXMLAAxisRowset* pRowset;
return CreateRowset(pUnkOuter, riid, ( DBPARAMS* ) pParams, pcRowsAffected, ppRowset, pRowset);
}
STDMETHODIMP command::GetConnectionHandler( void** connection )
{
*connection = mConnectionHandler.get();
return S_OK;
}