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.
Files changed (112) hide show
  1. package/CHANGELOG.md +135 -8
  2. package/README.md +6 -4
  3. package/build/Release/oracledb-abi48-darwin-x64.node +0 -0
  4. package/build/Release/oracledb-abi48-darwin-x64.node-buildinfo.txt +1 -0
  5. package/build/Release/oracledb-abi48-linux-x64.node +0 -0
  6. package/build/Release/oracledb-abi48-linux-x64.node-buildinfo.txt +1 -0
  7. package/build/Release/oracledb-abi48-win32-x64.node +0 -0
  8. package/build/Release/oracledb-abi48-win32-x64.node-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-abi57-darwin-x64.node +0 -0
  10. package/build/Release/oracledb-abi57-darwin-x64.node-buildinfo.txt +1 -0
  11. package/build/Release/oracledb-abi57-linux-x64.node +0 -0
  12. package/build/Release/oracledb-abi57-linux-x64.node-buildinfo.txt +1 -0
  13. package/build/Release/oracledb-abi57-win32-x64.node +0 -0
  14. package/build/Release/oracledb-abi57-win32-x64.node-buildinfo.txt +1 -0
  15. package/build/Release/oracledb-abi64-darwin-x64.node +0 -0
  16. package/build/Release/oracledb-abi64-darwin-x64.node-buildinfo.txt +1 -0
  17. package/build/Release/oracledb-abi64-linux-x64.node +0 -0
  18. package/build/Release/oracledb-abi64-linux-x64.node-buildinfo.txt +1 -0
  19. package/build/Release/oracledb-abi64-win32-x64.node +0 -0
  20. package/build/Release/oracledb-abi64-win32-x64.node-buildinfo.txt +1 -0
  21. package/build/Release/oracledb-abi67-darwin-x64.node +0 -0
  22. package/build/Release/oracledb-abi67-darwin-x64.node-buildinfo.txt +1 -0
  23. package/build/Release/oracledb-abi67-linux-x64.node +0 -0
  24. package/build/Release/oracledb-abi67-linux-x64.node-buildinfo.txt +1 -0
  25. package/build/Release/oracledb-abi67-win32-x64.node +0 -0
  26. package/build/Release/oracledb-abi67-win32-x64.node-buildinfo.txt +1 -0
  27. package/lib/connection.js +18 -4
  28. package/lib/oracledb.js +44 -92
  29. package/lib/pool.js +36 -2
  30. package/lib/sodaCollection.js +1 -1
  31. package/lib/sodaDatabase.js +1 -1
  32. package/lib/util.js +82 -5
  33. package/package/README.md +32 -101
  34. package/package/install.js +139 -0
  35. package/package/prunebinaries.js +51 -0
  36. package/package.json +4 -11
  37. package/binding.gyp +0 -162
  38. package/lib/rel.txt +0 -1
  39. package/odpi/.npmignore +0 -4
  40. package/odpi/LICENSE.md +0 -218
  41. package/odpi/README.md +0 -61
  42. package/odpi/embed/README.md +0 -4
  43. package/odpi/embed/dpi.c +0 -50
  44. package/odpi/include/dpi.h +0 -1748
  45. package/odpi/src/dpiConn.c +0 -2089
  46. package/odpi/src/dpiContext.c +0 -296
  47. package/odpi/src/dpiData.c +0 -797
  48. package/odpi/src/dpiDebug.c +0 -184
  49. package/odpi/src/dpiDeqOptions.c +0 -370
  50. package/odpi/src/dpiEnqOptions.c +0 -174
  51. package/odpi/src/dpiEnv.c +0 -189
  52. package/odpi/src/dpiError.c +0 -204
  53. package/odpi/src/dpiErrorMessages.h +0 -86
  54. package/odpi/src/dpiGen.c +0 -303
  55. package/odpi/src/dpiGlobal.c +0 -292
  56. package/odpi/src/dpiHandleList.c +0 -117
  57. package/odpi/src/dpiHandlePool.c +0 -118
  58. package/odpi/src/dpiImpl.h +0 -1707
  59. package/odpi/src/dpiLob.c +0 -506
  60. package/odpi/src/dpiMsgProps.c +0 -386
  61. package/odpi/src/dpiObject.c +0 -897
  62. package/odpi/src/dpiObjectAttr.c +0 -115
  63. package/odpi/src/dpiObjectType.c +0 -326
  64. package/odpi/src/dpiOci.c +0 -3527
  65. package/odpi/src/dpiOracleType.c +0 -492
  66. package/odpi/src/dpiPool.c +0 -549
  67. package/odpi/src/dpiRowid.c +0 -136
  68. package/odpi/src/dpiSodaColl.c +0 -685
  69. package/odpi/src/dpiSodaCollCursor.c +0 -143
  70. package/odpi/src/dpiSodaDb.c +0 -432
  71. package/odpi/src/dpiSodaDoc.c +0 -230
  72. package/odpi/src/dpiSodaDocCursor.c +0 -143
  73. package/odpi/src/dpiStmt.c +0 -1797
  74. package/odpi/src/dpiSubscr.c +0 -674
  75. package/odpi/src/dpiUtils.c +0 -410
  76. package/odpi/src/dpiVar.c +0 -1794
  77. package/package/MAKEPKG.BAT +0 -156
  78. package/package/Makefile +0 -85
  79. package/package/createpackage.js +0 -186
  80. package/package/extractpackage.js +0 -76
  81. package/package/getversion.js +0 -37
  82. package/package/oracledbinstall.js +0 -497
  83. package/package/package.json +0 -54
  84. package/package/util.js +0 -286
  85. package/src/njsCommon.cpp +0 -1055
  86. package/src/njsCommon.h +0 -484
  87. package/src/njsConnection.cpp +0 -2926
  88. package/src/njsConnection.h +0 -227
  89. package/src/njsIntLob.cpp +0 -618
  90. package/src/njsIntLob.h +0 -179
  91. package/src/njsMessages.cpp +0 -122
  92. package/src/njsMessages.h +0 -118
  93. package/src/njsOracle.cpp +0 -1274
  94. package/src/njsOracle.h +0 -237
  95. package/src/njsPool.cpp +0 -482
  96. package/src/njsPool.h +0 -132
  97. package/src/njsResultSet.cpp +0 -478
  98. package/src/njsResultSet.h +0 -120
  99. package/src/njsSodaCollection.cpp +0 -507
  100. package/src/njsSodaCollection.h +0 -128
  101. package/src/njsSodaDatabase.cpp +0 -335
  102. package/src/njsSodaDatabase.h +0 -108
  103. package/src/njsSodaDocCursor.cpp +0 -203
  104. package/src/njsSodaDocCursor.h +0 -94
  105. package/src/njsSodaDocument.cpp +0 -412
  106. package/src/njsSodaDocument.h +0 -105
  107. package/src/njsSodaOperation.cpp +0 -557
  108. package/src/njsSodaOperation.h +0 -123
  109. package/src/njsSubscription.cpp +0 -388
  110. package/src/njsSubscription.h +0 -111
  111. package/src/njsUtils.cpp +0 -158
  112. package/src/njsUtils.h +0 -68
@@ -1,143 +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
- // dpiSodaCollCursor.c
14
- // Implementation of SODA collection cursors.
15
- //-----------------------------------------------------------------------------
16
-
17
- #include "dpiImpl.h"
18
-
19
- //-----------------------------------------------------------------------------
20
- // dpiSodaCollCursor__allocate() [INTERNAL]
21
- // Allocate and initialize a SODA collection cursor structure.
22
- //-----------------------------------------------------------------------------
23
- int dpiSodaCollCursor__allocate(dpiSodaDb *db, void *handle,
24
- dpiSodaCollCursor **cursor, dpiError *error)
25
- {
26
- dpiSodaCollCursor *tempCursor;
27
-
28
- if (dpiGen__allocate(DPI_HTYPE_SODA_COLL_CURSOR, db->env,
29
- (void**) &tempCursor, error) < 0)
30
- return DPI_FAILURE;
31
- dpiGen__setRefCount(db, error, 1);
32
- tempCursor->db = db;
33
- tempCursor->handle = handle;
34
- *cursor = tempCursor;
35
- return DPI_SUCCESS;
36
- }
37
-
38
-
39
- //-----------------------------------------------------------------------------
40
- // dpiSodaCollCursor__check() [INTERNAL]
41
- // Determine if the SODA collection cursor is available to use.
42
- //-----------------------------------------------------------------------------
43
- static int dpiSodaCollCursor__check(dpiSodaCollCursor *cursor,
44
- const char *fnName, dpiError *error)
45
- {
46
- if (dpiGen__startPublicFn(cursor, DPI_HTYPE_SODA_COLL_CURSOR, fnName, 1,
47
- error) < 0)
48
- return DPI_FAILURE;
49
- if (!cursor->handle)
50
- return dpiError__set(error, "check closed",
51
- DPI_ERR_SODA_CURSOR_CLOSED);
52
- if (!cursor->db->conn->handle || cursor->db->conn->closing)
53
- return dpiError__set(error, "check connection", DPI_ERR_NOT_CONNECTED);
54
- return DPI_SUCCESS;
55
- }
56
-
57
-
58
- //-----------------------------------------------------------------------------
59
- // dpiSodaCollCursor__free() [INTERNAL]
60
- // Free the memory for a SODA collection cursor.
61
- //-----------------------------------------------------------------------------
62
- void dpiSodaCollCursor__free(dpiSodaCollCursor *cursor, dpiError *error)
63
- {
64
- if (cursor->db) {
65
- dpiGen__setRefCount(cursor->db, error, -1);
66
- cursor->db = NULL;
67
- }
68
- if (cursor->handle) {
69
- dpiOci__handleFree(cursor->handle, DPI_OCI_HTYPE_SODA_COLL_CURSOR);
70
- cursor->handle = NULL;
71
- }
72
- dpiUtils__freeMemory(cursor);
73
- }
74
-
75
-
76
- //-----------------------------------------------------------------------------
77
- // dpiSodaCollCursor_addRef() [PUBLIC]
78
- // Add a reference to the SODA collection cursor.
79
- //-----------------------------------------------------------------------------
80
- int dpiSodaCollCursor_addRef(dpiSodaCollCursor *cursor)
81
- {
82
- return dpiGen__addRef(cursor, DPI_HTYPE_SODA_COLL_CURSOR, __func__);
83
- }
84
-
85
-
86
- //-----------------------------------------------------------------------------
87
- // dpiSodaCollCursor_close() [PUBLIC]
88
- // Close the cursor.
89
- //-----------------------------------------------------------------------------
90
- int dpiSodaCollCursor_close(dpiSodaCollCursor *cursor)
91
- {
92
- dpiError error;
93
-
94
- if (dpiSodaCollCursor__check(cursor, __func__, &error) < 0)
95
- return dpiGen__endPublicFn(cursor, DPI_FAILURE, &error);
96
- if (cursor->handle) {
97
- dpiOci__handleFree(cursor->handle, DPI_OCI_HTYPE_SODA_COLL_CURSOR);
98
- cursor->handle = NULL;
99
- }
100
- return dpiGen__endPublicFn(cursor, DPI_SUCCESS, &error);
101
- }
102
-
103
-
104
- //-----------------------------------------------------------------------------
105
- // dpiSodaCollCursor_getNext() [PUBLIC]
106
- // Return the next collection available from the cursor.
107
- //-----------------------------------------------------------------------------
108
- int dpiSodaCollCursor_getNext(dpiSodaCollCursor *cursor, uint32_t flags,
109
- dpiSodaColl **coll)
110
- {
111
- dpiError error;
112
- uint32_t mode;
113
- void *handle;
114
-
115
- if (dpiSodaCollCursor__check(cursor, __func__, &error) < 0)
116
- return dpiGen__endPublicFn(cursor, DPI_FAILURE, &error);
117
- DPI_CHECK_PTR_NOT_NULL(cursor, coll)
118
- mode = DPI_OCI_DEFAULT;
119
- if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
120
- mode |= DPI_OCI_SODA_ATOMIC_COMMIT;
121
- if (dpiOci__sodaCollGetNext(cursor->db->conn, cursor->handle, &handle,
122
- mode, &error) < 0)
123
- return dpiGen__endPublicFn(cursor, DPI_FAILURE, &error);
124
- *coll = NULL;
125
- if (handle) {
126
- if (dpiSodaColl__allocate(cursor->db, handle, coll, &error) < 0) {
127
- dpiOci__handleFree(handle, DPI_OCI_HTYPE_SODA_COLLECTION);
128
- return dpiGen__endPublicFn(cursor, DPI_FAILURE, &error);
129
- }
130
- }
131
- return dpiGen__endPublicFn(cursor, DPI_SUCCESS, &error);
132
- }
133
-
134
-
135
- //-----------------------------------------------------------------------------
136
- // dpiSodaCollCursor_release() [PUBLIC]
137
- // Release a reference to the SODA collection cursor.
138
- //-----------------------------------------------------------------------------
139
- int dpiSodaCollCursor_release(dpiSodaCollCursor *cursor)
140
- {
141
- return dpiGen__release(cursor, DPI_HTYPE_SODA_COLL_CURSOR, __func__);
142
- }
143
-
@@ -1,432 +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
- // dpiSodaDb.c
14
- // Implementation of SODA database methods.
15
- //-----------------------------------------------------------------------------
16
-
17
- #include "dpiImpl.h"
18
-
19
- //-----------------------------------------------------------------------------
20
- // dpiSodaDb__checkConnected() [INTERNAL]
21
- // Check to see that the connection to the database is available for use.
22
- //-----------------------------------------------------------------------------
23
- static int dpiSodaDb__checkConnected(dpiSodaDb *db, const char *fnName,
24
- dpiError *error)
25
- {
26
- if (dpiGen__startPublicFn(db, DPI_HTYPE_SODA_DB, fnName, 1, error) < 0)
27
- return DPI_FAILURE;
28
- if (!db->conn->handle || db->conn->closing)
29
- return dpiError__set(error, "check connection", DPI_ERR_NOT_CONNECTED);
30
- return DPI_SUCCESS;
31
- }
32
-
33
-
34
- //-----------------------------------------------------------------------------
35
- // dpiSodaDb__getCollectionNames() [PUBLIC]
36
- // Internal method used for getting all collection names from the database.
37
- // The provided cursor handle is iterated until either the limit is reached
38
- // or there are no more collections to find.
39
- //-----------------------------------------------------------------------------
40
- static int dpiSodaDb__getCollectionNames(dpiSodaDb *db, void *cursorHandle,
41
- uint32_t limit, dpiSodaCollNames *names, char **namesBuffer,
42
- dpiError *error)
43
- {
44
- uint32_t numAllocatedNames, namesBufferUsed, namesBufferAllocated;
45
- uint32_t i, nameLength, *tempNameLengths;
46
- char *name, *tempNamesBuffer, *ptr;
47
- void *collectionHandle;
48
-
49
- ptr = *namesBuffer;
50
- namesBufferUsed = namesBufferAllocated = numAllocatedNames = 0;
51
- while (names->numNames < limit || limit == 0) {
52
-
53
- // get next collection from cursor
54
- if (dpiOci__sodaCollGetNext(db->conn, cursorHandle, &collectionHandle,
55
- DPI_OCI_DEFAULT, error) < 0)
56
- return DPI_FAILURE;
57
- if (!collectionHandle)
58
- break;
59
-
60
- // get name from collection
61
- if (dpiOci__attrGet(collectionHandle, DPI_OCI_HTYPE_SODA_COLLECTION,
62
- (void*) &name, &nameLength, DPI_OCI_ATTR_SODA_COLL_NAME,
63
- "get collection name", error) < 0) {
64
- dpiOci__handleFree(collectionHandle,
65
- DPI_OCI_HTYPE_SODA_COLLECTION);
66
- return DPI_FAILURE;
67
- }
68
-
69
- // allocate additional space for the lengths array, if needed
70
- if (numAllocatedNames <= names->numNames) {
71
- numAllocatedNames += 256;
72
- if (dpiUtils__allocateMemory(numAllocatedNames, sizeof(uint32_t),
73
- 0, "allocate lengths array", (void**) &tempNameLengths,
74
- error) < 0) {
75
- dpiOci__handleFree(collectionHandle,
76
- DPI_OCI_HTYPE_SODA_COLLECTION);
77
- return DPI_FAILURE;
78
- }
79
- if (names->nameLengths) {
80
- memcpy(tempNameLengths, names->nameLengths,
81
- names->numNames * sizeof(uint32_t));
82
- dpiUtils__freeMemory(names->nameLengths);
83
- }
84
- names->nameLengths = tempNameLengths;
85
- }
86
-
87
- // allocate additional space for the names buffer, if needed
88
- if (namesBufferUsed + nameLength > namesBufferAllocated) {
89
- namesBufferAllocated += 32768;
90
- if (dpiUtils__allocateMemory(namesBufferAllocated, 1, 0,
91
- "allocate names buffer", (void**) &tempNamesBuffer,
92
- error) < 0) {
93
- dpiOci__handleFree(collectionHandle,
94
- DPI_OCI_HTYPE_SODA_COLLECTION);
95
- return DPI_FAILURE;
96
- }
97
- if (*namesBuffer) {
98
- memcpy(tempNamesBuffer, *namesBuffer, namesBufferUsed);
99
- dpiUtils__freeMemory(*namesBuffer);
100
- }
101
- *namesBuffer = tempNamesBuffer;
102
- ptr = *namesBuffer + namesBufferUsed;
103
- }
104
-
105
- // store name in buffer and length in array
106
- // the names array itself is created and populated afterwards in order
107
- // to avoid unnecessary copying
108
- memcpy(ptr, name, nameLength);
109
- namesBufferUsed += nameLength;
110
- names->nameLengths[names->numNames] = nameLength;
111
- names->numNames++;
112
- ptr += nameLength;
113
-
114
- // free collection now that we have processed it successfully
115
- dpiOci__handleFree(collectionHandle, DPI_OCI_HTYPE_SODA_COLLECTION);
116
-
117
- }
118
-
119
- // now that all of the names have been determined, populate names array
120
- if (names->numNames > 0) {
121
- if (dpiUtils__allocateMemory(names->numNames, sizeof(char*), 0,
122
- "allocate names array", (void**) &names->names, error) < 0)
123
- return DPI_FAILURE;
124
- ptr = *namesBuffer;
125
- for (i = 0; i < names->numNames; i++) {
126
- names->names[i] = ptr;
127
- ptr += names->nameLengths[i];
128
- }
129
- }
130
-
131
- return DPI_SUCCESS;
132
- }
133
-
134
-
135
- //-----------------------------------------------------------------------------
136
- // dpiSodaDb__free() [INTERNAL]
137
- // Free the memory for a SODA database.
138
- //-----------------------------------------------------------------------------
139
- void dpiSodaDb__free(dpiSodaDb *db, dpiError *error)
140
- {
141
- if (db->conn) {
142
- dpiGen__setRefCount(db->conn, error, -1);
143
- db->conn = NULL;
144
- }
145
- dpiUtils__freeMemory(db);
146
- }
147
-
148
-
149
- //-----------------------------------------------------------------------------
150
- // dpiSodaDb_addRef() [PUBLIC]
151
- // Add a reference to the SODA database.
152
- //-----------------------------------------------------------------------------
153
- int dpiSodaDb_addRef(dpiSodaDb *db)
154
- {
155
- return dpiGen__addRef(db, DPI_HTYPE_SODA_DB, __func__);
156
- }
157
-
158
-
159
- //-----------------------------------------------------------------------------
160
- // dpiSodaDb_createCollection() [PUBLIC]
161
- // Create a new SODA collection with the given name and metadata.
162
- //-----------------------------------------------------------------------------
163
- int dpiSodaDb_createCollection(dpiSodaDb *db, const char *name,
164
- uint32_t nameLength, const char *metadata, uint32_t metadataLength,
165
- uint32_t flags, dpiSodaColl **coll)
166
- {
167
- dpiError error;
168
- uint32_t mode;
169
- void *handle;
170
-
171
- // validate parameters
172
- if (dpiSodaDb__checkConnected(db, __func__, &error) < 0)
173
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
174
- DPI_CHECK_PTR_AND_LENGTH(db, name)
175
- DPI_CHECK_PTR_AND_LENGTH(db, metadata)
176
- DPI_CHECK_PTR_NOT_NULL(db, coll)
177
-
178
- // determine OCI mode to use
179
- mode = DPI_OCI_DEFAULT;
180
- if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
181
- mode |= DPI_OCI_SODA_ATOMIC_COMMIT;
182
- if (flags & DPI_SODA_FLAGS_CREATE_COLL_MAP)
183
- mode |= DPI_OCI_SODA_COLL_CREATE_MAP;
184
-
185
- // create collection
186
- if (dpiOci__sodaCollCreateWithMetadata(db, name, nameLength, metadata,
187
- metadataLength, mode, &handle, &error) < 0)
188
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
189
- if (dpiSodaColl__allocate(db, handle, coll, &error) < 0) {
190
- dpiOci__handleFree(handle, DPI_OCI_HTYPE_SODA_COLLECTION);
191
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
192
- }
193
- return dpiGen__endPublicFn(db, DPI_SUCCESS, &error);
194
- }
195
-
196
-
197
- //-----------------------------------------------------------------------------
198
- // dpiSodaDb_createDocument() [PUBLIC]
199
- // Create a SODA document that can be inserted in the collection or can be
200
- // used to replace and existing document in the collection.
201
- //-----------------------------------------------------------------------------
202
- int dpiSodaDb_createDocument(dpiSodaDb *db, const char *key,
203
- uint32_t keyLength, const char *content, uint32_t contentLength,
204
- const char *mediaType, uint32_t mediaTypeLength, uint32_t flags,
205
- dpiSodaDoc **doc)
206
- {
207
- int detectEncoding;
208
- void *docHandle;
209
- dpiError error;
210
-
211
- // validate parameters
212
- if (dpiSodaDb__checkConnected(db, __func__, &error) < 0)
213
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
214
- DPI_CHECK_PTR_AND_LENGTH(db, key)
215
- DPI_CHECK_PTR_AND_LENGTH(db, content)
216
- DPI_CHECK_PTR_AND_LENGTH(db, mediaType)
217
- DPI_CHECK_PTR_NOT_NULL(db, doc)
218
-
219
- // allocate SODA document handle
220
- if (dpiOci__handleAlloc(db->env->handle, &docHandle,
221
- DPI_OCI_HTYPE_SODA_DOCUMENT, "allocate SODA document handle",
222
- &error) < 0)
223
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
224
-
225
- // set key, if applicable
226
- if (key && keyLength > 0) {
227
- if (dpiOci__attrSet(docHandle, DPI_OCI_HTYPE_SODA_DOCUMENT,
228
- (void*) key, keyLength, DPI_OCI_ATTR_SODA_KEY, "set key",
229
- &error) < 0) {
230
- dpiOci__handleFree(docHandle, DPI_OCI_HTYPE_SODA_DOCUMENT);
231
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
232
- }
233
- }
234
-
235
- // set content, if applicable
236
- if (content && contentLength > 0) {
237
- detectEncoding = 1;
238
- if (dpiOci__attrSet(docHandle, DPI_OCI_HTYPE_SODA_DOCUMENT,
239
- (void*) &detectEncoding, 0, DPI_OCI_ATTR_SODA_DETECT_JSON_ENC,
240
- "set detect encoding", &error) < 0) {
241
- dpiOci__handleFree(docHandle, DPI_OCI_HTYPE_SODA_DOCUMENT);
242
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
243
- }
244
- if (dpiOci__attrSet(docHandle, DPI_OCI_HTYPE_SODA_DOCUMENT,
245
- (void*) content, contentLength, DPI_OCI_ATTR_SODA_CONTENT,
246
- "set content", &error) < 0) {
247
- dpiOci__handleFree(docHandle, DPI_OCI_HTYPE_SODA_DOCUMENT);
248
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
249
- }
250
- }
251
-
252
- // set media type, if applicable
253
- if (mediaType && mediaTypeLength > 0) {
254
- if (dpiOci__attrSet(docHandle, DPI_OCI_HTYPE_SODA_DOCUMENT,
255
- (void*) mediaType, mediaTypeLength,
256
- DPI_OCI_ATTR_SODA_MEDIA_TYPE, "set media type", &error) < 0) {
257
- dpiOci__handleFree(docHandle, DPI_OCI_HTYPE_SODA_DOCUMENT);
258
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
259
- }
260
- }
261
-
262
- // allocate the ODPI-C document that will be returned
263
- if (dpiSodaDoc__allocate(db, docHandle, doc, &error) < 0) {
264
- dpiOci__handleFree(docHandle, DPI_OCI_HTYPE_SODA_DOCUMENT);
265
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
266
- }
267
- (*doc)->binaryContent = 1;
268
-
269
- return dpiGen__endPublicFn(db, DPI_SUCCESS, &error);
270
- }
271
-
272
-
273
- //-----------------------------------------------------------------------------
274
- // dpiSodaDb_freeCollectionNames() [PUBLIC]
275
- // Free the names of the collections allocated earlier with a call to
276
- // dpiSodaDb_getCollectionNames().
277
- //-----------------------------------------------------------------------------
278
- int dpiSodaDb_freeCollectionNames(dpiSodaDb *db, dpiSodaCollNames *names)
279
- {
280
- dpiError error;
281
-
282
- // validate parameters
283
- if (dpiSodaDb__checkConnected(db, __func__, &error) < 0)
284
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
285
- DPI_CHECK_PTR_NOT_NULL(db, names)
286
-
287
- // perform frees; note that the memory for the names themselves is stored
288
- // in one contiguous block pointed to by the first name
289
- if (names->names) {
290
- dpiUtils__freeMemory((void*) names->names[0]);
291
- dpiUtils__freeMemory((void*) names->names);
292
- names->names = NULL;
293
- }
294
- if (names->nameLengths) {
295
- dpiUtils__freeMemory(names->nameLengths);
296
- names->nameLengths = NULL;
297
- }
298
- names->numNames = 0;
299
-
300
- return dpiGen__endPublicFn(db, DPI_SUCCESS, &error);
301
- }
302
-
303
-
304
- //-----------------------------------------------------------------------------
305
- // dpiSodaDb_getCollections() [PUBLIC]
306
- // Return a cursor to iterate over the SODA collections in the database.
307
- //-----------------------------------------------------------------------------
308
- int dpiSodaDb_getCollections(dpiSodaDb *db, const char *startName,
309
- uint32_t startNameLength, uint32_t flags, dpiSodaCollCursor **cursor)
310
- {
311
- dpiError error;
312
- uint32_t mode;
313
- void *handle;
314
-
315
- if (dpiSodaDb__checkConnected(db, __func__, &error) < 0)
316
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
317
- DPI_CHECK_PTR_AND_LENGTH(db, startName)
318
- DPI_CHECK_PTR_NOT_NULL(db, cursor)
319
- mode = DPI_OCI_DEFAULT;
320
- if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
321
- mode |= DPI_OCI_SODA_ATOMIC_COMMIT;
322
- if (dpiOci__sodaCollList(db, startName, startNameLength, &handle, mode,
323
- &error) < 0)
324
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
325
- if (dpiSodaCollCursor__allocate(db, handle, cursor, &error) < 0) {
326
- dpiOci__handleFree(handle, DPI_OCI_HTYPE_SODA_COLL_CURSOR);
327
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
328
- }
329
- return dpiGen__endPublicFn(db, DPI_SUCCESS, &error);
330
- }
331
-
332
-
333
- //-----------------------------------------------------------------------------
334
- // dpiSodaDb_getCollectionNames() [PUBLIC]
335
- // Return the names of all collections in the provided array.
336
- //-----------------------------------------------------------------------------
337
- int dpiSodaDb_getCollectionNames(dpiSodaDb *db, const char *startName,
338
- uint32_t startNameLength, uint32_t limit, uint32_t flags,
339
- dpiSodaCollNames *names)
340
- {
341
- char *namesBuffer;
342
- dpiError error;
343
- uint32_t mode;
344
- void *handle;
345
- int status;
346
-
347
- // validate parameters
348
- if (dpiSodaDb__checkConnected(db, __func__, &error) < 0)
349
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
350
- DPI_CHECK_PTR_AND_LENGTH(db, startName)
351
- DPI_CHECK_PTR_NOT_NULL(db, names)
352
-
353
- // initialize output structure
354
- names->numNames = 0;
355
- names->names = NULL;
356
- names->nameLengths = NULL;
357
-
358
- // determine OCI mode to use
359
- mode = DPI_OCI_DEFAULT;
360
- if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
361
- mode |= DPI_OCI_SODA_ATOMIC_COMMIT;
362
-
363
- // acquire collection cursor
364
- if (dpiOci__sodaCollList(db, startName, startNameLength, &handle, mode,
365
- &error) < 0)
366
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
367
-
368
- // iterate over cursor to acquire collection names
369
- namesBuffer = NULL;
370
- status = dpiSodaDb__getCollectionNames(db, handle, limit, names,
371
- &namesBuffer, &error);
372
- dpiOci__handleFree(handle, DPI_OCI_HTYPE_SODA_COLL_CURSOR);
373
- if (status < 0) {
374
- names->numNames = 0;
375
- if (namesBuffer) {
376
- dpiUtils__freeMemory(namesBuffer);
377
- namesBuffer = NULL;
378
- }
379
- if (names->names) {
380
- dpiUtils__freeMemory((void*) names->names);
381
- names->names = NULL;
382
- }
383
- if (names->nameLengths) {
384
- dpiUtils__freeMemory(names->nameLengths);
385
- names->nameLengths = NULL;
386
- }
387
- }
388
- return dpiGen__endPublicFn(db, status, &error);
389
- }
390
-
391
-
392
- //-----------------------------------------------------------------------------
393
- // dpiSodaDb_openCollection() [PUBLIC]
394
- // Open an existing SODA collection and return a handle to it.
395
- //-----------------------------------------------------------------------------
396
- int dpiSodaDb_openCollection(dpiSodaDb *db, const char *name,
397
- uint32_t nameLength, uint32_t flags, dpiSodaColl **coll)
398
- {
399
- dpiError error;
400
- uint32_t mode;
401
- void *handle;
402
-
403
- if (dpiSodaDb__checkConnected(db, __func__, &error) < 0)
404
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
405
- DPI_CHECK_PTR_AND_LENGTH(db, name)
406
- DPI_CHECK_PTR_NOT_NULL(db, coll)
407
- mode = DPI_OCI_DEFAULT;
408
- if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT)
409
- mode |= DPI_OCI_SODA_ATOMIC_COMMIT;
410
- if (dpiOci__sodaCollOpen(db, name, nameLength, mode, &handle,
411
- &error) < 0)
412
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
413
- *coll = NULL;
414
- if (handle) {
415
- if (dpiSodaColl__allocate(db, handle, coll, &error) < 0) {
416
- dpiOci__handleFree(handle, DPI_OCI_HTYPE_SODA_COLLECTION);
417
- return dpiGen__endPublicFn(db, DPI_FAILURE, &error);
418
- }
419
- }
420
- return dpiGen__endPublicFn(db, DPI_SUCCESS, &error);
421
- }
422
-
423
-
424
- //-----------------------------------------------------------------------------
425
- // dpiSodaDb_release() [PUBLIC]
426
- // Release a reference to the SODA database.
427
- //-----------------------------------------------------------------------------
428
- int dpiSodaDb_release(dpiSodaDb *db)
429
- {
430
- return dpiGen__release(db, DPI_HTYPE_SODA_DB, __func__);
431
- }
432
-