oracledb 5.1.0 → 5.4.0

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 (40) hide show
  1. package/CHANGELOG.md +164 -2
  2. package/LICENSE.txt +443 -0
  3. package/NOTICE.txt +1 -0
  4. package/README.md +15 -13
  5. package/THIRD_PARTY_LICENSES.txt +52 -0
  6. package/build/Release/oracledb-5.4.0-darwin-x64.node +0 -0
  7. package/build/Release/oracledb-5.4.0-darwin-x64.node-buildinfo.txt +1 -0
  8. package/build/Release/oracledb-5.4.0-linux-x64.node +0 -0
  9. package/build/Release/oracledb-5.4.0-linux-x64.node-buildinfo.txt +1 -0
  10. package/build/Release/oracledb-5.4.0-win32-x64.node +0 -0
  11. package/build/Release/oracledb-5.4.0-win32-x64.node-buildinfo.txt +1 -0
  12. package/lib/aqDeqOptions.js +1 -1
  13. package/lib/aqEnqOptions.js +1 -1
  14. package/lib/aqMessage.js +1 -1
  15. package/lib/aqQueue.js +9 -5
  16. package/lib/connection.js +233 -33
  17. package/lib/dbObject.js +17 -17
  18. package/lib/lob.js +17 -5
  19. package/lib/oracledb.js +74 -11
  20. package/lib/pool.js +271 -163
  21. package/lib/poolStatistics.js +124 -0
  22. package/lib/queryStream.js +8 -6
  23. package/lib/resultset.js +37 -9
  24. package/lib/sodaCollection.js +46 -21
  25. package/lib/sodaDatabase.js +8 -4
  26. package/lib/sodaDocCursor.js +7 -3
  27. package/lib/sodaDocument.js +1 -1
  28. package/lib/sodaOperation.js +21 -9
  29. package/lib/util.js +80 -20
  30. package/package/README.md +8 -8
  31. package/package/install.js +8 -7
  32. package/package/prunebinaries.js +4 -5
  33. package/package.json +2 -2
  34. package/LICENSE.md +0 -2685
  35. package/build/Release/oracledb-5.1.0-darwin-x64.node +0 -0
  36. package/build/Release/oracledb-5.1.0-darwin-x64.node-buildinfo.txt +0 -1
  37. package/build/Release/oracledb-5.1.0-linux-x64.node +0 -0
  38. package/build/Release/oracledb-5.1.0-linux-x64.node-buildinfo.txt +0 -1
  39. package/build/Release/oracledb-5.1.0-win32-x64.node +0 -0
  40. package/build/Release/oracledb-5.1.0-win32-x64.node-buildinfo.txt +0 -1
package/README.md CHANGED
@@ -1,11 +1,10 @@
1
- # node-oracledb version 5.1
1
+ # node-oracledb version 5.4.0
2
2
 
3
- **This release is under development and information may be incomplete**
3
+ The node-oracledb add-on for Node.js powers high performance Oracle Database
4
+ applications. Applications can be written in TypeScript, or directly in
5
+ JavaScript.
4
6
 
5
- The node-oracledb add-on for Node.js powers high performance Oracle
6
- Database applications.
7
-
8
- Use node-oracledb 5.1 to connect Node.js 10.16, 12, 14, or later, to Oracle Database.
7
+ Use node-oracledb 5.4.0 to connect Node.js 14, or later, to Oracle Database.
9
8
  Older versions of node-oracledb may work with older versions of Node.js.
10
9
 
11
10
  Node-oracledb supports basic and advanced features of Oracle Database
@@ -45,7 +44,7 @@ have been made by the community.
45
44
 
46
45
  ## <a name="license"></a> License
47
46
 
48
- Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
47
+ Copyright (c) 2015, 2022, Oracle and/or its affiliates.
49
48
 
50
49
  You may not use the identified files except in compliance with the Apache
51
50
  License, Version 2.0 (the "License.")
@@ -59,7 +58,10 @@ CONDITIONS OF ANY KIND, either express or implied.
59
58
  See the License for the specific language governing permissions and
60
59
  limitations under the License.
61
60
 
62
-
61
+ Developers choosing to distribute a binary implementation of this project are
62
+ responsible for obtaining and providing all required licenses and copyright
63
+ notices for the third-party code used in order to ensure compliance with their
64
+ respective open source licenses.
63
65
 
64
66
  [1]: https://oracle.github.io/node-oracledb/doc/api.html#getstarted
65
67
  [2]: https://oracle.github.io/node-oracledb/INSTALL.html#quickstart
@@ -67,10 +69,10 @@ limitations under the License.
67
69
  [4]: https://oracle.github.io/node-oracledb
68
70
  [5]: https://node-oracledb.slack.com/
69
71
  [6]: https://join.slack.com/t/node-oracledb/shared_invite/enQtNDU4Mjc2NzM5OTA2LWMzY2ZlZDY5MDdlMGZiMGRkY2IzYjI5OGU4YTEzZWM5YjQ3ODUzMjcxNWQyNzE4MzM5YjNkYjVmNDk5OWU5NDM
70
- [30]: https://github.com/oracle/node-oracledb/blob/master/examples
71
- [31]: https://github.com/oracle/node-oracledb/blob/master/examples/example.js#L32
72
+ [30]: https://github.com/oracle/node-oracledb/blob/main/examples
73
+ [31]: https://github.com/oracle/node-oracledb/blob/main/examples/example.js#L32
72
74
  [32]: https://oracle.github.io/node-oracledb/doc/api.html
73
- [33]: https://github.com/oracle/node-oracledb/blob/master/CHANGELOG.md
74
- [34]: https://github.com/oracle/node-oracledb/blob/master/test/README.md
75
- [35]: https://github.com/oracle/node-oracledb/blob/master/CONTRIBUTING.md
75
+ [33]: https://github.com/oracle/node-oracledb/blob/main/CHANGELOG.md
76
+ [34]: https://github.com/oracle/node-oracledb/blob/main/test/README.md
77
+ [35]: https://github.com/oracle/node-oracledb/blob/main/CONTRIBUTING.md
76
78
  [36]: http://www.apache.org/licenses/LICENSE-2.0
@@ -0,0 +1,52 @@
1
+ This product calls the top level APIs of Node.js.
2
+
3
+ Node.js is licensed for use as follows:
4
+
5
+ """
6
+ Copyright Node.js contributors. All rights reserved.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to
10
+ deal in the Software without restriction, including without limitation the
11
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12
+ sell copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
+ IN THE SOFTWARE.
25
+ """
26
+
27
+ This license applies to parts of Node.js originating from the
28
+ https://github.com/joyent/node repository:
29
+
30
+ """
31
+ Copyright Joyent, Inc. and other Node contributors. All rights reserved.
32
+ Permission is hereby granted, free of charge, to any person obtaining a copy
33
+ of this software and associated documentation files (the "Software"), to
34
+ deal in the Software without restriction, including without limitation the
35
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
36
+ sell copies of the Software, and to permit persons to whom the Software is
37
+ furnished to do so, subject to the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be included in
40
+ all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
47
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
48
+ IN THE SOFTWARE.
49
+ """
50
+
51
+ The Node.js license applies to all parts of Node.js that are not externally
52
+ maintained libraries.
@@ -0,0 +1 @@
1
+ oracledb-5.4.0-darwin-x64.node v18.2.0 84de9360da1af5b66be23bd5dcf0de230baf2a86 7682f57b334c378986a2687b418fe45daaf70af0 Wed, 01 Jun 2022 07:28:15 GMT
@@ -0,0 +1 @@
1
+ oracledb-5.4.0-linux-x64.node v10.23.1 84de9360da1af5b66be23bd5dcf0de230baf2a86 7682f57b334c378986a2687b418fe45daaf70af0 Wed, 01 Jun 2022 07:08:49 GMT
@@ -0,0 +1 @@
1
+ oracledb-5.4.0-win32-x64.node v18.2.0 84de9360da1af5b66be23bd5dcf0de230baf2a86 7682f57b334c378986a2687b418fe45daaf70af0 Wed, 01 Jun 2022 07:24:49 GMT
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2019, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2019, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
package/lib/aqMessage.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2019, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
package/lib/aqQueue.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2019, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -70,10 +70,14 @@ async function enqMany(messages) {
70
70
  class AqQueue {
71
71
 
72
72
  _extend() {
73
- this.deqOne = nodbUtil.callbackify(deqOne);
74
- this.deqMany = nodbUtil.callbackify(deqMany);
75
- this.enqOne = nodbUtil.callbackify(enqOne);
76
- this.enqMany = nodbUtil.callbackify(enqMany);
73
+ this.deqOne = nodbUtil.callbackify(nodbUtil.serialize(deqOne));
74
+ this.deqMany = nodbUtil.callbackify(nodbUtil.serialize(deqMany));
75
+ this.enqOne = nodbUtil.callbackify(nodbUtil.serialize(enqOne));
76
+ this.enqMany = nodbUtil.callbackify(nodbUtil.serialize(enqMany));
77
+ }
78
+
79
+ _getConnection() {
80
+ return this._connection;
77
81
  }
78
82
 
79
83
  }
package/lib/connection.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2016, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -71,7 +71,7 @@ async function execute(sql, a2, a3) {
71
71
  }
72
72
  }
73
73
 
74
- return result;
74
+ return (result);
75
75
  }
76
76
 
77
77
 
@@ -97,7 +97,7 @@ async function executeMany(sql, bindsOrNumIters, a3) {
97
97
  options = a3;
98
98
  }
99
99
 
100
- return await this._executeMany(sql, bindsOrNumIters, options);
100
+ return (await this._executeMany(sql, bindsOrNumIters, options));
101
101
  }
102
102
 
103
103
 
@@ -115,7 +115,7 @@ async function getDbObjectClass(name) {
115
115
  if (cls) {
116
116
  return cls;
117
117
  }
118
- return await this._getDbObjectClass(name);
118
+ return (await this._getDbObjectClass(name));
119
119
  }
120
120
 
121
121
 
@@ -125,7 +125,7 @@ async function getDbObjectClass(name) {
125
125
  //-----------------------------------------------------------------------------
126
126
  async function getStatementInfo(sql) {
127
127
  nodbUtil.checkArgCount(arguments, 1, 1);
128
- return await this._getStatementInfo(sql);
128
+ return (await this._getStatementInfo(sql));
129
129
  }
130
130
 
131
131
 
@@ -146,7 +146,7 @@ async function commit() {
146
146
  async function createLob(type) {
147
147
  nodbUtil.checkArgCount(arguments, 1, 1);
148
148
  nodbUtil.assert(typeof type === 'number', 'NJS-005', 1);
149
- return await this._createLob(type);
149
+ return (await this._createLob(type));
150
150
  }
151
151
 
152
152
 
@@ -172,12 +172,25 @@ async function close(a1) {
172
172
  nodbUtil.assert(nodbUtil.isObject(a1), 'NJS-005', 1);
173
173
  options = a1;
174
174
  }
175
- await this._close(options);
175
+
176
+ // If already in the process of closing, throw an error instead of doing
177
+ // a roundtrip
178
+ if (this._closing) {
179
+ throw new Error (nodbUtil.getErrorMessage('NJS-003'));
180
+ }
181
+
182
+ this._closing = true;
183
+ try {
184
+ await this._close(options);
185
+ } finally {
186
+ this._closing = false;
187
+ }
188
+
176
189
  for (const cls of Object.values(this._dbObjectClasses)) {
177
190
  cls.prototype.constructor = Object;
178
191
  cls.prototype = null;
179
192
  }
180
- this.emit('_after_close');
193
+ this.emit('_afterConnClose');
181
194
  }
182
195
 
183
196
 
@@ -217,7 +230,7 @@ async function getQueue(name, a2) {
217
230
  nodbUtil.assert(nodbUtil.isObject(a2), 'NJS-005', 2);
218
231
  options = a2;
219
232
  }
220
- return await this._getQueue(name, options);
233
+ return (await this._getQueue(name, options));
221
234
  }
222
235
 
223
236
 
@@ -298,7 +311,7 @@ function buildDbObjectClass(schema, name, fqn) {
298
311
  this.append(initialValue[i]);
299
312
  }
300
313
  }
301
- return proxy;
314
+ return (proxy);
302
315
  } else if (initialValue !== undefined) {
303
316
  Object.assign(this, initialValue);
304
317
  }
@@ -309,9 +322,147 @@ function buildDbObjectClass(schema, name, fqn) {
309
322
  DbObject.prototype.name = name;
310
323
  DbObject.prototype.fqn = fqn;
311
324
  DbObject.toString = function() {
312
- return 'DbObjectClass [' + fqn + ']';
325
+ return ('DbObjectClass [' + fqn + ']');
313
326
  };
314
- return DbObject;
327
+ return (DbObject);
328
+ }
329
+
330
+ //-----------------------------------------------------------------------------
331
+ // tpcBegin()
332
+ // Starts a two-phase-commit transaction
333
+ //----------------------------------------------------------------------------
334
+ async function tpcBegin(xid, flag, timeout) {
335
+ nodbUtil.checkArgCount(arguments, 1, 3);
336
+ nodbUtil.assert(nodbUtil.isXid(xid), 'NJS-005', 1);
337
+
338
+ if (arguments.length < 3) {
339
+ timeout = 60; // seconds
340
+ } else {
341
+ nodbUtil.assert(typeof timeout === 'number', 'NJS-005', 3);
342
+ }
343
+
344
+ if (arguments.length < 2) {
345
+ flag = this._oracledb.TPC_BEGIN_NEW;
346
+ } else {
347
+ nodbUtil.assert(typeof flag === 'number', 'NJS-005', 2);
348
+ }
349
+ await this._tpcBegin(xid, flag, timeout);
350
+ }
351
+
352
+
353
+ //-----------------------------------------------------------------------------
354
+ // tpcCommit
355
+ // Commit the two-phase-commit transaction
356
+ //-----------------------------------------------------------------------------
357
+ async function tpcCommit(xid, onePhase) {
358
+ nodbUtil.checkArgCount(arguments, 0, 2);
359
+
360
+ if (arguments.length < 2) {
361
+ onePhase = false;
362
+ } else {
363
+ nodbUtil.assert(typeof onePhase === 'boolean', 'NJS-005', 2);
364
+ }
365
+ if (arguments.length >= 1) {
366
+ nodbUtil.assert(nodbUtil.isXid(xid), 'NJS-005', 1);
367
+ }
368
+ await this._tpcCommit(xid, onePhase);
369
+ }
370
+
371
+
372
+ //-----------------------------------------------------------------------------
373
+ // tpcEnd
374
+ // Ends the two-phase-commit transaction
375
+ //-----------------------------------------------------------------------------
376
+ async function tpcEnd(xid, flag) {
377
+ nodbUtil.checkArgCount(arguments, 0, 2);
378
+
379
+ if (arguments.length < 2) {
380
+ flag = this._oracledb.TPC_END_NORMAL;
381
+ } else {
382
+ nodbUtil.assert(typeof flag === 'number', 'NJS-005', 2);
383
+ }
384
+
385
+ if (arguments.length >= 1) {
386
+ nodbUtil.assert(nodbUtil.isXid(xid), 'NJS-005', 1);
387
+ }
388
+
389
+ await this._tpcEnd(xid, flag);
390
+ }
391
+
392
+
393
+ //-----------------------------------------------------------------------------
394
+ // tpcForget
395
+ // causes the server to forget a heuristically completed global transaction.
396
+ //-----------------------------------------------------------------------------
397
+ async function tpcForget(xid) {
398
+
399
+ nodbUtil.checkArgCount(arguments, 1, 1);
400
+ nodbUtil.assert(nodbUtil.isXid(xid), 'NJS-005', 1);
401
+
402
+ await this._tpcForget(xid);
403
+ }
404
+
405
+
406
+ //-----------------------------------------------------------------------------
407
+ // tpcPrepare
408
+ // prepares a global transaction for commit.
409
+ //-----------------------------------------------------------------------------
410
+ async function tpcPrepare(xid) {
411
+ nodbUtil.checkArgCount(arguments, 0, 1);
412
+
413
+ if (arguments.length >= 1) {
414
+ nodbUtil.assert(nodbUtil.isXid(xid), 'NJS-005', 1);
415
+ }
416
+
417
+ return await this._tpcPrepare(xid);
418
+ }
419
+
420
+
421
+ //-----------------------------------------------------------------------------
422
+ // tpcRecover
423
+ // Returns a list of pending transactions
424
+ //-----------------------------------------------------------------------------
425
+ async function tpcRecover(asString) {
426
+ nodbUtil.checkArgCount(arguments, 0, 1);
427
+
428
+ if (arguments.length == 1) {
429
+ nodbUtil.assert(typeof asString === 'boolean', 'NJS-005', 1);
430
+ } else {
431
+ asString = true;
432
+ }
433
+
434
+ const sqlStr = `
435
+ SELECT
436
+ formatid as "formatId",
437
+ UTL_RAW.CAST_TO_VARCHAR2(globalid) as "globalTransactionId",
438
+ UTL_RAW.CAST_TO_VARCHAR2(branchid) as "branchQualifier"
439
+ FROM DBA_PENDING_TRANSACTIONS`;
440
+ const sqlBuf = `
441
+ SELECT
442
+ formatid as "formatId",
443
+ globalid as "globalTransactionId",
444
+ branchid as "branchQualifier"
445
+ FROM DBA_PENDING_TRANSACTIONS`;
446
+ const options = {
447
+ outFormat: this._oracledb.OUT_FORMAT_OBJECT,
448
+ };
449
+
450
+ const result = await this._execute(asString ? sqlStr : sqlBuf, {}, options);
451
+ return result.resultSet._getAllRows(options, result.metaData, false);
452
+ }
453
+
454
+
455
+ //-----------------------------------------------------------------------------
456
+ // tpcRollback()
457
+ // Rollbacks the current changes in two-phase-commit
458
+ //-----------------------------------------------------------------------------
459
+ async function tpcRollback(xid) {
460
+ nodbUtil.checkArgCount(arguments, 0, 1);
461
+ if (arguments.length == 1) {
462
+ nodbUtil.assert(nodbUtil.isXid(xid), 'NJS-005', 1);
463
+ }
464
+
465
+ await this._tpcRollback(xid);
315
466
  }
316
467
 
317
468
 
@@ -321,28 +472,55 @@ class Connection extends EventEmitter {
321
472
  constructor() {
322
473
  super();
323
474
  this._dbObjectClasses = {};
475
+ this._requestQueue = [];
476
+ this._inProgress = false;
477
+ this._closing = false;
324
478
  }
325
479
 
326
480
  // extend class with promisified functions
327
481
  _extend(oracledb) {
328
482
  this._oracledb = oracledb;
329
- this.break = nodbUtil.callbackify(module.break);
330
- this.changePassword = nodbUtil.callbackify(changePassword);
331
- this.close = nodbUtil.callbackify(close);
332
- this.commit = nodbUtil.callbackify(commit);
333
- this.createLob = nodbUtil.callbackify(createLob);
334
- this.execute = nodbUtil.callbackify(execute);
335
- this.executeMany = nodbUtil.callbackify(executeMany);
336
- this.getDbObjectClass = nodbUtil.callbackify(getDbObjectClass);
337
- this.getQueue = nodbUtil.callbackify(getQueue);
338
- this.getStatementInfo = nodbUtil.callbackify(getStatementInfo);
339
- this.ping = nodbUtil.callbackify(ping);
340
- this.release = nodbUtil.callbackify(close);
341
- this.rollback = nodbUtil.callbackify(rollback);
342
- this.shutdown = nodbUtil.callbackify(shutdown);
343
- this.startup = nodbUtil.callbackify(startup);
344
- this.subscribe = nodbUtil.callbackify(subscribe);
345
- this.unsubscribe = nodbUtil.callbackify(unsubscribe);
483
+ this.break = nodbUtil.callbackify(module.break); // should not be serialized
484
+ this.changePassword = nodbUtil.callbackify(nodbUtil.serialize(changePassword));
485
+ this.close = nodbUtil.callbackify(nodbUtil.serialize(close));
486
+ this.commit = nodbUtil.callbackify(nodbUtil.serialize(commit));
487
+ this.createLob = nodbUtil.callbackify(nodbUtil.serialize(createLob));
488
+ this.execute = nodbUtil.callbackify(nodbUtil.serialize(execute));
489
+ this.executeMany = nodbUtil.callbackify(nodbUtil.serialize(executeMany));
490
+ this.getDbObjectClass = nodbUtil.callbackify(nodbUtil.serialize(getDbObjectClass));
491
+ this.getQueue = nodbUtil.callbackify(nodbUtil.serialize(getQueue));
492
+ this.getStatementInfo = nodbUtil.callbackify(nodbUtil.serialize(getStatementInfo));
493
+ this.ping = nodbUtil.callbackify(nodbUtil.serialize(ping));
494
+ this.release = nodbUtil.callbackify(nodbUtil.serialize(close));
495
+ this.rollback = nodbUtil.callbackify(nodbUtil.serialize(rollback));
496
+ this.shutdown = nodbUtil.callbackify(nodbUtil.serialize(shutdown));
497
+ this.startup = nodbUtil.callbackify(nodbUtil.serialize(startup));
498
+ this.subscribe = nodbUtil.callbackify(nodbUtil.serialize(subscribe));
499
+ this.tpcBegin = nodbUtil.callbackify(nodbUtil.serialize(tpcBegin));
500
+ this.tpcCommit = nodbUtil.callbackify(nodbUtil.serialize(tpcCommit));
501
+ this.tpcEnd = nodbUtil.callbackify(nodbUtil.serialize(tpcEnd));
502
+ this.tpcForget = nodbUtil.callbackify(nodbUtil.serialize(tpcForget));
503
+ this.tpcPrepare = nodbUtil.callbackify(nodbUtil.serialize(tpcPrepare));
504
+ this.tpcRecover = nodbUtil.callbackify(nodbUtil.serialize(tpcRecover));
505
+ this.tpcRollback = nodbUtil.callbackify(nodbUtil.serialize(tpcRollback));
506
+ this.unsubscribe = nodbUtil.callbackify(nodbUtil.serialize(unsubscribe));
507
+ }
508
+
509
+ async _acquireLock() {
510
+ if (this._inProgress) {
511
+ if (this._oracledb.errorOnConcurrentExecute) {
512
+ throw new Error(nodbUtil.getErrorMessage('NJS-081'));
513
+ }
514
+ await new Promise((resolve, reject) => {
515
+ const payload = {resolve: resolve, reject: reject};
516
+ this._requestQueue.push(payload);
517
+ });
518
+ }
519
+ this._inProgress = true;
520
+ }
521
+
522
+ _getConnection() {
523
+ return this;
346
524
  }
347
525
 
348
526
  _getDbObjectClassJS(schema, name) {
@@ -350,22 +528,44 @@ class Connection extends EventEmitter {
350
528
  let cls = this._dbObjectClasses[fqn];
351
529
  if (!cls) {
352
530
  cls = buildDbObjectClass(schema, name, fqn);
531
+ cls._connection = this;
353
532
  this._dbObjectClasses[fqn] = cls;
354
533
  }
355
- return cls;
534
+ return (cls);
356
535
  }
357
536
 
358
537
  _isDate(val) {
359
- return util.isDate(val);
538
+ return (util.isDate(val));
539
+ }
540
+
541
+ _releaseLock() {
542
+ if (this._requestQueue.length > 0) {
543
+ const payload = this._requestQueue.shift();
544
+ payload.resolve();
545
+ } else {
546
+ this._inProgress = false;
547
+ }
360
548
  }
361
549
 
362
550
  // To obtain a SodaDatabase object (high-level SODA object associated with
363
551
  // current connection)
364
552
  getSodaDatabase() {
365
553
  nodbUtil.checkArgCount(arguments, 0, 0);
366
- return this._getSodaDatabase();
554
+ return (this._getSodaDatabase());
367
555
  }
368
556
 
557
+ //--------------------------------------------------------------------------
558
+ // isHealthy()
559
+ // To get the health status of the connection.
560
+ // NOTE: if this function returns false, the application must close the
561
+ // connection obect.
562
+ // This is a synchronous call.
563
+ //---------------------------------------------------------------------------
564
+ isHealthy() {
565
+ return (!this._closing && this._isHealthy());
566
+ }
567
+
568
+
369
569
  // The queryStream function is similar to execute except that it immediately
370
570
  // returns a QueryStream.
371
571
  queryStream(sql, binding, options) {
@@ -408,7 +608,7 @@ class Connection extends EventEmitter {
408
608
  }
409
609
  });
410
610
 
411
- return stream;
611
+ return (stream);
412
612
  }
413
613
 
414
614
  }
package/lib/dbObject.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
1
+ // Copyright (c) 2019, 2022, Oracle and/or its affiliates.
2
2
  //
3
3
  //----------------------------------------------------------------------------
4
4
  //
@@ -51,7 +51,7 @@ class BaseDbObject {
51
51
  result[i] = result[i]._toPojo();
52
52
  }
53
53
  }
54
- return result;
54
+ return (result);
55
55
  }
56
56
  const result = {};
57
57
  for (let name in this.attributes) {
@@ -61,18 +61,18 @@ class BaseDbObject {
61
61
  }
62
62
  result[name] = value;
63
63
  }
64
- return result;
64
+ return (result);
65
65
  }
66
66
 
67
67
  // custom inspection routine
68
68
  [util.inspect.custom](depth, options) {
69
- return '[' + this.fqn + '] ' + util.inspect(this._toPojo(), options);
69
+ return ('[' + this.fqn + '] ' + util.inspect(this._toPojo(), options));
70
70
  }
71
71
 
72
72
  [Symbol.iterator]() {
73
73
  if (this.isCollection) {
74
74
  const values = this.getValues();
75
- return values[Symbol.iterator]();
75
+ return (values[Symbol.iterator]());
76
76
  }
77
77
  throw TypeError("obj is not iterable");
78
78
  }
@@ -80,18 +80,18 @@ class BaseDbObject {
80
80
  [Symbol.toPrimitive](hint) {
81
81
  switch (hint) {
82
82
  case 'number':
83
- return NaN;
83
+ return (NaN);
84
84
  default:
85
- return '[' + this.fqn + '] ' + util.inspect(this._toPojo(), {});
85
+ return ('[' + this.fqn + '] ' + util.inspect(this._toPojo(), {}));
86
86
  }
87
87
  }
88
88
 
89
89
  get [Symbol.toStringTag]() {
90
- return this.fqn;
90
+ return (this.fqn);
91
91
  }
92
92
 
93
93
  toJSON() {
94
- return this._toPojo();
94
+ return (this._toPojo());
95
95
  }
96
96
 
97
97
  }
@@ -104,10 +104,10 @@ BaseDbObject._collectionProxyHandler = {
104
104
  if (typeof prop === 'string') {
105
105
  const index = +prop;
106
106
  if (!isNaN(index)) {
107
- return target.deleteElement(index);
107
+ return (target.deleteElement(index));
108
108
  }
109
109
  }
110
- return delete target[prop];
110
+ return (delete target[prop]);
111
111
  },
112
112
 
113
113
  get(target, prop) {
@@ -118,18 +118,18 @@ BaseDbObject._collectionProxyHandler = {
118
118
  // available when calling napi_unwrap() on the target; this property
119
119
  // forces the target to get returned
120
120
  if (prop === '_target') {
121
- return target;
121
+ return (target);
122
122
  }
123
123
  const index = +prop;
124
124
  if (!isNaN(index)) {
125
- return target.getElement(index);
125
+ return (target.getElement(index));
126
126
  }
127
127
  }
128
128
  const value = target[prop];
129
129
  if (typeof value === 'function') {
130
- return value.bind(target);
130
+ return (value.bind(target));
131
131
  }
132
- return value;
132
+ return (value);
133
133
  },
134
134
 
135
135
  set(target, prop, value) {
@@ -137,11 +137,11 @@ BaseDbObject._collectionProxyHandler = {
137
137
  const index = +prop;
138
138
  if (!isNaN(index)) {
139
139
  target.setElement(index, value);
140
- return true;
140
+ return (true);
141
141
  }
142
142
  }
143
143
  target[prop] = value;
144
- return true;
144
+ return (true);
145
145
  }
146
146
 
147
147
  };