oracledb 6.3.0 → 6.5.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 (71) hide show
  1. package/LICENSE.txt +1 -1
  2. package/NOTICE.txt +1 -1
  3. package/README.md +3 -3
  4. package/build/Release/oracledb-6.5.0-darwin-x64.node +0 -0
  5. package/build/Release/oracledb-6.5.0-darwin-x64.node-buildinfo.txt +1 -0
  6. package/build/Release/oracledb-6.5.0-js-buildinfo.txt +1 -0
  7. package/build/Release/oracledb-6.5.0-linux-arm64.node +0 -0
  8. package/build/Release/oracledb-6.5.0-linux-arm64.node-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-6.5.0-linux-x64.node +0 -0
  10. package/build/Release/oracledb-6.5.0-linux-x64.node-buildinfo.txt +1 -0
  11. package/build/Release/oracledb-6.5.0-win32-x64.node +0 -0
  12. package/build/Release/oracledb-6.5.0-win32-x64.node-buildinfo.txt +1 -0
  13. package/examples/README.md +3 -0
  14. package/lib/aqQueue.js +8 -8
  15. package/lib/connection.js +65 -22
  16. package/lib/constants.js +7 -1
  17. package/lib/dbObject.js +72 -1
  18. package/lib/errors.js +51 -10
  19. package/lib/impl/connection.js +2 -1
  20. package/lib/{thin/protocol → impl/datahandlers}/buffer.js +36 -32
  21. package/lib/impl/datahandlers/constants.js +106 -0
  22. package/lib/{thin/protocol → impl/datahandlers}/oson.js +320 -151
  23. package/lib/impl/datahandlers/vector.js +137 -0
  24. package/lib/impl/pool.js +9 -0
  25. package/lib/impl/resultset.js +34 -17
  26. package/lib/lob.js +22 -6
  27. package/lib/oracledb.js +35 -1
  28. package/lib/pool.js +17 -2
  29. package/lib/poolStatistics.js +3 -1
  30. package/lib/settings.js +31 -6
  31. package/lib/sodaDocCursor.js +14 -1
  32. package/lib/thin/connection.js +120 -193
  33. package/lib/thin/dbObject.js +4 -2
  34. package/lib/thin/lob.js +6 -6
  35. package/lib/thin/pool.js +84 -10
  36. package/lib/thin/protocol/capabilities.js +20 -6
  37. package/lib/thin/protocol/constants.js +34 -54
  38. package/lib/thin/protocol/messages/auth.js +2 -2
  39. package/lib/thin/protocol/messages/base.js +28 -27
  40. package/lib/thin/protocol/messages/dataType.js +4 -2
  41. package/lib/thin/protocol/messages/execute.js +5 -1
  42. package/lib/thin/protocol/messages/{connectionCookie.js → fastAuth.js} +18 -16
  43. package/lib/thin/protocol/messages/fetch.js +4 -0
  44. package/lib/thin/protocol/messages/index.js +2 -2
  45. package/lib/thin/protocol/messages/protocol.js +9 -1
  46. package/lib/thin/protocol/messages/withData.js +40 -11
  47. package/lib/thin/protocol/packet.js +93 -8
  48. package/lib/thin/protocol/protocol.js +10 -5
  49. package/lib/thin/protocol/utils.js +11 -18
  50. package/lib/thin/sqlnet/constants.js +5 -2
  51. package/lib/thin/sqlnet/ezConnectResolver.js +9 -5
  52. package/lib/thin/sqlnet/navNodes.js +4 -3
  53. package/lib/thin/sqlnet/networkSession.js +27 -4
  54. package/lib/thin/sqlnet/packet.js +2 -5
  55. package/lib/thin/statement.js +43 -7
  56. package/lib/thin/statementCache.js +190 -0
  57. package/lib/thin/util.js +2 -2
  58. package/lib/transformer.js +21 -6
  59. package/lib/types.js +21 -3
  60. package/lib/util.js +30 -1
  61. package/lib/version.js +2 -2
  62. package/package.json +1 -1
  63. package/build/Release/oracledb-6.3.0-darwin-x64.node +0 -0
  64. package/build/Release/oracledb-6.3.0-darwin-x64.node-buildinfo.txt +0 -1
  65. package/build/Release/oracledb-6.3.0-js-buildinfo.txt +0 -1
  66. package/build/Release/oracledb-6.3.0-linux-arm64.node +0 -0
  67. package/build/Release/oracledb-6.3.0-linux-arm64.node-buildinfo.txt +0 -1
  68. package/build/Release/oracledb-6.3.0-linux-x64.node +0 -0
  69. package/build/Release/oracledb-6.3.0-linux-x64.node-buildinfo.txt +0 -1
  70. package/build/Release/oracledb-6.3.0-win32-x64.node +0 -0
  71. package/build/Release/oracledb-6.3.0-win32-x64.node-buildinfo.txt +0 -1
package/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015, 2023 Oracle and/or its affiliates.
1
+ Copyright (c) 2015, 2024 Oracle and/or its affiliates.
2
2
 
3
3
  This software is dual-licensed to you under the Universal Permissive License
4
4
  (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
package/NOTICE.txt CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2015, 2023, Oracle and/or its affiliates.
1
+ Copyright (c) 2015, 2024, Oracle and/or its affiliates.
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # node-oracledb version 6.3.0
1
+ # node-oracledb version 6.5.0
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.3.0 to connect Node.js 14.6, or later, to Oracle
7
+ Use node-oracledb 6.5.0 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
 
@@ -48,7 +48,7 @@ vulnerability disclosure process.
48
48
 
49
49
  ## License
50
50
 
51
- Copyright (c) 2015, 2023, Oracle and/or its affiliates.
51
+ Copyright (c) 2015, 2024, Oracle and/or its affiliates.
52
52
 
53
53
  This software is dual-licensed to you under the Universal Permissive License
54
54
  (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -0,0 +1 @@
1
+ oracledb-6.5.0-darwin-x64.node v20.11.1 91a7f419eccbfcd18513c19cd25f55f18a4d8ccc 42edf925eedae73b0d5bd7777167a21987bafc89 Tue, 30 Apr 2024 20:12:57 GMT
@@ -0,0 +1 @@
1
+ 91a7f419eccbfcd18513c19cd25f55f18a4d8ccc
@@ -0,0 +1 @@
1
+ oracledb-6.5.0-linux-arm64.node v18.19.1 91a7f419eccbfcd18513c19cd25f55f18a4d8ccc 42edf925eedae73b0d5bd7777167a21987bafc89 Wed, 01 May 2024 04:29:37 GMT
@@ -0,0 +1 @@
1
+ oracledb-6.5.0-linux-x64.node v16.20.2 91a7f419eccbfcd18513c19cd25f55f18a4d8ccc 42edf925eedae73b0d5bd7777167a21987bafc89 Wed, 01 May 2024 04:22:59 GMT
@@ -0,0 +1 @@
1
+ oracledb-6.5.0-win32-x64.node v18.16.0 91a7f419eccbfcd18513c19cd25f55f18a4d8ccc 42edf925eedae73b0d5bd7777167a21987bafc89 Wed, 01 May 2024 04:34:23 GMT
@@ -63,6 +63,7 @@ File Name | Description
63
63
  [`aqobject.js`](aqobject.js) | Oracle Advanced Queuing (AQ) example passing an Oracle Database object
64
64
  [`aqoptions.js`](aqoptions.js) | Oracle Advanced Queuing (AQ) example setting options and message attributes
65
65
  [`aqraw.js`](aqraw.js) | Basic Oracle Advanced Queuing (AQ) example passing text messages
66
+ [`aqutil.js`](aqutil.js) | Common file to setup the user credentials for all the Advanced Queuing (AQ) examples.
66
67
  [`blobhttp.js`](blobhttp.js) | Simple web app that streams an image
67
68
  [`calltimeout.js`](calltimeout.js) | Shows how to cancel a SQL statement if it doesn't complete in a specified time
68
69
  [`connect.js`](connect.js) | Basic example for creating a standalone (non-pooled) connection
@@ -112,6 +113,8 @@ File Name | Description
112
113
  [`resultset2.js`](resultset2.js) | Executes a query and uses a ResultSet to fetch batches of rows with `getRows()`
113
114
  [`resultsettoquerystream.js`](resultsettoquerystream.js) | Converts a ResultSet returned from `execute()` into a Readable Stream.
114
115
  [`rowlimit.js`](rowlimit.js) | Shows ways to limit the number of records fetched by queries
116
+ [`sampleazuretokenauth.js`](sampleazuretokenauth.js) | Shows connection pooling with Azure token based authentication.
117
+ [`sampleocitokenauth.js`](sampleocitokenauth.js) | Shows connection pooling with OCI OAuth 2.0 token based authentication.
115
118
  [`select1.js`](select1.js) | Executes a basic query without using a connection pool or ResultSet
116
119
  [`select2.js`](select2.js) | Executes queries to show array and object output formats
117
120
  [`selectgeometry.js`](selectgeometry.js) | Insert and query Oracle Spatial geometries
package/lib/aqQueue.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2019, 2023, Oracle and/or its affiliates.
1
+ // Copyright (c) 2019, 2024, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -169,7 +169,7 @@ class AqQueue {
169
169
  errors.assertArgCount(arguments, 1, 1);
170
170
  errors.assertParamValue(Number.isInteger(maxMessages) && maxMessages > 0,
171
171
  1);
172
- const msgImpls = await this._impl.deqMany(maxMessages);
172
+ const msgImpls = await this._impl.deq(maxMessages);
173
173
  return msgImpls.map(i => this._makeMessage(i));
174
174
  }
175
175
 
@@ -180,9 +180,9 @@ class AqQueue {
180
180
  //---------------------------------------------------------------------------
181
181
  async deqOne() {
182
182
  errors.assertArgCount(arguments, 0, 0);
183
- const msgImpl = await this._impl.deqOne();
184
- if (msgImpl)
185
- return this._makeMessage(msgImpl);
183
+ const msgImpls = await this._impl.deq(1);
184
+ if (msgImpls.length > 0)
185
+ return this._makeMessage(msgImpls[0]);
186
186
  }
187
187
 
188
188
  //---------------------------------------------------------------------------
@@ -212,7 +212,7 @@ class AqQueue {
212
212
  for (let i = 0; i < messages.length; i++) {
213
213
  verifiedMessages[i] = this._verifyMessage(messages[i]);
214
214
  }
215
- const msgImpls = await this._impl.enqMany(verifiedMessages);
215
+ const msgImpls = await this._impl.enq(verifiedMessages);
216
216
  return msgImpls.map(i => this._makeMessage(i));
217
217
  }
218
218
 
@@ -224,8 +224,8 @@ class AqQueue {
224
224
  async enqOne(message) {
225
225
  errors.assertArgCount(arguments, 1, 1);
226
226
  message = this._verifyMessage(message);
227
- const msgImpl = await this._impl.enqOne(message);
228
- return this._makeMessage(msgImpl);
227
+ const msgImpls = await this._impl.enq([message]);
228
+ return this._makeMessage(msgImpls[0]);
229
229
  }
230
230
 
231
231
  //---------------------------------------------------------------------------
package/lib/connection.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2016, 2023, Oracle and/or its affiliates.
1
+ // Copyright (c) 2016, 2024, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -43,6 +43,7 @@ const constants = require('./constants.js');
43
43
  const settings = require('./settings.js');
44
44
  const transformer = require('./transformer.js');
45
45
  const types = require('./types.js');
46
+ const oson = require('./impl/datahandlers/oson.js');
46
47
 
47
48
  // global mapping of subscriptions; these cannot be tied to a particular
48
49
  // connection or pool since subscriptions can be created with one connection
@@ -105,7 +106,10 @@ class Connection extends EventEmitter {
105
106
  const cls = this._getDbObjectClass(objType.elementTypeClass);
106
107
  objType.elementTypeClass = cls;
107
108
  }
108
- nodbUtil.addTypeProperties(objType, "elementType");
109
+ if (objType.isCollection) {
110
+ nodbUtil.addTypeProperties(objType, "elementType");
111
+ objType.elementTypeInfo.type = objType.elementType;
112
+ }
109
113
  if (objType.attributes) {
110
114
  const props = {};
111
115
  for (const attr of objType.attributes) {
@@ -196,9 +200,13 @@ class Connection extends EventEmitter {
196
200
  typeof value === 'number' ||
197
201
  typeof value === 'string' ||
198
202
  typeof value === 'boolean' ||
203
+ typeof value === 'bigint' ||
199
204
  Array.isArray(value) ||
205
+ value instanceof Float32Array ||
206
+ value instanceof Float64Array ||
207
+ value instanceof Int8Array ||
200
208
  Buffer.isBuffer(value) ||
201
- util.isDate(value) ||
209
+ util.types.isDate(value) ||
202
210
  value instanceof Lob ||
203
211
  value instanceof ResultSet ||
204
212
  value instanceof BaseDbObject
@@ -563,11 +571,8 @@ class Connection extends EventEmitter {
563
571
  } else {
564
572
 
565
573
  // fetchArraySize must be a positive integer
566
- if (options.fetchArraySize !== undefined) {
567
- errors.assertParamPropValue(Number.isInteger(options.fetchArraySize) &&
568
- options.fetchArraySize > 0, 3, "fetchArraySize");
569
- outOptions.fetchArraySize = options.fetchArraySize;
570
- }
574
+ errors.assertParamPropUnsignedIntNonZero(options, 3, "fetchArraySize");
575
+ outOptions.fetchArraySize = options.fetchArraySize;
571
576
 
572
577
  // fetchInfo must be an object with keys containing an object with a
573
578
  // "type" property; these are converted to an array of objects for ease
@@ -833,6 +838,29 @@ class Connection extends EventEmitter {
833
838
  this._impl.setECID(value);
834
839
  }
835
840
 
841
+ //---------------------------------------------------------------------------
842
+ // decode()
843
+ //
844
+ // Decodes OSON Buffer to JS data type.
845
+ //---------------------------------------------------------------------------
846
+ decodeOSON(buf) {
847
+ errors.assertArgCount(arguments, 1, 1);
848
+ errors.assertParamValue(Buffer.isBuffer(buf), 1);
849
+ const decoder = new oson.OsonDecoder(buf);
850
+ return decoder.decode();
851
+ }
852
+
853
+
854
+ //---------------------------------------------------------------------------
855
+ // encode()
856
+ //
857
+ // Encodes the JS value into OSON bytes.
858
+ //---------------------------------------------------------------------------
859
+ encodeOSON(value) {
860
+ const encoder = new oson.OsonEncoder();
861
+ return encoder.encode(transformer.transformJsonValue(value), this._impl._osonMaxFieldNameSize);
862
+ }
863
+
836
864
  //---------------------------------------------------------------------------
837
865
  // execute()
838
866
  //
@@ -844,13 +872,24 @@ class Connection extends EventEmitter {
844
872
  let options = {};
845
873
 
846
874
  // process arguments
847
- errors.assertArgCount(arguments, 1, 3);
848
- errors.assertParamValue(typeof sql === 'string', 1);
849
- if (arguments.length >= 2) {
850
- binds = await this._processExecuteBinds(a2);
851
- }
852
- if (arguments.length == 3) {
853
- options = this._verifyExecOpts(a3, false);
875
+ if (nodbUtil.isObject(sql) && typeof sql.statement === 'string') {
876
+ errors.assertArgCount(arguments, 1, 2);
877
+ if (sql.values) {
878
+ binds = await this._processExecuteBinds(sql.values);
879
+ }
880
+ sql = sql.statement;
881
+ if (arguments.length == 2) {
882
+ options = this._verifyExecOpts(a2, false);
883
+ }
884
+ } else {
885
+ errors.assertArgCount(arguments, 1, 3);
886
+ errors.assertParamValue(typeof sql === 'string', 1);
887
+ if (arguments.length >= 2) {
888
+ binds = await this._processExecuteBinds(a2);
889
+ }
890
+ if (arguments.length == 3) {
891
+ options = this._verifyExecOpts(a3, false);
892
+ }
854
893
  }
855
894
  this._addDefaultsToExecOpts(options);
856
895
  errors.assert(this._impl, errors.ERR_INVALID_CONNECTION);
@@ -886,8 +925,8 @@ class Connection extends EventEmitter {
886
925
 
887
926
  // process output binds
888
927
  if (result.outBinds !== undefined) {
889
- for (const key in result.outBinds) {
890
- const val = this._transformOutBind(result.outBinds[key], options);
928
+ for (const [key, value] of Object.entries(result.outBinds)) {
929
+ const val = this._transformOutBind(value, options);
891
930
  result.outBinds[key] = val;
892
931
  }
893
932
  }
@@ -896,10 +935,9 @@ class Connection extends EventEmitter {
896
935
  // array size fixed, or, if a result set is not requested, that all rows
897
936
  // are fetched
898
937
  if (result.implicitResults) {
899
- for (const key in result.implicitResults) {
900
- const resultSetImpl = result.implicitResults[key];
938
+ for (const [key, impl] of Object.entries(result.implicitResults)) {
901
939
  const resultSet = new ResultSet();
902
- resultSet._setup(this, resultSetImpl);
940
+ resultSet._setup(this, impl);
903
941
  if (options.resultSet) {
904
942
  result.implicitResults[key] = resultSet;
905
943
  } else {
@@ -946,12 +984,17 @@ class Connection extends EventEmitter {
946
984
  const result = await this._impl.execute(sql, numIters, binds, options,
947
985
  true);
948
986
 
987
+ // convert ORA warnings to NJS
988
+ if (result.warning) {
989
+ result.warning = errors.transformErr(result.warning);
990
+ }
991
+
949
992
  // process output binds
950
993
  if (result.outBinds !== undefined) {
951
994
  for (let i = 0; i < result.outBinds.length; i++) {
952
995
  const outBind = result.outBinds[i];
953
- for (const key in outBind) {
954
- outBind[key] = this._transformOutBind(outBind[key], options);
996
+ for (const [key, value] of Object.entries(outBind)) {
997
+ outBind[key] = this._transformOutBind(value, options);
955
998
  }
956
999
  }
957
1000
  }
package/lib/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2022, 2023, Oracle and/or its affiliates.
1
+ // Copyright (c) 2022, 2024, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -200,4 +200,10 @@ module.exports = {
200
200
  // TPC/XA two-phase commit flags
201
201
  TPC_END_NORMAL: 0,
202
202
  TPC_END_SUSPEND: 0x00100000,
203
+
204
+ // vector types
205
+ VECTOR_FORMAT_FLOAT32: 2,
206
+ VECTOR_FORMAT_FLOAT64: 3,
207
+ VECTOR_FORMAT_INT8: 4,
208
+
203
209
  };
package/lib/dbObject.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2019, 2023, Oracle and/or its affiliates.
1
+ // Copyright (c) 2019, 2024, Oracle and/or its affiliates.
2
2
 
3
3
  //----------------------------------------------------------------------------
4
4
  //
@@ -32,6 +32,48 @@ const errors = require('./errors.js');
32
32
  const types = require('./types.js');
33
33
  const util = require('util');
34
34
 
35
+ //---------------------------------------------------------------------------
36
+ // validatePropertyValue
37
+ //
38
+ // Validate the value based on metadata.
39
+ // For object type, metaData corresponds to the attribute which is set.
40
+ // For collection type, metaData corresponds to element in the collection.
41
+ //---------------------------------------------------------------------------
42
+ function validatePropertyValue(objType, metaData, value, index) {
43
+ let valueLen, lengthErr = false;
44
+
45
+ if (value) {
46
+ switch (metaData.type) {
47
+ case types.DB_TYPE_VARCHAR:
48
+ case types.DB_TYPE_NVARCHAR:
49
+ case types.DB_TYPE_NCHAR:
50
+ case types.DB_TYPE_CHAR:
51
+ valueLen = Buffer.byteLength(value);
52
+ if (valueLen > metaData.maxSize) {
53
+ lengthErr = true;
54
+ }
55
+ break;
56
+ case types.DB_TYPE_RAW:
57
+ valueLen = value.length;
58
+ if (valueLen > metaData.maxSize) {
59
+ lengthErr = true;
60
+ }
61
+ break;
62
+ default:
63
+ break;
64
+ }
65
+ if (lengthErr) {
66
+ if (index !== undefined) {
67
+ errors.throwErr(errors.ERR_WRONG_LENGTH_FOR_DBOBJECT_ELEM,
68
+ index, objType.fqn, valueLen, metaData.maxSize);
69
+ } else {
70
+ errors.throwErr(errors.ERR_WRONG_LENGTH_FOR_DBOBJECT_ATTR,
71
+ metaData.name, objType.fqn, valueLen, metaData.maxSize);
72
+ }
73
+ }
74
+ }
75
+ }
76
+
35
77
  // define base database object class; instances of this class are never
36
78
  // instantiated; instead, classes subclassed from this one will be
37
79
  // instantiated; a cache of these classes are maintained on each connection
@@ -61,6 +103,7 @@ class BaseDbObject {
61
103
  };
62
104
  const options = {allowArray: false};
63
105
  value = transformer.transformValueIn(info, value, options);
106
+ validatePropertyValue(this._objType, attr, value);
64
107
  this._impl.setAttrValue(attr, value);
65
108
  }
66
109
 
@@ -124,6 +167,13 @@ class BaseDbObject {
124
167
  };
125
168
  const options = {allowArray: false};
126
169
  value = transformer.transformValueIn(info, value, options);
170
+ let index = this._impl.getLastIndex();
171
+ if (index) {
172
+ index = index + 1; // element will be appended at index + 1.
173
+ } else {
174
+ index = 0; // undefined for initial append, so set it to 0
175
+ }
176
+ validatePropertyValue(this._objType, this._objType.elementTypeInfo, value, index);
127
177
  this._impl.append(value);
128
178
  }
129
179
 
@@ -344,6 +394,7 @@ class BaseDbObject {
344
394
  };
345
395
  const options = {allowArray: false};
346
396
  value = transformer.transformValueIn(info, value, options);
397
+ validatePropertyValue(this._objType, this._objType.elementTypeInfo, value, index);
347
398
  this._impl.setElement(index, value);
348
399
  }
349
400
 
@@ -388,6 +439,25 @@ class BaseDbObject {
388
439
  return (this._toPojo());
389
440
  }
390
441
 
442
+ //---------------------------------------------------------------------------
443
+ // toMap()
444
+ //
445
+ // Returns the Map object where the collection’s indexes are the keys and
446
+ // the elements are its values.
447
+ //---------------------------------------------------------------------------
448
+ toMap() {
449
+ errors.assertArgCount(arguments, 0, 0);
450
+ if (!this.isCollection) {
451
+ errors.throwErr(errors.ERR_OBJECT_IS_NOT_A_COLLECTION,
452
+ this.name);
453
+ }
454
+ const result = new Map();
455
+ this.getKeys().forEach(element => {
456
+ result.set(element, this.getElement(element));
457
+ });
458
+ return result;
459
+ }
460
+
391
461
  }
392
462
 
393
463
  // method for transforming the error
@@ -421,6 +491,7 @@ wrapFns(BaseDbObject.prototype,
421
491
  "getNextIndex",
422
492
  "getPrevIndex",
423
493
  "getValues",
494
+ "toMap",
424
495
  "hasElement",
425
496
  "setElement",
426
497
  "trim"
package/lib/errors.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2022, 2023, Oracle and/or its affiliates.
1
+ // Copyright (c) 2022, 2024, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -107,7 +107,6 @@ const ERR_POOL_HAS_BUSY_CONNECTIONS = 104;
107
107
  const ERR_NAN_VALUE = 105;
108
108
  const ERR_INTERNAL = 106;
109
109
  const ERR_INVALID_REF_CURSOR = 107;
110
- const ERR_LOB_CLOSED = 108;
111
110
  const ERR_INVALID_TYPE_NUM = 109;
112
111
  const ERR_INVALID_ORACLE_TYPE_NUM = 110;
113
112
  const ERR_UNEXPECTED_NEGATIVE_INTEGER = 111;
@@ -138,6 +137,14 @@ const ERR_MISSING_BIND_VALUE = 137;
138
137
  const ERR_SERVER_VERSION_NOT_SUPPORTED = 138;
139
138
  const ERR_UNEXPECTED_XML_TYPE = 139;
140
139
  const ERR_WRONG_USER_FORMAT_EXTAUTH_PROXY = 140;
140
+ const ERR_TOO_MANY_BATCH_ERRORS = 141;
141
+ const ERR_WRONG_LENGTH_FOR_DBOBJECT_ATTR = 142;
142
+ const ERR_WRONG_LENGTH_FOR_DBOBJECT_ELEM = 143;
143
+ const ERR_VECTOR_FORMAT_NOT_SUPPORTED = 144;
144
+ const ERR_VECTOR_VERSION_NOT_SUPPORTED = 145;
145
+ const ERR_OBJECT_IS_NOT_A_COLLECTION = 146;
146
+ const ERR_CURSOR_HAS_BEEN_CLOSED = 147;
147
+ const ERR_DML_RETURNING_DUP_BINDS = 149;
141
148
 
142
149
  // Oracle Net layer errors start from 500
143
150
  const ERR_CONNECTION_CLOSED = 500;
@@ -168,9 +175,8 @@ const WRN_COMPILATION_CREATE = 700;
168
175
  // define mapping for ODPI-C, OCI & ORA errors that need to be wrapped
169
176
  // with NJS errors
170
177
  const adjustErrorXref = new Map();
171
- adjustErrorXref.set("DPI-1010", ERR_CONNECTION_CLOSED);
178
+ adjustErrorXref.set("DPI-1010", ERR_INVALID_CONNECTION);
172
179
  adjustErrorXref.set("DPI-1024", [ERR_INVALID_COLL_INDEX_GET, 'at index ([0-9]+) does']);
173
- adjustErrorXref.set("DPI-1040", ERR_LOB_CLOSED);
174
180
  adjustErrorXref.set("DPI-1044", ERR_ORACLE_NUMBER_NO_REPR);
175
181
  adjustErrorXref.set("DPI-1055", ERR_NAN_VALUE);
176
182
  adjustErrorXref.set("DPI-1063", ERR_EXEC_MODE_ONLY_FOR_DML);
@@ -190,7 +196,7 @@ const messages = new Map();
190
196
  messages.set(ERR_INVALID_POOL, // NJS-002
191
197
  'invalid pool');
192
198
  messages.set(ERR_INVALID_CONNECTION, // NJS-003
193
- 'invalid connection');
199
+ 'invalid or closed connection');
194
200
  messages.set(ERR_INVALID_PROPERTY_VALUE, // NJS-004
195
201
  'invalid value for property "%s"');
196
202
  messages.set(ERR_INVALID_PARAMETER_VALUE, // NJS-005
@@ -341,8 +347,6 @@ messages.set(ERR_INTERNAL, // NJS-106
341
347
  'internal error: %s');
342
348
  messages.set(ERR_INVALID_REF_CURSOR, // NJS-107
343
349
  'invalid cursor');
344
- messages.set(ERR_LOB_CLOSED, // NJS-108
345
- 'LOB was already closed');
346
350
  messages.set(ERR_INVALID_TYPE_NUM, // NJS-109
347
351
  'invalid type number %d');
348
352
  messages.set(ERR_INVALID_ORACLE_TYPE_NUM, // NJS-110
@@ -354,7 +358,7 @@ messages.set(ERR_INTEGER_TOO_LARGE, // NJS-112
354
358
  messages.set(ERR_UNEXPECTED_DATA, // NJS-113
355
359
  'unexpected data received: %s');
356
360
  messages.set(ERR_OSON_FIELD_NAME_LIMITATION, // NJS-114
357
- 'OSON field names may not exceed 255 UTF-8 encoded bytes');
361
+ 'OSON field names may not exceed %d UTF-8 encoded bytes');
358
362
  messages.set(ERR_ORACLE_NUMBER_NO_REPR, // NJS-115
359
363
  'value cannot be represented as an Oracle Database number');
360
364
  messages.set(ERR_UNSUPPORTED_VERIFIER_TYPE, // NJS-116
@@ -403,6 +407,22 @@ messages.set(ERR_UNEXPECTED_XML_TYPE, // NJS-139
403
407
  'unexpected XML type with flag %d');
404
408
  messages.set(ERR_WRONG_USER_FORMAT_EXTAUTH_PROXY, // NJS-140
405
409
  'user name must be enclosed in [] when using external authentication with a proxy user');
410
+ messages.set(ERR_TOO_MANY_BATCH_ERRORS, // NJS-141
411
+ 'the number of batch errors from executemany() exceeds 65535');
412
+ messages.set(ERR_WRONG_LENGTH_FOR_DBOBJECT_ATTR, // NJS-142
413
+ 'value too large for attribute %s of object %s (actual: %d, maximum: %d)');
414
+ messages.set(ERR_WRONG_LENGTH_FOR_DBOBJECT_ELEM, // NJS-143
415
+ 'value too large for element %d of object %s (actual: %d, maximum: %d)');
416
+ messages.set(ERR_VECTOR_FORMAT_NOT_SUPPORTED, // NJS-144
417
+ 'VECTOR format %d is not supported');
418
+ messages.set(ERR_VECTOR_VERSION_NOT_SUPPORTED, // NJS-145
419
+ 'VECTOR version %d is not supported');
420
+ messages.set(ERR_OBJECT_IS_NOT_A_COLLECTION, // NJS-146
421
+ 'object %s is not a collection');
422
+ messages.set(ERR_CURSOR_HAS_BEEN_CLOSED, // NJS-147
423
+ 'cursor has been closed by the database');
424
+ messages.set(ERR_DML_RETURNING_DUP_BINDS, // NJS-149
425
+ 'the bind variable placeholder "%s" cannot be used both before and after the RETURNING clause in a DML RETURNING statement');
406
426
 
407
427
  // Oracle Net layer errors
408
428
 
@@ -529,6 +549,19 @@ function assertParamPropUnsignedInt(obj, parameterNum, propName) {
529
549
  }
530
550
  }
531
551
 
552
+ //-----------------------------------------------------------------------------
553
+ // assertParamPropUnsignedIntNonZero()
554
+ //
555
+ // Asserts that the property value of a parameter is a positive integer value
556
+ // (or undefined).
557
+ //-----------------------------------------------------------------------------
558
+ function assertParamPropUnsignedIntNonZero(obj, parameterNum, propName) {
559
+ if (obj[propName] !== undefined) {
560
+ assertParamPropValue(Number.isInteger(obj[propName]) && obj[propName] > 0,
561
+ parameterNum, propName);
562
+ }
563
+ }
564
+
532
565
  //-----------------------------------------------------------------------------
533
566
  // assertParamPropString()
534
567
  //
@@ -625,7 +658,7 @@ function transformErr(err, fnOpt) {
625
658
  err.code = err.message.substr(0, pos);
626
659
  /* add Oracle Database Error Help Portal URL for database error
627
660
  messages, but only in thin mode since this is done
628
- automatically in thick mode with Oracle Client 23c and higher
661
+ automatically in thick mode with Oracle Client 23ai and higher
629
662
  */
630
663
  const settings = require('./settings.js');
631
664
  if (err.errorNum && settings.thin) {
@@ -756,7 +789,6 @@ module.exports = {
756
789
  ERR_INVALID_REF_CURSOR,
757
790
  ERR_UNSUPPORTED_VERIFIER_TYPE,
758
791
  ERR_NAN_VALUE,
759
- ERR_LOB_CLOSED,
760
792
  ERR_ORACLE_NUMBER_NO_REPR,
761
793
  ERR_INVALID_SERVICE_NAME,
762
794
  ERR_INVALID_SID,
@@ -789,6 +821,14 @@ module.exports = {
789
821
  ERR_SERVER_VERSION_NOT_SUPPORTED,
790
822
  ERR_UNEXPECTED_XML_TYPE,
791
823
  ERR_WRONG_USER_FORMAT_EXTAUTH_PROXY,
824
+ ERR_TOO_MANY_BATCH_ERRORS,
825
+ ERR_WRONG_LENGTH_FOR_DBOBJECT_ATTR,
826
+ ERR_WRONG_LENGTH_FOR_DBOBJECT_ELEM,
827
+ ERR_VECTOR_FORMAT_NOT_SUPPORTED,
828
+ ERR_VECTOR_VERSION_NOT_SUPPORTED,
829
+ ERR_OBJECT_IS_NOT_A_COLLECTION,
830
+ ERR_CURSOR_HAS_BEEN_CLOSED,
831
+ ERR_DML_RETURNING_DUP_BINDS,
792
832
  ERR_CONNECTION_CLOSED_CODE: `${ERR_PREFIX}-${ERR_CONNECTION_CLOSED}`,
793
833
  WRN_COMPILATION_CREATE,
794
834
  assert,
@@ -798,6 +838,7 @@ module.exports = {
798
838
  assertParamPropInt,
799
839
  assertParamPropString,
800
840
  assertParamPropUnsignedInt,
841
+ assertParamPropUnsignedIntNonZero,
801
842
  assertParamPropValue,
802
843
  assertParamValue,
803
844
  assertPropValue,
@@ -37,6 +37,7 @@ class ConnectionImpl {
37
37
  this._inProgress = false;
38
38
  this._dbObjectTypes = new Map();
39
39
  this._requestQueue = [];
40
+ this._osonMaxFieldNameSize = 255;
40
41
  }
41
42
 
42
43
  //---------------------------------------------------------------------------
@@ -110,7 +111,7 @@ class ConnectionImpl {
110
111
  // removed once Node-API version 5 is used in the C extension.
111
112
  // ---------------------------------------------------------------------------
112
113
  _isDate(val) {
113
- return (util.isDate(val));
114
+ return (util.types.isDate(val));
114
115
  }
115
116
 
116
117
  //---------------------------------------------------------------------------