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
@@ -0,0 +1,137 @@
1
+ // Copyright (c) 2024, Oracle and/or its affiliates.
2
+
3
+ //-----------------------------------------------------------------------------
4
+ //
5
+ // This software is dual-licensed to you under the Universal Permissive License
6
+ // (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
7
+ // 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
8
+ // either license.
9
+ //
10
+ // If you elect to accept the software under the Apache License, Version 2.0,
11
+ // the following applies:
12
+ //
13
+ // Licensed under the Apache License, Version 2.0 (the "License");
14
+ // you may not use this file except in compliance with the License.
15
+ // You may obtain a copy of the License at
16
+ //
17
+ // https://www.apache.org/licenses/LICENSE-2.0
18
+ //
19
+ // Unless required by applicable law or agreed to in writing, software
20
+ // distributed under the License is distributed on an "AS IS" BASIS,
21
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ // See the License for the specific language governing permissions and
23
+ // limitations under the License.
24
+ //
25
+ //-----------------------------------------------------------------------------
26
+
27
+ 'use strict';
28
+
29
+ const { BaseBuffer, GrowableBuffer } = require('./buffer.js');
30
+ const { Buffer } = require('buffer');
31
+ const constants = require("./constants.js");
32
+ const errors = require("../../errors.js");
33
+
34
+ /**
35
+ * Class used for decoding
36
+ */
37
+ class VectorDecoder extends BaseBuffer {
38
+
39
+ //---------------------------------------------------------------------------
40
+ // decode()
41
+ //
42
+ // Decodes the VECTOR image and returns a JavaScript array corresponding to
43
+ // its contents.
44
+ //---------------------------------------------------------------------------
45
+ decode() {
46
+
47
+ // parse header
48
+ const magicByte = this.readUInt8();
49
+ if (magicByte != constants.TNS_VECTOR_MAGIC_BYTE)
50
+ errors.throwErr(errors.ERR_UNEXPECTED_DATA,
51
+ Buffer.from([magicByte]).toString('hex'));
52
+ const version = this.readUInt8();
53
+ if (version != constants.TNS_VECTOR_VERSION)
54
+ errors.throwErr(errors.ERR_VECTOR_VERSION_NOT_SUPPORTED, version);
55
+ const flags = this.readUInt16BE();
56
+ const vectorFormat = this.readUInt8();
57
+ const numElements = this.readUInt32BE();
58
+ let elementSize, result;
59
+ if (vectorFormat === constants.VECTOR_FORMAT_FLOAT32) {
60
+ elementSize = 4;
61
+ result = new Float32Array(numElements);
62
+ } else if (vectorFormat === constants.VECTOR_FORMAT_FLOAT64) {
63
+ elementSize = 8;
64
+ result = new Float64Array(numElements);
65
+ } else if (vectorFormat === constants.VECTOR_FORMAT_INT8) {
66
+ elementSize = 1;
67
+ result = new Int8Array(numElements);
68
+ } else {
69
+ errors.throwErr(errors.ERR_VECTOR_FORMAT_NOT_SUPPORTED, vectorFormat);
70
+ }
71
+ if (flags & constants.TNS_VECTOR_FLAG_NORM)
72
+ this.skipBytes(8);
73
+
74
+ // parse data
75
+ for (let i = 0; i < numElements; i++) {
76
+ const buf = this.readBytes(elementSize);
77
+ if (vectorFormat === constants.VECTOR_FORMAT_FLOAT32) {
78
+ result[i] = this.parseBinaryFloat(buf);
79
+ } else if (vectorFormat === constants.VECTOR_FORMAT_FLOAT64) {
80
+ result[i] = this.parseBinaryDouble(buf);
81
+ } else {
82
+ result[i] = buf[0];
83
+ }
84
+ }
85
+
86
+ return result;
87
+ }
88
+
89
+ }
90
+
91
+ class VectorEncoder extends GrowableBuffer {
92
+
93
+ //---------------------------------------------------------------------------
94
+ // encode()
95
+ //
96
+ // Encodes the value as OSON and returns a buffer containing the OSON bytes.
97
+ //---------------------------------------------------------------------------
98
+ encode(value) {
99
+
100
+ // determine some basic information about the vector
101
+ let vectorFormat = constants.VECTOR_FORMAT_FLOAT32;
102
+ let writeFn = this.writeBinaryFloat.bind(this);
103
+
104
+ if (Array.isArray(value) || value instanceof Float64Array) {
105
+ vectorFormat = constants.VECTOR_FORMAT_FLOAT64;
106
+ writeFn = this.writeBinaryDouble.bind(this);
107
+ } else if (value instanceof Int8Array) {
108
+ vectorFormat = constants.VECTOR_FORMAT_INT8;
109
+ writeFn = this.writeSB1.bind(this);
110
+ }
111
+
112
+ // Let server generate the norm (TNS_VECTOR_FLAG_NORMSRC)
113
+ const flags = constants.TNS_VECTOR_FLAG_NORM
114
+ | constants.TNS_VECTOR_FLAG_NORMSRC;
115
+
116
+ // write header
117
+ this.writeUInt8(constants.TNS_VECTOR_MAGIC_BYTE);
118
+ this.writeUInt8(constants.TNS_VECTOR_VERSION);
119
+ this.writeUInt16BE(flags);
120
+ this.writeUInt8(vectorFormat);
121
+ this.writeUInt32BE(value.length);
122
+ this.reserveBytes(8);
123
+
124
+ // write data
125
+ value.forEach((element) => {
126
+ writeFn(element);
127
+ });
128
+
129
+ return this.buf.subarray(0, this.pos);
130
+ }
131
+
132
+ }
133
+
134
+ module.exports = {
135
+ VectorDecoder,
136
+ VectorEncoder
137
+ };
package/lib/impl/pool.js CHANGED
@@ -147,6 +147,15 @@ class PoolImpl {
147
147
  errors.throwNotImplemented("getting the pool ping interval");
148
148
  }
149
149
 
150
+ //---------------------------------------------------------------------------
151
+ // getPoolPingTimeout()
152
+ //
153
+ // Returns the pool ping Timeout (milliseconds).
154
+ //---------------------------------------------------------------------------
155
+ getPoolPingTimeout() {
156
+ errors.throwNotImplemented("getting the pool ping Timeout");
157
+ }
158
+
150
159
  //---------------------------------------------------------------------------
151
160
  // getPoolTimeout()
152
161
  //
@@ -33,6 +33,7 @@ const settings = require('../settings.js');
33
33
  const future = require('../future.js');
34
34
  const types = require('../types.js');
35
35
  const Lob = require('../lob.js');
36
+ const oson = require('./datahandlers/oson.js');
36
37
 
37
38
  // define implementation class
38
39
  class ResultSetImpl {
@@ -105,26 +106,42 @@ class ResultSetImpl {
105
106
  let converter;
106
107
  const userConverter = metadata.converter;
107
108
 
108
- // If IsJson is set convert to JSON objects unless
109
+ // If IsJson or IsOson is set, convert to JSON objects unless
109
110
  // user defined output type handler overwrites it.
110
- if (future.oldJsonColumnAsObj && metadata.isJson && metadata.dbType !== types.DB_TYPE_JSON
111
+ if (metadata.dbType !== types.DB_TYPE_JSON && future.oldJsonColumnAsObj
111
112
  && userConverter === undefined) {
112
- const outConverter = async function(val) {
113
- if (!val) {
114
- return val;
115
- }
113
+ let outConverter;
114
+ if (metadata.isOson) {
115
+ outConverter = async function(val) {
116
+ if (!val) {
117
+ return val;
118
+ }
119
+ let result = val;
120
+ if (val instanceof Lob) {
121
+ result = await val.getData();
122
+ }
123
+ const decoder = new oson.OsonDecoder(result);
124
+ return decoder.decode();
125
+ };
126
+ converter = outConverter;
127
+ } else if (metadata.isJson) {
128
+ outConverter = async function(val) {
129
+ if (!val) {
130
+ return val;
131
+ }
116
132
 
117
- let result = val;
118
- if (val instanceof Lob) {
119
- result = await val.getData();
120
- }
121
- if (result instanceof Buffer) {
122
- result = result.toString();
123
- }
124
- result = JSON.parse(result);
125
- return result;
126
- };
127
- converter = outConverter;
133
+ let result = val;
134
+ if (val instanceof Lob) {
135
+ result = await val.getData();
136
+ }
137
+ if (result instanceof Buffer) {
138
+ result = result.toString();
139
+ }
140
+ result = JSON.parse(result);
141
+ return result;
142
+ };
143
+ converter = outConverter;
144
+ }
128
145
  }
129
146
 
130
147
  // in thin mode, Oracle NUMBER values are internally fetched as string in
package/lib/lob.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
  //
@@ -50,7 +50,7 @@ class Lob extends Duplex {
50
50
  // not already been closed (never called directly)
51
51
  async _destroy(err, cb) {
52
52
  // if LOB was already closed, nothing to do!
53
- if (err && err.message.startsWith("NJS-108:"))
53
+ if (err && err.message.startsWith("NJS-003:"))
54
54
  delete this._impl;
55
55
  if (this._impl) {
56
56
  const lobImpl = this._impl;
@@ -185,12 +185,28 @@ class Lob extends Duplex {
185
185
  //---------------------------------------------------------------------------
186
186
  // getData()
187
187
  //
188
- // Returns all of the data in the LOB as a single string or buffer.
188
+ // Return a portion (or all) of the data in the LOB. Note that the amount
189
+ // and offset are in bytes for BLOB and BFILE type LOBs and in UCS - 2 code
190
+ // points for CLOB and NCLOB type LOBs.UCS-2 code points are equivalent
191
+ // to characters for all but supplemental characters.If supplemental
192
+ // characters are in the LOB, the offset and amount will have to be chosen
193
+ // carefully to avoid splitting a character.
194
+ // Returns data in the LOB as a single string or buffer.
189
195
  //---------------------------------------------------------------------------
190
- async getData() {
191
- errors.assertArgCount(arguments, 0, 0);
196
+ async getData(offset, amount) {
197
+ errors.assertArgCount(arguments, 0, 2);
198
+ if (offset === undefined) {
199
+ offset = 1;
200
+ } else {
201
+ errors.assertParamValue(Number.isInteger(offset) && offset > 0, 1);
202
+ }
203
+ if (amount === undefined) {
204
+ amount = 0;
205
+ } else {
206
+ errors.assertParamValue(Number.isInteger(amount) && amount > 0, 2);
207
+ }
192
208
  errors.assert(this._impl, errors.ERR_INVALID_LOB);
193
- return await this._impl.getData();
209
+ return await this._impl.getData(offset, amount);
194
210
  }
195
211
 
196
212
  //---------------------------------------------------------------------------
package/lib/oracledb.js CHANGED
@@ -124,6 +124,16 @@ function _initializeThinDriver() {
124
124
  // Returns a boolean indicating if the supplied value is a valid privilege.
125
125
  //---------------------------------------------------------------------------
126
126
  function _isPrivilege(value) {
127
+ // Privileges are mutually exclusive and cannot be specified together
128
+ // except SYSPRELIM, which cannot be specified alone, it is specified in a
129
+ // combo with SYSOPER or SYSDBA. SYSPRELIM is used only for
130
+ // startup/shutdown
131
+
132
+ // If SYSPRELIM specified, clear the bit
133
+ if (value & constants.SYSPRELIM) {
134
+ value = value ^ constants.SYSPRELIM;
135
+ }
136
+
127
137
  return (
128
138
  value === constants.SYSASM ||
129
139
  value === constants.SYSBACKUP ||
@@ -131,7 +141,6 @@ function _isPrivilege(value) {
131
141
  value === constants.SYSDG ||
132
142
  value === constants.SYSKM ||
133
143
  value === constants.SYSOPER ||
134
- value === constants.SYSPRELIM ||
135
144
  value === constants.SYSRAC
136
145
  );
137
146
  }
@@ -368,6 +377,13 @@ async function _verifyOptions(options, inCreatePool) {
368
377
  outOptions.poolPingInterval = options.poolPingInterval;
369
378
  }
370
379
 
380
+ // poolPingTimeout must be an integer (>= 0)
381
+ if (options.poolPingTimeout !== undefined) {
382
+ errors.assertParamPropValue(Number.isInteger(options.poolPingTimeout) &&
383
+ options.poolPingTimeout >= 0, 1, "poolPingTimeout");
384
+ outOptions.poolPingTimeout = options.poolPingTimeout;
385
+ }
386
+
371
387
  // homogeneous must be a boolean (and defaults to True)
372
388
  outOptions.homogeneous = true;
373
389
  if (options.homogeneous !== undefined) {
@@ -558,6 +574,7 @@ async function createPool(options) {
558
574
  "poolIncrement",
559
575
  "poolTimeout",
560
576
  "poolPingInterval",
577
+ "poolPingTimeout",
561
578
  "queueMax",
562
579
  "queueTimeout");
563
580
 
@@ -824,6 +841,7 @@ module.exports = {
824
841
  AqQueue,
825
842
  BaseDbObject,
826
843
  Connection,
844
+ JsonId: types.JsonId,
827
845
  Lob,
828
846
  Pool,
829
847
  PoolStatistics,
@@ -880,6 +898,7 @@ module.exports = {
880
898
  DB_TYPE_TIMESTAMP_TZ: types.DB_TYPE_TIMESTAMP_TZ,
881
899
  DB_TYPE_VARCHAR: types.DB_TYPE_VARCHAR,
882
900
  DB_TYPE_XMLTYPE: types.DB_TYPE_XMLTYPE,
901
+ DB_TYPE_VECTOR: types.DB_TYPE_VECTOR,
883
902
 
884
903
  // fetchInfo type defaulting
885
904
  DEFAULT: constants.DEFAULT,
@@ -1011,6 +1030,11 @@ module.exports = {
1011
1030
  TPC_END_NORMAL: constants.TPC_END_NORMAL,
1012
1031
  TPC_END_SUSPEND: constants.TPC_END_SUSPEND,
1013
1032
 
1033
+ // vector types
1034
+ VECTOR_FORMAT_FLOAT32: constants.VECTOR_FORMAT_FLOAT32,
1035
+ VECTOR_FORMAT_FLOAT64: constants.VECTOR_FORMAT_FLOAT64,
1036
+ VECTOR_FORMAT_INT8: constants.VECTOR_FORMAT_INT8,
1037
+
1014
1038
  // database type aliases
1015
1039
  BLOB: types.DB_TYPE_BLOB,
1016
1040
  BUFFER: types.DB_TYPE_RAW,
@@ -1113,6 +1137,10 @@ module.exports = {
1113
1137
  return settings.poolPingInterval;
1114
1138
  },
1115
1139
 
1140
+ get poolPingTimeout() {
1141
+ return settings.poolPingTimeout;
1142
+ },
1143
+
1116
1144
  get poolTimeout() {
1117
1145
  return settings.poolTimeout;
1118
1146
  },
@@ -1251,6 +1279,12 @@ module.exports = {
1251
1279
  settings.poolPingInterval = value;
1252
1280
  },
1253
1281
 
1282
+ set poolPingTimeout(value) {
1283
+ errors.assertPropValue(Number.isInteger(value) && value >= 0,
1284
+ "poolPingTimeout");
1285
+ settings.poolPingTimeout = value;
1286
+ },
1287
+
1254
1288
  set poolTimeout(value) {
1255
1289
  errors.assertPropValue(Number.isInteger(value) && value >= 0,
1256
1290
  "poolTimeout");
package/lib/pool.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2016, 2022, Oracle and/or its affiliates.
1
+ // Copyright (c) 2016, 2024, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -628,6 +628,15 @@ class Pool extends EventEmitter {
628
628
  return this._impl.getPoolPingInterval();
629
629
  }
630
630
 
631
+ //---------------------------------------------------------------------------
632
+ // poolPingTimeout
633
+ //
634
+ // Property for the ping timeout associated with the pool.
635
+ //---------------------------------------------------------------------------
636
+ get poolPingTimeout() {
637
+ return this._impl.getPoolPingTimeout();
638
+ }
639
+
631
640
  //---------------------------------------------------------------------------
632
641
  // poolTimeout
633
642
  //
@@ -672,7 +681,7 @@ class Pool extends EventEmitter {
672
681
  errors.assertParamPropBool(options, 1, "enableStatistics");
673
682
  errors.assertParamPropBool(options, 1, "resetStatistics");
674
683
  errors.assertParamPropUnsignedInt(options, 1, "poolMin");
675
- errors.assertParamPropUnsignedInt(options, 1, "poolMax");
684
+ errors.assertParamPropUnsignedIntNonZero(options, 1, "poolMax");
676
685
  errors.assertParamPropUnsignedInt(options, 1, "poolMaxPerShard");
677
686
  errors.assertParamPropUnsignedInt(options, 1, "poolIncrement");
678
687
  errors.assertParamPropInt(options, 1, "poolPingInterval");
@@ -680,6 +689,12 @@ class Pool extends EventEmitter {
680
689
  errors.assertParamPropUnsignedInt(options, 1, "stmtCacheSize");
681
690
  errors.assertParamPropBool(options, 1, "sodaMetaDataCache");
682
691
 
692
+ // poolMax must be greater than or equal to poolMin
693
+ if (options.poolMin > options.poolMax) {
694
+ errors.throwErr(errors.ERR_INVALID_NUMBER_OF_CONNECTIONS, options.poolMax,
695
+ options.poolMin);
696
+ }
697
+
683
698
  // reconfiguration can happen only when status is OPEN
684
699
  this._checkPoolOpen(false);
685
700
 
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2021, 2023, Oracle and/or its affiliates.
1
+ // Copyright (c) 2021, 2024, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -72,6 +72,7 @@ class PoolStatistics {
72
72
  this.poolMaxPerShard = pool.poolMaxPerShard;
73
73
  this.poolMin = pool.poolMin;
74
74
  this.poolPingInterval = pool.poolPingInterval;
75
+ this.poolPingTimeout = pool.poolPingTimeout;
75
76
  this.poolTimeout = pool.poolTimeout;
76
77
  this.queueMax = pool.queueMax;
77
78
  this.queueTimeout = pool.queueTimeout;
@@ -124,6 +125,7 @@ class PoolStatistics {
124
125
  console.log('...poolMaxPerShard:', this.poolMaxPerShard);
125
126
  console.log('...poolMin:', this.poolMin);
126
127
  console.log('...poolPingInterval (seconds):', this.poolPingInterval);
128
+ console.log('...poolPingTimeout (milliseconds):', this.poolPingTimeout);
127
129
  console.log('...poolTimeout (seconds):', this.poolTimeout);
128
130
  console.log('...queueMax:', this.queueMax);
129
131
  console.log('...queueTimeout (milliseconds):', this.queueTimeout);
package/lib/settings.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
  //
@@ -29,6 +29,8 @@
29
29
  const constants = require('./constants.js');
30
30
  const errors = require('./errors.js');
31
31
  const types = require('./types.js');
32
+ const nodbUtil = require("./util.js");
33
+ const vector = require('./impl/datahandlers/vector.js');
32
34
 
33
35
  class Settings {
34
36
 
@@ -51,6 +53,7 @@ class Settings {
51
53
  this.poolMaxPerShard = 0;
52
54
  this.poolMin = 0;
53
55
  this.poolPingInterval = 60;
56
+ this.poolPingTimeout = 5000;
54
57
  this.poolTimeout = 60;
55
58
  this.prefetchRows = 2;
56
59
  this.queueTimeout = 60000;
@@ -60,6 +63,7 @@ class Settings {
60
63
  this.thinDriverInitialized = false;
61
64
  this.createFetchTypeMap(this.fetchAsString, this.fetchAsBuffer);
62
65
  this.fetchTypeHandler = undefined;
66
+ this._JsonId = types.JsonId;
63
67
  }
64
68
 
65
69
  //---------------------------------------------------------------------------
@@ -105,11 +109,29 @@ class Settings {
105
109
  // information).
106
110
  //---------------------------------------------------------------------------
107
111
  _makeDate(useLocal, year, month, day, hour, minute, second, fseconds, offset) {
108
- if (useLocal) {
109
- return new Date(year, month - 1, day, hour, minute, second, fseconds);
110
- }
111
- return new Date(Date.UTC(year, month - 1, day, hour, minute, second,
112
- fseconds) - offset * 60000);
112
+ return nodbUtil.makeDate(useLocal, year, month, day, hour, minute, second, fseconds, offset);
113
+ }
114
+
115
+ //---------------------------------------------------------------------------
116
+ // _decodeVector()
117
+ //
118
+ // Returns a typed array by decoding buffer.
119
+ //
120
+ //---------------------------------------------------------------------------
121
+ _decodeVector(buffer) {
122
+ const decoder = new vector.VectorDecoder(buffer);
123
+ return decoder.decode();
124
+ }
125
+
126
+ //---------------------------------------------------------------------------
127
+ // _encodeVector()
128
+ //
129
+ // Create a Vector image from typedarray
130
+ //
131
+ //---------------------------------------------------------------------------
132
+ _encodeVector(value) {
133
+ const encoder = new vector.VectorEncoder();
134
+ return encoder.encode(value);
113
135
  }
114
136
 
115
137
  //---------------------------------------------------------------------------
@@ -159,6 +181,9 @@ class Settings {
159
181
  map.set(types.DB_TYPE_CLOB, types.DB_TYPE_LONG);
160
182
  map.set(types.DB_TYPE_NCLOB, types.DB_TYPE_LONG_NVARCHAR);
161
183
  break;
184
+ case types.DB_TYPE_VECTOR:
185
+ map.set(types.DB_TYPE_VECTOR, types.DB_TYPE_LONG);
186
+ break;
162
187
  case types.DB_TYPE_RAW:
163
188
  map.set(types.DB_TYPE_RAW, types.DB_TYPE_VARCHAR);
164
189
  break;
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1
+ // Copyright (c) 2018, 2024, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -60,6 +60,19 @@ class SodaDocCursor {
60
60
  }
61
61
  }
62
62
 
63
+ [Symbol.asyncIterator]() {
64
+ const cursor = this;
65
+ return {
66
+ async next() {
67
+ const doc = await cursor.getNext();
68
+ return {value: doc, done: doc === undefined};
69
+ },
70
+ return() {
71
+ return {done: true};
72
+ }
73
+ };
74
+ }
75
+
63
76
  }
64
77
 
65
78
  nodbUtil.wrapFns(SodaDocCursor.prototype,