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,478 +0,0 @@
1
- /* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. */
2
-
3
- /******************************************************************************
4
- *
5
- * You may not use the identified files except in compliance with the Apache
6
- * License, Version 2.0 (the "License.")
7
- *
8
- * You may obtain a copy of the License at
9
- * http://www.apache.org/licenses/LICENSE-2.0.
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- *
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * This file uses NAN:
19
- *
20
- * Copyright (c) 2015 NAN contributors
21
- *
22
- * NAN contributors listed at https://github.com/rvagg/nan#contributors
23
- *
24
- * Permission is hereby granted, free of charge, to any person obtaining
25
- * a copy of this software and associated documentation files (the
26
- * "Software"), to deal in the Software without restriction, including
27
- * without limitation the rights to use, copy, modify, merge, publish,
28
- * distribute, sublicense, and/or sell copies of the Software, and to
29
- * permit persons to whom the Software is furnished to do so, subject to
30
- * the following conditions:
31
- *
32
- * The above copyright notice and this permission notice shall be
33
- * included in all copies or substantial portions of the Software.
34
- *
35
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
37
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
38
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
39
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
40
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
41
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42
- *
43
- * NAME
44
- * njsResultSet.cpp
45
- *
46
- * DESCRIPTION
47
- * ResultSet class implementation.
48
- *
49
- *****************************************************************************/
50
- #include "node.h"
51
- #include <string>
52
- #include "njsResultSet.h"
53
- #include "njsConnection.h"
54
-
55
- #include <iostream>
56
-
57
- using namespace std;
58
- using namespace node;
59
- using namespace v8;
60
-
61
- // peristent ResultSet class handle
62
- Nan::Persistent<FunctionTemplate> njsResultSet::resultSetTemplate_s;
63
-
64
- //-----------------------------------------------------------------------------
65
- // njsResultSet::~njsResultSet()
66
- // Destructor.
67
- //-----------------------------------------------------------------------------
68
- njsResultSet::~njsResultSet()
69
- {
70
- jsConnection.Reset();
71
- jsOracledb.Reset();
72
- if (queryVars) {
73
- delete [] queryVars;
74
- queryVars = NULL;
75
- }
76
- if (dpiStmtHandle) {
77
- dpiStmt_release(dpiStmtHandle);
78
- dpiStmtHandle = NULL;
79
- }
80
- }
81
-
82
-
83
- //-----------------------------------------------------------------------------
84
- // njsResultSet::Init()
85
- // Initialization function of ResultSet class. Maps functions and properties
86
- // from JS to C++.
87
- //-----------------------------------------------------------------------------
88
- void njsResultSet::Init(Local<Object> target)
89
- {
90
- Nan::HandleScope scope;
91
- Local<FunctionTemplate> temp = Nan::New<FunctionTemplate>(New);
92
-
93
- temp->InstanceTemplate()->SetInternalFieldCount(1);
94
- temp->SetClassName(Nan::New<v8::String>("ResultSet").ToLocalChecked());
95
-
96
- Nan::SetPrototypeMethod(temp, "close", Close);
97
- Nan::SetPrototypeMethod(temp, "getRows", GetRows);
98
-
99
- Nan::SetAccessor(temp->InstanceTemplate(),
100
- Nan::New<v8::String>("metaData").ToLocalChecked(),
101
- njsResultSet::GetMetaData, njsResultSet::SetMetaData);
102
-
103
- resultSetTemplate_s.Reset(temp);
104
- Nan::Set(target, Nan::New<v8::String>("ResultSet").ToLocalChecked(),
105
- temp->GetFunction());
106
- }
107
-
108
-
109
- //-----------------------------------------------------------------------------
110
- // njsResultSet::CreateFromBaton()
111
- // Create a new result set from the baton.
112
- //-----------------------------------------------------------------------------
113
- Local<Object> njsResultSet::CreateFromBaton(njsBaton *baton)
114
- {
115
- Nan::EscapableHandleScope scope;
116
- njsResultSet *resultSet;
117
- Local<Function> func;
118
- Local<Object> obj;
119
-
120
- func = Nan::GetFunction(
121
- Nan::New<FunctionTemplate>(resultSetTemplate_s)).ToLocalChecked();
122
- obj = Nan::NewInstance(func).ToLocalChecked();
123
- resultSet = Nan::ObjectWrap::Unwrap<njsResultSet>(obj);
124
- resultSet->dpiStmtHandle = baton->dpiStmtHandle;
125
- baton->dpiStmtHandle = NULL;
126
- resultSet->dpiConnHandle = baton->dpiConnHandle;
127
- resultSet->jsOracledb.Reset(baton->jsOracledb);
128
- resultSet->outFormat = baton->outFormat;
129
- resultSet->numQueryVars = baton->numQueryVars;
130
- resultSet->queryVars = baton->queryVars;
131
- if (!baton->getRS) {
132
- resultSet->autoClose = true;
133
- resultSet->maxRows = baton->maxRows;
134
- }
135
- baton->queryVars = NULL;
136
- resultSet->activeBaton = NULL;
137
- resultSet->jsConnection.Reset(baton->jsCallingObj);
138
- resultSet->extendedMetaData = baton->extendedMetaData;
139
- return scope.Escape(obj);
140
- }
141
-
142
-
143
- //-----------------------------------------------------------------------------
144
- // njsResultSet::CreateFromRefCursor()
145
- // Create a new result set from the baton (
146
- //-----------------------------------------------------------------------------
147
- bool njsResultSet::CreateFromRefCursor(njsBaton *baton, dpiStmt *dpiStmtHandle,
148
- njsVariable *queryVars, uint32_t numQueryVars, Local<Value> &value)
149
- {
150
- Nan::EscapableHandleScope scope;
151
- njsResultSet *resultSet;
152
- Local<Function> func;
153
- Local<Object> obj;
154
-
155
- func = Nan::GetFunction(
156
- Nan::New<FunctionTemplate>(resultSetTemplate_s)).ToLocalChecked();
157
- obj = Nan::NewInstance(func).ToLocalChecked();
158
- resultSet = Nan::ObjectWrap::Unwrap<njsResultSet>(obj);
159
- if (dpiStmt_addRef(dpiStmtHandle) < 0)
160
- return false;
161
- resultSet->dpiStmtHandle = dpiStmtHandle;
162
- resultSet->dpiConnHandle = baton->dpiConnHandle;
163
- resultSet->jsOracledb.Reset(baton->jsOracledb);
164
- resultSet->jsConnection.Reset(baton->jsCallingObj);
165
- resultSet->outFormat = baton->outFormat;
166
- resultSet->extendedMetaData = baton->extendedMetaData;
167
- resultSet->activeBaton = NULL;
168
- resultSet->queryVars = queryVars;
169
- resultSet->numQueryVars = numQueryVars;
170
- baton->queryVars = NULL;
171
- value = scope.Escape(obj);
172
- return true;
173
- }
174
-
175
-
176
- //-----------------------------------------------------------------------------
177
- // njsResultSet::IsValid()
178
- // Returns whether the result set is valid.
179
- //-----------------------------------------------------------------------------
180
- bool njsResultSet::IsValid() const
181
- {
182
- // no DPI statement implies result set is not valid
183
- if (!dpiStmtHandle)
184
- return false;
185
-
186
- // otherwise, check to see if the connection is valid
187
- Nan::HandleScope scope;
188
- Local<Object> obj = Nan::New(jsConnection);
189
- njsConnection *connection = Nan::ObjectWrap::Unwrap<njsConnection>(obj);
190
- if (!connection)
191
- return false;
192
- return connection->IsValid();
193
- }
194
-
195
-
196
- //-----------------------------------------------------------------------------
197
- // njsResultSet::New()
198
- // Create new object accesible from JS. This is always called from within
199
- // njsResultSet::CreateFromBaton() and never from any external JS.
200
- //-----------------------------------------------------------------------------
201
- NAN_METHOD(njsResultSet::New)
202
- {
203
- njsResultSet *resultSet = new njsResultSet();
204
- resultSet->Wrap(info.Holder());
205
- info.GetReturnValue().Set(info.Holder());
206
- }
207
-
208
-
209
- //-----------------------------------------------------------------------------
210
- // ResulSet::GetMetaData()
211
- // Get accessor of "metaData" property.
212
- //-----------------------------------------------------------------------------
213
- NAN_GETTER(njsResultSet::GetMetaData)
214
- {
215
- njsResultSet *resultSet = (njsResultSet*) ValidateGetter(info);
216
- if (!resultSet)
217
- return;
218
- if (!resultSet->IsValid()) {
219
- info.GetReturnValue().Set(Nan::Undefined());
220
- return;
221
- }
222
- Local<Value> meta = njsConnection::GetMetaData(resultSet->queryVars,
223
- resultSet->numQueryVars, resultSet->extendedMetaData);
224
- info.GetReturnValue().Set(meta);
225
- }
226
-
227
-
228
- //-----------------------------------------------------------------------------
229
- // njsResultSet::SetMetaData()
230
- // Set accessor of "metaData" property.
231
- //-----------------------------------------------------------------------------
232
- NAN_SETTER(njsResultSet::SetMetaData)
233
- {
234
- PropertyIsReadOnly("metaData");
235
- }
236
-
237
-
238
- //-----------------------------------------------------------------------------
239
- // njsResultSet::GetRows()
240
- // Get a number of rows from the result set.
241
- //
242
- // PARAMETERS
243
- // - max number of rows to fetch at this time
244
- // - JS callback which will receive (error, row)
245
- //-----------------------------------------------------------------------------
246
- NAN_METHOD(njsResultSet::GetRows)
247
- {
248
- njsResultSet *resultSet;
249
- uint32_t maxRows;
250
- njsBaton *baton;
251
-
252
- resultSet = (njsResultSet*) ValidateArgs(info, 2, 2);
253
- if (!resultSet)
254
- return;
255
- if (!resultSet->GetUnsignedIntArg(info, 0, &maxRows))
256
- return;
257
- if (maxRows == 0) {
258
- string errMsg = njsMessages::Get(errInvalidParameterValue, 1);
259
- Nan::ThrowError(errMsg.c_str());
260
- return;
261
- }
262
- baton = resultSet->CreateBaton(info);
263
- if (!baton)
264
- return;
265
- if (resultSet->activeBaton) {
266
- baton->error = njsMessages::Get(errBusyResultSet);
267
- } else if (baton->error.empty()) {
268
- resultSet->activeBaton = baton;
269
- baton->outFormat = resultSet->outFormat;
270
- baton->jsOracledb.Reset(resultSet->jsOracledb);
271
- baton->fetchArraySize = maxRows;
272
- }
273
- baton->QueueWork("GetRows", Async_GetRows, Async_AfterGetRows, 2);
274
- }
275
-
276
-
277
- //-----------------------------------------------------------------------------
278
- // njsResultSet::GetRowsHelper()
279
- // Get rows from the result set and return a boolean indicating if the
280
- // fetch was successful or not.
281
- //-----------------------------------------------------------------------------
282
- bool njsResultSet::GetRowsHelper(njsBaton *baton, int *moreRows)
283
- {
284
- uint32_t i, numRowsToFetch;
285
- njsVariable *var;
286
-
287
- // determine how many rows to fetch; use fetchArraySize unless it is less
288
- // than maxRows (no need to waste memory!)
289
- numRowsToFetch = baton->fetchArraySize;
290
- if (this->maxRows > 0 && this->maxRows < numRowsToFetch)
291
- numRowsToFetch = this->maxRows;
292
-
293
- // create ODPI-C variables and define them, if necessary
294
- for (i = 0; i < this->numQueryVars; i++) {
295
- var = &this->queryVars[i];
296
- if (var->dpiVarHandle && var->maxArraySize >= numRowsToFetch)
297
- continue;
298
- if (var->dpiVarHandle) {
299
- if (dpiVar_release(var->dpiVarHandle) < 0) {
300
- baton->GetDPIError();
301
- return false;
302
- }
303
- var->dpiVarHandle = NULL;
304
- }
305
- if (dpiConn_newVar(this->dpiConnHandle, var->varTypeNum,
306
- var->nativeTypeNum, numRowsToFetch, var->maxSize, 1, 0, NULL,
307
- &var->dpiVarHandle, &var->buffer.dpiVarData) < 0) {
308
- baton->GetDPIError();
309
- return false;
310
- }
311
- var->maxArraySize = numRowsToFetch;
312
- if (dpiStmt_define(this->dpiStmtHandle, i + 1,
313
- var->dpiVarHandle) < 0) {
314
- baton->GetDPIError();
315
- return false;
316
- }
317
- }
318
-
319
- // set fetch array size as requested
320
- if (dpiStmt_setFetchArraySize(this->dpiStmtHandle,
321
- numRowsToFetch) < 0) {
322
- baton->GetDPIError();
323
- return false;
324
- }
325
-
326
- // perform fetch
327
- if (dpiStmt_fetchRows(this->dpiStmtHandle, numRowsToFetch,
328
- &baton->bufferRowIndex, &baton->rowsFetched, moreRows) < 0) {
329
- baton->GetDPIError();
330
- return false;
331
- }
332
-
333
- // result sets that should be auto closed are closed if the result set
334
- // is exhaused or the maximum number of rows has been fetched
335
- if (*moreRows && this->maxRows > 0) {
336
- if (baton->rowsFetched == this->maxRows) {
337
- *moreRows = 0;
338
- } else {
339
- this->maxRows -= baton->rowsFetched;
340
- }
341
- }
342
- return njsConnection::ProcessVars(baton, this->queryVars,
343
- this->numQueryVars, baton->rowsFetched);
344
- }
345
-
346
-
347
- //-----------------------------------------------------------------------------
348
- // njsResultSet::Async_GetRows()
349
- // Worker function for njsResultSet::GetRows() method.
350
- //-----------------------------------------------------------------------------
351
- void njsResultSet::Async_GetRows(njsBaton *baton)
352
- {
353
- njsResultSet *resultSet = (njsResultSet*) baton->callingObj;
354
- int moreRows;
355
- bool success;
356
-
357
- // result sets that should be auto closed are closed if the result set
358
- // is exhaused or the maximum number of rows has been fetched or an error
359
- // has taken place
360
- success = resultSet->GetRowsHelper(baton, &moreRows);
361
- if ((!success || !moreRows) && resultSet->autoClose) {
362
- dpiStmt_release(resultSet->dpiStmtHandle);
363
- resultSet->dpiStmtHandle = NULL;
364
- }
365
- }
366
-
367
-
368
- //-----------------------------------------------------------------------------
369
- // njsResultSet::Async_AfterGetRows()
370
- // Returns result to JS by invoking JS callback.
371
- //-----------------------------------------------------------------------------
372
- void njsResultSet::Async_AfterGetRows(njsBaton *baton, Local<Value> argv[])
373
- {
374
- Nan::EscapableHandleScope scope;
375
- Local<Object> rowAsObj, rows;
376
- Local<Value> val, keyVal;
377
- Local<Array> rowAsArray;
378
- njsResultSet *resultSet;
379
- njsVariable *var;
380
-
381
- rows = Nan::New<Array>(baton->rowsFetched);
382
- resultSet = (njsResultSet*) baton->callingObj;
383
- for (uint32_t row = 0; row < baton->rowsFetched; row++) {
384
- if (baton->outFormat == NJS_ROWS_ARRAY) {
385
- rowAsArray = Nan::New<Array>(resultSet->numQueryVars);
386
- } else {
387
- rowAsObj = Nan::New<Object>();
388
- }
389
- for (uint32_t col = 0; col < resultSet->numQueryVars; col++) {
390
- var = &resultSet->queryVars[col];
391
- if (!njsConnection::GetScalarValueFromVar(baton, var, &var->buffer,
392
- row, val))
393
- return;
394
- if (baton->outFormat == NJS_ROWS_ARRAY) {
395
- Nan::Set(rowAsArray, col, val);
396
- } else {
397
- keyVal = Nan::New<String>(var->name).ToLocalChecked();
398
- Nan::Set(rowAsObj, keyVal, val);
399
- }
400
- }
401
- if (baton->outFormat == NJS_ROWS_ARRAY) {
402
- Nan::Set(rows, row, rowAsArray);
403
- } else {
404
- Nan::Set(rows, row, rowAsObj);
405
- }
406
- }
407
- if (!resultSet->dpiStmtHandle) {
408
- delete [] resultSet->queryVars;
409
- resultSet->queryVars = NULL;
410
- }
411
- argv[1] = scope.Escape(rows);
412
- }
413
-
414
-
415
- //-----------------------------------------------------------------------------
416
- // njsResultSet::Close()
417
- // Close the result set. The reference to the DPI handle is transferred to
418
- // the baton so that it will be cleared automatically upon success and so that
419
- // the result set is marked as invalid immediately.
420
- //
421
- // PARAMETERS
422
- // - JS callback which will receive (error)
423
- //-----------------------------------------------------------------------------
424
- NAN_METHOD(njsResultSet::Close)
425
- {
426
- njsResultSet *resultSet;
427
- njsBaton *baton;
428
-
429
- resultSet = (njsResultSet*) ValidateArgs(info, 1, 1);
430
- if (!resultSet)
431
- return;
432
- baton = resultSet->CreateBaton(info);
433
- if (!baton)
434
- return;
435
- if (resultSet->activeBaton) {
436
- baton->error = njsMessages::Get(errBusyResultSet);
437
- } else {
438
- baton->dpiStmtHandle = resultSet->dpiStmtHandle;
439
- resultSet->dpiStmtHandle = NULL;
440
- }
441
- baton->QueueWork("Close", Async_Close, Async_AfterClose, 1);
442
- }
443
-
444
-
445
- //-----------------------------------------------------------------------------
446
- // njsResultSet::Async_Close()
447
- // Worker function for njsResultSet::Close() method. If the attempt to close
448
- // the statement fails, the reference to the DPI handle is transferred back
449
- // from the baton to the result set.
450
- //-----------------------------------------------------------------------------
451
- void njsResultSet::Async_Close(njsBaton *baton)
452
- {
453
- if (dpiStmt_close(baton->dpiStmtHandle, NULL, 0) < 0) {
454
- njsResultSet *resultSet = (njsResultSet*) baton->callingObj;
455
- resultSet->dpiStmtHandle = baton->dpiStmtHandle;
456
- baton->dpiStmtHandle = NULL;
457
- baton->GetDPIError();
458
- }
459
- }
460
-
461
-
462
- //-----------------------------------------------------------------------------
463
- // njsResultSet::Async_AfterClose()
464
- // Finishes close by transferring variables and fetch as types to the baton
465
- // where they will be freed.
466
- //-----------------------------------------------------------------------------
467
- void njsResultSet::Async_AfterClose(njsBaton *baton, Local<Value> argv[])
468
- {
469
- njsResultSet *resultSet = (njsResultSet*) baton->callingObj;
470
-
471
- resultSet->jsConnection.Reset();
472
- resultSet->jsOracledb.Reset();
473
- baton->queryVars = resultSet->queryVars;
474
- baton->numQueryVars = resultSet->numQueryVars;
475
- resultSet->queryVars = NULL;
476
- resultSet->numQueryVars = 0;
477
- }
478
-
@@ -1,120 +0,0 @@
1
- /* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. */
2
-
3
- /******************************************************************************
4
- *
5
- * You may not use the identified files except in compliance with the Apache
6
- * License, Version 2.0 (the "License.")
7
- *
8
- * You may obtain a copy of the License at
9
- * http://www.apache.org/licenses/LICENSE-2.0.
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- *
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * This file uses NAN:
19
- *
20
- * Copyright (c) 2015 NAN contributors
21
- *
22
- * NAN contributors listed at https://github.com/rvagg/nan#contributors
23
- *
24
- * Permission is hereby granted, free of charge, to any person obtaining
25
- * a copy of this software and associated documentation files (the
26
- * "Software"), to deal in the Software without restriction, including
27
- * without limitation the rights to use, copy, modify, merge, publish,
28
- * distribute, sublicense, and/or sell copies of the Software, and to
29
- * permit persons to whom the Software is furnished to do so, subject to
30
- * the following conditions:
31
- *
32
- * The above copyright notice and this permission notice shall be
33
- * included in all copies or substantial portions of the Software.
34
- *
35
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
37
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
38
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
39
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
40
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
41
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42
- *
43
- * NAME
44
- * njsResultSet.h
45
- *
46
- * DESCRIPTION
47
- * ResultSet class
48
- *
49
- *****************************************************************************/
50
-
51
- #ifndef __NJSRESULTSET_H__
52
- #define __NJSRESULTSET_H__
53
-
54
- #include <node.h>
55
- #include "nan.h"
56
- #include <v8.h>
57
- #include <string>
58
- #include "njsOracle.h"
59
- #include "njsConnection.h"
60
-
61
- using namespace v8;
62
- using namespace node;
63
-
64
- //-----------------------------------------------------------------------------
65
- // njsResultSet
66
- // Class exposed to JS for handling result sets.
67
- //-----------------------------------------------------------------------------
68
- class njsResultSet: public njsCommon {
69
- public:
70
-
71
- static void Init(Local<Object> target);
72
- bool IsValid() const;
73
- njsErrorType GetInvalidErrorType() const { return errInvalidResultSet; }
74
- static Local<Object> CreateFromBaton(njsBaton *baton);
75
- static bool CreateFromRefCursor(njsBaton *baton, dpiStmt *dpiStmtHandle,
76
- njsVariable *queryVars, uint32_t numQueryVars,
77
- Local<Value> &value);
78
-
79
- private:
80
-
81
- njsResultSet() : dpiStmtHandle(NULL), dpiConnHandle(NULL), numQueryVars(0),
82
- queryVars(NULL), outFormat(0), maxRows(0),
83
- extendedMetaData(false), autoClose(false) {}
84
- ~njsResultSet();
85
-
86
- bool GetRowsHelper(njsBaton *baton, int *moreRows);
87
-
88
- static NAN_METHOD(New);
89
-
90
- // Get Rows Methods
91
- static NAN_METHOD(GetRows);
92
- static void Async_GetRows(njsBaton *baton);
93
- static void Async_AfterGetRows(njsBaton *baton, Local<Value> argv[]);
94
-
95
- // Close Methods
96
- static NAN_METHOD(Close);
97
- static void Async_Close(njsBaton *baton);
98
- static void Async_AfterClose(njsBaton *baton, Local<Value> argv[]);
99
-
100
- // Define Getter Accessors to properties
101
- static NAN_GETTER(GetMetaData);
102
-
103
- // Define Setter Accessors to properties
104
- static NAN_SETTER(SetMetaData);
105
-
106
- dpiStmt *dpiStmtHandle;
107
- dpiConn *dpiConnHandle;
108
- uint32_t numQueryVars;
109
- njsVariable *queryVars;
110
- uint32_t outFormat;
111
- uint32_t maxRows;
112
- bool extendedMetaData;
113
- bool autoClose;
114
- Nan::Persistent<Object> jsOracledb;
115
- Nan::Persistent<Object> jsConnection;
116
-
117
- static Nan::Persistent<FunctionTemplate> resultSetTemplate_s;
118
- };
119
-
120
- #endif /* __NJSRESULTSET_H__ */