oracledb 3.0.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +135 -8
- package/README.md +6 -4
- package/build/Release/oracledb-abi48-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi48-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi48-linux-x64.node +0 -0
- package/build/Release/oracledb-abi48-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi48-win32-x64.node +0 -0
- package/build/Release/oracledb-abi48-win32-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi57-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi57-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi57-linux-x64.node +0 -0
- package/build/Release/oracledb-abi57-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi57-win32-x64.node +0 -0
- package/build/Release/oracledb-abi57-win32-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi64-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi64-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi64-linux-x64.node +0 -0
- package/build/Release/oracledb-abi64-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi64-win32-x64.node +0 -0
- package/build/Release/oracledb-abi64-win32-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi67-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi67-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi67-linux-x64.node +0 -0
- package/build/Release/oracledb-abi67-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi67-win32-x64.node +0 -0
- package/build/Release/oracledb-abi67-win32-x64.node-buildinfo.txt +1 -0
- package/lib/connection.js +18 -4
- package/lib/oracledb.js +44 -92
- package/lib/pool.js +36 -2
- package/lib/sodaCollection.js +1 -1
- package/lib/sodaDatabase.js +1 -1
- package/lib/util.js +82 -5
- package/package/README.md +32 -101
- package/package/install.js +139 -0
- package/package/prunebinaries.js +51 -0
- package/package.json +4 -11
- package/binding.gyp +0 -162
- package/lib/rel.txt +0 -1
- package/odpi/.npmignore +0 -4
- package/odpi/LICENSE.md +0 -218
- package/odpi/README.md +0 -61
- package/odpi/embed/README.md +0 -4
- package/odpi/embed/dpi.c +0 -50
- package/odpi/include/dpi.h +0 -1748
- package/odpi/src/dpiConn.c +0 -2089
- package/odpi/src/dpiContext.c +0 -296
- package/odpi/src/dpiData.c +0 -797
- package/odpi/src/dpiDebug.c +0 -184
- package/odpi/src/dpiDeqOptions.c +0 -370
- package/odpi/src/dpiEnqOptions.c +0 -174
- package/odpi/src/dpiEnv.c +0 -189
- package/odpi/src/dpiError.c +0 -204
- package/odpi/src/dpiErrorMessages.h +0 -86
- package/odpi/src/dpiGen.c +0 -303
- package/odpi/src/dpiGlobal.c +0 -292
- package/odpi/src/dpiHandleList.c +0 -117
- package/odpi/src/dpiHandlePool.c +0 -118
- package/odpi/src/dpiImpl.h +0 -1707
- package/odpi/src/dpiLob.c +0 -506
- package/odpi/src/dpiMsgProps.c +0 -386
- package/odpi/src/dpiObject.c +0 -897
- package/odpi/src/dpiObjectAttr.c +0 -115
- package/odpi/src/dpiObjectType.c +0 -326
- package/odpi/src/dpiOci.c +0 -3527
- package/odpi/src/dpiOracleType.c +0 -492
- package/odpi/src/dpiPool.c +0 -549
- package/odpi/src/dpiRowid.c +0 -136
- package/odpi/src/dpiSodaColl.c +0 -685
- package/odpi/src/dpiSodaCollCursor.c +0 -143
- package/odpi/src/dpiSodaDb.c +0 -432
- package/odpi/src/dpiSodaDoc.c +0 -230
- package/odpi/src/dpiSodaDocCursor.c +0 -143
- package/odpi/src/dpiStmt.c +0 -1797
- package/odpi/src/dpiSubscr.c +0 -674
- package/odpi/src/dpiUtils.c +0 -410
- package/odpi/src/dpiVar.c +0 -1794
- package/package/MAKEPKG.BAT +0 -156
- package/package/Makefile +0 -85
- package/package/createpackage.js +0 -186
- package/package/extractpackage.js +0 -76
- package/package/getversion.js +0 -37
- package/package/oracledbinstall.js +0 -497
- package/package/package.json +0 -54
- package/package/util.js +0 -286
- package/src/njsCommon.cpp +0 -1055
- package/src/njsCommon.h +0 -484
- package/src/njsConnection.cpp +0 -2926
- package/src/njsConnection.h +0 -227
- package/src/njsIntLob.cpp +0 -618
- package/src/njsIntLob.h +0 -179
- package/src/njsMessages.cpp +0 -122
- package/src/njsMessages.h +0 -118
- package/src/njsOracle.cpp +0 -1274
- package/src/njsOracle.h +0 -237
- package/src/njsPool.cpp +0 -482
- package/src/njsPool.h +0 -132
- package/src/njsResultSet.cpp +0 -478
- package/src/njsResultSet.h +0 -120
- package/src/njsSodaCollection.cpp +0 -507
- package/src/njsSodaCollection.h +0 -128
- package/src/njsSodaDatabase.cpp +0 -335
- package/src/njsSodaDatabase.h +0 -108
- package/src/njsSodaDocCursor.cpp +0 -203
- package/src/njsSodaDocCursor.h +0 -94
- package/src/njsSodaDocument.cpp +0 -412
- package/src/njsSodaDocument.h +0 -105
- package/src/njsSodaOperation.cpp +0 -557
- package/src/njsSodaOperation.h +0 -123
- package/src/njsSubscription.cpp +0 -388
- package/src/njsSubscription.h +0 -111
- package/src/njsUtils.cpp +0 -158
- package/src/njsUtils.h +0 -68
package/odpi/src/dpiSodaColl.c
DELETED
|
@@ -1,685 +0,0 @@
|
|
|
1
|
-
//-----------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
|
3
|
-
// This program is free software: you can modify it and/or redistribute it
|
|
4
|
-
// under the terms of:
|
|
5
|
-
//
|
|
6
|
-
// (i) the Universal Permissive License v 1.0 or at your option, any
|
|
7
|
-
// later version (http://oss.oracle.com/licenses/upl); and/or
|
|
8
|
-
//
|
|
9
|
-
// (ii) the Apache License v 2.0. (http://www.apache.org/licenses/LICENSE-2.0)
|
|
10
|
-
//-----------------------------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
//-----------------------------------------------------------------------------
|
|
13
|
-
// dpiSodaColl.c
|
|
14
|
-
// Implementation of SODA collections.
|
|
15
|
-
//-----------------------------------------------------------------------------
|
|
16
|
-
|
|
17
|
-
#include "dpiImpl.h"
|
|
18
|
-
|
|
19
|
-
//-----------------------------------------------------------------------------
|
|
20
|
-
// dpiSodaColl__allocate() [INTERNAL]
|
|
21
|
-
// Allocate and initialize a SODA collection structure.
|
|
22
|
-
//-----------------------------------------------------------------------------
|
|
23
|
-
int dpiSodaColl__allocate(dpiSodaDb *db, void *handle, dpiSodaColl **coll,
|
|
24
|
-
dpiError *error)
|
|
25
|
-
{
|
|
26
|
-
uint8_t sqlType, contentType;
|
|
27
|
-
dpiSodaColl *tempColl;
|
|
28
|
-
|
|
29
|
-
if (dpiOci__attrGet(handle, DPI_OCI_HTYPE_SODA_COLLECTION,
|
|
30
|
-
(void*) &sqlType, 0, DPI_OCI_ATTR_SODA_CTNT_SQL_TYPE,
|
|
31
|
-
"get content sql type", error) < 0)
|
|
32
|
-
return DPI_FAILURE;
|
|
33
|
-
if (dpiGen__allocate(DPI_HTYPE_SODA_COLL, db->env, (void**) &tempColl,
|
|
34
|
-
error) < 0)
|
|
35
|
-
return DPI_FAILURE;
|
|
36
|
-
dpiGen__setRefCount(db, error, 1);
|
|
37
|
-
tempColl->db = db;
|
|
38
|
-
tempColl->handle = handle;
|
|
39
|
-
if (sqlType == DPI_SQLT_BLOB) {
|
|
40
|
-
tempColl->binaryContent = 1;
|
|
41
|
-
contentType = 0;
|
|
42
|
-
dpiOci__attrGet(handle, DPI_OCI_HTYPE_SODA_COLLECTION,
|
|
43
|
-
(void*) &contentType, 0, DPI_OCI_ATTR_SODA_CTNT_FORMAT,
|
|
44
|
-
NULL, error);
|
|
45
|
-
if (contentType == DPI_OCI_JSON_FORMAT_OSON)
|
|
46
|
-
tempColl->binaryContent = 0;
|
|
47
|
-
}
|
|
48
|
-
*coll = tempColl;
|
|
49
|
-
return DPI_SUCCESS;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
//-----------------------------------------------------------------------------
|
|
54
|
-
// dpiSodaColl__check() [INTERNAL]
|
|
55
|
-
// Determine if the SODA collection is available to use.
|
|
56
|
-
//-----------------------------------------------------------------------------
|
|
57
|
-
static int dpiSodaColl__check(dpiSodaColl *coll, const char *fnName,
|
|
58
|
-
dpiError *error)
|
|
59
|
-
{
|
|
60
|
-
if (dpiGen__startPublicFn(coll, DPI_HTYPE_SODA_COLL, fnName, 1, error) < 0)
|
|
61
|
-
return DPI_FAILURE;
|
|
62
|
-
if (!coll->db->conn->handle || coll->db->conn->closing)
|
|
63
|
-
return dpiError__set(error, "check connection", DPI_ERR_NOT_CONNECTED);
|
|
64
|
-
return DPI_SUCCESS;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
//-----------------------------------------------------------------------------
|
|
69
|
-
// dpiSodaColl__createOperOptions() [INTERNAL]
|
|
70
|
-
// Create a SODA operation options handle with the specified information.
|
|
71
|
-
//-----------------------------------------------------------------------------
|
|
72
|
-
static int dpiSodaColl__createOperOptions(dpiSodaColl *coll,
|
|
73
|
-
const dpiSodaOperOptions *options, void **handle, dpiError *error)
|
|
74
|
-
{
|
|
75
|
-
dpiSodaOperOptions localOptions;
|
|
76
|
-
|
|
77
|
-
// if no options specified, use default values
|
|
78
|
-
if (!options) {
|
|
79
|
-
dpiContext__initSodaOperOptions(&localOptions);
|
|
80
|
-
options = &localOptions;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// allocate new handle
|
|
84
|
-
if (dpiOci__handleAlloc(coll->env->handle, handle,
|
|
85
|
-
DPI_OCI_HTYPE_SODA_OPER_OPTIONS,
|
|
86
|
-
"allocate SODA operation options handle", error) < 0)
|
|
87
|
-
return DPI_FAILURE;
|
|
88
|
-
|
|
89
|
-
// set multiple keys, if applicable
|
|
90
|
-
if (options->numKeys > 0) {
|
|
91
|
-
if (dpiOci__sodaOperKeysSet(options, *handle, error) < 0) {
|
|
92
|
-
dpiOci__handleFree(*handle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS);
|
|
93
|
-
return DPI_FAILURE;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// set single key, if applicable
|
|
98
|
-
if (options->keyLength > 0) {
|
|
99
|
-
if (dpiOci__attrSet(*handle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS,
|
|
100
|
-
(void*) options->key, options->keyLength,
|
|
101
|
-
DPI_OCI_ATTR_SODA_KEY, "set key", error) < 0) {
|
|
102
|
-
dpiOci__handleFree(*handle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS);
|
|
103
|
-
return DPI_FAILURE;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// set single version, if applicable
|
|
108
|
-
if (options->versionLength > 0) {
|
|
109
|
-
if (dpiOci__attrSet(*handle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS,
|
|
110
|
-
(void*) options->version, options->versionLength,
|
|
111
|
-
DPI_OCI_ATTR_SODA_VERSION, "set version", error) < 0) {
|
|
112
|
-
dpiOci__handleFree(*handle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS);
|
|
113
|
-
return DPI_FAILURE;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// set filter, if applicable
|
|
118
|
-
if (options->filterLength > 0) {
|
|
119
|
-
if (dpiOci__attrSet(*handle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS,
|
|
120
|
-
(void*) options->filter, options->filterLength,
|
|
121
|
-
DPI_OCI_ATTR_SODA_FILTER, "set filter", error) < 0) {
|
|
122
|
-
dpiOci__handleFree(*handle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS);
|
|
123
|
-
return DPI_FAILURE;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// set skip count, if applicable
|
|
128
|
-
if (options->skip > 0) {
|
|
129
|
-
if (dpiOci__attrSet(*handle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS,
|
|
130
|
-
(void*) &options->skip, 0, DPI_OCI_ATTR_SODA_SKIP,
|
|
131
|
-
"set skip count", error) < 0) {
|
|
132
|
-
dpiOci__handleFree(*handle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS);
|
|
133
|
-
return DPI_FAILURE;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// set limit, if applicable
|
|
138
|
-
if (options->limit > 0) {
|
|
139
|
-
if (dpiOci__attrSet(*handle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS,
|
|
140
|
-
(void*) &options->limit, 0, DPI_OCI_ATTR_SODA_LIMIT,
|
|
141
|
-
"set limit", error) < 0) {
|
|
142
|
-
dpiOci__handleFree(*handle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS);
|
|
143
|
-
return DPI_FAILURE;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return DPI_SUCCESS;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
//-----------------------------------------------------------------------------
|
|
152
|
-
// dpiSodaColl__find() [INTERNAL]
|
|
153
|
-
// Perform a find of SODA documents by creating an operation options handle
|
|
154
|
-
// and populating it with the requested options. Once the find is complete,
|
|
155
|
-
// return either a cursor or a document.
|
|
156
|
-
//-----------------------------------------------------------------------------
|
|
157
|
-
static int dpiSodaColl__find(dpiSodaColl *coll,
|
|
158
|
-
const dpiSodaOperOptions *options, uint32_t flags,
|
|
159
|
-
dpiSodaDocCursor **cursor, dpiSodaDoc **doc, dpiError *error)
|
|
160
|
-
{
|
|
161
|
-
uint32_t ociMode, returnHandleType, ociFlags;
|
|
162
|
-
void *optionsHandle, *ociReturnHandle;
|
|
163
|
-
int status;
|
|
164
|
-
|
|
165
|
-
// determine OCI mode to pass
|
|
166
|
-
ociMode = DPI_OCI_DEFAULT;
|
|
167
|
-
if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
|
|
168
|
-
ociMode |= DPI_OCI_SODA_ATOMIC_COMMIT;
|
|
169
|
-
|
|
170
|
-
// create new OCI operation options handle
|
|
171
|
-
if (dpiSodaColl__createOperOptions(coll, options, &optionsHandle,
|
|
172
|
-
error) < 0)
|
|
173
|
-
return DPI_FAILURE;
|
|
174
|
-
|
|
175
|
-
// determine OCI flags to use
|
|
176
|
-
ociFlags = (coll->binaryContent) ? DPI_OCI_SODA_AS_STORED :
|
|
177
|
-
DPI_OCI_SODA_AS_AL32UTF8;
|
|
178
|
-
|
|
179
|
-
// perform actual find
|
|
180
|
-
if (cursor) {
|
|
181
|
-
*cursor = NULL;
|
|
182
|
-
status = dpiOci__sodaFind(coll, optionsHandle, ociFlags, ociMode,
|
|
183
|
-
&ociReturnHandle, error);
|
|
184
|
-
} else {
|
|
185
|
-
*doc = NULL;
|
|
186
|
-
status = dpiOci__sodaFindOne(coll, optionsHandle, ociFlags, ociMode,
|
|
187
|
-
&ociReturnHandle, error);
|
|
188
|
-
}
|
|
189
|
-
dpiOci__handleFree(optionsHandle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS);
|
|
190
|
-
if (status < 0)
|
|
191
|
-
return DPI_FAILURE;
|
|
192
|
-
|
|
193
|
-
// return cursor or document, as appropriate
|
|
194
|
-
if (cursor) {
|
|
195
|
-
status = dpiSodaDocCursor__allocate(coll, ociReturnHandle, cursor,
|
|
196
|
-
error);
|
|
197
|
-
returnHandleType = DPI_OCI_HTYPE_SODA_DOC_CURSOR;
|
|
198
|
-
} else if (ociReturnHandle) {
|
|
199
|
-
status = dpiSodaDoc__allocate(coll->db, ociReturnHandle, doc, error);
|
|
200
|
-
returnHandleType = DPI_OCI_HTYPE_SODA_DOCUMENT;
|
|
201
|
-
}
|
|
202
|
-
if (status < 0)
|
|
203
|
-
dpiOci__handleFree(ociReturnHandle, returnHandleType);
|
|
204
|
-
|
|
205
|
-
return status;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
//-----------------------------------------------------------------------------
|
|
210
|
-
// dpiSodaColl__free() [INTERNAL]
|
|
211
|
-
// Free the memory for a SODA collection.
|
|
212
|
-
//-----------------------------------------------------------------------------
|
|
213
|
-
void dpiSodaColl__free(dpiSodaColl *coll, dpiError *error)
|
|
214
|
-
{
|
|
215
|
-
if (coll->db) {
|
|
216
|
-
dpiGen__setRefCount(coll->db, error, -1);
|
|
217
|
-
coll->db = NULL;
|
|
218
|
-
}
|
|
219
|
-
if (coll->handle) {
|
|
220
|
-
dpiOci__handleFree(coll->handle, DPI_OCI_HTYPE_SODA_COLLECTION);
|
|
221
|
-
coll->handle = NULL;
|
|
222
|
-
}
|
|
223
|
-
dpiUtils__freeMemory(coll);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
//-----------------------------------------------------------------------------
|
|
228
|
-
// dpiSodaColl__getDocCount() [INTERNAL]
|
|
229
|
-
// Internal method for getting document count.
|
|
230
|
-
//-----------------------------------------------------------------------------
|
|
231
|
-
static int dpiSodaColl__getDocCount(dpiSodaColl *coll,
|
|
232
|
-
const dpiSodaOperOptions *options, uint32_t flags, uint64_t *count,
|
|
233
|
-
dpiError *error)
|
|
234
|
-
{
|
|
235
|
-
void *optionsHandle;
|
|
236
|
-
uint32_t ociMode;
|
|
237
|
-
int status;
|
|
238
|
-
|
|
239
|
-
// determine OCI mode to pass
|
|
240
|
-
ociMode = DPI_OCI_DEFAULT;
|
|
241
|
-
if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
|
|
242
|
-
ociMode |= DPI_OCI_SODA_ATOMIC_COMMIT;
|
|
243
|
-
|
|
244
|
-
// create new OCI operation options handle
|
|
245
|
-
if (dpiSodaColl__createOperOptions(coll, options, &optionsHandle,
|
|
246
|
-
error) < 0)
|
|
247
|
-
return DPI_FAILURE;
|
|
248
|
-
|
|
249
|
-
// perform actual document count
|
|
250
|
-
status = dpiOci__sodaDocCount(coll, optionsHandle, ociMode, count, error);
|
|
251
|
-
dpiOci__handleFree(optionsHandle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS);
|
|
252
|
-
return status;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
//-----------------------------------------------------------------------------
|
|
257
|
-
// dpiSodaColl__remove() [INTERNAL]
|
|
258
|
-
// Internal method for removing documents from a collection.
|
|
259
|
-
//-----------------------------------------------------------------------------
|
|
260
|
-
static int dpiSodaColl__remove(dpiSodaColl *coll,
|
|
261
|
-
const dpiSodaOperOptions *options, uint32_t flags, uint64_t *count,
|
|
262
|
-
dpiError *error)
|
|
263
|
-
{
|
|
264
|
-
void *optionsHandle;
|
|
265
|
-
uint32_t mode;
|
|
266
|
-
int status;
|
|
267
|
-
|
|
268
|
-
// determine OCI mode to pass
|
|
269
|
-
mode = DPI_OCI_DEFAULT;
|
|
270
|
-
if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
|
|
271
|
-
mode |= DPI_OCI_SODA_ATOMIC_COMMIT;
|
|
272
|
-
|
|
273
|
-
// create new OCI operation options handle
|
|
274
|
-
if (dpiSodaColl__createOperOptions(coll, options, &optionsHandle,
|
|
275
|
-
error) < 0)
|
|
276
|
-
return DPI_FAILURE;
|
|
277
|
-
|
|
278
|
-
// remove documents from collection
|
|
279
|
-
status = dpiOci__sodaRemove(coll, optionsHandle, mode, count, error);
|
|
280
|
-
dpiOci__handleFree(optionsHandle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS);
|
|
281
|
-
return status;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
//-----------------------------------------------------------------------------
|
|
286
|
-
// dpiSodaColl__replace() [INTERNAL]
|
|
287
|
-
// Internal method for replacing a document in the collection.
|
|
288
|
-
//-----------------------------------------------------------------------------
|
|
289
|
-
static int dpiSodaColl__replace(dpiSodaColl *coll,
|
|
290
|
-
const dpiSodaOperOptions *options, dpiSodaDoc *doc, uint32_t flags,
|
|
291
|
-
int *replaced, dpiSodaDoc **replacedDoc, dpiError *error)
|
|
292
|
-
{
|
|
293
|
-
void *docHandle, *optionsHandle;
|
|
294
|
-
int status, dummyIsReplaced;
|
|
295
|
-
uint32_t mode;
|
|
296
|
-
|
|
297
|
-
// use dummy value if the replaced flag is not desired
|
|
298
|
-
if (!replaced)
|
|
299
|
-
replaced = &dummyIsReplaced;
|
|
300
|
-
|
|
301
|
-
// determine OCI mode to pass
|
|
302
|
-
mode = DPI_OCI_DEFAULT;
|
|
303
|
-
if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
|
|
304
|
-
mode |= DPI_OCI_SODA_ATOMIC_COMMIT;
|
|
305
|
-
|
|
306
|
-
// create new OCI operation options handle
|
|
307
|
-
if (dpiSodaColl__createOperOptions(coll, options, &optionsHandle,
|
|
308
|
-
error) < 0)
|
|
309
|
-
return DPI_FAILURE;
|
|
310
|
-
|
|
311
|
-
// replace document in collection
|
|
312
|
-
// use "AndGet" variant if the replaced document is requested
|
|
313
|
-
docHandle = doc->handle;
|
|
314
|
-
if (!replacedDoc) {
|
|
315
|
-
status = dpiOci__sodaReplOne(coll, optionsHandle, docHandle, mode,
|
|
316
|
-
replaced, error);
|
|
317
|
-
} else {
|
|
318
|
-
*replacedDoc = NULL;
|
|
319
|
-
status = dpiOci__sodaReplOneAndGet(coll, optionsHandle, &docHandle,
|
|
320
|
-
mode, replaced, error);
|
|
321
|
-
if (status == 0 && docHandle) {
|
|
322
|
-
status = dpiSodaDoc__allocate(coll->db, docHandle, replacedDoc,
|
|
323
|
-
error);
|
|
324
|
-
if (status < 0)
|
|
325
|
-
dpiOci__handleFree(docHandle, DPI_OCI_HTYPE_SODA_DOCUMENT);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
dpiOci__handleFree(optionsHandle, DPI_OCI_HTYPE_SODA_OPER_OPTIONS);
|
|
330
|
-
return status;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
//-----------------------------------------------------------------------------
|
|
335
|
-
// dpiSodaColl_addRef() [PUBLIC]
|
|
336
|
-
// Add a reference to the SODA collection.
|
|
337
|
-
//-----------------------------------------------------------------------------
|
|
338
|
-
int dpiSodaColl_addRef(dpiSodaColl *coll)
|
|
339
|
-
{
|
|
340
|
-
return dpiGen__addRef(coll, DPI_HTYPE_SODA_COLL, __func__);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
//-----------------------------------------------------------------------------
|
|
345
|
-
// dpiSodaColl_createIndex() [PUBLIC]
|
|
346
|
-
// Create an index on the collection.
|
|
347
|
-
//-----------------------------------------------------------------------------
|
|
348
|
-
int dpiSodaColl_createIndex(dpiSodaColl *coll, const char *indexSpec,
|
|
349
|
-
uint32_t indexSpecLength, uint32_t flags)
|
|
350
|
-
{
|
|
351
|
-
dpiError error;
|
|
352
|
-
uint32_t mode;
|
|
353
|
-
int status;
|
|
354
|
-
|
|
355
|
-
// validate parameters
|
|
356
|
-
if (dpiSodaColl__check(coll, __func__, &error) < 0)
|
|
357
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
358
|
-
DPI_CHECK_PTR_AND_LENGTH(coll, indexSpec)
|
|
359
|
-
|
|
360
|
-
// determine mode to pass to OCI
|
|
361
|
-
mode = DPI_OCI_DEFAULT;
|
|
362
|
-
if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
|
|
363
|
-
mode |= DPI_OCI_SODA_ATOMIC_COMMIT;
|
|
364
|
-
|
|
365
|
-
// create index
|
|
366
|
-
status = dpiOci__sodaIndexCreate(coll, indexSpec, indexSpecLength, mode,
|
|
367
|
-
&error);
|
|
368
|
-
return dpiGen__endPublicFn(coll, status, &error);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
//-----------------------------------------------------------------------------
|
|
373
|
-
// dpiSodaColl_drop() [PUBLIC]
|
|
374
|
-
// Drop the collection.
|
|
375
|
-
//-----------------------------------------------------------------------------
|
|
376
|
-
int dpiSodaColl_drop(dpiSodaColl *coll, uint32_t flags, int *isDropped)
|
|
377
|
-
{
|
|
378
|
-
int status, dummyIsDropped;
|
|
379
|
-
dpiError error;
|
|
380
|
-
uint32_t mode;
|
|
381
|
-
|
|
382
|
-
// validate parameters
|
|
383
|
-
if (dpiSodaColl__check(coll, __func__, &error) < 0)
|
|
384
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
385
|
-
|
|
386
|
-
// isDropped is not a mandatory parameter, but it is for OCI
|
|
387
|
-
if (!isDropped)
|
|
388
|
-
isDropped = &dummyIsDropped;
|
|
389
|
-
|
|
390
|
-
// determine mode to pass to OCI
|
|
391
|
-
mode = DPI_OCI_DEFAULT;
|
|
392
|
-
if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
|
|
393
|
-
mode |= DPI_OCI_SODA_ATOMIC_COMMIT;
|
|
394
|
-
|
|
395
|
-
// drop collection
|
|
396
|
-
status = dpiOci__sodaCollDrop(coll, isDropped, mode, &error);
|
|
397
|
-
return dpiGen__endPublicFn(coll, status, &error);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
//-----------------------------------------------------------------------------
|
|
402
|
-
// dpiSodaColl_dropIndex() [PUBLIC]
|
|
403
|
-
// Drop the index on the collection.
|
|
404
|
-
//-----------------------------------------------------------------------------
|
|
405
|
-
int dpiSodaColl_dropIndex(dpiSodaColl *coll, const char *name,
|
|
406
|
-
uint32_t nameLength, uint32_t flags, int *isDropped)
|
|
407
|
-
{
|
|
408
|
-
int status, dummyIsDropped;
|
|
409
|
-
dpiError error;
|
|
410
|
-
uint32_t mode;
|
|
411
|
-
|
|
412
|
-
// validate parameters
|
|
413
|
-
if (dpiSodaColl__check(coll, __func__, &error) < 0)
|
|
414
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
415
|
-
DPI_CHECK_PTR_AND_LENGTH(coll, name)
|
|
416
|
-
|
|
417
|
-
// isDropped is not a mandatory parameter, but it is for OCI
|
|
418
|
-
if (!isDropped)
|
|
419
|
-
isDropped = &dummyIsDropped;
|
|
420
|
-
|
|
421
|
-
// determine mode to pass to OCI
|
|
422
|
-
mode = DPI_OCI_DEFAULT;
|
|
423
|
-
if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
|
|
424
|
-
mode |= DPI_OCI_SODA_ATOMIC_COMMIT;
|
|
425
|
-
if (flags & DPI_SODA_FLAGS_INDEX_DROP_FORCE)
|
|
426
|
-
mode |= DPI_OCI_SODA_INDEX_DROP_FORCE;
|
|
427
|
-
|
|
428
|
-
// drop index
|
|
429
|
-
status = dpiOci__sodaIndexDrop(coll, name, nameLength, mode, isDropped,
|
|
430
|
-
&error);
|
|
431
|
-
return dpiGen__endPublicFn(coll, status, &error);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
//-----------------------------------------------------------------------------
|
|
436
|
-
// dpiSodaColl_find() [PUBLIC]
|
|
437
|
-
// Find documents in a collection and return a cursor.
|
|
438
|
-
//-----------------------------------------------------------------------------
|
|
439
|
-
int dpiSodaColl_find(dpiSodaColl *coll, const dpiSodaOperOptions *options,
|
|
440
|
-
uint32_t flags, dpiSodaDocCursor **cursor)
|
|
441
|
-
{
|
|
442
|
-
dpiError error;
|
|
443
|
-
|
|
444
|
-
// validate parameters
|
|
445
|
-
if (dpiSodaColl__check(coll, __func__, &error) < 0)
|
|
446
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
447
|
-
DPI_CHECK_PTR_NOT_NULL(coll, cursor)
|
|
448
|
-
|
|
449
|
-
// perform find and return a cursor
|
|
450
|
-
if (dpiSodaColl__find(coll, options, flags, cursor, NULL, &error) < 0)
|
|
451
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
452
|
-
|
|
453
|
-
return dpiGen__endPublicFn(coll, DPI_SUCCESS, &error);
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
//-----------------------------------------------------------------------------
|
|
458
|
-
// dpiSodaColl_findOne() [PUBLIC]
|
|
459
|
-
// Find a single document in a collection and return it.
|
|
460
|
-
//-----------------------------------------------------------------------------
|
|
461
|
-
int dpiSodaColl_findOne(dpiSodaColl *coll, const dpiSodaOperOptions *options,
|
|
462
|
-
uint32_t flags, dpiSodaDoc **doc)
|
|
463
|
-
{
|
|
464
|
-
dpiError error;
|
|
465
|
-
|
|
466
|
-
// validate parameters
|
|
467
|
-
if (dpiSodaColl__check(coll, __func__, &error) < 0)
|
|
468
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
469
|
-
DPI_CHECK_PTR_NOT_NULL(coll, doc)
|
|
470
|
-
|
|
471
|
-
// perform find and return a document
|
|
472
|
-
if (dpiSodaColl__find(coll, options, flags, NULL, doc, &error) < 0)
|
|
473
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
474
|
-
|
|
475
|
-
return dpiGen__endPublicFn(coll, DPI_SUCCESS, &error);
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
//-----------------------------------------------------------------------------
|
|
480
|
-
// dpiSodaColl_getDataGuide() [PUBLIC]
|
|
481
|
-
// Return the data guide document for the collection.
|
|
482
|
-
//-----------------------------------------------------------------------------
|
|
483
|
-
int dpiSodaColl_getDataGuide(dpiSodaColl *coll, uint32_t flags,
|
|
484
|
-
dpiSodaDoc **doc)
|
|
485
|
-
{
|
|
486
|
-
void *docHandle;
|
|
487
|
-
dpiError error;
|
|
488
|
-
uint32_t mode;
|
|
489
|
-
|
|
490
|
-
// validate parameters
|
|
491
|
-
if (dpiSodaColl__check(coll, __func__, &error) < 0)
|
|
492
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
493
|
-
DPI_CHECK_PTR_NOT_NULL(coll, doc)
|
|
494
|
-
|
|
495
|
-
// determine mode to pass
|
|
496
|
-
mode = DPI_OCI_DEFAULT;
|
|
497
|
-
if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
|
|
498
|
-
mode |= DPI_OCI_SODA_ATOMIC_COMMIT;
|
|
499
|
-
|
|
500
|
-
// get data guide
|
|
501
|
-
if (dpiOci__sodaDataGuideGet(coll, &docHandle, mode, &error) < 0)
|
|
502
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
503
|
-
if (!docHandle) {
|
|
504
|
-
*doc = NULL;
|
|
505
|
-
} else if (dpiSodaDoc__allocate(coll->db, docHandle, doc, &error) < 0) {
|
|
506
|
-
dpiOci__handleFree(docHandle, DPI_OCI_HTYPE_SODA_DOCUMENT);
|
|
507
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
return dpiGen__endPublicFn(coll, DPI_SUCCESS, &error);
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
//-----------------------------------------------------------------------------
|
|
515
|
-
// dpiSodaColl_getDocCount() [PUBLIC]
|
|
516
|
-
// Return the number of documents in the collection that match the specified
|
|
517
|
-
// criteria.
|
|
518
|
-
//-----------------------------------------------------------------------------
|
|
519
|
-
int dpiSodaColl_getDocCount(dpiSodaColl *coll,
|
|
520
|
-
const dpiSodaOperOptions *options, uint32_t flags, uint64_t *count)
|
|
521
|
-
{
|
|
522
|
-
dpiError error;
|
|
523
|
-
|
|
524
|
-
// validate parameters
|
|
525
|
-
if (dpiSodaColl__check(coll, __func__, &error) < 0)
|
|
526
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
527
|
-
DPI_CHECK_PTR_NOT_NULL(coll, count)
|
|
528
|
-
|
|
529
|
-
// get document count
|
|
530
|
-
if (dpiSodaColl__getDocCount(coll, options, flags, count, &error) < 0)
|
|
531
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
532
|
-
|
|
533
|
-
return dpiGen__endPublicFn(coll, DPI_SUCCESS, &error);
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
//-----------------------------------------------------------------------------
|
|
538
|
-
// dpiSodaColl_getMetadata() [PUBLIC]
|
|
539
|
-
// Return the metadata for the collection.
|
|
540
|
-
//-----------------------------------------------------------------------------
|
|
541
|
-
int dpiSodaColl_getMetadata(dpiSodaColl *coll, const char **value,
|
|
542
|
-
uint32_t *valueLength)
|
|
543
|
-
{
|
|
544
|
-
dpiError error;
|
|
545
|
-
int status;
|
|
546
|
-
|
|
547
|
-
// validate parameters
|
|
548
|
-
if (dpiSodaColl__check(coll, __func__, &error) < 0)
|
|
549
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
550
|
-
DPI_CHECK_PTR_NOT_NULL(coll, value)
|
|
551
|
-
DPI_CHECK_PTR_NOT_NULL(coll, valueLength)
|
|
552
|
-
|
|
553
|
-
// get attribute value
|
|
554
|
-
status = dpiOci__attrGet(coll->handle, DPI_OCI_HTYPE_SODA_COLLECTION,
|
|
555
|
-
(void*) value, valueLength, DPI_OCI_ATTR_SODA_COLL_DESCRIPTOR,
|
|
556
|
-
"get value", &error);
|
|
557
|
-
return dpiGen__endPublicFn(coll, status, &error);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
//-----------------------------------------------------------------------------
|
|
562
|
-
// dpiSodaColl_getName() [PUBLIC]
|
|
563
|
-
// Return the name of the collection.
|
|
564
|
-
//-----------------------------------------------------------------------------
|
|
565
|
-
int dpiSodaColl_getName(dpiSodaColl *coll, const char **value,
|
|
566
|
-
uint32_t *valueLength)
|
|
567
|
-
{
|
|
568
|
-
dpiError error;
|
|
569
|
-
int status;
|
|
570
|
-
|
|
571
|
-
// validate parameters
|
|
572
|
-
if (dpiSodaColl__check(coll, __func__, &error) < 0)
|
|
573
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
574
|
-
DPI_CHECK_PTR_NOT_NULL(coll, value)
|
|
575
|
-
DPI_CHECK_PTR_NOT_NULL(coll, valueLength)
|
|
576
|
-
|
|
577
|
-
// get attribute value
|
|
578
|
-
status = dpiOci__attrGet(coll->handle, DPI_OCI_HTYPE_SODA_COLLECTION,
|
|
579
|
-
(void*) value, valueLength, DPI_OCI_ATTR_SODA_COLL_NAME,
|
|
580
|
-
"get value", &error);
|
|
581
|
-
return dpiGen__endPublicFn(coll, status, &error);
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
//-----------------------------------------------------------------------------
|
|
586
|
-
// dpiSodaColl_insertOne() [PUBLIC]
|
|
587
|
-
// Insert a document into the collection and return a handle to the newly
|
|
588
|
-
// created document, if desired.
|
|
589
|
-
//-----------------------------------------------------------------------------
|
|
590
|
-
int dpiSodaColl_insertOne(dpiSodaColl *coll, dpiSodaDoc *doc, uint32_t flags,
|
|
591
|
-
dpiSodaDoc **insertedDoc)
|
|
592
|
-
{
|
|
593
|
-
void *docHandle;
|
|
594
|
-
dpiError error;
|
|
595
|
-
uint32_t mode;
|
|
596
|
-
int status;
|
|
597
|
-
|
|
598
|
-
// validate parameters
|
|
599
|
-
if (dpiSodaColl__check(coll, __func__, &error) < 0)
|
|
600
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
601
|
-
if (dpiGen__checkHandle(doc, DPI_HTYPE_SODA_DOC, "check document",
|
|
602
|
-
&error) < 0)
|
|
603
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
604
|
-
|
|
605
|
-
// determine OCI mode to use
|
|
606
|
-
mode = DPI_OCI_DEFAULT;
|
|
607
|
-
if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
|
|
608
|
-
mode |= DPI_OCI_SODA_ATOMIC_COMMIT;
|
|
609
|
-
|
|
610
|
-
// insert document into collection
|
|
611
|
-
// use "AndGet" variant if the inserted document is requested
|
|
612
|
-
docHandle = doc->handle;
|
|
613
|
-
if (!insertedDoc)
|
|
614
|
-
status = dpiOci__sodaInsert(coll, docHandle, mode, &error);
|
|
615
|
-
else {
|
|
616
|
-
status = dpiOci__sodaInsertAndGet(coll, &docHandle, mode, &error);
|
|
617
|
-
if (status == 0) {
|
|
618
|
-
status = dpiSodaDoc__allocate(coll->db, docHandle, insertedDoc,
|
|
619
|
-
&error);
|
|
620
|
-
if (status < 0)
|
|
621
|
-
dpiOci__handleFree(docHandle, DPI_OCI_HTYPE_SODA_DOCUMENT);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
return dpiGen__endPublicFn(coll, status, &error);
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
//-----------------------------------------------------------------------------
|
|
630
|
-
// dpiSodaColl_release() [PUBLIC]
|
|
631
|
-
// Release a reference to the SODA collection.
|
|
632
|
-
//-----------------------------------------------------------------------------
|
|
633
|
-
int dpiSodaColl_release(dpiSodaColl *coll)
|
|
634
|
-
{
|
|
635
|
-
return dpiGen__release(coll, DPI_HTYPE_SODA_COLL, __func__);
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
//-----------------------------------------------------------------------------
|
|
640
|
-
// dpiSodaColl_remove() [PUBLIC]
|
|
641
|
-
// Remove the documents from the collection that match the given criteria.
|
|
642
|
-
//-----------------------------------------------------------------------------
|
|
643
|
-
int dpiSodaColl_remove(dpiSodaColl *coll, const dpiSodaOperOptions *options,
|
|
644
|
-
uint32_t flags, uint64_t *count)
|
|
645
|
-
{
|
|
646
|
-
dpiError error;
|
|
647
|
-
|
|
648
|
-
// validate parameters
|
|
649
|
-
if (dpiSodaColl__check(coll, __func__, &error) < 0)
|
|
650
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
651
|
-
DPI_CHECK_PTR_NOT_NULL(coll, count)
|
|
652
|
-
|
|
653
|
-
// perform removal
|
|
654
|
-
if (dpiSodaColl__remove(coll, options, flags, count, &error) < 0)
|
|
655
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
656
|
-
|
|
657
|
-
return dpiGen__endPublicFn(coll, DPI_SUCCESS, &error);
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
//-----------------------------------------------------------------------------
|
|
662
|
-
// dpiSodaColl_replaceOne() [PUBLIC]
|
|
663
|
-
// Replace the first document in the collection that matches the given
|
|
664
|
-
// criteria. Returns a handle to the newly replaced document, if desired.
|
|
665
|
-
//-----------------------------------------------------------------------------
|
|
666
|
-
int dpiSodaColl_replaceOne(dpiSodaColl *coll,
|
|
667
|
-
const dpiSodaOperOptions *options, dpiSodaDoc *doc, uint32_t flags,
|
|
668
|
-
int *replaced, dpiSodaDoc **replacedDoc)
|
|
669
|
-
{
|
|
670
|
-
dpiError error;
|
|
671
|
-
int status;
|
|
672
|
-
|
|
673
|
-
// validate parameters
|
|
674
|
-
if (dpiSodaColl__check(coll, __func__, &error) < 0)
|
|
675
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
676
|
-
if (dpiGen__checkHandle(doc, DPI_HTYPE_SODA_DOC, "check document",
|
|
677
|
-
&error) < 0)
|
|
678
|
-
return dpiGen__endPublicFn(coll, DPI_FAILURE, &error);
|
|
679
|
-
|
|
680
|
-
// perform replace
|
|
681
|
-
status = dpiSodaColl__replace(coll, options, doc, flags, replaced,
|
|
682
|
-
replacedDoc, &error);
|
|
683
|
-
return dpiGen__endPublicFn(coll, status, &error);
|
|
684
|
-
}
|
|
685
|
-
|