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
package/src/njsIntLob.cpp DELETED
@@ -1,618 +0,0 @@
1
- /* Copyright (c) 2015, 2017, 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
- * njsIntLob.cpp
45
- *
46
- * DESCRIPTION
47
- * ILob class implementation.
48
- *
49
- *****************************************************************************/
50
-
51
-
52
- #include <stdlib.h>
53
- #include <iostream>
54
- using namespace std;
55
-
56
-
57
- #ifndef NODE_BUFFER_H_
58
- # include <node_buffer.h>
59
- #endif
60
-
61
-
62
- #include "njsIntLob.h"
63
-
64
-
65
- // peristent ILob class handle
66
- Nan::Persistent<FunctionTemplate> njsILob::iLobTemplate_s;
67
-
68
- //-----------------------------------------------------------------------------
69
- // njsILob::Init()
70
- // Initialization function of ILob class. Maps functions and properties from
71
- // JS to C++.
72
- //-----------------------------------------------------------------------------
73
- void njsILob::Init(Local<Object> target)
74
- {
75
- Nan::HandleScope scope;
76
-
77
- Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
78
- tpl->InstanceTemplate()->SetInternalFieldCount(1);
79
- tpl->SetClassName(Nan::New<v8::String>("ILob").ToLocalChecked());
80
-
81
- Nan::SetPrototypeMethod(tpl, "close", Close);
82
- Nan::SetPrototypeMethod(tpl, "read", Read);
83
- Nan::SetPrototypeMethod(tpl, "write", Write);
84
-
85
- Nan::SetAccessor(tpl->InstanceTemplate(),
86
- Nan::New<v8::String>("chunkSize").ToLocalChecked(),
87
- njsILob::GetChunkSize, njsILob::SetChunkSize);
88
-
89
- Nan::SetAccessor(tpl->InstanceTemplate(),
90
- Nan::New<v8::String>("length").ToLocalChecked(),
91
- njsILob::GetLength, njsILob::SetLength);
92
-
93
- Nan::SetAccessor(tpl->InstanceTemplate(),
94
- Nan::New<v8::String>("pieceSize").ToLocalChecked(),
95
- njsILob::GetPieceSize, njsILob::SetPieceSize);
96
-
97
- Nan::SetAccessor(tpl->InstanceTemplate(),
98
- Nan::New<v8::String>("offset").ToLocalChecked(),
99
- njsILob::GetOffset, njsILob::SetOffset);
100
-
101
- Nan::SetAccessor(tpl->InstanceTemplate(),
102
- Nan::New<v8::String>("type").ToLocalChecked(),
103
- njsILob::GetType, njsILob::SetType);
104
-
105
- Nan::SetAccessor(tpl->InstanceTemplate(),
106
- Nan::New<v8::String>("autoCloseLob").ToLocalChecked(),
107
- njsILob::GetIsAutoClose, njsILob::SetIsAutoClose);
108
-
109
- Nan::SetAccessor(tpl->InstanceTemplate(),
110
- Nan::New<v8::String>("valid").ToLocalChecked(),
111
- njsILob::GetIsValid, njsILob::SetIsValid);
112
-
113
- iLobTemplate_s.Reset(tpl);
114
- Nan::Set(target, Nan::New<v8::String>("ILob").ToLocalChecked(),
115
- tpl->GetFunction());
116
- }
117
-
118
-
119
- //-----------------------------------------------------------------------------
120
- // njsILob::CreateFromProtoLob()
121
- // Create a new LOB from the njsProtoILob instance.
122
- //-----------------------------------------------------------------------------
123
- Local<Object> njsILob::CreateFromProtoLob(njsProtoILob *protoLob)
124
- {
125
- Nan::EscapableHandleScope scope;
126
- Local<Function> func;
127
- Local<Object> obj;
128
- njsILob *lob;
129
-
130
- func = Nan::GetFunction(
131
- Nan::New<FunctionTemplate>(iLobTemplate_s)).ToLocalChecked();
132
- obj = Nan::NewInstance(func).ToLocalChecked();
133
- lob = Nan::ObjectWrap::Unwrap<njsILob>(obj);
134
- lob->dpiLobHandle = protoLob->dpiLobHandle;
135
- protoLob->dpiLobHandle = NULL;
136
- lob->chunkSize = protoLob->chunkSize;
137
- lob->pieceSize = protoLob->chunkSize;
138
- lob->length = protoLob->length;
139
- lob->dataType = protoLob->dataType;
140
- lob->isAutoClose = protoLob->isAutoClose;
141
- lob->activeBaton = NULL;
142
- lob->offset = 1;
143
- return scope.Escape(obj);
144
- }
145
-
146
-
147
- //-----------------------------------------------------------------------------
148
- // njsILob::GetInstance()
149
- // Return the instance associated with the value, or NULL if there is no
150
- // instance associated with the value. Javascript code provides the stream;
151
- // this extracts the member iLob instance which is used internally.
152
- //-----------------------------------------------------------------------------
153
- njsILob *njsILob::GetInstance(Local<Value> val)
154
- {
155
- Nan::HandleScope scope;
156
- Local<Object> obj = val->ToObject();
157
- Local <String> key = Nan::New<v8::String>("iLob").ToLocalChecked();
158
- Local<Value> v8Value = Nan::Get(obj, key).ToLocalChecked();
159
-
160
- if (v8Value->IsObject()) {
161
- Local<Object> obj = v8Value->ToObject();
162
- if (Nan::New(iLobTemplate_s)->HasInstance(obj))
163
- return Nan::ObjectWrap::Unwrap<njsILob>(obj);
164
- }
165
- return NULL;
166
- }
167
-
168
-
169
- //-----------------------------------------------------------------------------
170
- // njsILob::HasInstance()
171
- // Return boolean indicating if the specified V8 object refers to an ILob
172
- // instance or not.
173
- //-----------------------------------------------------------------------------
174
- bool njsILob::HasInstance(Local<Value> val)
175
- {
176
- njsILob *lob = GetInstance(val);
177
- return (lob) ? true : false;
178
- }
179
-
180
-
181
- //-----------------------------------------------------------------------------
182
- // njsILob::ClearDPILobHandle()
183
- // Clear the DPI LOB handle. This is done for the IN side of an IN/OUT bind
184
- // once the LOB has been successfully cloned.
185
- //-----------------------------------------------------------------------------
186
- bool njsILob::ClearDPILobHandle(njsBaton *baton)
187
- {
188
- if (dpiLob_close(dpiLobHandle) < 0) {
189
- baton->GetDPIError();
190
- return false;
191
- }
192
- if (dpiLob_release(dpiLobHandle) < 0) {
193
- baton->GetDPIError();
194
- return false;
195
- }
196
- dpiLobHandle = NULL;
197
- return true;
198
- }
199
-
200
-
201
- //-----------------------------------------------------------------------------
202
- // njsILob::New()
203
- // Create new object accesible from JS. This is always called from within
204
- // njsILob::CreateFromBaton() and never from any external JS.
205
- //-----------------------------------------------------------------------------
206
- NAN_METHOD(njsILob::New)
207
- {
208
- njsILob *iLob = new njsILob();
209
- iLob->Wrap(info.Holder());
210
- info.GetReturnValue().Set(info.Holder());
211
- }
212
-
213
-
214
- //-----------------------------------------------------------------------------
215
- // njsILob::GetChunkSize()
216
- // Get accessor of "chunkSize" property.
217
- //-----------------------------------------------------------------------------
218
- NAN_GETTER(njsILob::GetChunkSize)
219
- {
220
- njsILob *lob = (njsILob*) ValidateGetter(info);
221
- if (lob)
222
- info.GetReturnValue().Set(lob->chunkSize);
223
- }
224
-
225
-
226
- //-----------------------------------------------------------------------------
227
- // njsILob::SetChunkSize()
228
- // Set accessor of "chunkSize" property.
229
- //-----------------------------------------------------------------------------
230
- NAN_SETTER(njsILob::SetChunkSize)
231
- {
232
- PropertyIsReadOnly("chunkSize");
233
- }
234
-
235
-
236
- //-----------------------------------------------------------------------------
237
- // njsILob::GetLength()
238
- // Get accessor of "length" property.
239
- //-----------------------------------------------------------------------------
240
- NAN_GETTER(njsILob::GetLength)
241
- {
242
- njsILob *lob = (njsILob*) ValidateGetter(info);
243
- if (lob)
244
- info.GetReturnValue().Set( (double) lob->length);
245
- }
246
-
247
-
248
- //-----------------------------------------------------------------------------
249
- // njsILob::SetLength()
250
- // Set accessor of "length" property.
251
- //-----------------------------------------------------------------------------
252
- NAN_SETTER(njsILob::SetLength)
253
- {
254
- PropertyIsReadOnly("length");
255
- }
256
-
257
-
258
- //-----------------------------------------------------------------------------
259
- // njsILob::GetPieceSize()
260
- // Get accessor of "pieceSize" property.
261
- //-----------------------------------------------------------------------------
262
- NAN_GETTER(njsILob::GetPieceSize)
263
- {
264
- njsILob *lob = (njsILob*) ValidateGetter(info);
265
- if (lob)
266
- info.GetReturnValue().Set(lob->pieceSize);
267
- }
268
-
269
-
270
- //-----------------------------------------------------------------------------
271
- // njsILob::SetPieceSize()
272
- // Set accessor of "pieceSize" property.
273
- //-----------------------------------------------------------------------------
274
- NAN_SETTER(njsILob::SetPieceSize)
275
- {
276
- njsILob *lob = (njsILob*) ValidateSetter(info);
277
- if (!lob)
278
- return;
279
- if (lob->bufferPtr) {
280
- delete [] lob->bufferPtr;
281
- lob->bufferPtr = NULL;
282
- }
283
- if (!lob->SetPropUnsignedInt(value, &lob->pieceSize, "pieceSize"))
284
- return;
285
- }
286
-
287
-
288
- //-----------------------------------------------------------------------------
289
- // njsILob::GetOffset()
290
- // Get accessor of "offset" property.
291
- //-----------------------------------------------------------------------------
292
- NAN_GETTER(njsILob::GetOffset)
293
- {
294
- njsILob *lob = (njsILob*) ValidateGetter(info);
295
- if (lob)
296
- info.GetReturnValue().Set((uint32_t) lob->offset);
297
- }
298
-
299
-
300
- //-----------------------------------------------------------------------------
301
- // njsILob::SetOffset()
302
- // Set accessor of "offset" property.
303
- //-----------------------------------------------------------------------------
304
- NAN_SETTER(njsILob::SetOffset)
305
- {
306
- njsILob *lob = (njsILob*) ValidateSetter(info);
307
- if (!lob)
308
- return;
309
- uint32_t offset;
310
- if (lob->SetPropUnsignedInt(value, &offset, "offset"))
311
- lob->offset = offset;
312
- }
313
-
314
-
315
- //-----------------------------------------------------------------------------
316
- // njsILob::GetType()
317
- // Get accessor of "type" property.
318
- //-----------------------------------------------------------------------------
319
- NAN_GETTER(njsILob::GetType)
320
- {
321
- njsILob *lob = (njsILob*) ValidateGetter(info);
322
- if (lob)
323
- info.GetReturnValue().Set(lob->dataType);
324
- }
325
-
326
-
327
- //-----------------------------------------------------------------------------
328
- // njsILob::SetType()
329
- // Set accessor of "type" property.
330
- //-----------------------------------------------------------------------------
331
- NAN_SETTER(njsILob::SetType)
332
- {
333
- PropertyIsReadOnly("type");
334
- }
335
-
336
-
337
- //-----------------------------------------------------------------------------
338
- // njsILob::GetIsAutoClose()
339
- // Get accessor of "autoCloseLob" property.
340
- //-----------------------------------------------------------------------------
341
- NAN_GETTER(njsILob::GetIsAutoClose)
342
- {
343
- njsILob *lob = (njsILob*) ValidateGetter(info);
344
- if (lob)
345
- info.GetReturnValue().Set(lob->isAutoClose);
346
- }
347
-
348
-
349
- //-----------------------------------------------------------------------------
350
- // njsILob::SetIsAutoClose()
351
- // Set accessor of "autoCloseLob" property.
352
- //-----------------------------------------------------------------------------
353
- NAN_SETTER(njsILob::SetIsAutoClose)
354
- {
355
- PropertyIsReadOnly("autoCloseLob");
356
- }
357
-
358
-
359
- //-----------------------------------------------------------------------------
360
- // njsILob::GetIsValid()
361
- // Get accessor of "valid" property.
362
- //-----------------------------------------------------------------------------
363
- NAN_GETTER(njsILob::GetIsValid)
364
- {
365
- njsILob *lob;
366
-
367
- lob = Nan::ObjectWrap::Unwrap<njsILob>(info.Holder());
368
- if (!lob) {
369
- std::string errMsg = njsMessages::Get(errInvalidJSObject);
370
- Nan::ThrowError(errMsg.c_str());
371
- return;
372
- }
373
- info.GetReturnValue().Set(lob->IsValid());
374
- }
375
-
376
-
377
- //-----------------------------------------------------------------------------
378
- // njsILob::SetIsValid()
379
- // Set accessor of "valid" property.
380
- //-----------------------------------------------------------------------------
381
- NAN_SETTER(njsILob::SetIsValid)
382
- {
383
- PropertyIsReadOnly("valid");
384
- }
385
-
386
-
387
- //-----------------------------------------------------------------------------
388
- // njsILob::Read()
389
- // Read some data from the LOB.
390
- //
391
- // PARAMETERS
392
- // - JS callback which will receive (error, data)
393
- //-----------------------------------------------------------------------------
394
- NAN_METHOD(njsILob::Read)
395
- {
396
- njsBaton *baton;
397
- njsILob *lob;
398
-
399
- lob = (njsILob*) ValidateArgs(info, 1, 1);
400
- if (!lob)
401
- return;
402
- baton = lob->CreateBaton(info);
403
- if (!baton)
404
- return;
405
- if (lob->activeBaton) {
406
- baton->error = njsMessages::Get(errBusyLob);
407
- } else if (baton->error.empty()) {
408
- lob->activeBaton = baton;
409
- if (lob->dataType == NJS_DATATYPE_BLOB) {
410
- baton->bufferSize = lob->pieceSize;
411
- } else if (dpiLob_getBufferSize(lob->dpiLobHandle, lob->pieceSize,
412
- &baton->bufferSize) < 0) {
413
- baton->GetDPIError();
414
- }
415
- if (baton->error.empty()) {
416
- if (!lob->bufferPtr)
417
- lob->bufferPtr = new char[baton->bufferSize];
418
- baton->bufferPtr = lob->bufferPtr;
419
- baton->SetDPILobHandle(lob->dpiLobHandle);
420
- baton->lobAmount = lob->pieceSize;
421
- baton->lobOffset = lob->offset;
422
- }
423
- }
424
- baton->QueueWork("Read", Async_Read, Async_AfterRead, 2);
425
- }
426
-
427
-
428
- //-----------------------------------------------------------------------------
429
- // njsILob::Async_Read()
430
- // Worker function for njsILob::Read() method.
431
- //-----------------------------------------------------------------------------
432
- void njsILob::Async_Read(njsBaton *baton)
433
- {
434
- if (dpiLob_readBytes(baton->dpiLobHandle, baton->lobOffset,
435
- baton->lobAmount, baton->bufferPtr, &baton->bufferSize) < 0)
436
- baton->GetDPIError();
437
-
438
- // if an error occurs or the end of the LOB has been reached, and the LOB
439
- // is marked as one that should be automatically closed, close and release
440
- // it, ignoring any further errors that occur during the attempt to close
441
- njsILob *lob = (njsILob*) baton->callingObj;
442
- if (lob->isAutoClose && (!baton->bufferSize || !baton->error.empty())) {
443
- dpiLob_close(lob->dpiLobHandle);
444
- dpiLob_release(lob->dpiLobHandle);
445
- lob->dpiLobHandle = NULL;
446
- }
447
- }
448
-
449
-
450
- //-----------------------------------------------------------------------------
451
- // njsILob::Close()
452
- // Close the LOB. The reference to the DPI handle is transferred to the baton
453
- // so that it will be cleared automatically upon success and so that the LOB
454
- // is marked as invalid immediately.
455
- //
456
- // PARAMETERS
457
- // - JS callback which will receive (error)
458
- //-----------------------------------------------------------------------------
459
- NAN_METHOD(njsILob::Close)
460
- {
461
- njsBaton *baton;
462
- njsILob *lob;
463
-
464
- lob = (njsILob*) ValidateArgs(info, 1, 1);
465
- if (!lob)
466
- return;
467
- baton = lob->CreateBaton(info);
468
- if (!baton)
469
- return;
470
- if (lob->activeBaton) {
471
- baton->error = njsMessages::Get(errBusyLob);
472
- } else {
473
- baton->dpiLobHandle = lob->dpiLobHandle;
474
- lob->dpiLobHandle = NULL;
475
- }
476
- baton->QueueWork("Close", Async_Close, NULL, 1);
477
- }
478
-
479
-
480
- //-----------------------------------------------------------------------------
481
- // njsILob::Async_Close()
482
- // Worker function for njsILob::Close() method. If the attempt to close
483
- // fails, the reference to the DPI handle is transferred back from the baton to
484
- // the LOB.
485
- //-----------------------------------------------------------------------------
486
- void njsILob::Async_Close(njsBaton *baton)
487
- {
488
- if (dpiLob_close(baton->dpiLobHandle) < 0) {
489
- njsILob *lob = (njsILob*) baton->callingObj;
490
- lob->dpiLobHandle = baton->dpiLobHandle;
491
- baton->dpiLobHandle = NULL;
492
- baton->GetDPIError();
493
- }
494
- }
495
-
496
-
497
- //-----------------------------------------------------------------------------
498
- // njsILob::Async_AfterRead()
499
- // Returns result to JS by invoking JS callback.
500
- //-----------------------------------------------------------------------------
501
- void njsILob::Async_AfterRead(njsBaton *baton, Local<Value> argv[])
502
- {
503
- Nan::EscapableHandleScope scope;
504
- njsILob *lob = (njsILob*) baton->callingObj;
505
-
506
- if (!baton->bufferSize) {
507
- argv[1] = scope.Escape(Nan::Null());
508
- } else if (lob->dataType == NJS_DATATYPE_CLOB) {
509
- Local<String> strValue = Nan::New<String>(baton->bufferPtr,
510
- (int) baton->bufferSize).ToLocalChecked();
511
- lob->offset += strValue->ToString()->Length();
512
- argv[1] = scope.Escape(strValue);
513
- } else {
514
- Local<Value> bufferValue = Nan::CopyBuffer(baton->bufferPtr,
515
- (uint32_t) baton->bufferSize).ToLocalChecked();
516
- lob->offset += baton->bufferSize;
517
- argv[1] = scope.Escape(bufferValue);
518
- }
519
- }
520
-
521
-
522
- //-----------------------------------------------------------------------------
523
- // njsILob::Write()
524
- // Write some data to the LOB.
525
- //
526
- // PARAMETERS
527
- // - JS callback which will receive (error)
528
- //-----------------------------------------------------------------------------
529
- NAN_METHOD(njsILob::Write)
530
- {
531
- Local<Object> jsBuffer;
532
- njsBaton *baton;
533
- njsILob *lob;
534
-
535
- lob = (njsILob*) ValidateArgs(info, 2, 2);
536
- if (!lob)
537
- return;
538
- if (!lob->GetObjectArg(info, 0, jsBuffer))
539
- return;
540
- baton = lob->CreateBaton(info);
541
- if (!baton)
542
- return;
543
- if (lob->activeBaton) {
544
- baton->error = njsMessages::Get(errBusyLob);
545
- } else if (baton->error.empty()) {
546
- baton->jsBuffer.Reset(jsBuffer);
547
- baton->bufferPtr = Buffer::Data(jsBuffer);
548
- baton->bufferSize = Buffer::Length(jsBuffer);
549
- if (jsBuffer->IsString()) {
550
- baton->lobAmount += jsBuffer.As<String>()->Length();
551
- } else {
552
- baton->lobAmount += baton->bufferSize;
553
- }
554
- baton->lobOffset = lob->offset;
555
- lob->activeBaton = baton;
556
- baton->SetDPILobHandle(lob->dpiLobHandle);
557
- }
558
- baton->QueueWork("Write", Async_Write, Async_AfterWrite, 1);
559
- }
560
-
561
-
562
- //-----------------------------------------------------------------------------
563
- // njsILob::Async_Write()
564
- // Worker function for njsILob::Write() method.
565
- //-----------------------------------------------------------------------------
566
- void njsILob::Async_Write(njsBaton *baton)
567
- {
568
- if (dpiLob_writeBytes(baton->dpiLobHandle, baton->lobOffset,
569
- baton->bufferPtr, baton->bufferSize) < 0) {
570
- baton->GetDPIError();
571
-
572
- // if an error occurs and the LOB is marked as one that should be
573
- // automatically closed, close and release it, ignoring any further
574
- // errors that occur during the attempt to close
575
- njsILob *lob = (njsILob*) baton->callingObj;
576
- if (lob->isAutoClose) {
577
- dpiLob_close(lob->dpiLobHandle);
578
- dpiLob_release(lob->dpiLobHandle);
579
- lob->dpiLobHandle = NULL;
580
- }
581
- }
582
- }
583
-
584
-
585
- //-----------------------------------------------------------------------------
586
- // njsILob::Async_AfterWrite()
587
- // Sets the offset after writing.
588
- //-----------------------------------------------------------------------------
589
- void njsILob::Async_AfterWrite(njsBaton *baton, Local<Value> argv[])
590
- {
591
- njsILob *lob = (njsILob*) baton->callingObj;
592
- lob->offset += baton->lobAmount;
593
- }
594
-
595
-
596
- //-----------------------------------------------------------------------------
597
- // njsProtoILob::PopulateFromDPI()
598
- // Populate the proto internal LOB from DPI.
599
- //-----------------------------------------------------------------------------
600
- bool njsProtoILob::PopulateFromDPI(njsBaton *baton, dpiLob *dpiLobHandle,
601
- bool addRef)
602
- {
603
- if (addRef && dpiLob_addRef(dpiLobHandle) < 0) {
604
- baton->GetDPIError();
605
- return false;
606
- }
607
- this->dpiLobHandle = dpiLobHandle;
608
- if (dpiLob_getChunkSize(dpiLobHandle, &this->chunkSize) < 0) {
609
- baton->GetDPIError();
610
- return false;
611
- }
612
- if (dpiLob_getSize(dpiLobHandle, &this->length) < 0) {
613
- baton->GetDPIError();
614
- return false;
615
- }
616
- return true;
617
- }
618
-