oracledb 6.0.0 → 6.0.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 (52) hide show
  1. package/README.md +8 -7
  2. package/build/Release/oracledb-6.0.2-darwin-x64.node +0 -0
  3. package/build/Release/oracledb-6.0.2-darwin-x64.node-buildinfo.txt +1 -0
  4. package/build/Release/oracledb-6.0.2-js-buildinfo.txt +1 -0
  5. package/build/Release/oracledb-6.0.2-linux-arm64.node +0 -0
  6. package/build/Release/oracledb-6.0.2-linux-arm64.node-buildinfo.txt +1 -0
  7. package/build/Release/oracledb-6.0.2-linux-x64.node-buildinfo.txt +1 -0
  8. package/build/Release/{oracledb-6.0.0-win32-x64.node → oracledb-6.0.2-win32-x64.node} +0 -0
  9. package/build/Release/oracledb-6.0.2-win32-x64.node-buildinfo.txt +1 -0
  10. package/examples/README.md +1 -1
  11. package/lib/aqDeqOptions.js +2 -1
  12. package/lib/aqQueue.js +1 -0
  13. package/lib/connection.js +3 -0
  14. package/lib/errors.js +5 -1
  15. package/lib/lob.js +1 -0
  16. package/lib/oracledb.js +1 -1
  17. package/lib/poolStatistics.js +1 -0
  18. package/lib/queryStream.js +2 -1
  19. package/lib/sodaDatabase.js +1 -0
  20. package/lib/thin/connection.js +24 -19
  21. package/lib/thin/dbObject.js +16 -3
  22. package/lib/thin/lob.js +1 -0
  23. package/lib/thin/pool.js +10 -9
  24. package/lib/thin/protocol/buffer.js +9 -6
  25. package/lib/thin/protocol/capabilities.js +8 -3
  26. package/lib/thin/protocol/constants.js +2 -1
  27. package/lib/thin/protocol/encryptDecrypt.js +26 -14
  28. package/lib/thin/protocol/messages/auth.js +1 -0
  29. package/lib/thin/protocol/messages/base.js +1 -0
  30. package/lib/thin/protocol/messages/dataType.js +10 -1
  31. package/lib/thin/protocol/messages/execute.js +1 -1
  32. package/lib/thin/protocol/messages/lobOp.js +2 -1
  33. package/lib/thin/protocol/messages/withData.js +21 -19
  34. package/lib/thin/protocol/oson.js +1 -0
  35. package/lib/thin/protocol/packet.js +14 -13
  36. package/lib/thin/protocol/utils.js +1 -0
  37. package/lib/thin/sqlnet/networkSession.js +5 -4
  38. package/lib/thin/sqlnet/ntTcp.js +3 -7
  39. package/lib/thin/sqlnet/paramParser.js +6 -8
  40. package/lib/thin/statement.js +13 -14
  41. package/lib/transformer.js +10 -8
  42. package/lib/util.js +2 -0
  43. package/lib/version.js +1 -1
  44. package/package.json +1 -1
  45. package/build/Release/oracledb-6.0.0-darwin-x64.node +0 -0
  46. package/build/Release/oracledb-6.0.0-darwin-x64.node-buildinfo.txt +0 -1
  47. package/build/Release/oracledb-6.0.0-js-buildinfo.txt +0 -1
  48. package/build/Release/oracledb-6.0.0-linux-arm64.node +0 -0
  49. package/build/Release/oracledb-6.0.0-linux-arm64.node-buildinfo.txt +0 -1
  50. package/build/Release/oracledb-6.0.0-linux-x64.node-buildinfo.txt +0 -1
  51. package/build/Release/oracledb-6.0.0-win32-x64.node-buildinfo.txt +0 -1
  52. /package/build/Release/{oracledb-6.0.0-linux-x64.node → oracledb-6.0.2-linux-x64.node} +0 -0
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # node-oracledb version 6.0.0
1
+ # node-oracledb version 6.0.2
2
2
 
3
3
  The node-oracledb add-on for Node.js powers high performance Oracle Database
4
4
  applications. Applications can be written in TypeScript, or directly in
5
5
  JavaScript.
6
6
 
7
- Use node-oracledb 6.0.0 to connect Node.js 14.6, or later, to Oracle
7
+ Use node-oracledb 6.0.2 to connect Node.js 14.6, or later, to Oracle
8
8
  Database. Older versions of node-oracledb may work with older versions of
9
9
  Node.js.
10
10
 
@@ -20,7 +20,8 @@ See [Getting Started with Node-oracledb][1] and [Quick Start Node-oracledb Insta
20
20
 
21
21
  ## Documentation
22
22
 
23
- See [Documentation for the Oracle Database Node.js Add-on][32] and the [CHANGELOG][33].
23
+ See [Documentation for the Oracle Database Node.js Add-on][32] and the [release
24
+ notes][33].
24
25
 
25
26
  ## Examples
26
27
 
@@ -28,8 +29,8 @@ See the [examples][30] directory. Start with [examples/example.js][31].
28
29
 
29
30
  ## Help
30
31
 
31
- Issues and questions about node-oracledb can be posted on [GitHub][3] or
32
- [Slack][5] ([link to join Slack][6]).
32
+ Questions about node-oracledb can be posted on [GitHub][3] or [Slack][5] ([link
33
+ to join Slack][6]).
33
34
 
34
35
  ## <a name="testing"></a> Tests
35
36
 
@@ -74,13 +75,13 @@ limitations under the License.
74
75
 
75
76
  [1]: https://node-oracledb.readthedocs.io/en/latest/user_guide/introduction.html#getstarted
76
77
  [2]: https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html#quickstart
77
- [3]: https://github.com/oracle/node-oracledb/issues
78
+ [3]: https://github.com/oracle/node-oracledb/discussions
78
79
  [4]: https://oracle.github.io/node-oracledb
79
80
  [5]: https://node-oracledb.slack.com/
80
81
  [6]: https://join.slack.com/t/node-oracledb/shared_invite/enQtNDU4Mjc2NzM5OTA2LWMzY2ZlZDY5MDdlMGZiMGRkY2IzYjI5OGU4YTEzZWM5YjQ3ODUzMjcxNWQyNzE4MzM5YjNkYjVmNDk5OWU5NDM
81
82
  [30]: https://github.com/oracle/node-oracledb/blob/main/examples
82
83
  [31]: https://github.com/oracle/node-oracledb/blob/main/examples/example.js
83
84
  [32]: https://node-oracledb.readthedocs.io/en/latest/
84
- [33]: https://github.com/oracle/node-oracledb/blob/main/CHANGELOG.md
85
+ [33]: https://node-oracledb.readthedocs.io/en/latest/release_notes.html
85
86
  [34]: https://github.com/oracle/node-oracledb/blob/main/test/README.md
86
87
  [35]: https://github.com/oracle/node-oracledb/blob/main/CONTRIBUTING.md
@@ -0,0 +1 @@
1
+ oracledb-6.0.2-darwin-x64.node v18.16.0 5caec79c2095133bc3d39b0e08d0d7a7952a4352 ccbaddf0256153ecfa6702c6ae1a4e5003e3775e Tue, 20 Jun 2023 15:14:06 GMT
@@ -0,0 +1 @@
1
+ 5caec79c2095133bc3d39b0e08d0d7a7952a4352
@@ -0,0 +1 @@
1
+ oracledb-6.0.2-linux-arm64.node v14.16.0 5caec79c2095133bc3d39b0e08d0d7a7952a4352 ccbaddf0256153ecfa6702c6ae1a4e5003e3775e Tue, 20 Jun 2023 16:56:30 GMT
@@ -0,0 +1 @@
1
+ oracledb-6.0.2-linux-x64.node v16.20.0 5caec79c2095133bc3d39b0e08d0d7a7952a4352 ccbaddf0256153ecfa6702c6ae1a4e5003e3775e Tue, 20 Jun 2023 15:29:14 GMT
@@ -0,0 +1 @@
1
+ oracledb-6.0.2-win32-x64.node v16.19.0 5caec79c2095133bc3d39b0e08d0d7a7952a4352 ccbaddf0256153ecfa6702c6ae1a4e5003e3775e Tue, 20 Jun 2023 15:13:50 GMT
@@ -108,6 +108,6 @@ File Name | Description
108
108
  [`sessiontagging2.js`](sessiontagging2.js) | More complex example of pooled connection tagging for setting session state
109
109
  [`soda1.js`](soda1.js) | Basic Simple Oracle Document Access (SODA) example
110
110
  [`typehandlerdate.js`](typehandlerdate.js) | Show how a type handler can format a queried date in a locale-specific way
111
- [`typehandlernum.js`](typehandlernum.js) | Show how a type handler can format a queried number in a locale-specific way
111
+ [`typehandlernum.js`](typehandlernum.js) | Show how a type handler can alter queried numbers
112
112
  [`version.js`](version.js) | Shows the node-oracledb version attributes
113
113
  [`webapp.js`](webapp.js) | A simple web application using a connection pool
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2019, 2022, Oracle and/or its affiliates.
1
+ // Copyright (c) 2019, 2023, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const constants = require('./constants.js');
30
31
  const errors = require('./errors.js');
31
32
 
package/lib/aqQueue.js CHANGED
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const constants = require('./constants.js');
30
31
  const errors = require('./errors.js');
31
32
  const nodbUtil = require('./util.js');
package/lib/connection.js CHANGED
@@ -28,6 +28,7 @@
28
28
 
29
29
  const AqQueue = require('./aqQueue.js');
30
30
  const BaseDbObject = require('./dbObject.js');
31
+ const { Buffer } = require('buffer');
31
32
  const Lob = require('./lob.js');
32
33
  const ResultSet = require('./resultset.js');
33
34
  const SodaDatabase = require('./sodaDatabase.js');
@@ -36,6 +37,7 @@ const QueryStream = require('./queryStream.js');
36
37
  const errors = require('./errors.js');
37
38
  const nodbUtil = require('./util.js');
38
39
  const impl = require('./impl');
40
+ const process = require('process');
39
41
  const util = require('util');
40
42
  const constants = require('./constants.js');
41
43
  const settings = require('./settings.js');
@@ -144,6 +146,7 @@ class Connection extends EventEmitter {
144
146
  cls = this._buildDbObjectClass(objType);
145
147
  cls._connection = this;
146
148
  cls._objType = objType;
149
+ objType._connection = this._impl;
147
150
  this._dbObjectClasses.set(objType, cls);
148
151
  }
149
152
  return (cls);
package/lib/errors.js CHANGED
@@ -136,6 +136,7 @@ const ERR_WRONG_VALUE_FOR_DBOBJECT_ATTR = 134;
136
136
  const ERR_WRONG_VALUE_FOR_DBOBJECT_ELEM = 135;
137
137
  const ERR_WRONG_CRED_FOR_EXTAUTH = 136;
138
138
  const ERR_MISSING_BIND_VALUE = 137;
139
+ const ERR_SERVER_VERSION_NOT_SUPPORTED = 138;
139
140
 
140
141
  // Oracle Net layer errors start from 500
141
142
  const ERR_CONNECTION_CLOSED = 500;
@@ -314,7 +315,7 @@ messages.set(ERR_INVALID_NUMBER_OF_CONNECTIONS, // NJS-092
314
315
  messages.set(ERR_EXEC_MODE_ONLY_FOR_DML, // NJS-095
315
316
  'setting "batchErrors" or "dmlRowCounts" to true is only permitted for DML statements');
316
317
  messages.set(ERR_INVALID_BIND_NAME, // NJS-097
317
- 'no bind placeholder named ":%s" was found in the SQL text');
318
+ 'no bind placeholder named ":%s" was found in the statement text');
318
319
  messages.set(ERR_WRONG_NUMBER_OF_POSITIONAL_BINDS, // NJS-098
319
320
  '%s positional bind values are required but %s were provided');
320
321
  messages.set(ERR_BUFFER_LENGTH_INSUFFICIENT, // NJS-099
@@ -393,6 +394,8 @@ messages.set(ERR_WRONG_CRED_FOR_EXTAUTH, // NJS-136
393
394
  'user name and password cannot be set when using external authentication');
394
395
  messages.set(ERR_MISSING_BIND_VALUE, // NJS-137
395
396
  'a bind variable replacement value for placeholder ":%s" was not provided');
397
+ messages.set(ERR_SERVER_VERSION_NOT_SUPPORTED, // NJS-138
398
+ 'connections to this database server version are not supported by node-oracledb in Thin mode');
396
399
 
397
400
  // Oracle Net layer errors
398
401
 
@@ -763,6 +766,7 @@ module.exports = {
763
766
  ERR_WRONG_VALUE_FOR_DBOBJECT_ELEM,
764
767
  ERR_WRONG_CRED_FOR_EXTAUTH,
765
768
  ERR_MISSING_BIND_VALUE,
769
+ ERR_SERVER_VERSION_NOT_SUPPORTED,
766
770
  ERR_CONNECTION_CLOSED_CODE: `${ERR_PREFIX}-${ERR_CONNECTION_CLOSED}`,
767
771
  assert,
768
772
  assertArgCount,
package/lib/lob.js CHANGED
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const { Duplex } = require('stream');
30
31
  const constants = require('./constants.js');
31
32
  const errors = require('./errors.js');
package/lib/oracledb.js CHANGED
@@ -31,6 +31,7 @@ const nodbUtil = require('./util.js');
31
31
  const errors = require('./errors.js');
32
32
  const types = require('./types.js');
33
33
  const impl = require('./impl');
34
+ const process = require('process');
34
35
  const util = require('util');
35
36
 
36
37
  // This version of node-oracledb works with Node.js 14.6 or later.
@@ -68,7 +69,6 @@ const defaultPoolAlias = 'default';
68
69
  let _initOracleClientArgs;
69
70
  let _thinDriverInitialized = false;
70
71
 
71
-
72
72
  // Load the Oracledb binary
73
73
  function _initCLib() {
74
74
  /*global __non_webpack_require__*/ // quieten eslint
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const process = require('process');
29
30
  const settings = require('./settings.js');
30
31
 
31
32
  //-----------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2015, 2022, Oracle and/or its affiliates.
1
+ // Copyright (c) 2015, 2023, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const process = require('process');
29
30
  const { Readable } = require('stream');
30
31
 
31
32
  class QueryStream extends Readable {
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const SodaCollection = require('./sodaCollection.js');
30
31
  const SodaDocument = require('./sodaDocument.js');
31
32
  const errors = require('./errors.js');
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const ConnectionImpl = require('../impl/connection.js');
30
31
  const ThinResultSetImpl = require('./resultSet.js');
31
32
  const ThinLobImpl = require("./lob.js");
@@ -36,6 +37,7 @@ const { Statement } = require("./statement");
36
37
  const thinUtil = require('./util');
37
38
  const sqlNetConstants = require('./sqlnet/constants.js');
38
39
  const constants = require('./protocol/constants.js');
40
+ const process = require('process');
39
41
  const types = require('../types.js');
40
42
  const errors = require("../errors.js");
41
43
  const messages = require('./protocol/messages');
@@ -528,6 +530,13 @@ class ThinConnectionImpl extends ConnectionImpl {
528
530
  }
529
531
 
530
532
  this._protocol = new Protocol(this);
533
+
534
+ // check if the protocol version supported by the database is high
535
+ // enough; if not, reject the connection immediately
536
+ if (this._protocol.caps.protocolVersion < constants.TNS_VERSION_MIN_ACCEPTED) {
537
+ errors.throwErr(errors.ERR_SERVER_VERSION_NOT_SUPPORTED);
538
+ }
539
+
531
540
  try {
532
541
  let message = new messages.ProtocolMessage(this);
533
542
  await this._protocol._processMessage(message);
@@ -568,40 +577,34 @@ class ThinConnectionImpl extends ConnectionImpl {
568
577
  }
569
578
  if (statement.returnToCache) {
570
579
  statement.inUse = false;
571
- this._adjustStatementCache();
572
580
  } else if (statement.cursorId !== 0) {
573
- this._addCursorToClose(statement);
581
+ this._addCursorToClose(statement.cursorId);
574
582
  }
575
583
  }
576
584
 
577
585
  //---------------------------------------------------------------------------
578
586
  // Adds the cursors that needs to be closed to the _cursorsToClose set
579
587
  //---------------------------------------------------------------------------
580
- _addCursorToClose(stmt) {
581
- if (stmt.cursorId > 0 && this._cursorsToClose.has(stmt.cursorId)) {
582
- const reason = `attempt to close cursor ${stmt.cursorId} twice`;
588
+ _addCursorToClose(cursorId) {
589
+ if (this._cursorsToClose.has(cursorId)) {
590
+ const reason = `attempt to close cursor ${cursorId} twice`;
583
591
  errors.throwErr(errors.ERR_INTERNAL, reason);
584
592
  }
585
-
586
- if (this.statementCache.has(stmt.sql)) {
587
- this.statementCache.delete(stmt.sql);
588
- this._cursorsToClose.add(stmt.cursorId);
589
- } else if (stmt.cursorId > 0) {
590
- this._cursorsToClose.add(stmt.cursorId);
591
- }
593
+ this._cursorsToClose.add(cursorId);
592
594
  }
593
595
 
594
596
  //---------------------------------------------------------------------------
595
597
  // Adjusts the statement cache to remove least recently used statements
596
598
  //---------------------------------------------------------------------------
597
599
  _adjustStatementCache() {
598
- while (this.statementCache.size >= this.statementCacheSize) {
599
- let stmt = this.statementCache.get(this.statementCache.keys().next().value);
600
- this.statementCache.delete(this.statementCache.keys().next().value);
600
+ while (this.statementCache.size > this.statementCacheSize) {
601
+ const sql = this.statementCache.keys().next().value;
602
+ const stmt = this.statementCache.get(sql);
603
+ this.statementCache.delete(sql);
601
604
  if (stmt.inUse) {
602
605
  stmt.returnToCache = false;
603
606
  } else if (stmt.cursorId !== 0) {
604
- this._addCursorToClose(stmt);
607
+ this._addCursorToClose(stmt.cursorId);
605
608
  }
606
609
  }
607
610
  }
@@ -902,12 +905,14 @@ class ThinConnectionImpl extends ConnectionImpl {
902
905
  if (!statement) {
903
906
  statement = new Statement();
904
907
  statement._prepare(sql);
905
- if (cacheStatement && this.statementCache.size < this.statementCacheSize && !this._drcpEstablishSession && !statement.isDdl) {
906
- this.statementCache.set(sql, statement);
908
+ if (cacheStatement && !this._drcpEstablishSession && !statement.isDdl &&
909
+ this.statementCacheSize > 0) {
907
910
  statement.returnToCache = true;
911
+ this.statementCache.set(sql, statement);
908
912
  this._adjustStatementCache();
909
913
  }
910
- } else if (statement.inUse || !cacheStatement || this._drcpEstablishSession) {
914
+ } else if (statement.inUse || !cacheStatement ||
915
+ this._drcpEstablishSession) {
911
916
  if (!cacheStatement) {
912
917
  this.statementCache.delete(sql);
913
918
  statement.returnToCache = false;
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const constants = require('./protocol/constants.js');
30
31
  const errors = require('../errors.js');
31
32
  const types = require('../types.js');
@@ -34,6 +35,19 @@ const { GrowableBuffer } = require('./protocol/buffer.js');
34
35
 
35
36
  class DbObjectPickleBuffer extends GrowableBuffer {
36
37
 
38
+ //---------------------------------------------------------------------------
39
+ // _readBytesWithLength()
40
+ //
41
+ // Helper function that processes the number of bytes (if needed) and then
42
+ // acquires the specified number of bytes from the buffer.
43
+ //---------------------------------------------------------------------------
44
+ _readBytesWithLength(numBytes) {
45
+ if (numBytes === constants.TNS_LONG_LENGTH_INDICATOR) {
46
+ numBytes = this.readUInt32BE();
47
+ }
48
+ return this.readBytes(numBytes);
49
+ }
50
+
37
51
  //---------------------------------------------------------------------------
38
52
  // getIsAtomicNull()
39
53
  //
@@ -353,7 +367,7 @@ class ThinDbObjectImpl extends DbObjectImpl {
353
367
  case types.DB_TYPE_NCHAR:
354
368
  return buf.readStr(constants.TNS_CS_NCHAR);
355
369
  case types.DB_TYPE_RAW:
356
- return buf.readBytesWithLength();
370
+ return Buffer.from(buf.readBytesWithLength());
357
371
  case types.DB_TYPE_BINARY_DOUBLE:
358
372
  return buf.readBinaryDouble();
359
373
  case types.DB_TYPE_BINARY_FLOAT:
@@ -364,7 +378,6 @@ class ThinDbObjectImpl extends DbObjectImpl {
364
378
  case types.DB_TYPE_TIMESTAMP_LTZ:
365
379
  case types.DB_TYPE_TIMESTAMP_TZ:
366
380
  return buf.readOracleDate(false);
367
- case types.DB_TYPE_BLOB:
368
381
  case types.DB_TYPE_BOOLEAN:
369
382
  return buf.readBool();
370
383
  case types.DB_TYPE_OBJECT:
@@ -373,7 +386,7 @@ class ThinDbObjectImpl extends DbObjectImpl {
373
386
  return null;
374
387
  obj = new ThinDbObjectImpl(typeClass);
375
388
  if (obj._objType.isCollection || this._objType.isCollection) {
376
- obj.packedData = buf.readBytesWithLength();
389
+ obj.packedData = Buffer.from(buf.readBytesWithLength());
377
390
  } else {
378
391
  obj._unpackDataFromBuf(buf);
379
392
  }
package/lib/thin/lob.js CHANGED
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const LobImpl = require('../impl/lob.js');
30
31
  const constants = require('./protocol/constants.js');
31
32
  const LobOpMessage = require('./protocol/messages/lobOp.js');
package/lib/thin/pool.js CHANGED
@@ -144,13 +144,13 @@ class ThinPoolImpl extends PoolImpl {
144
144
  }
145
145
 
146
146
  //---------------------------------------------------------------------------
147
- // get connection from pool
147
+ // credentials are obfuscated and stored in an object(userConfig) during
148
+ // pool creation. _getConnAttrs() method is used to deobfuscate encrypted
149
+ // credentials for creating new connections
148
150
  //---------------------------------------------------------------------------
149
- async _connect(connAttrs) {
151
+ async _getConnAttrs() {
150
152
  let accessToken;
151
- const conn = new ThinConnectionImpl();
152
- conn._pool = this;
153
- let clonedAttrs = Object.assign({}, connAttrs);
153
+ const clonedAttrs = Object.assign({}, this._userConfig);
154
154
  if (clonedAttrs.password === null) {
155
155
  clonedAttrs.password = protocolUtil.getDeobfuscatedValue(this._password,
156
156
  this._obfuscatedPassword);
@@ -204,9 +204,7 @@ class ThinPoolImpl extends PoolImpl {
204
204
  protocolUtil.getDeobfuscatedValue(this._privateKey,
205
205
  this._obfuscatedPrivateKey);
206
206
  }
207
- await conn.connect(clonedAttrs);
208
- clonedAttrs = null;
209
- return conn;
207
+ return clonedAttrs;
210
208
  }
211
209
 
212
210
  //---------------------------------------------------------------------------
@@ -318,8 +316,11 @@ class ThinPoolImpl extends PoolImpl {
318
316
  // Grows the pool to include the specified number of connections.
319
317
  //---------------------------------------------------------------------------
320
318
  async _growPool(numConns) {
319
+ const clonedAttrs = await this._getConnAttrs();
321
320
  while (numConns > 0) {
322
- let conn = await this._connect(this._userConfig);
321
+ const conn = new ThinConnectionImpl();
322
+ conn._pool = this;
323
+ await conn.connect(clonedAttrs);
323
324
  conn._newSession = true;
324
325
  conn._dropSess = false;
325
326
  conn._lastTimeUsed = Date.now();
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const constants = require("./constants.js");
30
31
  const errors = require("../../errors.js");
31
32
  const settings = require("../../settings.js");
@@ -374,18 +375,18 @@ class BaseBuffer {
374
375
  const obj = {};
375
376
  let numBytes = this.readUB4();
376
377
  if (numBytes > 0)
377
- obj.toid = this.readBytesWithLength();
378
+ obj.toid = Buffer.from(this.readBytesWithLength());
378
379
  numBytes = this.readUB4();
379
380
  if (numBytes > 0)
380
- obj.oid = this.readBytesWithLength();
381
+ obj.oid = Buffer.from(this.readBytesWithLength());
381
382
  numBytes = this.readUB4();
382
383
  if (numBytes > 0)
383
- obj.snapshot = this.readBytesWithLength();
384
+ obj.snapshot = Buffer.from(this.readBytesWithLength());
384
385
  this.skipUB2(); // version
385
386
  numBytes = this.readUB4();
386
387
  this.skipUB2(); // flags
387
388
  if (numBytes > 0)
388
- obj.packedData = this.readBytesWithLength();
389
+ obj.packedData = Buffer.from(this.readBytesWithLength());
389
390
  return obj;
390
391
  }
391
392
 
@@ -686,7 +687,9 @@ class BaseBuffer {
686
687
  let numBytes = value.length;
687
688
  if (numBytes <= constants.TNS_MAX_SHORT_LENGTH) {
688
689
  this.writeUInt8(numBytes);
689
- this.writeBytes(value);
690
+ if (numBytes > 0) {
691
+ this.writeBytes(value);
692
+ }
690
693
  } else {
691
694
  let start = 0;
692
695
  this.writeUInt8(constants.TNS_LONG_LENGTH_INDICATOR);
@@ -984,7 +987,7 @@ class BaseBuffer {
984
987
  writeUInt64BE(n) {
985
988
  const buf = this.reserveBytes(8);
986
989
  buf.writeUInt32BE(0);
987
- buf.writeUInt32BE(n);
990
+ buf.writeUInt32BE(n, 4);
988
991
  }
989
992
 
990
993
  //---------------------------------------------------------------------------
@@ -26,7 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
- const Buffer = require("buffer").Buffer;
29
+ const { Buffer } = require('buffer');
30
30
  const constants = require("./constants.js");
31
31
  const errors = require('../../errors');
32
32
 
@@ -46,6 +46,7 @@ class Capabilities {
46
46
  this.runtimeCaps = Buffer.alloc(constants.TNS_RCAP_MAX);
47
47
  this.initCompileCaps();
48
48
  this.initRuntimeCaps();
49
+ this.maxStringSize = 0;
49
50
  }
50
51
 
51
52
  adjustForServerCompileCaps(serverCaps) {
@@ -56,8 +57,12 @@ class Capabilities {
56
57
  }
57
58
  }
58
59
 
59
- adjustForServerRuntimeCaps() {
60
- // nothing to do currently
60
+ adjustForServerRuntimeCaps(serverCaps) {
61
+ if (serverCaps[constants.TNS_RCAP_TTC] & constants.TNS_RCAP_TTC_32K) {
62
+ this.maxStringSize = 32767;
63
+ } else {
64
+ this.maxStringSize = 4000;
65
+ }
61
66
  }
62
67
 
63
68
  initCompileCaps() {
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const constants = require('../../constants.js');
30
31
 
31
32
  module.exports = {
@@ -557,6 +558,7 @@ module.exports = {
557
558
  // versions
558
559
  TNS_VERSION_DESIRED: 316,
559
560
  TNS_VERSION_MINIMUM: 300,
561
+ TNS_VERSION_MIN_ACCEPTED: 315,
560
562
  TNS_VERSION_MIN_LARGE_SDU: 315,
561
563
 
562
564
  // other connection constants
@@ -684,7 +686,6 @@ module.exports = {
684
686
  TNS_DURATION_MID: 0x80000000,
685
687
  TNS_DURATION_OFFSET: 60,
686
688
  TNS_DURATION_SESSION: 10,
687
- TNS_MIN_LONG_LENGTH: 0x8000,
688
689
  TNS_MAX_LONG_LENGTH: 0x7fffffff,
689
690
  TNS_SDU: 8192,
690
691
  TNS_TDU: 65535,
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2022, Oracle and/or its affiliates.
1
+ // Copyright (c) 2022, 2023, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -26,7 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
- const Buffer = require('buffer').Buffer;
29
+ const { Buffer } = require('buffer');
30
30
  const crypto = require('crypto');
31
31
 
32
32
  let algorithm = 'aes-256-cbc';
@@ -138,18 +138,30 @@ class EncryptDecrypt {
138
138
  if (newPassword) {
139
139
  newPasswordBytes = Buffer.from(newPassword, 'utf8');
140
140
  }
141
- let sessionKeyParta = this._decrypt(passwordHash, encodedServerKey);
142
- let sessionKeyPartb = Buffer.alloc(32);
143
- crypto.randomFillSync(sessionKeyPartb, 0, 32);
144
- let encodedClientKey = this._encrypt(passwordHash, sessionKeyPartb);
145
- authObj.sessionKey = encodedClientKey.slice().toString('hex').toUpperCase().slice(0, 64);
146
-
147
- iterations = Number(sessionData['AUTH_PBKDF2_SDER_COUNT']);
148
- let mixingSalt = Buffer.from(sessionData['AUTH_PBKDF2_CSK_SALT'], 'hex');
149
- let partABKey = Buffer.concat([sessionKeyPartb.slice(0, keyLen), sessionKeyParta.slice(0, keyLen)]);
150
- let partABKeyStr = partABKey.toString('hex').toUpperCase();
151
- let partABKeyBuffer = Buffer.from(partABKeyStr, 'utf8');
152
- authObj.comboKey = crypto.pbkdf2Sync(partABKeyBuffer, mixingSalt, iterations, keyLen, 'sha512');
141
+ const sessionKeyParta = this._decrypt(passwordHash, encodedServerKey);
142
+ const sessionKeyPartb = Buffer.alloc(sessionKeyParta.length);
143
+ crypto.randomFillSync(sessionKeyPartb);
144
+ const encodedClientKey = this._encrypt(passwordHash, sessionKeyPartb);
145
+
146
+ if (sessionKeyParta.length === 48) {
147
+ authObj.sessionKey = encodedClientKey.slice().toString('hex').toUpperCase().slice(0, 96);
148
+ const buf = Buffer.alloc(24);
149
+ for (let i = 16; i <= 40; i++) {
150
+ buf[i - 16] = sessionKeyParta[i] ^ sessionKeyPartb[i];
151
+ }
152
+ const part1 = crypto.createHash("md5").update(buf.subarray(0, 16)).digest();
153
+ const part2 = crypto.createHash("md5").update(buf.subarray(16)).digest();
154
+ authObj.comboKey = Buffer.concat([part1, part2]).slice(0, keyLen);
155
+ } else {
156
+ authObj.sessionKey = encodedClientKey.slice().toString('hex').toUpperCase().slice(0, 64);
157
+ const mixingSalt = Buffer.from(sessionData['AUTH_PBKDF2_CSK_SALT'], 'hex');
158
+ iterations = Number(sessionData['AUTH_PBKDF2_SDER_COUNT']);
159
+ const partABKey = Buffer.concat([sessionKeyPartb.slice(0, keyLen), sessionKeyParta.slice(0, keyLen)]);
160
+ const partABKeyStr = partABKey.toString('hex').toUpperCase();
161
+ const partABKeyBuffer = Buffer.from(partABKeyStr, 'utf8');
162
+ authObj.comboKey = crypto.pbkdf2Sync(partABKeyBuffer, mixingSalt,
163
+ iterations, keyLen, 'sha512');
164
+ }
153
165
 
154
166
  let salt = Buffer.alloc(16);
155
167
  if (!verifier11G) {
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const constants = require("../constants.js");
30
31
  const errors = require("../../../errors.js");
31
32
  const os = require("os");
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const constants = require("../constants.js");
30
31
  const errors = require("../../../errors.js");
31
32
 
@@ -38,7 +38,16 @@ const Message = require("./base.js");
38
38
  */
39
39
  class DataTypeMessage extends Message {
40
40
 
41
- decode() { }
41
+ processMessage(buf) {
42
+ while (true) { // eslint-disable-line
43
+ const dataType = buf.readUInt16BE();
44
+ if (dataType === 0)
45
+ break;
46
+ const convDataType = buf.readUInt16BE();
47
+ if (convDataType !== 0)
48
+ buf.skipBytes(4);
49
+ }
50
+ }
42
51
 
43
52
  encode(buf) {
44
53
  buf.writeUInt8(constants.TNS_MSG_TYPE_DATA_TYPES);
@@ -275,7 +275,7 @@ class ExecuteMessage extends MessageWithData {
275
275
  // no rows have yet been sent so the header information needs to be sent
276
276
  if (this.currentRow === 0) {
277
277
  let stmt = this.statement;
278
- if (stmt.cursorId !== 0 && !stmt.requiresFullExecute && !stmt.requiresDefine && !stmt.isDdl) {
278
+ if (stmt.cursorId !== 0 && !stmt.requiresFullExecute && !this.parseOnly && !stmt.requiresDefine && !stmt.isDdl && !this.batchErrors) {
279
279
  if (stmt.isQuery && !stmt.requiresDefine && this.options.prefetchRows > 0) {
280
280
  this.functionCode = constants.TNS_FUNC_REEXECUTE_AND_FETCH;
281
281
  } else {
@@ -26,8 +26,9 @@
26
26
 
27
27
  'use strict';
28
28
 
29
- const Message = require('./base.js');
29
+ const { Buffer } = require('buffer');
30
30
  const constants = require('../constants.js');
31
+ const Message = require('./base.js');
31
32
 
32
33
  /**
33
34
  * Abstracts all LOB operations.
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const utils = require("../utils");
30
31
  const constants = require("../constants.js");
31
32
  const Message = require("./base.js");
@@ -95,7 +96,9 @@ class MessageWithData extends Message {
95
96
 
96
97
  processErrorInfo(buf) {
97
98
  super.processErrorInfo(buf);
98
- this.statement.cursorId = this.errorInfo.cursorId;
99
+ if (this.errorInfo.cursorId !== 0) {
100
+ this.statement.cursorId = this.errorInfo.cursorId;
101
+ }
99
102
  if (!this.statement.isPlSql) {
100
103
  this.statement.rowCount = this.errorInfo.rowCount;
101
104
  }
@@ -111,11 +114,8 @@ class MessageWithData extends Message {
111
114
  this.errorInfo.num = 0;
112
115
  this.errorOccurred = false;
113
116
  this.statement.moreRowsToFetch = false;
114
- } else if (this.errorInfo.num === constants.TNS_ERR_VAR_NOT_IN_SELECT_LIST) {
115
- this.connection._addCursorToClose(this.statement);
116
- this.connection.statementCache.delete(this.statement.sql);
117
117
  } else if (this.errorInfo.num !== 0 && this.errorInfo.cursorId !== 0) {
118
- this.connection._addCursorToClose(this.statement);
118
+ this.connection._addCursorToClose(this.statement.cursorId);
119
119
  this.connection.statementCache.delete(this.statement.sql);
120
120
  }
121
121
  if (this.errorInfo.batchErrors) {
@@ -173,7 +173,7 @@ class MessageWithData extends Message {
173
173
  let oid;
174
174
  let numBytes = buf.readUB4(); // OID
175
175
  if (numBytes > 0) {
176
- oid = buf.readBytesWithLength();
176
+ oid = Buffer.from(buf.readBytesWithLength());
177
177
  }
178
178
  buf.skipUB2(); // version
179
179
  buf.skipUB2(); // character set id
@@ -316,10 +316,11 @@ class MessageWithData extends Message {
316
316
  processIOVector(buf) {
317
317
  let numBytes;
318
318
  buf.skipUB1(); // flag
319
- const numBinds = buf.readUB2(); // num requests
320
- this.rowIndex = buf.readUB4(); // iter num
319
+ const temp16 = buf.readUB2(); // num requests
320
+ const temp32 = buf.readUB4(); // iter num
321
+ const numBinds = temp32 * 256 + temp16;
321
322
  buf.skipUB4(); // num iters this time
322
- buf.readUB2(); // uac buffer length
323
+ buf.skipUB2(); // uac buffer length
323
324
  numBytes = buf.readUB2(); // bit vector for fast fetch
324
325
  if (numBytes > 0) {
325
326
  buf.skipBytes(numBytes);
@@ -378,7 +379,7 @@ class MessageWithData extends Message {
378
379
  const useLocalTime = (oraTypeNum === constants.TNS_DATA_TYPE_DATE ||
379
380
  oraTypeNum === constants.TNS_DATA_TYPE_TIMESTAMP);
380
381
  colValue = buf.readOracleDate(useLocalTime);
381
- } else if (oraTypeNum === constants.TNS_DATA_TYPE_ROWID) {
382
+ } else if (oraTypeNum === constants.TNS_DATA_TYPE_ROWID) {
382
383
  if (!this.inFetch) {
383
384
  colValue = buf.readStr(constants.TNS_CS_IMPLICIT);
384
385
  } else {
@@ -450,10 +451,12 @@ class MessageWithData extends Message {
450
451
 
451
452
  if (!this.inFetch) {
452
453
  const actualNumBytes = buf.readSB4();
453
- if (actualNumBytes !== 0 && colValue !== null) {
454
+ if (actualNumBytes < 0 && oraTypeNum === constants.TNS_DATA_TYPE_BOOLEAN) {
455
+ colValue = null;
456
+ } else if (actualNumBytes !== 0 && colValue !== null) {
454
457
  errors.throwErr(errors.ERR_INSUFFICIENT_BUFFER_FOR_BINDS);
455
458
  }
456
- } else if (oraTypeNum === constants.TNS_DATA_TYPE_LONG || oraTypeNum === constants.TNS_DATA_TYPE_LONG_RAW || variable.maxSize >= constants.TNS_MIN_LONG_LENGTH) {
459
+ } else if (oraTypeNum === constants.TNS_DATA_TYPE_LONG || oraTypeNum === constants.TNS_DATA_TYPE_LONG_RAW || variable.maxSize > buf.caps.maxStringSize) {
457
460
  buf.skipSB4(); // null indicator
458
461
  buf.skipUB4(); // return code
459
462
  }
@@ -561,7 +564,7 @@ class MessageWithData extends Message {
561
564
 
562
565
  if (this.statement.isQuery) {
563
566
  this.inFetch = true;
564
- if (this.statement.queryVars) {
567
+ if (this.statement.queryVars) {
565
568
  this.outVariables = [];
566
569
  for (let i = 0; i < this.statement.queryVars.length; i++) {
567
570
  this.outVariables.push(this.statement.queryVars[i]);
@@ -580,7 +583,7 @@ class MessageWithData extends Message {
580
583
  }
581
584
 
582
585
  getBitVector(buf, numBytes) {
583
- this.bitVector = buf.readBytes(numBytes);
586
+ this.bitVector = Buffer.from(buf.readBytes(numBytes));
584
587
  }
585
588
 
586
589
  processBindParams(buf, params) {
@@ -631,7 +634,7 @@ class MessageWithData extends Message {
631
634
  // expects that and complains if any other value is sent!
632
635
  buf.writeUInt8(0);
633
636
  buf.writeUInt8(0);
634
- if (maxSize >= constants.TNS_MIN_LONG_LENGTH) {
637
+ if (maxSize > buf.caps.maxStringSize) {
635
638
  buf.writeUB4(constants.TNS_MAX_LONG_LENGTH);
636
639
  } else {
637
640
  buf.writeUB4(maxSize);
@@ -679,7 +682,7 @@ class MessageWithData extends Message {
679
682
  this.writeBindParamsColumn(buf, variable, variable.values[i]);
680
683
  }
681
684
  } else {
682
- if (variable.maxSize >= constants.TNS_MIN_LONG_LENGTH) {
685
+ if (variable.maxSize > buf.caps.maxStringSize) {
683
686
  foundLong = true;
684
687
  } else {
685
688
  this.writeBindParamsColumn(buf, variable,
@@ -692,9 +695,8 @@ class MessageWithData extends Message {
692
695
  if (bindInfo.isReturnBind)
693
696
  continue;
694
697
  const variable = bindInfo.bindVar;
695
- if (variable.maxSize >= constants.TNS_MIN_LONG_LENGTH) {
696
- this.writeBindParamsColumn(buf, variable,
697
- variable.values[pos + offset]);
698
+ if (variable.maxSize > buf.caps.maxStringSize) {
699
+ this.writeBindParamsColumn(buf, variable, variable.values[pos + offset]);
698
700
  }
699
701
  }
700
702
  }
@@ -27,6 +27,7 @@
27
27
  'use strict';
28
28
 
29
29
  const { BaseBuffer, GrowableBuffer } = require('./buffer.js');
30
+ const { Buffer } = require('buffer');
30
31
  const constants = require("./constants.js");
31
32
  const errors = require("../../errors.js");
32
33
  const types = require("../../types.js");
@@ -27,9 +27,8 @@
27
27
  'use strict';
28
28
 
29
29
  const { BaseBuffer } = require('./buffer.js');
30
+ const { Buffer } = require('buffer');
30
31
  const constants = require("./constants.js");
31
-
32
- const buffer = require("buffer");
33
32
  const oson = require('./oson.js');
34
33
  const utils = require('./utils.js');
35
34
 
@@ -221,12 +220,17 @@ class ReadPacket extends BaseBuffer {
221
220
  }
222
221
 
223
222
  // the requested bytes are split across multiple packets; if a chunked read
224
- // is not in progress one is implicitly started; copy the bytes from the
225
- // end of this packet
226
- if (!inChunkedRead) {
227
- this.chunkedBytesBuf.startChunkedRead();
223
+ // is in progress, a chunk is acquired that will accommodate the requested
224
+ // bytes; otherwise, a separate buffer will be allocated to accommodate the
225
+ // requested bytes
226
+ let buf;
227
+ if (inChunkedRead) {
228
+ buf = this.chunkedBytesBuf.getBuf(numBytes);
229
+ } else {
230
+ buf = Buffer.alloc(numBytes);
228
231
  }
229
- const buf = this.chunkedBytesBuf.getBuf(numBytes);
232
+
233
+ // copy the bytes to the buffer from the remainder of this packet
230
234
  let offset = 0;
231
235
  this.buf.copy(buf, offset, this.pos, this.pos + numBytesLeft);
232
236
  offset += numBytesLeft;
@@ -242,10 +246,7 @@ class ReadPacket extends BaseBuffer {
242
246
  numBytes -= numSplitBytes;
243
247
  }
244
248
 
245
- // if not in a chunked bytes read, return the buffer directly
246
- if (!inChunkedRead) {
247
- return this.chunkedBytesBuf.endChunkedRead();
248
- }
249
+ return buf;
249
250
 
250
251
  }
251
252
 
@@ -485,8 +486,8 @@ class WritePacket extends BaseBuffer {
485
486
  }
486
487
 
487
488
  writeKeyValue(key, value, flags = 0) {
488
- let keyBytesLen = buffer.Buffer.byteLength(key);
489
- let valBytesLen = buffer.Buffer.byteLength(value);
489
+ const keyBytesLen = Buffer.byteLength(key);
490
+ const valBytesLen = Buffer.byteLength(value);
490
491
  this.writeUB4(keyBytesLen);
491
492
  this.writeBytesWithLength(Buffer.from(key));
492
493
  this.writeUB4(valBytesLen);
@@ -26,6 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const constants = require('./constants');
30
31
  const crypto = require('crypto');
31
32
 
@@ -30,12 +30,13 @@ const Packet = require("./packet.js");
30
30
  const NTTCP = require("./ntTcp.js");
31
31
  const SessionAtts = require("./sessionAtts.js");
32
32
  const constants = require("./constants.js");
33
- const {createNode} = require('./connStrategy.js');
33
+ const { createNode } = require('./connStrategy.js');
34
34
  const errors = require("../../errors.js");
35
- const {findNVPairRecurse, createNVPair, findValue } = require("./nvStrToNvPair.js");
36
- const Buffer = require("buffer").Buffer;
35
+ const { findNVPairRecurse, createNVPair, findValue } = require("./nvStrToNvPair.js");
36
+ const { Buffer } = require('buffer');
37
37
  const EzConnect = require("./ezConnectResolver.js");
38
- const {NLParamParser, tnsnamesFilePath} = require("./paramParser.js");
38
+ const { NLParamParser, tnsnamesFilePath } = require("./paramParser.js");
39
+ const process = require('process');
39
40
 
40
41
  /**
41
42
  *
@@ -26,7 +26,9 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const net = require("net");
31
+ const process = require("process");
30
32
  const tls = require("tls");
31
33
  const http = require("http");
32
34
  const Timers = require('timers');
@@ -350,13 +352,7 @@ class NTTCP {
350
352
  async pauseWrite() {
351
353
  this.checkErr();
352
354
  if (this.needsDrain) {
353
- await new Promise((resolve) => {
354
- this.waiter = resolve;
355
- this.stream.once('drain', () => {
356
- resolve();
357
- this.waiter = null;
358
- });
359
- });
355
+ await new Promise((resolve) => this.stream.once('drain', resolve));
360
356
  this.checkErr();
361
357
  } else {
362
358
  await new Promise((resolve) => Timers.setImmediate(resolve));
@@ -28,6 +28,7 @@
28
28
 
29
29
  const {createNVPair, findValue} = require("./nvStrToNvPair.js");
30
30
  const fs = require('fs');
31
+ const process = require('process');
31
32
  const readline = require('readline');
32
33
  const errors = require("../../errors.js");
33
34
 
@@ -162,22 +163,19 @@ class NLParamParser {
162
163
  let res = ibuf.split(/\r?\n/).filter(element => element);
163
164
  for (let i = 0; i < res.length; i++) {
164
165
  if (res[i].charAt(0) != '(') {
165
- res[i] = '(' + res[i];
166
- }
167
- if (res[i].charAt(res[i].length - 1 != ')')) {
168
- res[i] = res[i] + ')';
166
+ res[i] = '(' + res[i] + ')';
169
167
  }
170
168
  let nvp = createNVPair(res[i]);
171
169
  let name = nvp.name;
172
170
  let uname = name.toUpperCase();
173
171
  nvp.name = uname;
174
- this.add_NLPListElement(uname, nvp);
172
+ const unames = uname.split(","); //multiple aliases (alias1, alias2, alias3)
173
+ for (let i = 0; i < unames.length; i++) {
174
+ this.ht.set(unames[i], nvp);
175
+ }
175
176
  }
176
177
  }
177
178
 
178
- add_NLPListElement(name, value) {
179
- this.ht.set(name, value);
180
- }
181
179
 
182
180
  toString() {
183
181
  let out = "";
@@ -26,7 +26,7 @@
26
26
 
27
27
  'use strict';
28
28
 
29
- const buffer = require('buffer').Buffer;
29
+ const { Buffer } = require('buffer');
30
30
  const constants = require('../constants');
31
31
  const thinUtil = require("./util.js");
32
32
 
@@ -48,8 +48,8 @@ const BIND_PATTERN = /(?<=:)\s*((?:".*?")|(?:[\p{L}][\p{L}\p{Nd}_\$#]*)|\p{Nd}+)
48
48
  const DML_RETURNING_KEY = /(?<=\bRETURN(?:ING)?\b)/si;
49
49
  const DML_RETURNING_INTO_KEY = /(?<=\bINTO\b)/gsi;
50
50
 
51
- const SINGLE_LINE_COMMENT_PATTERN = /--.*/;
52
- const MULTI_LINE_COMMENT_PATTERN = /\/\*.*?\*\//s;
51
+ const SINGLE_LINE_COMMENT_PATTERN = /--.*/g;
52
+ const MULTI_LINE_COMMENT_PATTERN = /\/\*.*?\*\//sg;
53
53
  const CONSTANT_STRING_PATTERN = /'.*?'/sg;
54
54
 
55
55
  /**
@@ -110,8 +110,7 @@ class Statement {
110
110
  // Copying existing statement into new statement object required by drcp
111
111
  //---------------------------------------------------------------------------
112
112
  _copy() {
113
- let copiedStatement = new Statement();
114
- let bindInfoDict;
113
+ const copiedStatement = new Statement();
115
114
  copiedStatement.sql = this.sql;
116
115
  copiedStatement.sqlBytes = this.sqlBytes;
117
116
  copiedStatement.sqlLength = this.sqlLength;
@@ -121,16 +120,16 @@ class Statement {
121
120
  copiedStatement.isDdl = this.isDdl;
122
121
  copiedStatement.isReturning = this.isReturning;
123
122
  copiedStatement.bindInfoList = [];
124
- for (let bindInfo of this.bindInfoList) {
125
- copiedStatement.bindInfoList.push(bindInfo);
123
+ for (const bindInfo of this.bindInfoList) {
124
+ const newBindInfo = new BindInfo(bindInfo.bindName, bindInfo.isReturnBind);
125
+ copiedStatement.bindInfoList.push(newBindInfo);
126
126
  }
127
- copiedStatement.bindInfoDict = new Map();
128
- bindInfoDict = copiedStatement.bindInfoDict;
129
- for (let bindInfoObj of this.bindInfoList) {
130
- if (bindInfoDict.has(bindInfoObj.bindName)) {
131
- bindInfoDict.get(bindInfoObj.bindName).push(bindInfoObj);
127
+ const bindInfoDict = copiedStatement.bindInfoDict = new Map();
128
+ for (const bindInfo of copiedStatement.bindInfoList) {
129
+ if (bindInfoDict.has(bindInfo.bindName)) {
130
+ bindInfoDict.get(bindInfo.bindName).push(bindInfo);
132
131
  } else {
133
- bindInfoDict.set(bindInfoObj.bindName, [bindInfoObj]);
132
+ bindInfoDict.set(bindInfo.bindName, [bindInfo]);
134
133
  }
135
134
  }
136
135
  copiedStatement.returnToCache = false;
@@ -203,7 +202,7 @@ class Statement {
203
202
  //---------------------------------------------------------------------------
204
203
  _prepare(sql) {
205
204
  this.sql = sql;
206
- this.sqlBytes = buffer.from(this.sql, 'utf8');
205
+ this.sqlBytes = Buffer.from(this.sql, 'utf8');
207
206
  this.sqlLength = this.sqlBytes.length;
208
207
  // replace literals with a specific literal
209
208
  sql = sql.replace(CONSTANT_STRING_PATTERN, "'S'");
@@ -27,6 +27,7 @@
27
27
  'use strict';
28
28
 
29
29
  const BaseDbObject = require('./dbObject.js');
30
+ const { Buffer } = require('buffer');
30
31
  const Lob = require('./lob.js');
31
32
  const ResultSet = require('./resultset.js');
32
33
  const constants = require('./constants.js');
@@ -151,14 +152,15 @@ function transformValueIn(info, value, options) {
151
152
  types.DB_TYPE_CLOB,
152
153
  types.DB_TYPE_NCLOB);
153
154
  if (info.type !== types.DB_TYPE_CLOB &&
154
- info.type !== types.DB_TYPE_NCLOB &&
155
- info.cqn === undefined &&
156
- (info.maxSize === undefined || value.length > info.maxSize)) {
157
- if (info.checkSize) {
158
- errors.throwErr(errors.ERR_MAX_SIZE_TOO_SMALL, info.maxSize,
159
- value.length, options.pos);
155
+ info.type !== types.DB_TYPE_NCLOB) {
156
+ const valueLen = Buffer.byteLength(value);
157
+ if (info.maxSize === undefined || valueLen > info.maxSize) {
158
+ if (info.checkSize) {
159
+ errors.throwErr(errors.ERR_MAX_SIZE_TOO_SMALL, info.maxSize,
160
+ valueLen, options.pos);
161
+ }
162
+ info.maxSize = valueLen;
160
163
  }
161
- info.maxSize = value.length;
162
164
  }
163
165
  return value;
164
166
 
@@ -193,7 +195,7 @@ function transformValueIn(info, value, options) {
193
195
  checkType(info, options,
194
196
  types.DB_TYPE_RAW,
195
197
  types.DB_TYPE_BLOB);
196
- if (info.type === types.DB_TYPE_RAW && info.cqn === undefined &&
198
+ if (info.type === types.DB_TYPE_RAW &&
197
199
  (info.maxSize === undefined || value.length > info.maxSize)) {
198
200
  if (info.checkSize) {
199
201
  errors.throwErr(errors.ERR_MAX_SIZE_TOO_SMALL, info.maxSize,
package/lib/util.js CHANGED
@@ -26,7 +26,9 @@
26
26
 
27
27
  'use strict';
28
28
 
29
+ const { Buffer } = require('buffer');
29
30
  const errors = require('./errors.js');
31
+ const process = require('process');
30
32
  const util = require('util');
31
33
  const types = require('./types.js');
32
34
 
package/lib/version.js CHANGED
@@ -31,6 +31,6 @@
31
31
  module.exports = {
32
32
  VERSION_MAJOR: 6,
33
33
  VERSION_MINOR: 0,
34
- VERSION_PATCH: 0,
34
+ VERSION_PATCH: 2,
35
35
  VERSION_SUFFIX: ''
36
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oracledb",
3
- "version": "6.0.0",
3
+ "version": "6.0.2",
4
4
  "description": "A Node.js module for Oracle Database access from JavaScript and TypeScript",
5
5
  "license": "(Apache-2.0 OR UPL-1.0)",
6
6
  "homepage": "http://oracle.github.io/node-oracledb/",
@@ -1 +0,0 @@
1
- oracledb-6.0.0-darwin-x64.node v16.20.0 860028aa05a0de50f81df433ab99d4f907f9a99a ccbaddf0256153ecfa6702c6ae1a4e5003e3775e Tue, 16 May 2023 11:28:59 GMT
@@ -1 +0,0 @@
1
- 860028aa05a0de50f81df433ab99d4f907f9a99a
@@ -1 +0,0 @@
1
- oracledb-6.0.0-linux-arm64.node v16.20.0 860028aa05a0de50f81df433ab99d4f907f9a99a ccbaddf0256153ecfa6702c6ae1a4e5003e3775e Tue, 16 May 2023 11:56:16 GMT
@@ -1 +0,0 @@
1
- oracledb-6.0.0-linux-x64.node v16.20.0 860028aa05a0de50f81df433ab99d4f907f9a99a ccbaddf0256153ecfa6702c6ae1a4e5003e3775e Tue, 16 May 2023 13:29:42 GMT
@@ -1 +0,0 @@
1
- oracledb-6.0.0-win32-x64.node v16.19.0 860028aa05a0de50f81df433ab99d4f907f9a99a ccbaddf0256153ecfa6702c6ae1a4e5003e3775e Tue, 16 May 2023 13:40:01 GMT