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/njsOracle.cpp DELETED
@@ -1,1274 +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
- * njsOracle.cpp
45
- *
46
- * DESCRIPTION
47
- * Oracledb class implementation.
48
- *
49
- *****************************************************************************/
50
-
51
- #include "node.h"
52
-
53
- #include "njsOracle.h"
54
- #include "njsConnection.h"
55
- #include "njsPool.h"
56
- #include "njsResultSet.h"
57
- #include "njsMessages.h"
58
- #include "njsIntLob.h"
59
- #include "njsSubscription.h"
60
- #include "njsSodaDatabase.h"
61
- #include "njsSodaCollection.h"
62
- #include "njsSodaDocument.h"
63
- #include "njsSodaOperation.h"
64
- #include "njsSodaDocCursor.h"
65
-
66
- #include <sstream>
67
-
68
- // peristent Oracledb class handle
69
- Nan::Persistent<FunctionTemplate> njsOracledb::oracledbTemplate_s;
70
-
71
- // persistent handle for subscriptions
72
- Nan::Persistent<Object> njsOracledb::subscriptions;
73
-
74
- // DPI context
75
- dpiContext *njsOracledb::globalDPIContext = NULL;
76
-
77
-
78
- //-----------------------------------------------------------------------------
79
- // njsOracledb::njsOracledb()
80
- // Constructor.
81
- //-----------------------------------------------------------------------------
82
- njsOracledb::njsOracledb()
83
- {
84
- outFormat = NJS_ROWS_ARRAY;
85
- maxRows = NJS_MAX_ROWS;
86
- autoCommit = false;
87
- extendedMetaData = false;
88
- stmtCacheSize = NJS_STMT_CACHE_SIZE;
89
- poolMax = NJS_POOL_MAX;
90
- poolMin = NJS_POOL_MIN;
91
- poolIncrement = NJS_POOL_INCR;
92
- poolTimeout = NJS_POOL_TIMEOUT;
93
- fetchArraySize = DPI_DEFAULT_FETCH_ARRAY_SIZE;
94
- connClass = "";
95
- edition = "";
96
- externalAuth = false;
97
- lobPrefetchSize = NJS_LOB_PREFETCH_SIZE;
98
- poolPingInterval = NJS_POOL_DEFAULT_PING_INTERVAL;
99
- oraClientVer = 0;
100
- events = false;
101
- }
102
-
103
-
104
- //-----------------------------------------------------------------------------
105
- // njsOracledb::Init()
106
- // Initialization function. Maps functions and properties from JS to C++.
107
- //-----------------------------------------------------------------------------
108
- void njsOracledb::Init(Local<Object> target)
109
- {
110
- Nan::HandleScope scope;
111
- dpiErrorInfo errorInfo;
112
-
113
- // create DPI context
114
- if (dpiContext_create(DPI_MAJOR_VERSION, DPI_MINOR_VERSION,
115
- &globalDPIContext, &errorInfo) < 0) {
116
- Nan::ThrowError(errorInfo.message);
117
- return;
118
- }
119
-
120
- Local<FunctionTemplate> temp = Nan::New<FunctionTemplate>(New);
121
- temp->InstanceTemplate()->SetInternalFieldCount(1);
122
- temp->SetClassName(Nan::New<v8::String>("Oracledb").ToLocalChecked());
123
-
124
- Nan::SetPrototypeMethod(temp, "getConnection", GetConnection);
125
- Nan::SetPrototypeMethod(temp, "createPool", CreatePool);
126
-
127
- Nan::SetAccessor(temp->InstanceTemplate(),
128
- Nan::New<v8::String>("poolMax").ToLocalChecked(),
129
- njsOracledb::GetPoolMax, njsOracledb::SetPoolMax);
130
- Nan::SetAccessor(temp->InstanceTemplate(),
131
- Nan::New<v8::String>("poolMin").ToLocalChecked(),
132
- njsOracledb::GetPoolMin, njsOracledb::SetPoolMin);
133
- Nan::SetAccessor(temp->InstanceTemplate(),
134
- Nan::New<v8::String>("poolIncrement").ToLocalChecked(),
135
- njsOracledb::GetPoolIncrement, njsOracledb::SetPoolIncrement);
136
- Nan::SetAccessor(temp->InstanceTemplate(),
137
- Nan::New<v8::String>("poolTimeout").ToLocalChecked(),
138
- njsOracledb::GetPoolTimeout, njsOracledb::SetPoolTimeout);
139
- Nan::SetAccessor(temp->InstanceTemplate(),
140
- Nan::New<v8::String>("stmtCacheSize").ToLocalChecked(),
141
- njsOracledb::GetStmtCacheSize, njsOracledb::SetStmtCacheSize);
142
- Nan::SetAccessor(temp->InstanceTemplate(),
143
- Nan::New<v8::String>("fetchArraySize").ToLocalChecked(),
144
- njsOracledb::GetFetchArraySize, njsOracledb::SetFetchArraySize);
145
- Nan::SetAccessor(temp->InstanceTemplate(),
146
- Nan::New<v8::String>("autoCommit").ToLocalChecked(),
147
- njsOracledb::GetAutoCommit, njsOracledb::SetAutoCommit);
148
- Nan::SetAccessor(temp->InstanceTemplate(),
149
- Nan::New<v8::String>("extendedMetaData").ToLocalChecked(),
150
- njsOracledb::GetExtendedMetaData,
151
- njsOracledb::SetExtendedMetaData);
152
- Nan::SetAccessor(temp->InstanceTemplate(),
153
- Nan::New<v8::String>("maxRows").ToLocalChecked(),
154
- njsOracledb::GetMaxRows, njsOracledb::SetMaxRows);
155
- Nan::SetAccessor(temp->InstanceTemplate(),
156
- Nan::New<v8::String>("outFormat").ToLocalChecked(),
157
- njsOracledb::GetOutFormat, njsOracledb::SetOutFormat);
158
- Nan::SetAccessor(temp->InstanceTemplate(),
159
- Nan::New<v8::String>("version").ToLocalChecked(),
160
- njsOracledb::GetVersion, njsOracledb::SetVersion);
161
- Nan::SetAccessor(temp->InstanceTemplate(),
162
- Nan::New<v8::String>("versionString").ToLocalChecked(),
163
- njsOracledb::GetVersionString, njsOracledb::SetVersionString);
164
- Nan::SetAccessor(temp->InstanceTemplate(),
165
- Nan::New<v8::String>("versionSuffix").ToLocalChecked(),
166
- njsOracledb::GetVersionSuffix, njsOracledb::SetVersionSuffix);
167
- Nan::SetAccessor(temp->InstanceTemplate(),
168
- Nan::New<v8::String>("connectionClass").ToLocalChecked(),
169
- njsOracledb::GetConnectionClass, njsOracledb::SetConnectionClass);
170
- Nan::SetAccessor(temp->InstanceTemplate(),
171
- Nan::New<v8::String>("edition").ToLocalChecked(),
172
- njsOracledb::GetEdition, njsOracledb::SetEdition);
173
- Nan::SetAccessor(temp->InstanceTemplate(),
174
- Nan::New<v8::String>("externalAuth").ToLocalChecked(),
175
- njsOracledb::GetExternalAuth, njsOracledb::SetExternalAuth);
176
- Nan::SetAccessor(temp->InstanceTemplate(),
177
- Nan::New<v8::String>("fetchAsString").ToLocalChecked(),
178
- njsOracledb::GetFetchAsString, njsOracledb::SetFetchAsString);
179
- Nan::SetAccessor(temp->InstanceTemplate(),
180
- Nan::New<v8::String>("fetchAsBuffer").ToLocalChecked(),
181
- njsOracledb::GetFetchAsBuffer, njsOracledb::SetFetchAsBuffer);
182
- Nan::SetAccessor(temp->InstanceTemplate(),
183
- Nan::New<v8::String>("lobPrefetchSize").ToLocalChecked(),
184
- njsOracledb::GetLobPrefetchSize, njsOracledb::SetLobPrefetchSize);
185
- Nan::SetAccessor(temp->InstanceTemplate (),
186
- Nan::New<v8::String>("oracleClientVersion").ToLocalChecked(),
187
- njsOracledb::GetOracleClientVersion,
188
- njsOracledb::SetOracleClientVersion);
189
- Nan::SetAccessor(temp->InstanceTemplate (),
190
- Nan::New<v8::String>("oracleClientVersionString").ToLocalChecked(),
191
- njsOracledb::GetOracleClientVersionString,
192
- njsOracledb::SetOracleClientVersionString);
193
- Nan::SetAccessor(temp->InstanceTemplate (),
194
- Nan::New<v8::String>("poolPingInterval").ToLocalChecked(),
195
- njsOracledb::GetPoolPingInterval,
196
- njsOracledb::SetPoolPingInterval);
197
- Nan::SetAccessor(temp->InstanceTemplate (),
198
- Nan::New<v8::String>("events").ToLocalChecked(),
199
- njsOracledb::GetEvents, njsOracledb::SetEvents);
200
-
201
- oracledbTemplate_s.Reset(temp);
202
- Nan::Set(target, Nan::New<v8::String>("Oracledb").ToLocalChecked(),
203
- temp->GetFunction());
204
-
205
- Local<Object> obj = Nan::New<v8::Object>();
206
- subscriptions.Reset(obj);
207
- }
208
-
209
-
210
- //-----------------------------------------------------------------------------
211
- // njsOracledb::New()
212
- // Invoked when new of oracledb is called from JS.
213
- //-----------------------------------------------------------------------------
214
- NAN_METHOD(njsOracledb::New)
215
- {
216
- dpiVersionInfo versionInfo;
217
-
218
- if (dpiContext_getClientVersion(globalDPIContext, &versionInfo) < 0) {
219
- ThrowDPIError();
220
- return;
221
- }
222
- njsOracledb *oracledb = new njsOracledb();
223
- oracledb->oraClientVer = static_cast<unsigned int> (
224
- 100000000 * versionInfo.versionNum +
225
- 1000000 * versionInfo.releaseNum +
226
- 10000 * versionInfo.updateNum +
227
- 100 * versionInfo.portReleaseNum +
228
- versionInfo.portUpdateNum );
229
- oracledb->Wrap(info.Holder());
230
- info.GetReturnValue().Set(info.Holder());
231
- }
232
-
233
-
234
- //-----------------------------------------------------------------------------
235
- // njsOracledb::InitCommonCreateParams()
236
- // Initialize common creation parameters for pools and standalone
237
- // connection creation.
238
- //-----------------------------------------------------------------------------
239
- bool njsOracledb::InitCommonCreateParams(njsBaton *baton,
240
- dpiCommonCreateParams *params)
241
- {
242
- if (dpiContext_initCommonCreateParams(globalDPIContext, params) < 0) {
243
- baton->GetDPIError();
244
- return false;
245
- }
246
- params->createMode = DPI_MODE_CREATE_THREADED;
247
- if (baton->events)
248
- params->createMode = (dpiCreateMode)
249
- ((int) params->createMode | DPI_MODE_CREATE_EVENTS);
250
- params->encoding = "UTF-8";
251
- params->nencoding = "UTF-8";
252
- params->driverName = NJS_DRIVER_NAME;
253
- params->driverNameLength = (uint32_t) strlen(params->driverName);
254
- return true;
255
- }
256
-
257
-
258
- //-----------------------------------------------------------------------------
259
- // njsOracledb::GetPoolMin()
260
- // Get accessor of "poolMin" property.
261
- //-----------------------------------------------------------------------------
262
- NAN_GETTER(njsOracledb::GetPoolMin)
263
- {
264
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
265
- if (oracledb)
266
- info.GetReturnValue().Set(oracledb->poolMin);
267
- }
268
-
269
-
270
- //-----------------------------------------------------------------------------
271
- // njsOracledb::SetPoolMin()
272
- // Set accessor of "poolMin" property.
273
- //-----------------------------------------------------------------------------
274
- NAN_SETTER(njsOracledb::SetPoolMin)
275
- {
276
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
277
- if (oracledb)
278
- oracledb->SetPropUnsignedInt(value, &oracledb->poolMin, "poolMin");
279
- }
280
-
281
-
282
- //-----------------------------------------------------------------------------
283
- // njsOracledb::GetPoolMax()
284
- // Get accessor of "poolMax" property.
285
- //-----------------------------------------------------------------------------
286
- NAN_GETTER(njsOracledb::GetPoolMax)
287
- {
288
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
289
- if (oracledb)
290
- info.GetReturnValue().Set(oracledb->poolMax);
291
- }
292
-
293
-
294
- //-----------------------------------------------------------------------------
295
- // njsOracledb::SetPoolMax()
296
- // Set accessor of "poolMax" property.
297
- //-----------------------------------------------------------------------------
298
- NAN_SETTER(njsOracledb::SetPoolMax)
299
- {
300
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
301
- if (oracledb)
302
- oracledb->SetPropUnsignedInt(value, &oracledb->poolMax, "poolMax");
303
- }
304
-
305
-
306
- //-----------------------------------------------------------------------------
307
- // njsOracledb::GetPoolIncrement()
308
- // Get accessor of "poolIncrement" property.
309
- //-----------------------------------------------------------------------------
310
- NAN_GETTER(njsOracledb::GetPoolIncrement)
311
- {
312
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
313
- if (oracledb)
314
- info.GetReturnValue().Set(oracledb->poolIncrement);
315
- }
316
-
317
-
318
- //-----------------------------------------------------------------------------
319
- // njsOracledb::SetPoolIncrement()
320
- // Set accessor of "poolIncrement" property.
321
- //-----------------------------------------------------------------------------
322
- NAN_SETTER(njsOracledb::SetPoolIncrement)
323
- {
324
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
325
- if (oracledb)
326
- oracledb->SetPropUnsignedInt(value, &oracledb->poolIncrement,
327
- "poolIncrement");
328
- }
329
-
330
-
331
- //-----------------------------------------------------------------------------
332
- // njsOracledb::GetPoolPingInterval()
333
- // Get accessor of "poolPingInterval" property.
334
- //-----------------------------------------------------------------------------
335
- NAN_GETTER(njsOracledb::GetPoolPingInterval)
336
- {
337
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
338
- if (oracledb)
339
- info.GetReturnValue().Set(oracledb->poolPingInterval);
340
- }
341
-
342
-
343
- //-----------------------------------------------------------------------------
344
- // njsOracledb::SetPoolPingInterval()
345
- // Set accessor of "poolPingInterval" property.
346
- //-----------------------------------------------------------------------------
347
- NAN_SETTER(njsOracledb::SetPoolPingInterval)
348
- {
349
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
350
- if (oracledb)
351
- oracledb->SetPropInt(value, &oracledb->poolPingInterval,
352
- "poolPingInterval");
353
- }
354
-
355
-
356
-
357
- //-----------------------------------------------------------------------------
358
- // njsOracledb::GetPoolTimeout()
359
- // Get accessor of "poolTimeout" property.
360
- //-----------------------------------------------------------------------------
361
- NAN_GETTER(njsOracledb::GetPoolTimeout)
362
- {
363
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
364
- if (oracledb)
365
- info.GetReturnValue().Set(oracledb->poolTimeout);
366
- }
367
-
368
-
369
- //-----------------------------------------------------------------------------
370
- // njsOracledb::SetPoolTimeout()
371
- // Set accessor of "poolTimeout" property.
372
- //-----------------------------------------------------------------------------
373
- NAN_SETTER(njsOracledb::SetPoolTimeout)
374
- {
375
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
376
- if (oracledb)
377
- oracledb->SetPropUnsignedInt(value, &oracledb->poolTimeout,
378
- "poolTimeout");
379
- }
380
-
381
-
382
- //-----------------------------------------------------------------------------
383
- // njsOracledb::GetMaxRows()
384
- // Get accessor of "maxRows" property.
385
- //-----------------------------------------------------------------------------
386
- NAN_GETTER(njsOracledb::GetMaxRows)
387
- {
388
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
389
- if (oracledb)
390
- info.GetReturnValue().Set(oracledb->maxRows);
391
- }
392
-
393
-
394
- //-----------------------------------------------------------------------------
395
- // njsOracledb::SetMaxRows()
396
- // Set accessor of "maxRows" property.
397
- //-----------------------------------------------------------------------------
398
- NAN_SETTER(njsOracledb::SetMaxRows)
399
- {
400
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
401
- if (oracledb)
402
- oracledb->SetPropUnsignedInt(value, &oracledb->maxRows, "maxRows");
403
- }
404
-
405
-
406
- //-----------------------------------------------------------------------------
407
- // njsOracledb::GetOUtFormat()
408
- // Get accessor of "outFormat" property.
409
- //-----------------------------------------------------------------------------
410
- NAN_GETTER(njsOracledb::GetOutFormat)
411
- {
412
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
413
- if (oracledb)
414
- info.GetReturnValue().Set(oracledb->outFormat);
415
- }
416
-
417
-
418
- //-----------------------------------------------------------------------------
419
- // njsOracledb::SetOUtFormat()
420
- // Set accessor of "outFormat" property.
421
- //-----------------------------------------------------------------------------
422
- NAN_SETTER(njsOracledb::SetOutFormat)
423
- {
424
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
425
- if (oracledb)
426
- oracledb->SetPropUnsignedInt(value, &oracledb->outFormat, "outFormat");
427
- }
428
-
429
-
430
- //-----------------------------------------------------------------------------
431
- // njsOracledb::GetStmtCacheSize()
432
- // Get accessor of "stmtCacheSize" property.
433
- //-----------------------------------------------------------------------------
434
- NAN_GETTER(njsOracledb::GetStmtCacheSize)
435
- {
436
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
437
- if (oracledb)
438
- info.GetReturnValue().Set(oracledb->stmtCacheSize);
439
- }
440
-
441
-
442
- //-----------------------------------------------------------------------------
443
- // njsOracledb::SetStmtCacheSize()
444
- // Set accessor of "stmtCacheSize" property.
445
- //-----------------------------------------------------------------------------
446
- NAN_SETTER(njsOracledb::SetStmtCacheSize)
447
- {
448
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
449
- if (oracledb)
450
- oracledb->SetPropUnsignedInt(value, &oracledb->stmtCacheSize,
451
- "stmtCacheSize");
452
- }
453
-
454
-
455
- //-----------------------------------------------------------------------------
456
- // njsOracledb::GetFetchArraySize()
457
- // Get accessor of "fetchArraySize" property.
458
- //-----------------------------------------------------------------------------
459
- NAN_GETTER(njsOracledb::GetFetchArraySize)
460
- {
461
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
462
- if (oracledb)
463
- info.GetReturnValue().Set(oracledb->fetchArraySize);
464
- }
465
-
466
-
467
- //-----------------------------------------------------------------------------
468
- // njsOracledb::SetFetchArraySize()
469
- // Set accessor of "fetchArraySize" property.
470
- //-----------------------------------------------------------------------------
471
- NAN_SETTER(njsOracledb::SetFetchArraySize)
472
- {
473
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
474
- if (oracledb)
475
- oracledb->SetPropPositiveInt(value, &oracledb->fetchArraySize,
476
- "fetchArraySize");
477
- }
478
-
479
-
480
- //-----------------------------------------------------------------------------
481
- // njsOracledb::GetAutoCommit()
482
- // Get accessor of "autoCommit" property.
483
- //-----------------------------------------------------------------------------
484
- NAN_GETTER(njsOracledb::GetAutoCommit)
485
- {
486
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
487
- if (oracledb)
488
- info.GetReturnValue().Set(oracledb->autoCommit);
489
- }
490
-
491
-
492
- //-----------------------------------------------------------------------------
493
- // njsOracledb::SetAutoCommit()
494
- // Set accessor of "autoCommit" property.
495
- //-----------------------------------------------------------------------------
496
- NAN_SETTER(njsOracledb::SetAutoCommit)
497
- {
498
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
499
- if (oracledb)
500
- oracledb->SetPropBool(value, &oracledb->autoCommit, "autoCommit");
501
- }
502
-
503
-
504
- //-----------------------------------------------------------------------------
505
- // njsOracledb::GetExtendedMetaData()
506
- // Get accessor of "extendedMetaData" property.
507
- //-----------------------------------------------------------------------------
508
- NAN_GETTER(njsOracledb::GetExtendedMetaData)
509
- {
510
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
511
- if (oracledb)
512
- info.GetReturnValue().Set(oracledb->extendedMetaData);
513
- }
514
-
515
-
516
- //-----------------------------------------------------------------------------
517
- // njsOracledb::SetExtendedMetaData()
518
- // Set accessor of "extendedMetaData" property.
519
- //-----------------------------------------------------------------------------
520
- NAN_SETTER(njsOracledb::SetExtendedMetaData)
521
- {
522
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
523
- if (oracledb)
524
- oracledb->SetPropBool ( value, &oracledb->extendedMetaData,
525
- "extendedMetaData" ) ;
526
- }
527
-
528
-
529
- //-----------------------------------------------------------------------------
530
- // njsOracledb::GetVersion()
531
- // Get accessor of "version" property.
532
- //-----------------------------------------------------------------------------
533
- NAN_GETTER(njsOracledb::GetVersion)
534
- {
535
- info.GetReturnValue().Set(NJS_NODE_ORACLEDB_VERSION);
536
- }
537
-
538
-
539
- //-----------------------------------------------------------------------------
540
- // njsOracledb::SetVersion()
541
- // Set accessor of "version" property.
542
- //-----------------------------------------------------------------------------
543
- NAN_SETTER(njsOracledb::SetVersion)
544
- {
545
- PropertyIsReadOnly("version");
546
- }
547
-
548
-
549
- //-----------------------------------------------------------------------------
550
- // njsOracledb::GetVersionString()
551
- // Get accessor of "versionString" property.
552
- //-----------------------------------------------------------------------------
553
- NAN_GETTER(njsOracledb::GetVersionString)
554
- {
555
- Local<String> value =
556
- Nan::New<v8::String>(NJS_VERSION_STRING).ToLocalChecked();
557
- info.GetReturnValue().Set(value);
558
- }
559
-
560
-
561
- //-----------------------------------------------------------------------------
562
- // njsOracledb::SetVersionString()
563
- // Set accessor of "versionString" property.
564
- //-----------------------------------------------------------------------------
565
- NAN_SETTER(njsOracledb::SetVersionString)
566
- {
567
- PropertyIsReadOnly("versionString");
568
- }
569
-
570
-
571
- //-----------------------------------------------------------------------------
572
- // njsOracledb::GetVersionSuffix()
573
- // Get accessor of "versionSuffix" property.
574
- //-----------------------------------------------------------------------------
575
- NAN_GETTER(njsOracledb::GetVersionSuffix)
576
- {
577
- Local<String> value =
578
- #ifdef NJS_NODE_ORACLEDB_SUFFIX
579
- Nan::New<v8::String>(NJS_NODE_ORACLEDB_SUFFIX).ToLocalChecked();
580
- #else
581
- Nan::Undefined();
582
- #endif
583
- info.GetReturnValue().Set(value);
584
- }
585
-
586
-
587
- //-----------------------------------------------------------------------------
588
- // njsOracledb::SetVersionSuffix()
589
- // Set accessor of "versionSuffix" property.
590
- //-----------------------------------------------------------------------------
591
- NAN_SETTER(njsOracledb::SetVersionSuffix)
592
- {
593
- PropertyIsReadOnly("versionSuffix");
594
- }
595
-
596
-
597
- //-----------------------------------------------------------------------------
598
- // njsOracledb::GetConnectionClass()
599
- // Get accessor of "connectionClass" property.
600
- //-----------------------------------------------------------------------------
601
- NAN_GETTER(njsOracledb::GetConnectionClass)
602
- {
603
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
604
- if (!oracledb)
605
- return;
606
- Local<String> value =
607
- Nan::New<v8::String>(oracledb->connClass).ToLocalChecked();
608
- info.GetReturnValue().Set(value);
609
- }
610
-
611
-
612
- //-----------------------------------------------------------------------------
613
- // njsOracledb::SetConnectionClass()
614
- // Set accessor of "connectionClass" property.
615
- //-----------------------------------------------------------------------------
616
- NAN_SETTER(njsOracledb::SetConnectionClass)
617
- {
618
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
619
- if (oracledb)
620
- oracledb->SetPropString(value, &oracledb->connClass,
621
- "connectionClass");
622
- }
623
-
624
- //-----------------------------------------------------------------------------
625
- // njsOracledb::GetEdition()
626
- // Get accessor of "edition" property.
627
- //-----------------------------------------------------------------------------
628
- NAN_GETTER(njsOracledb::GetEdition)
629
- {
630
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
631
- if (!oracledb)
632
- return;
633
- Local<String> value =
634
- Nan::New<v8::String>(oracledb->edition).ToLocalChecked();
635
- info.GetReturnValue().Set(value);
636
- }
637
-
638
- //-----------------------------------------------------------------------------
639
- // njsOracledb::SetEdition()
640
- // Set accessor of "edition" property.
641
- //-----------------------------------------------------------------------------
642
- NAN_SETTER(njsOracledb::SetEdition)
643
- {
644
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
645
- if (oracledb)
646
- oracledb->SetPropString(value, &oracledb->edition,
647
- "edition");
648
- }
649
-
650
-
651
- //-----------------------------------------------------------------------------
652
- // njsOracledb::GetExternalAuth()
653
- // Get accessor of "externalAuth" property.
654
- //-----------------------------------------------------------------------------
655
- NAN_GETTER(njsOracledb::GetExternalAuth)
656
- {
657
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
658
- if (oracledb)
659
- info.GetReturnValue().Set(oracledb->externalAuth);
660
- }
661
-
662
-
663
- //-----------------------------------------------------------------------------
664
- // njsOracledb::SetExternalAuth()
665
- // Set accessor of "externalAuth" property.
666
- //-----------------------------------------------------------------------------
667
- NAN_SETTER(njsOracledb::SetExternalAuth)
668
- {
669
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
670
- if (oracledb)
671
- oracledb->SetPropBool(value, &oracledb->externalAuth, "externalAuth" );
672
- }
673
-
674
-
675
- //-----------------------------------------------------------------------------
676
- // njsOracledb::GetLobPrefetchSize()
677
- // Get accessor of "lobPrefetchSize" property.
678
- //-----------------------------------------------------------------------------
679
- NAN_GETTER(njsOracledb::GetLobPrefetchSize)
680
- {
681
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
682
- if (oracledb)
683
- info.GetReturnValue().Set(oracledb->lobPrefetchSize);
684
- }
685
-
686
-
687
- //-----------------------------------------------------------------------------
688
- // njsOracledb::SetLobPrefetchSize()
689
- // Set accessor of "lobPrefetchSize" property.
690
- //-----------------------------------------------------------------------------
691
- NAN_SETTER(njsOracledb::SetLobPrefetchSize)
692
- {
693
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
694
- if (oracledb)
695
- oracledb->SetPropUnsignedInt(value, &oracledb->lobPrefetchSize,
696
- "lobPrefetchSize");
697
- }
698
-
699
-
700
- //-----------------------------------------------------------------------------
701
- // njsOracledb::GetFetchAsString()
702
- // Get accessor of "fetchAsString" property.
703
- //-----------------------------------------------------------------------------
704
- NAN_GETTER(njsOracledb::GetFetchAsString)
705
- {
706
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
707
- if (oracledb) {
708
- Local<Value> val = Nan::New(oracledb->jsFetchAsStringTypes);
709
- if (val.IsEmpty())
710
- val = Nan::New<Array>(0);
711
- info.GetReturnValue().Set(val);
712
- }
713
- }
714
-
715
-
716
- //-----------------------------------------------------------------------------
717
- // njsOracledb::SetFetchAsString()
718
- // Set accessor of "fetchAsString" property.
719
- //-----------------------------------------------------------------------------
720
- NAN_SETTER(njsOracledb::SetFetchAsString)
721
- {
722
- string errMsg;
723
-
724
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
725
- if (!oracledb)
726
- return;
727
-
728
- // make sure we have an array
729
- if (!value->IsArray()) {
730
- errMsg = njsMessages::Get(errInvalidPropertyValue, "fetchAsString");
731
- Nan::ThrowError(errMsg.c_str());
732
- return;
733
- }
734
-
735
- // validate values in array
736
- Local<Array> array = value.As<Array>();
737
- for (uint32_t i = 0; i < array->Length(); i++) {
738
- int32_t dataType = Nan::To<int32_t>
739
- (Nan::Get(array,
740
- i).ToLocalChecked().As<Integer>()).FromJust();
741
- njsDataType type = static_cast<njsDataType>(dataType);
742
- switch (type) {
743
- case NJS_DATATYPE_NUM:
744
- case NJS_DATATYPE_DATE:
745
- case NJS_DATATYPE_BUFFER:
746
- case NJS_DATATYPE_CLOB:
747
- break;
748
- default:
749
- errMsg = njsMessages::Get(errInvalidTypeForConversion);
750
- Nan::ThrowError(errMsg.c_str());
751
- return;
752
- }
753
- }
754
-
755
- // retain value
756
- oracledb->jsFetchAsStringTypes.Reset(array);
757
- }
758
-
759
-
760
- //-----------------------------------------------------------------------------
761
- // njsOracledb::GetFetchAsBuffer()
762
- // Get accessor of "fetchAsBuffer" property.
763
- //-----------------------------------------------------------------------------
764
- NAN_GETTER(njsOracledb::GetFetchAsBuffer)
765
- {
766
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
767
- if (oracledb) {
768
- Local<Value> val = Nan::New(oracledb->jsFetchAsBufferTypes);
769
- if (val.IsEmpty())
770
- val = Nan::New<Array>(0);
771
- info.GetReturnValue().Set(val);
772
- }
773
- }
774
-
775
-
776
- //-----------------------------------------------------------------------------
777
- // njsOracledb::SetFetchAsBuffer()
778
- // Set accessor of "fetchAsBuffer" property.
779
- //-----------------------------------------------------------------------------
780
- NAN_SETTER(njsOracledb::SetFetchAsBuffer)
781
- {
782
- string errMsg;
783
-
784
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
785
- if (!oracledb)
786
- return;
787
-
788
- // make sure we have an array
789
- if (!value->IsArray()) {
790
- errMsg = njsMessages::Get(errInvalidPropertyValue, "fetchAsBuffer");
791
- Nan::ThrowError(errMsg.c_str());
792
- return;
793
- }
794
-
795
- // validate values in array
796
- Local<Array> array = value.As<Array>();
797
- for (uint32_t i = 0; i < array->Length(); i++) {
798
- int32_t dataType = Nan::To<int32_t>(
799
- Nan::Get(array, i).
800
- ToLocalChecked().As<v8::Integer>()).FromJust();
801
- njsDataType type = static_cast<njsDataType>(dataType);
802
-
803
- if (type != NJS_DATATYPE_BLOB) {
804
- errMsg = njsMessages::Get(errInvalidTypeForConversion);
805
- Nan::ThrowError(errMsg.c_str());
806
- return;
807
- }
808
- }
809
-
810
- // retain value
811
- oracledb->jsFetchAsBufferTypes.Reset(array);
812
- }
813
-
814
-
815
- //-----------------------------------------------------------------------------
816
- // njsOracledb::GetOracleClientVersion()
817
- // Get accessor of "oracleClientVersion" property.
818
- //-----------------------------------------------------------------------------
819
- NAN_GETTER(njsOracledb::GetOracleClientVersion)
820
- {
821
- dpiVersionInfo versionInfo;
822
- unsigned int version;
823
-
824
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
825
- if (!oracledb)
826
- return;
827
-
828
- if (dpiContext_getClientVersion(globalDPIContext, &versionInfo) < 0) {
829
- ThrowDPIError();
830
- return;
831
- }
832
-
833
- version = static_cast <unsigned int> (
834
- 100000000 * versionInfo.versionNum +
835
- 1000000 * versionInfo.releaseNum +
836
- 10000 * versionInfo.updateNum +
837
- 100 * versionInfo.portReleaseNum +
838
- versionInfo.portUpdateNum );
839
-
840
- info.GetReturnValue().Set(version);
841
- }
842
-
843
-
844
- //-----------------------------------------------------------------------------
845
- // njsOracledb::SetOracleClientVersion()
846
- // Set accessor of "oracleClientVersion" property.
847
- //-----------------------------------------------------------------------------
848
- NAN_SETTER(njsOracledb::SetOracleClientVersion)
849
- {
850
- PropertyIsReadOnly("oracleClientVersion");
851
- }
852
-
853
-
854
- //-----------------------------------------------------------------------------
855
- // njsOracledb::GetOracleClientVersionString()
856
- // Get accessor of "oracleClientVersionString" property.
857
- //-----------------------------------------------------------------------------
858
- NAN_GETTER(njsOracledb::GetOracleClientVersionString)
859
- {
860
- dpiVersionInfo versionInfo;
861
- char versionString[40];
862
- Local<String> value;
863
-
864
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
865
- if (!oracledb)
866
- return;
867
-
868
- if (dpiContext_getClientVersion(globalDPIContext, &versionInfo) < 0) {
869
- ThrowDPIError();
870
- return;
871
- }
872
-
873
- (void) sprintf(versionString, "%d.%d.%d.%d.%d", versionInfo.versionNum,
874
- versionInfo.releaseNum, versionInfo.updateNum,
875
- versionInfo.portReleaseNum, versionInfo.portUpdateNum);
876
- value = Nan::New<v8::String>(versionString).ToLocalChecked();
877
- info.GetReturnValue().Set(value);
878
- }
879
-
880
-
881
- //-----------------------------------------------------------------------------
882
- // njsOracledb::SetOracleClientVersionString()
883
- // Set accessor of "oracleClientVersionString" property.
884
- //-----------------------------------------------------------------------------
885
- NAN_SETTER(njsOracledb::SetOracleClientVersionString)
886
- {
887
- PropertyIsReadOnly("oracleClientVersionString");
888
- }
889
-
890
-
891
- // njsOracledb::GetEvents()
892
- // Get accessor of "events" property.
893
- //-----------------------------------------------------------------------------
894
- NAN_GETTER(njsOracledb::GetEvents)
895
- {
896
- njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
897
- if (oracledb)
898
- info.GetReturnValue().Set(oracledb->events);
899
- }
900
-
901
-
902
- //-----------------------------------------------------------------------------
903
- // njsOracledb::SetEvents()
904
- // Set accessor of "events" property.
905
- //-----------------------------------------------------------------------------
906
- NAN_SETTER(njsOracledb::SetEvents)
907
- {
908
- njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
909
- if (oracledb)
910
- oracledb->SetPropBool(value, &oracledb->events, "events");
911
- }
912
-
913
-
914
- //-----------------------------------------------------------------------------
915
- // njsOracledb::GetConnection()
916
- // Establishes a standalone connection to the database using the parameters
917
- // specified in an asynchronous fashion, calling the JS callback when complete.
918
- //
919
- // PARAMETERS
920
- // - Connection attributes as JSON object
921
- // - JS callback which will receive (error, connection)
922
- //-----------------------------------------------------------------------------
923
- NAN_METHOD(njsOracledb::GetConnection)
924
- {
925
- Local<Object> connProps;
926
- njsOracledb *oracledb;
927
- njsBaton *baton;
928
-
929
- oracledb = (njsOracledb*) ValidateArgs(info, 2, 2);
930
- if (!oracledb)
931
- return;
932
- if (!oracledb->GetObjectArg(info, 0, connProps))
933
- return;
934
- baton = oracledb->CreateBaton(info);
935
- if (!baton)
936
- return;
937
- baton->jsOracledb.Reset(info.Holder());
938
-
939
- baton->GetStringFromJSON(connProps, "user", 0, baton->user);
940
- baton->GetStringFromJSON(connProps, "password", 0, baton->password);
941
- baton->GetStringFromJSON(connProps, "connectString", 0,
942
- baton->connectString);
943
- baton->GetStringFromJSON(connProps, "newPassword", 0, baton->newPassword);
944
- baton->connClass = oracledb->connClass;
945
- baton->edition = oracledb->edition;
946
- baton->stmtCacheSize = oracledb->stmtCacheSize;
947
- baton->externalAuth = oracledb->externalAuth;
948
- baton->events = oracledb->events;
949
- baton->GetStringFromJSON(connProps, "edition", 0, baton->edition);
950
- baton->GetUnsignedIntFromJSON(connProps, "stmtCacheSize", 0,
951
- &baton->stmtCacheSize);
952
- baton->GetUnsignedIntFromJSON(connProps, "privilege", 0,
953
- &baton->privilege);
954
- baton->GetBoolFromJSON(connProps, "externalAuth", 0, &baton->externalAuth);
955
- baton->GetBoolFromJSON(connProps, "events", 0, &baton->events);
956
- baton->lobPrefetchSize = oracledb->lobPrefetchSize;
957
-
958
- baton->QueueWork("GetConnection", Async_GetConnection,
959
- Async_AfterGetConnection, 2);
960
- }
961
-
962
-
963
- //-----------------------------------------------------------------------------
964
- // njsOracledb::Async_GetConnection()
965
- // Worker function for GetConnection() performed on thread. This establishes
966
- // the connection using the information found in the baton.
967
- //-----------------------------------------------------------------------------
968
- void njsOracledb::Async_GetConnection(njsBaton *baton)
969
- {
970
- dpiCommonCreateParams commonParams;
971
- dpiConnCreateParams params;
972
-
973
- if (dpiContext_initConnCreateParams(globalDPIContext, &params) < 0) {
974
- baton->GetDPIError();
975
- return;
976
- }
977
- if (baton->privilege)
978
- params.authMode = (dpiAuthMode) baton->privilege;
979
- params.externalAuth = baton->externalAuth;
980
- if (!baton->connClass.empty()) {
981
- params.connectionClass = baton->connClass.c_str();
982
- params.connectionClassLength = baton->connClass.length();
983
- }
984
-
985
- if(!baton->newPassword.empty()) {
986
- params.newPassword = baton->newPassword.c_str();
987
- params.newPasswordLength = baton->newPassword.length();
988
- }
989
- if (!InitCommonCreateParams(baton, &commonParams))
990
- return;
991
- if (!baton->edition.empty()) {
992
- commonParams.edition = baton->edition.c_str();
993
- commonParams.editionLength = baton->edition.length();
994
- }
995
-
996
- if (dpiConn_create(globalDPIContext, baton->user.c_str(),
997
- (uint32_t) baton->user.length(), baton->password.c_str(),
998
- (uint32_t) baton->password.length(), baton->connectString.c_str(),
999
- (uint32_t) baton->connectString.length(), &commonParams, &params,
1000
- &baton->dpiConnHandle) < 0) {
1001
- baton->GetDPIError();
1002
- } else if (dpiConn_setStmtCacheSize(baton->dpiConnHandle,
1003
- baton->stmtCacheSize) < 0) {
1004
- baton->GetDPIError();
1005
- }
1006
- }
1007
-
1008
-
1009
- //-----------------------------------------------------------------------------
1010
- // njsOracledb::Async_AfterGetConnection()
1011
- // Sets up the arguments for the callback to JS. The connection object is
1012
- // created and passed as the second argument. The first argument is always the
1013
- // error and at this point it is known that no error has taken place.
1014
- //-----------------------------------------------------------------------------
1015
- void njsOracledb::Async_AfterGetConnection(njsBaton *baton,
1016
- Local<Value> argv[])
1017
- {
1018
- argv[1] = njsConnection::CreateFromBaton(baton);
1019
- }
1020
-
1021
-
1022
- //-----------------------------------------------------------------------------
1023
- // njsOracledb::CreatePool()
1024
- // Creates a session pool using the parameters specified in an asynchronous
1025
- // fashion, calling the JS callback when complete.
1026
- //
1027
- // PARAMETERS
1028
- // - Pool attributes as JSON object
1029
- // - JS callback which will receive (error, pool)
1030
- //-----------------------------------------------------------------------------
1031
- NAN_METHOD(njsOracledb::CreatePool)
1032
- {
1033
- Local<Object> poolProps;
1034
- njsOracledb *oracledb;
1035
- njsBaton *baton;
1036
-
1037
- oracledb = (njsOracledb*) ValidateArgs(info, 2, 2);
1038
- if (!oracledb)
1039
- return;
1040
- if (!oracledb->GetObjectArg(info, 0, poolProps))
1041
- return;
1042
- baton = oracledb->CreateBaton(info);
1043
- if (!baton)
1044
- return;
1045
-
1046
- baton->GetStringFromJSON(poolProps, "user", 0, baton->user);
1047
- baton->GetStringFromJSON(poolProps, "password", 0, baton->password);
1048
- baton->GetStringFromJSON(poolProps, "connectString", 0,
1049
- baton->connectString);
1050
- baton->poolMax = oracledb->poolMax;
1051
- baton->poolMin = oracledb->poolMin;
1052
- baton->poolIncrement = oracledb->poolIncrement;
1053
- baton->poolTimeout = oracledb->poolTimeout;
1054
- baton->poolPingInterval = oracledb->poolPingInterval;
1055
- baton->stmtCacheSize = oracledb->stmtCacheSize;
1056
- baton->externalAuth = oracledb->externalAuth;
1057
- baton->edition = oracledb->edition;
1058
- baton->events = oracledb->events;
1059
- baton->GetUnsignedIntFromJSON(poolProps, "poolMax", 0, &baton->poolMax);
1060
- baton->GetUnsignedIntFromJSON(poolProps, "poolMin", 0, &baton->poolMin);
1061
- baton->GetUnsignedIntFromJSON(poolProps, "poolIncrement", 0,
1062
- &baton->poolIncrement);
1063
- baton->GetUnsignedIntFromJSON(poolProps, "poolTimeout", 0,
1064
- &baton->poolTimeout);
1065
- baton->GetUnsignedIntFromJSON(poolProps, "stmtCacheSize", 0,
1066
- &baton->stmtCacheSize);
1067
- baton->GetIntFromJSON(poolProps, "poolPingInterval", 0,
1068
- &baton->poolPingInterval);
1069
- baton->GetBoolFromJSON(poolProps, "externalAuth", 0, &baton->externalAuth);
1070
- baton->GetBoolFromJSON(poolProps, "homogeneous", 0, &baton->homogeneous);
1071
- baton->GetBoolFromJSON(poolProps, "events", 0, &baton->events);
1072
- baton->GetStringFromJSON(poolProps, "edition", 0, baton->edition);
1073
- baton->lobPrefetchSize = oracledb->lobPrefetchSize;
1074
- baton->jsOracledb.Reset(info.Holder());
1075
-
1076
- baton->QueueWork("CreatePool", Async_CreatePool, Async_AfterCreatePool, 2);
1077
- }
1078
-
1079
-
1080
- //-----------------------------------------------------------------------------
1081
- // njsOracledb::Async_CreatePool()
1082
- // Worker function for GetConnection() performed on thread. This establishes
1083
- // the connection using the information found in the baton.
1084
- //-----------------------------------------------------------------------------
1085
- void njsOracledb::Async_CreatePool(njsBaton *baton)
1086
- {
1087
- dpiCommonCreateParams commonParams;
1088
- dpiPoolCreateParams params;
1089
-
1090
- if (dpiContext_initPoolCreateParams(globalDPIContext, &params) < 0) {
1091
- baton->GetDPIError();
1092
- return;
1093
- }
1094
- params.minSessions = baton->poolMin;
1095
- params.maxSessions = baton->poolMax;
1096
- params.sessionIncrement = baton->poolIncrement;
1097
- params.getMode = DPI_MODE_POOL_GET_WAIT;
1098
- params.externalAuth = baton->externalAuth;
1099
- params.homogeneous = baton->homogeneous;
1100
-
1101
- if (params.externalAuth)
1102
- params.homogeneous = 0;
1103
- params.pingInterval = baton->poolPingInterval;
1104
- if (!InitCommonCreateParams(baton, &commonParams))
1105
- return;
1106
- if (!baton->edition.empty()) {
1107
- commonParams.edition = baton->edition.c_str();
1108
- commonParams.editionLength = baton->edition.length();
1109
- }
1110
- if (dpiPool_create(globalDPIContext, baton->user.c_str(),
1111
- (uint32_t) baton->user.length(), baton->password.c_str(),
1112
- (uint32_t) baton->password.length(), baton->connectString.c_str(),
1113
- (uint32_t) baton->connectString.length(), &commonParams, &params,
1114
- &baton->dpiPoolHandle) < 0) {
1115
- baton->GetDPIError();
1116
- } else if (dpiPool_setTimeout(baton->dpiPoolHandle,
1117
- baton->poolTimeout) < 0) {
1118
- baton->GetDPIError();
1119
- } else if (dpiPool_setStmtCacheSize(baton->dpiPoolHandle,
1120
- baton->stmtCacheSize) < 0) {
1121
- baton->GetDPIError();
1122
- }
1123
- }
1124
-
1125
-
1126
- //-----------------------------------------------------------------------------
1127
- // njsOracledb::Async_AfterCreatePool()
1128
- // Sets up the arguments for the callback to JS. The pool object is created
1129
- // and passed as the second argument. The first argument is always the
1130
- // error and at this point it is known that no error has taken place.
1131
- //-----------------------------------------------------------------------------
1132
- void njsOracledb::Async_AfterCreatePool(njsBaton *baton, Local<Value> argv[])
1133
- {
1134
- argv[1] = njsPool::CreateFromBaton(baton);
1135
- }
1136
-
1137
-
1138
- //-----------------------------------------------------------------------------
1139
- // njsOracledb::SetFetchAsStringTypesOnBaton()
1140
- // Store information about the fetch as string types from the oracledb
1141
- // module. Note that these are copied since the value may change after this
1142
- // code has completed.
1143
- //-----------------------------------------------------------------------------
1144
- void njsOracledb::SetFetchAsStringTypesOnBaton(njsBaton *baton) const
1145
- {
1146
- Nan::HandleScope scope;
1147
-
1148
- Local<Array> array = Nan::New(jsFetchAsStringTypes);
1149
- if (array.IsEmpty())
1150
- return;
1151
- baton->numFetchAsStringTypes = array->Length();
1152
- baton->fetchAsStringTypes = new njsDataType[baton->numFetchAsStringTypes];
1153
- for (uint32_t i = 0; i < baton->numFetchAsStringTypes; i++) {
1154
- int32_t dataType = Nan::To<int32_t>(Nan::Get(array, i).
1155
- ToLocalChecked().As<v8::Integer>()).FromJust();
1156
- baton->fetchAsStringTypes[i] = static_cast<njsDataType>(dataType);
1157
- }
1158
- }
1159
-
1160
-
1161
- //-----------------------------------------------------------------------------
1162
- // njsOracledb::SetFetchAsBufferTypesOnBaton()
1163
- // Store information about the fetch as buffer types from the oracledb
1164
- // module. Note that these are copied since the value may change after this
1165
- // code has completed.
1166
- //-----------------------------------------------------------------------------
1167
- void njsOracledb::SetFetchAsBufferTypesOnBaton(njsBaton *baton) const
1168
- {
1169
- Nan::HandleScope scope;
1170
-
1171
- Local<Array> array = Nan::New(jsFetchAsBufferTypes);
1172
- if (array.IsEmpty())
1173
- return;
1174
- baton->numFetchAsBufferTypes = array->Length();
1175
- baton->fetchAsBufferTypes = new njsDataType[baton->numFetchAsBufferTypes];
1176
- for (uint32_t i = 0; i < baton->numFetchAsBufferTypes; i++) {
1177
- int32_t dataType = Nan::To<int32_t>(Nan::Get (array, i).
1178
- ToLocalChecked().As<v8::Integer>()).FromJust();
1179
- baton->fetchAsBufferTypes[i] = static_cast<njsDataType>(dataType);
1180
- }
1181
- }
1182
-
1183
-
1184
- //-----------------------------------------------------------------------------
1185
- // njsOracledb::ThrowDPIError()
1186
- // Gets the error information from ODPI-C and throws an exception.
1187
- //-----------------------------------------------------------------------------
1188
- void njsOracledb::ThrowDPIError(void)
1189
- {
1190
- dpiErrorInfo errorInfo;
1191
- Local<Value> exception;
1192
- Local<Object> errorObj;
1193
- std::string errMsg;
1194
-
1195
- dpiContext_getError(globalDPIContext, &errorInfo);
1196
- errMsg = std::string(errorInfo.message, errorInfo.messageLength);
1197
- exception = Nan::Error(errMsg.c_str());
1198
- errorObj = exception->ToObject();
1199
- Nan::Set(errorObj, Nan::New<v8::String>("errorNum").ToLocalChecked(),
1200
- Nan::New<v8::Number>(errorInfo.code));
1201
- Nan::Set(errorObj, Nan::New<v8::String>("offset").ToLocalChecked(),
1202
- Nan::New<v8::Number>(errorInfo.offset));
1203
- Nan::ThrowError(exception);
1204
- }
1205
-
1206
-
1207
- //-----------------------------------------------------------------------------
1208
- // njsOracledb::GetSubscription()
1209
- // Gets the subscription with the give name if it exists, or returns NULL if
1210
- // it does not exist in the subscriptions object.
1211
- //-----------------------------------------------------------------------------
1212
- njsSubscription *njsOracledb::GetSubscription(std::string &name)
1213
- {
1214
- Nan::HandleScope scope;
1215
- Local<String> nameObj = Nan::New<String>(name).ToLocalChecked();
1216
- Local<Object> allSubscriptions = Nan::New(subscriptions);
1217
- Local<Value> value = Nan::Get(allSubscriptions, nameObj).ToLocalChecked();
1218
- if (value->IsUndefined())
1219
- return NULL;
1220
- return Nan::ObjectWrap::Unwrap<njsSubscription>(value.As<Object>());
1221
- }
1222
-
1223
-
1224
- //-----------------------------------------------------------------------------
1225
- // njsOracledb::SetSubscription()
1226
- // Sets the subscription in the subscriptions object for later recovery,
1227
- // either to subscribe another query or to unsubscribe.
1228
- //-----------------------------------------------------------------------------
1229
- void njsOracledb::SetSubscription(std::string &name, Local<Value> subscription)
1230
- {
1231
- Nan::HandleScope scope;
1232
- Local<String> nameObj = Nan::New<String>(name).ToLocalChecked();
1233
- Local<Object> allSubscriptions = Nan::New(subscriptions);
1234
- Nan::Set(allSubscriptions, nameObj, subscription);
1235
- }
1236
-
1237
-
1238
- //-----------------------------------------------------------------------------
1239
- // njsOracledb::ClearSubscription()
1240
- // Clears the subscription from the subscriptions object.
1241
- //-----------------------------------------------------------------------------
1242
- void njsOracledb::ClearSubscription(std::string &name)
1243
- {
1244
- Nan::HandleScope scope;
1245
- Local<String> nameObj = Nan::New<String>(name).ToLocalChecked();
1246
- Local<Object> allSubscriptions = Nan::New(subscriptions);
1247
- Nan::Delete(allSubscriptions, nameObj);
1248
- }
1249
-
1250
-
1251
- //-----------------------------------------------------------------------------
1252
- // init()
1253
- // Invoked when require on oracledb is called.
1254
- //-----------------------------------------------------------------------------
1255
- extern "C"
1256
- {
1257
- static void init(Local<Object> target)
1258
- {
1259
- njsOracledb::Init(target);
1260
- njsConnection::Init(target);
1261
- njsPool::Init(target);
1262
- njsResultSet::Init(target);
1263
- njsILob::Init(target);
1264
- njsSubscription::Init(target);
1265
- njsSodaDatabase::Init(target);
1266
- njsSodaCollection::Init(target);
1267
- njsSodaDocument::Init(target);
1268
- njsSodaOperation::Init(target);
1269
- njsSodaDocCursor::Init(target);
1270
- }
1271
-
1272
- NODE_MODULE(oracledb, init)
1273
- }
1274
-