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/lib/lob.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
  //
@@ -60,6 +60,7 @@ class Lob extends Duplex {
60
60
  constructor() {
61
61
  super({ decodeStrings: false });
62
62
  this.offset = 1;
63
+ this._isActive = false;
63
64
  this.once('finish', function() {
64
65
  if (this._autoCloseLob) {
65
66
  this.destroy();
@@ -69,8 +70,10 @@ class Lob extends Duplex {
69
70
 
70
71
  _extend(oracledb) {
71
72
  this._oracledb = oracledb;
72
- this.close = nodbUtil.callbackify(close);
73
- this.getData = nodbUtil.callbackify(getData);
73
+ this.close = nodbUtil.callbackify(nodbUtil.preventConcurrent(nodbUtil.serialize(close), 'NJS-023'));
74
+ this.getData = nodbUtil.callbackify(nodbUtil.preventConcurrent(nodbUtil.serialize(getData), 'NJS-023'));
75
+ this._serializedRead = nodbUtil.serialize(this.__read);
76
+ this._serializedWrite = nodbUtil.serialize(this.__write);
74
77
  }
75
78
 
76
79
  // called by stream.destroy() and ensures that the LOB is closed if it has
@@ -87,13 +90,22 @@ class Lob extends Duplex {
87
90
  cb(err);
88
91
  }
89
92
 
93
+ // return the connection associated with the LOB (used for serializing
94
+ // accesses to the connection)
95
+ _getConnection() {
96
+ let connection = this._parentObj;
97
+ while (!(connection instanceof this._oracledb.Connection))
98
+ connection = connection._parentObj;
99
+ return connection;
100
+ }
101
+
90
102
  // implementation of streaming read; if lob is set to auto-close, the lob is
91
103
  // automatically closed within the C code when an error occurs or when there
92
104
  // are no more bytes to transfer; all that needs to be done in the JS layer
93
105
  // is to destroy the streaming LOB
94
106
  async _read() {
95
107
  try {
96
- const data = await this.__read(this.offset);
108
+ const data = await this._serializedRead(this.offset);
97
109
  if (data) {
98
110
  this.offset += data.length;
99
111
  this.push(data);
@@ -122,7 +134,7 @@ class Lob extends Duplex {
122
134
  }
123
135
 
124
136
  try {
125
- await this.__write(this.offset, data);
137
+ await this._serializedWrite(this.offset, data);
126
138
  } catch (err) {
127
139
  cb(err);
128
140
  this.destroy(err);
package/lib/oracledb.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2015, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -25,7 +25,7 @@ const util = require('util');
25
25
  // This version of node-oracledb works with Node.js 8.16, 10.16 or
26
26
  // later. The test stops hard-to-interpret runtime errors and crashes
27
27
  // with older Node.js versions. Also Node.js 8.16 and 10.16 (and
28
- // 12.0) contain an important N-API performance regression fix. If
28
+ // 12.0) contain an important Node-API performance regression fix. If
29
29
  // you're using the obsolete Node.js 9 or 11 versions, you're on your
30
30
  // own regarding performance and functionality
31
31
  let vs = process.version.substring(1).split(".").map(Number);
@@ -43,6 +43,7 @@ const BaseDbObject = require('./dbObject.js');
43
43
  const Connection = require('./connection.js');
44
44
  const Lob = require('./lob.js');
45
45
  const Pool = require('./pool.js');
46
+ const PoolStatistics = require('./poolStatistics.js');
46
47
  const ResultSet = require('./resultset.js');
47
48
  const SodaDatabase = require('./sodaDatabase.js');
48
49
  const SodaCollection = require('./sodaCollection.js');
@@ -74,7 +75,7 @@ for (let i = 0; i < binaryLocations.length; i++) {
74
75
  try {
75
76
  oracledbCLib = requireBinary(binaryLocations[i]);
76
77
  break;
77
- } catch(err) {
78
+ } catch (err) {
78
79
  if (err.code !== 'MODULE_NOT_FOUND' || i == binaryLocations.length - 1) {
79
80
  let nodeInfo;
80
81
  if (err.code === 'MODULE_NOT_FOUND') {
@@ -95,18 +96,20 @@ class OracleDb {
95
96
  constructor() {
96
97
  this.queueTimeout = 60000;
97
98
  this.queueMax = 500;
99
+ this.errorOnConcurrentExecute = false;
98
100
  }
99
101
 
100
102
  // extend class with promisified functions
101
- _extend() {
102
- this.getConnection = nodbUtil.callbackify(getConnection);
103
- this.createPool = nodbUtil.callbackify(createPool);
104
- this.shutdown = nodbUtil.callbackify(shutdown);
105
- this.startup = nodbUtil.callbackify(startup);
103
+ _extend(_oracledb) {
104
+ this.getConnection = nodbUtil.callbackify(getConnection).bind(_oracledb);
105
+ this.createPool = nodbUtil.callbackify(createPool).bind(_oracledb);
106
+ this.shutdown = nodbUtil.callbackify(shutdown).bind(_oracledb);
107
+ this.startup = nodbUtil.callbackify(startup).bind(_oracledb);
108
+ this.initOracleClient = this.initOracleClient.bind(_oracledb);
106
109
  }
107
110
 
108
111
  // temporary method for determining if an object is a date until
109
- // napi_is_date() can be used (when N-API v5 can be used)
112
+ // napi_is_date() can be used (when Node-API v5 can be used)
110
113
  _isDate(val) {
111
114
  return util.isDate(val);
112
115
  }
@@ -196,6 +199,39 @@ async function createPool(poolAttrs) {
196
199
  tempUsedPoolAliases[poolAlias] = true;
197
200
  }
198
201
 
202
+ if (adjustedPoolAttrs.accessToken !== undefined) {
203
+ // token and privateKey must be set for token based
204
+ // authentication
205
+ if (adjustedPoolAttrs.accessToken.token === undefined ||
206
+ adjustedPoolAttrs.accessToken.token === '' ||
207
+ adjustedPoolAttrs.accessToken.privateKey === undefined ||
208
+ adjustedPoolAttrs.accessToken.privateKey === '') {
209
+ throw new Error(nodbUtil.getErrorMessage('NJS-084'));
210
+ }
211
+
212
+ // cannot set username or password for token based authentication
213
+ if (adjustedPoolAttrs.user !== undefined ||
214
+ adjustedPoolAttrs.password !== undefined) {
215
+ throw new Error(nodbUtil.getErrorMessage('NJS-084'));
216
+ }
217
+
218
+ // homogeneous and externalAuth must be set to true for token based
219
+ // authentication
220
+ if (adjustedPoolAttrs.homogeneous === false ||
221
+ adjustedPoolAttrs.externalAuth === false) {
222
+ throw new Error(nodbUtil.getErrorMessage('NJS-085'));
223
+ }
224
+
225
+ adjustedPoolAttrs.token = adjustedPoolAttrs.accessToken.token;
226
+ adjustedPoolAttrs.privateKey =
227
+ adjustedPoolAttrs.accessToken.privateKey;
228
+ }
229
+
230
+ if (adjustedPoolAttrs.accessToken === undefined &&
231
+ adjustedPoolAttrs.accessTokenCallback !== undefined) {
232
+ throw new Error(nodbUtil.getErrorMessage('NJS-084'));
233
+ }
234
+
199
235
  try {
200
236
  const pool = await this._createPool(adjustedPoolAttrs);
201
237
 
@@ -207,7 +243,7 @@ async function createPool(poolAttrs) {
207
243
  }
208
244
 
209
245
  pool._setup(poolAttrs, poolAlias, this);
210
- pool.on('_after_close', () => {
246
+ pool.on('_afterPoolClose', () => {
211
247
  if (pool.poolAlias) {
212
248
  delete poolCache[pool.poolAlias];
213
249
  }
@@ -268,9 +304,35 @@ async function getConnection(a1) {
268
304
 
269
305
  // otherwise, create a new standalone connection
270
306
  } else {
307
+ if (connAttrs.accessToken !== undefined) {
308
+ // token and privateKey must be set for token based
309
+ // authentication
310
+ if (connAttrs.accessToken.token === undefined ||
311
+ connAttrs.accessToken.token === '' ||
312
+ connAttrs.accessToken.privateKey === undefined ||
313
+ connAttrs.accessToken.privateKey === '') {
314
+ throw new Error(nodbUtil.getErrorMessage('NJS-084'));
315
+ }
316
+
317
+ // cannot set username or password for token based authentication
318
+ if (connAttrs.user !== undefined ||
319
+ connAttrs.password !== undefined) {
320
+ throw new Error(nodbUtil.getErrorMessage('NJS-084'));
321
+ }
322
+
323
+ // externalAuth must be set to true for token based authentication
324
+ if (connAttrs.externalAuth === false) {
325
+ throw new Error(nodbUtil.getErrorMessage('NJS-086'));
326
+ }
327
+
328
+ connAttrs.token = connAttrs.accessToken.token;
329
+ connAttrs.privateKey =
330
+ connAttrs.accessToken.privateKey;
331
+ }
332
+
271
333
  try {
272
334
  return await this._getConnection(connAttrs);
273
- } catch(err) {
335
+ } catch (err) {
274
336
  if (err.message.match(/DPI-1047/)) {
275
337
  err.message += "\n" + nodbUtil.getInstallHelp();
276
338
  }
@@ -379,6 +441,7 @@ proto.BaseDbObject = BaseDbObject;
379
441
  proto.Connection = Connection;
380
442
  proto.Lob = Lob;
381
443
  proto.Pool = Pool;
444
+ proto.PoolStatistics = PoolStatistics;
382
445
  proto.ResultSet = ResultSet;
383
446
  proto.SodaDatabase = SodaDatabase;
384
447
  proto.SodaCollection = SodaCollection;