forked from CUBRID/cubrid-oledb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataSource.h
295 lines (267 loc) · 12.5 KB
/
DataSource.h
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/*
* Copyright (C) 2008 Search Solution Corporation. All rights reserved by Search Solution.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of the <ORGANIZATION> nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
*/
// DataSource.h : Declaration of the CCUBRIDDataSource
#pragma once
#include <atldb.h>
#include "resource.h" // main symbols
#include "Session.h"
#include "ProviderInfo.h"
// extern으로 선언하니 GUID_NULL이 되버렸다. 동작원리를 잘 모르겠음.
//extern const OLEDBDECLSPEC GUID DBPROPSET_UNIPROVIDER_DBINIT;
static const GUID DBPROPSET_UNIPROVIDER_DBINIT = {0x7f555b1d,0xc6d2,0x40ce,{0x9a,0xb4,0x49,0x62,0x78,0x1e,0xb6,0x6c}};
#define DBPROP_UNIPROVIDER_UNICAS_PORT 0x200
#define UNIPROVIDER_UNICAS_PORT_Type VT_I4
#define UNIPROVIDER_UNICAS_PORT_Flags ( DBPROPFLAGS_DBINIT | DBPROPFLAGS_READ | DBPROPFLAGS_WRITE )
#define DBPROP_UNIPROVIDER_FETCH_SIZE 0x201
#define UNIPROVIDER_FETCH_SIZE_Type VT_I4
#define UNIPROVIDER_FETCH_SIZE_Flags ( DBPROPFLAGS_DBINIT | DBPROPFLAGS_READ | DBPROPFLAGS_WRITE )
#define DBPROP_UNIPROVIDER_CHARSET 0x202
#define UNIPROVIDER_CHARSET_Type VT_BSTR
#define UNIPROVIDER_CHARSET_Flags ( DBPROPFLAGS_DBINIT | DBPROPFLAGS_READ | DBPROPFLAGS_WRITE )
class CCUBRIDExtraProperties
{
public:
BEGIN_PROPSET_MAP(CCUBRIDExtraProperties)
BEGIN_PROPERTY_SET(DBPROPSET_COLUMN)
PROPERTY_INFO_ENTRY(COL_DEFAULT)
PROPERTY_INFO_ENTRY(COL_UNIQUE)
PROPERTY_INFO_ENTRY(COL_PRIMARYKEY)
PROPERTY_INFO_ENTRY(COL_NULLABLE)
PROPERTY_INFO_ENTRY(COL_FIXEDLENGTH)
END_PROPERTY_SET(DBPROPSET_COLUMN)
BEGIN_PROPERTY_SET(DBPROPSET_INDEX)
PROPERTY_INFO_ENTRY_VALUE(INDEX_UNIQUE, ATL_VARIANT_FALSE)
END_PROPERTY_SET(DBPROPSET_INDEX)
END_PROPSET_MAP()
};
class CConnectionProperties
{
public:
CComBSTR strDB;
CComBSTR strUser;
CComBSTR strPass;
CComBSTR strAddr;
int nPort;
int nCommitLevel;
UINT uCodepage;
};
// CCUBRIDDataSource
[
coclass,
threading(apartment),
vi_progid("CUBRIDProvider"),
progid("CUBRIDProvider.1"),
version(1.0),
uuid("15A12058-4353-4c9a-8421-23D80F25EE4E"),
helpstring("CUBRIDProvider Class"),
support_error_info(IDBInitialize),
support_error_info(IDBInfo),
registration_script("CUBRIDDataSource.rgs")
]
class ATL_NO_VTABLE CCUBRIDDataSource :
public IDBCreateSessionImpl<CCUBRIDDataSource, CCUBRIDSession>,
public IDBInitializeImpl<CCUBRIDDataSource>,
public IDBPropertiesImpl<CCUBRIDDataSource>,
public IPersistImpl<CCUBRIDDataSource>,
public IDBInfo,
public IInternalConnectionImpl<CCUBRIDDataSource>
{
public:
static CCUBRIDDataSource *GetDataSourcePtr(IObjectWithSite *pSite);
public:
ULONG PARAM_MAX_STRING_LENGTH;
CCUBRIDDataSource() : PARAM_MAX_STRING_LENGTH(1024)
{
}
~CCUBRIDDataSource()
{
}
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
ATLTRACE2(atlTraceDBProvider, 3, "CCUBRIDDataSource::FinalConstruct\n");
return FInit();
}
void FinalRelease()
{
ATLTRACE2(atlTraceDBProvider, 3, "CCUBRIDDataSource::FinalRelease\n");
}
virtual HRESULT IsValidValue(ULONG iCurSet, DBPROP* pDBProp)
{
ATLASSERT(pDBProp);
if(pDBProp->dwPropertyID==DBPROP_INIT_ASYNCH)
{
LONG val = V_I4(&pDBProp->vValue);
if(val==0 || val==DBPROPVAL_ASYNCH_INITIALIZE)
return S_OK;
return S_FALSE;
}
if(pDBProp->dwPropertyID==DBPROP_INIT_PROMPT)
{
short val = V_I2(&pDBProp->vValue);
if(val==DBPROMPT_NOPROMPT || val==DBPROMPT_COMPLETE ||
val==DBPROMPT_COMPLETEREQUIRED || val==DBPROMPT_PROMPT)
return S_OK;
return S_FALSE;
}
return IDBPropertiesImpl<CCUBRIDDataSource>::IsValidValue(iCurSet, pDBProp);
}
OUT_OF_LINE HRESULT GetDefaultValue(ULONG iPropSet, DBPROPID dwPropId, DWORD* pdwOption, VARIANT* pVar)
{
if( m_pUProp[iPropSet].pUPropVal &&
(dwPropId==DBPROP_DBMSVER || dwPropId==DBPROP_PROVIDERVER ||
dwPropId==DBPROP_CONNECTIONSTATUS || dwPropId==DBPROP_DATASOURCENAME) )
{
GetPropValue(&DBPROPSET_DATASOURCEINFO, dwPropId, pVar);
return S_OK;
}
return IDBPropertiesImpl<CCUBRIDDataSource>::GetDefaultValue(iPropSet, dwPropId, pdwOption, pVar);
}
// IUnknown
static HRESULT WINAPI InternalQueryInterface(void* pThis,
const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, void** ppvObject)
{
// Data Source가 초기화되지 않은 상태면
// 다음 두 인터페이스 요청에 대해 E_NOINTERFACE를 반환한다.
if( !(((CCUBRIDDataSource *)pThis)->m_dwStatus & DSF_INITIALIZED) )
{
if( InlineIsEqualGUID(iid, __uuidof(IDBCreateSession)) ||
InlineIsEqualGUID(iid, __uuidof(IDBInfo)) )
{
if(ppvObject) *ppvObject = NULL;
return E_NOINTERFACE;
}
}
return CComObjectRootBase::InternalQueryInterface(pThis, pEntries, iid, ppvObject);
}
// IDBInitialize
STDMETHOD(Initialize)(void);
STDMETHOD(Uninitialize)(void);
// IDBCreateSession
STDMETHOD(CreateSession)(IUnknown *pUnkOuter, REFIID riid, IUnknown **ppDBSession);
// IDBInfo
STDMETHOD(GetLiteralInfo)(ULONG cLiterals, const DBLITERAL rgLiterals[],
ULONG *pcLiteralInfo, DBLITERALINFO **prgLiteralInfo,
OLECHAR **ppCharBuffer);
STDMETHOD(GetKeywords)(LPOLESTR *ppwszKeywords);
// DBPROPFLAGS_CHANGE flag에 대해서는 CCUBRIDDataSource::Initialize 참조
BEGIN_PROPSET_MAP(CCUBRIDDataSource)
//BEGIN_PROPERTY_SET(DBPROPSET_DATASOURCE)
//PROPERTY_INFO_ENTRY_VALUE(CURRENTCATALOG, OLESTR(""))
//PROPERTY_INFO_ENTRY_VALUE(MULTIPLECONNECTIONS, ATL_VARIANT_TRUE)
//PROPERTY_INFO_ENTRY_VALUE_FLAGS(RESETDATASOURCE, DBPROPVAL_RD_RESETALL, DBPROPFLAGS_DATASOURCE | DBPROPFLAGS_READ)
//END_PROPERTY_SET(DBPROPSET_DATASOURCE)
BEGIN_PROPERTY_SET(DBPROPSET_DATASOURCEINFO)
PROPERTY_INFO_ENTRY_VALUE(ACTIVESESSIONS, 0)
PROPERTY_INFO_ENTRY_VALUE(ASYNCTXNABORT, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(ASYNCTXNCOMMIT, ATL_VARIANT_FALSE)
// 실제 값은 CCUBRIDDataSource::Initialize에서 채운다.
PROPERTY_INFO_ENTRY_VALUE_FLAGS(DBMSVER, OLESTR(""), DBPROPFLAGS_DATASOURCEINFO | DBPROPFLAGS_READ | DBPROPFLAGS_CHANGE )
PROPERTY_INFO_ENTRY_VALUE(BYREFACCESSORS, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(CATALOGTERM, OLESTR(""))
PROPERTY_INFO_ENTRY_VALUE(CATALOGLOCATION, 0)
PROPERTY_INFO_ENTRY_VALUE(CATALOGUSAGE, 0)
PROPERTY_INFO_ENTRY_VALUE(CONCATNULLBEHAVIOR,DBPROPVAL_CB_NON_NULL)
PROPERTY_INFO_ENTRY_VALUE_FLAGS(CONNECTIONSTATUS, DBPROPVAL_CS_UNINITIALIZED, DBPROPFLAGS_DATASOURCEINFO | DBPROPFLAGS_READ | DBPROPFLAGS_CHANGE)
// DBPROP_DATASOURCENAME == DBPROP_INIT_LOCATION
PROPERTY_INFO_ENTRY_VALUE_FLAGS(DATASOURCENAME, OLESTR(""), DBPROPFLAGS_DATASOURCEINFO | DBPROPFLAGS_READ | DBPROPFLAGS_CHANGE)
PROPERTY_INFO_ENTRY_VALUE(DATASOURCEREADONLY, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(DBMSNAME, OLESTR("CUBRID"))
PROPERTY_INFO_ENTRY_VALUE(DSOTHREADMODEL, DBPROPVAL_RT_APTMTTHREAD)
PROPERTY_INFO_ENTRY_VALUE(GROUPBY, DBPROPVAL_GB_CONTAINS_SELECT)
PROPERTY_INFO_ENTRY_VALUE(IDENTIFIERCASE, DBPROPVAL_IC_MIXED)
PROPERTY_INFO_ENTRY_VALUE(MAXINDEXSIZE, 0)
PROPERTY_INFO_ENTRY_VALUE(MAXROWSIZE, 0)
PROPERTY_INFO_ENTRY_VALUE(MAXTABLESINSELECT, 0)
PROPERTY_INFO_ENTRY_VALUE(MAXROWSIZEINCLUDESBLOB, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(MULTIPLEPARAMSETS, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(MULTIPLERESULTS, DBPROPVAL_MR_SUPPORTED)
PROPERTY_INFO_ENTRY_VALUE(MULTIPLESTORAGEOBJECTS, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(MULTITABLEUPDATE, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(NULLCOLLATION, DBPROPVAL_NC_LOW)
PROPERTY_INFO_ENTRY_VALUE(OLEOBJECTS, DBPROPVAL_OO_BLOB|DBPROPVAL_OO_ROWOBJECT|DBPROPVAL_OO_SINGLETON)
PROPERTY_INFO_ENTRY_VALUE(ORDERBYCOLUMNSINSELECT, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(OUTPUTPARAMETERAVAILABILITY, DBPROPVAL_OA_NOTSUPPORTED)
PROPERTY_INFO_ENTRY_VALUE(PROVIDERFRIENDLYNAME, OLESTR("CUBRID OLE DB Provider"))
PROPERTY_INFO_ENTRY_VALUE(PERSISTENTIDTYPE, DBPROPVAL_PT_GUID_NAME)
PROPERTY_INFO_ENTRY_VALUE(OPENROWSETSUPPORT, DBPROPVAL_ORS_TABLE)
PROPERTY_INFO_ENTRY_VALUE(PREPAREABORTBEHAVIOR, DBPROPVAL_CB_DELETE)
PROPERTY_INFO_ENTRY_VALUE(PREPARECOMMITBEHAVIOR, DBPROPVAL_CB_DELETE)
PROPERTY_INFO_ENTRY_VALUE(PROCEDURETERM, OLESTR(""))
// MDAC 2.5 이후로는 DBPROP_PROVIDERFILENAME이지만 ATL이 지원하지 않는다.
PROPERTY_INFO_ENTRY_VALUE(PROVIDERNAME, OLESTR("CUBRIDProvider.dll"))
PROPERTY_INFO_ENTRY_VALUE(PROVIDEROLEDBVER, OLESTR("02.70"))
// DBPROP_PROVIDERVER == DBPRDBPROP_DBMSVER
PROPERTY_INFO_ENTRY_VALUE_FLAGS(PROVIDERVER, OLESTR(""), DBPROPFLAGS_DATASOURCEINFO | DBPROPFLAGS_READ | DBPROPFLAGS_CHANGE )
PROPERTY_INFO_ENTRY_VALUE(QUOTEDIDENTIFIERCASE, DBPROPVAL_IC_LOWER)
PROPERTY_INFO_ENTRY_VALUE(ROWSETCONVERSIONSONCOMMAND, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(SCHEMATERM, OLESTR(""))
PROPERTY_INFO_ENTRY_VALUE(SCHEMAUSAGE, 0)
PROPERTY_INFO_ENTRY_VALUE(SQLSUPPORT, DBPROPVAL_SQL_ODBC_MINIMUM | DBPROPVAL_SQL_ANSI92_ENTRY)
PROPERTY_INFO_ENTRY_VALUE(STRUCTUREDSTORAGE, DBPROPVAL_SS_ISEQUENTIALSTREAM)
PROPERTY_INFO_ENTRY_VALUE(SUBQUERIES, DBPROPVAL_SQ_CORRELATEDSUBQUERIES | DBPROPVAL_SQ_COMPARISON | DBPROPVAL_SQ_EXISTS | DBPROPVAL_SQ_IN | DBPROPVAL_SQ_QUANTIFIED | DBPROPVAL_SQ_TABLE)
PROPERTY_INFO_ENTRY_VALUE(SUPPORTEDTXNDDL, DBPROPVAL_TC_DDL_LOCK)
PROPERTY_INFO_ENTRY_VALUE(SUPPORTEDTXNISOLEVELS, DBPROPVAL_TI_READUNCOMMITTED | DBPROPVAL_TI_READCOMMITTED | DBPROPVAL_TI_REPEATABLEREAD | DBPROPVAL_TI_SERIALIZABLE)
PROPERTY_INFO_ENTRY_VALUE(SUPPORTEDTXNISORETAIN, 0)
PROPERTY_INFO_ENTRY_VALUE(TABLETERM, OLESTR("table"))
END_PROPERTY_SET(DBPROPSET_DATASOURCEINFO)
BEGIN_PROPERTY_SET(DBPROPSET_DBINIT)
#if _DEBUG
PROPERTY_INFO_ENTRY_VALUE(INIT_LOCATION, OLESTR("10.34.64.67"))
PROPERTY_INFO_ENTRY_VALUE(INIT_DATASOURCE, OLESTR("demodb"))
PROPERTY_INFO_ENTRY_VALUE(AUTH_USERID, OLESTR("dba"))
PROPERTY_INFO_ENTRY_VALUE(AUTH_PASSWORD, OLESTR(""))
#else
PROPERTY_INFO_ENTRY_VALUE(INIT_LOCATION, OLESTR(""))
PROPERTY_INFO_ENTRY_VALUE(INIT_DATASOURCE, OLESTR(""))
PROPERTY_INFO_ENTRY_VALUE(AUTH_USERID, OLESTR(""))
PROPERTY_INFO_ENTRY_VALUE(AUTH_PASSWORD, OLESTR(""))
#endif
PROPERTY_INFO_ENTRY_VALUE(AUTH_CACHE_AUTHINFO, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(AUTH_ENCRYPT_PASSWORD, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(AUTH_MASK_PASSWORD, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(AUTH_PERSIST_ENCRYPTED, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(AUTH_PERSIST_SENSITIVE_AUTHINFO, ATL_VARIANT_FALSE)
PROPERTY_INFO_ENTRY_VALUE(INIT_ASYNCH, 0)
PROPERTY_INFO_ENTRY_VALUE(INIT_HWND, 0)
PROPERTY_INFO_ENTRY_VALUE(INIT_PROMPT, DBPROMPT_NOPROMPT)
PROPERTY_INFO_ENTRY_VALUE(SESS_AUTOCOMMITISOLEVELS, DBPROPVAL_TI_READCOMMITTED)
END_PROPERTY_SET(DBPROPSET_DBINIT)
// Extended properties
BEGIN_PROPERTY_SET_EX(DBPROPSET_UNIPROVIDER_DBINIT, UPROPSET_USERINIT)
PROPERTY_INFO_ENTRY_VALUE(UNIPROVIDER_UNICAS_PORT, 30000)
PROPERTY_INFO_ENTRY_VALUE(UNIPROVIDER_FETCH_SIZE, ProvInfo::DEFAULT_FETCH_SIZE)
PROPERTY_INFO_ENTRY_VALUE(UNIPROVIDER_CHARSET, OLESTR("utf-8"))
END_PROPERTY_SET(DBPROPSET_UNIPROVIDER_DBINIT)
CHAIN_PROPERTY_SET(CCUBRIDSession)
CHAIN_PROPERTY_SET(CCUBRIDCommand)
CHAIN_PROPERTY_SET(CCUBRIDExtraProperties)
END_PROPSET_MAP()
};