oracledb 6.2.0 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) 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.4.0-darwin-x64.node +0 -0
  5. package/build/Release/oracledb-6.4.0-darwin-x64.node-buildinfo.txt +1 -0
  6. package/build/Release/oracledb-6.4.0-js-buildinfo.txt +1 -0
  7. package/build/Release/oracledb-6.4.0-linux-arm64.node +0 -0
  8. package/build/Release/oracledb-6.4.0-linux-arm64.node-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-6.4.0-linux-x64.node +0 -0
  10. package/build/Release/oracledb-6.4.0-linux-x64.node-buildinfo.txt +1 -0
  11. package/build/Release/oracledb-6.4.0-win32-x64.node +0 -0
  12. package/build/Release/oracledb-6.4.0-win32-x64.node-buildinfo.txt +1 -0
  13. package/examples/README.md +29 -8
  14. package/examples/dbconfig.js +50 -26
  15. package/examples/example.js +6 -4
  16. package/lib/aqQueue.js +8 -8
  17. package/lib/connection.js +121 -9
  18. package/lib/constants.js +7 -1
  19. package/lib/dbObject.js +72 -1
  20. package/lib/errors.js +45 -8
  21. package/lib/future.js +53 -0
  22. package/lib/impl/connection.js +56 -0
  23. package/lib/{thin/protocol → impl/datahandlers}/buffer.js +51 -39
  24. package/lib/impl/datahandlers/constants.js +105 -0
  25. package/lib/{thin/protocol → impl/datahandlers}/oson.js +19 -1
  26. package/lib/impl/datahandlers/vector.js +156 -0
  27. package/lib/impl/pool.js +14 -3
  28. package/lib/impl/resultset.js +65 -11
  29. package/lib/lob.js +22 -6
  30. package/lib/oracledb.js +47 -8
  31. package/lib/pool.js +20 -1
  32. package/lib/poolStatistics.js +3 -1
  33. package/lib/settings.js +30 -6
  34. package/lib/sodaDocCursor.js +14 -1
  35. package/lib/thin/connection.js +146 -146
  36. package/lib/thin/dbObject.js +49 -3
  37. package/lib/thin/index.js +1 -1
  38. package/lib/thin/lob.js +6 -6
  39. package/lib/thin/pool.js +25 -6
  40. package/lib/thin/protocol/capabilities.js +6 -2
  41. package/lib/thin/protocol/constants.js +50 -65
  42. package/lib/thin/protocol/messages/auth.js +6 -2
  43. package/lib/thin/protocol/messages/base.js +50 -32
  44. package/lib/thin/protocol/messages/dataType.js +10 -6
  45. package/lib/thin/protocol/messages/lobOp.js +7 -8
  46. package/lib/thin/protocol/messages/withData.js +91 -24
  47. package/lib/thin/protocol/packet.js +58 -4
  48. package/lib/thin/protocol/utils.js +1 -1
  49. package/lib/thin/sqlnet/connStrategy.js +8 -4
  50. package/lib/thin/sqlnet/constants.js +138 -138
  51. package/lib/thin/sqlnet/navNodes.js +5 -5
  52. package/lib/thin/sqlnet/networkSession.js +22 -3
  53. package/lib/thin/sqlnet/ntTcp.js +7 -7
  54. package/lib/thin/statement.js +8 -8
  55. package/lib/thin/statementCache.js +167 -0
  56. package/lib/thin/util.js +15 -4
  57. package/lib/transformer.js +13 -4
  58. package/lib/types.js +17 -2
  59. package/lib/util.js +37 -0
  60. package/lib/version.js +2 -2
  61. package/package.json +1 -1
  62. package/build/Release/oracledb-6.2.0-darwin-x64.node +0 -0
  63. package/build/Release/oracledb-6.2.0-darwin-x64.node-buildinfo.txt +0 -1
  64. package/build/Release/oracledb-6.2.0-js-buildinfo.txt +0 -1
  65. package/build/Release/oracledb-6.2.0-linux-arm64.node +0 -0
  66. package/build/Release/oracledb-6.2.0-linux-arm64.node-buildinfo.txt +0 -1
  67. package/build/Release/oracledb-6.2.0-linux-x64.node +0 -0
  68. package/build/Release/oracledb-6.2.0-linux-x64.node-buildinfo.txt +0 -1
  69. package/build/Release/oracledb-6.2.0-win32-x64.node +0 -0
  70. package/build/Release/oracledb-6.2.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.2.0
1
+ # node-oracledb version 6.4.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.2.0 to connect Node.js 14.6, or later, to Oracle
7
+ Use node-oracledb 6.4.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.4.0-darwin-x64.node v18.17.0 df971fa2503fcf9ab4a63f2f2508f5fb5780c0e1 31cd3b6682f32ad860df63d1dd06e3bf1c5e62aa Thu, 29 Feb 2024 13:53:47 GMT
@@ -0,0 +1 @@
1
+ df971fa2503fcf9ab4a63f2f2508f5fb5780c0e1
@@ -0,0 +1 @@
1
+ oracledb-6.4.0-linux-arm64.node v18.19.0 df971fa2503fcf9ab4a63f2f2508f5fb5780c0e1 31cd3b6682f32ad860df63d1dd06e3bf1c5e62aa Thu, 29 Feb 2024 15:01:23 GMT
@@ -0,0 +1 @@
1
+ oracledb-6.4.0-linux-x64.node v16.20.2 df971fa2503fcf9ab4a63f2f2508f5fb5780c0e1 31cd3b6682f32ad860df63d1dd06e3bf1c5e62aa Thu, 29 Feb 2024 14:56:18 GMT
@@ -0,0 +1 @@
1
+ oracledb-6.4.0-win32-x64.node v18.16.0 df971fa2503fcf9ab4a63f2f2508f5fb5780c0e1 31cd3b6682f32ad860df63d1dd06e3bf1c5e62aa Thu, 29 Feb 2024 15:35:39 GMT
@@ -1,8 +1,7 @@
1
1
  # Node-oracledb Examples
2
2
 
3
- The directory in node-oracledb's [Github repository](https://github.com/oracle/node-oracledb/tree/main/examples) contains a lot of [node-oracledb](https://www.npmjs.com/package/oracledb)
4
- examples. Documentation is
5
- [here](https://node-oracledb.readthedocs.io/en/latest/).
3
+ The directory in node-oracledb's [Github repository](https://github.com/oracle/node-oracledb/tree/main/examples) contains a lot of [node-oracledb](https://www.npmjs.com/package/oracledb) examples.
4
+ Documentation is [here](https://node-oracledb.readthedocs.io/en/latest/).
6
5
 
7
6
  To run the examples:
8
7
 
@@ -11,18 +10,37 @@ To run the examples:
11
10
  - Ensure that you navigate to the `examples` directory in your terminal window
12
11
  or IDE, where you are running the samples.
13
12
 
14
- - Review `dbconfig.js`. In your terminal window or IDE, set the environment
15
- variables. For example, set `NODE_ORACLEDB_PASSWORD` to the value of your
16
- database password.
13
+ - Review `dbconfig.js`.
17
14
 
18
- - Review the samples and then run them individually. For example, to see what
15
+ In your terminal window or IDE, set the following environment variables to
16
+ provide credentials for the `dbconfig.js` file.
17
+
18
+ - `NODE_ORACLEDB_USER` must be set to the database user.
19
+
20
+ - `NODE_ORACLEDB_PASSWORD` must be set to the database password.
21
+
22
+ - `NODE_ORACLEDB_CONNECTIONSTRING` must be set to the connection string that points to your database's location.
23
+
24
+ - `NODE_ORACLEDB_EXTERNALAUTH` provides the options for enabling external authentication. Setting this environment variable to "true" will enable external authentication. To ensure external authentication works, firstly make sure the Oracle external authentication service is correctly configured. See [Documentation for External Authentication](https://node-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html#extauth) for details.
25
+
26
+ - `NODE_ORACLEDB_DRIVER_MODE` provides an option to set the 'Thin' or 'Thick' modes of node-oracledb. Setting this environment variable to "thick" will enable Thick mode.
27
+ Setting it to "thin" will retain the Thin mode. The default mode is Thin.
28
+
29
+ - `NODE_ORACLEDB_WALLET_LOCATION` must be set to the local directory name for the wallets that may be required for mutual TLS (mTLS) connections, especially to Oracle Cloud
30
+ Autonomous Databases optionally. The wallet location can also be provided as a part of the database connect string.
31
+
32
+ - `NODE_ORACLEDB_WALLET_PASSWORD` must set to the password for the wallets that may be required for mutual TLS (mTLS) connections, especially to Oracle Cloud Autonomous Databases.
33
+
34
+ - `NODE_ORACLEDB_CLIENT_LIB_DIR` provides an optional path for the Oracle Client libraries to be used on Windows and macOS platforms, when using Thick mode in node-oracledb.
35
+
36
+ Review the examples and then run them individually. For example, to see what
19
37
  the file `example.js` does, use:
20
38
 
21
39
  ```
22
40
  node example.js
23
41
  ```
24
42
 
25
- - After running examples, the demonstration objects can be dropped with
43
+ After running the examples, the demonstration objects can be dropped with
26
44
  `demodrop.js`:
27
45
 
28
46
  ```
@@ -45,6 +63,7 @@ File Name | Description
45
63
  [`aqobject.js`](aqobject.js) | Oracle Advanced Queuing (AQ) example passing an Oracle Database object
46
64
  [`aqoptions.js`](aqoptions.js) | Oracle Advanced Queuing (AQ) example setting options and message attributes
47
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.
48
67
  [`blobhttp.js`](blobhttp.js) | Simple web app that streams an image
49
68
  [`calltimeout.js`](calltimeout.js) | Shows how to cancel a SQL statement if it doesn't complete in a specified time
50
69
  [`connect.js`](connect.js) | Basic example for creating a standalone (non-pooled) connection
@@ -94,6 +113,8 @@ File Name | Description
94
113
  [`resultset2.js`](resultset2.js) | Executes a query and uses a ResultSet to fetch batches of rows with `getRows()`
95
114
  [`resultsettoquerystream.js`](resultsettoquerystream.js) | Converts a ResultSet returned from `execute()` into a Readable Stream.
96
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.
97
118
  [`select1.js`](select1.js) | Executes a basic query without using a connection pool or ResultSet
98
119
  [`select2.js`](select2.js) | Executes queries to show array and object output formats
99
120
  [`selectgeometry.js`](selectgeometry.js) | Insert and query Oracle Spatial geometries
@@ -26,17 +26,16 @@
26
26
  * dbconfig.js
27
27
  *
28
28
  * DESCRIPTION
29
- * Holds the credentials used by node-oracledb examples to connect
30
- * to the database. Production applications should consider using
31
- * External Authentication to avoid hard coded credentials.
29
+ * Holds the credentials used by node-oracledb examples to connect to the
30
+ * database. Production applications should consider using External
31
+ * Authentication to avoid hard coded credentials.
32
32
  *
33
33
  * To create a database user, see
34
34
  * https://blogs.oracle.com/sql/post/how-to-create-users-grant-them-privileges-and-remove-them-in-oracle-database
35
35
  *
36
- * Applications can set the connectString value to an Easy Connect
37
- * string, or a Net Service Name from a tnsnames.ora file or
38
- * external naming service, or it can be the name of a local Oracle
39
- * database instance.
36
+ * Applications can set the connectString value to an Easy Connect string,
37
+ * or a Net Service Name from the tnsnames.ora file or an external naming
38
+ * service, or it can be the name of a local Oracle Database instance.
40
39
  *
41
40
  * If node-oracledb is linked with Instant Client, then an Easy
42
41
  * Connect string is generally appropriate. The basic syntax is:
@@ -50,20 +49,20 @@
50
49
  * refer to the latest Oracle documentation on Easy Connect syntax:
51
50
  * https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-B0437826-43C1-49EC-A94D-B650B6A4A6EE
52
51
  *
53
- * If using a tnsnames.ora file, the file can be in a default
54
- * location such as $ORACLE_HOME/network/admin/tnsnames.ora or
55
- * /etc/tnsnames.ora. Alternatively set the TNS_ADMIN environment
56
- * variable and put the file in $TNS_ADMIN/tnsnames.ora.
52
+ * If using a tnsnames.ora file, the file can be in a default location such
53
+ * as $ORACLE_HOME/network/admin/tnsnames.ora or /etc/tnsnames.ora.
54
+ * Alternatively set the TNS_ADMIN environment variable and put the file in
55
+ * $TNS_ADMIN/tnsnames.ora.
57
56
  *
58
- * If connectString is not specified, the empty string "" is used
59
- * which indicates to connect to the local, default database.
57
+ * If connectString is not specified, the empty string "" is used which
58
+ * indicates to connect to the local, default database.
60
59
  *
61
- * External Authentication can be used by setting the optional
62
- * property externalAuth to true. External Authentication allows
63
- * applications to use an external password store such as Oracle
64
- * Wallet so passwords do not need to be hard coded into the
65
- * application. The user and password properties for connecting or
66
- * creating a pool should not be set when externalAuth is true.
60
+ * External Authentication can be used by setting the optional property
61
+ * externalAuth to true. External Authentication allows applications to use
62
+ * an external password store such as Oracle Wallet, so that passwords
63
+ * do not need to be hard coded into the application. The user and password
64
+ * application. The user and password properties for connecting or creating
65
+ * a pool should not be set when externalAuth is true.
67
66
  *
68
67
  * TROUBLESHOOTING
69
68
  * Refer to the Error Handling section in node-oracledb documentation
@@ -73,21 +72,46 @@
73
72
  *
74
73
  *****************************************************************************/
75
74
 
76
- module.exports = {
77
- user : process.env.NODE_ORACLEDB_USER,
75
+ const config = {
76
+ user: process.env.NODE_ORACLEDB_USER,
78
77
 
79
78
  // Get the password from the environment variable
80
79
  // NODE_ORACLEDB_PASSWORD. The password could also be a hard coded
81
80
  // string (not recommended), or it could be prompted for.
82
- // Alternatively use External Authentication so that no password is
83
- // needed.
84
- password : process.env.NODE_ORACLEDB_PASSWORD,
81
+ // Alternatively use External Authentication so that no password is needed.
82
+ password: process.env.NODE_ORACLEDB_PASSWORD,
85
83
 
86
84
  // For information on connection strings see:
87
85
  // https://node-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html#connectionstrings
88
- connectString : process.env.NODE_ORACLEDB_CONNECTIONSTRING,
86
+ connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING,
89
87
 
90
88
  // Setting externalAuth is optional. It defaults to false. See:
91
89
  // https://node-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html#extauth
92
- externalAuth : process.env.NODE_ORACLEDB_EXTERNALAUTH ? true : false,
90
+ externalAuth: process.env.NODE_ORACLEDB_EXTERNALAUTH ? true : false,
93
91
  };
92
+
93
+ // Set the NODE_ORACLEDB_WALLET_LOCATION and NODE_ORACLEDB_WALLET_PASSWORD
94
+ // environment variables for database connections that require wallets.
95
+ // For example, creating and dropping a user.
96
+ // See the README.md file in this directory for more details.
97
+ if (process.env.NODE_ORACLEDB_WALLET_PASSWORD) {
98
+ config.walletPassword = process.env.NODE_ORACLEDB_WALLET_PASSWORD;
99
+ }
100
+
101
+ if (process.env.NODE_ORACLEDB_WALLET_LOCATION) {
102
+ config.walletLocation = process.env.NODE_ORACLEDB_WALLET_LOCATION;
103
+ }
104
+
105
+ // Set the NODE_ORACLEDB_DBA_USER and NODE_ORACLEDB_DBA_PASSWORD environment
106
+ // variables for database operations which require SYSDBA privileges.
107
+ // For example, creating and dropping a user. See the README.md file in this
108
+ // directory for more details.
109
+ if (process.env.NODE_ORACLEDB_DBA_USER) {
110
+ config.DBA_user = process.env.NODE_ORACLEDB_DBA_USER;
111
+ }
112
+
113
+ if (process.env.NODE_ORACLEDB_DBA_PASSWORD) {
114
+ config.DBA_password = process.env.NODE_ORACLEDB_DBA_PASSWORD;
115
+ }
116
+
117
+ module.exports = config;
@@ -54,14 +54,16 @@ if (process.env.NODE_ORACLEDB_DRIVER_MODE === 'thick') {
54
54
  // is not correct, you will get a DPI-1047 error. See the node-oracledb
55
55
  // installation documentation.
56
56
  let clientOpts = {};
57
- if (process.platform === 'win32') { // Windows
58
- clientOpts = { libDir: 'C:\\oracle\\instantclient_19_17' };
59
- } else if (process.platform === 'darwin' && process.arch === 'x64') { // macOS Intel
60
- clientOpts = { libDir: process.env.HOME + '/Downloads/instantclient_19_8' };
57
+ // On Windows and macOS Intel platforms, set the environment
58
+ // variable NODE_ORACLEDB_CLIENT_LIB_DIR to the Oracle Client library path
59
+ if (process.platform === 'win32' || (process.platform === 'darwin' && process.arch === 'x64')) {
60
+ clientOpts = { libDir: process.env.NODE_ORACLEDB_CLIENT_LIB_DIR };
61
61
  }
62
62
  oracledb.initOracleClient(clientOpts); // enable node-oracledb Thick mode
63
63
  }
64
64
 
65
+ console.log(oracledb.thin ? 'Running in thin mode' : 'Running in thick mode');
66
+
65
67
  async function run() {
66
68
  let connection;
67
69
 
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)
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) {
@@ -197,6 +201,9 @@ class Connection extends EventEmitter {
197
201
  typeof value === 'string' ||
198
202
  typeof value === 'boolean' ||
199
203
  Array.isArray(value) ||
204
+ value instanceof Float32Array ||
205
+ value instanceof Float64Array ||
206
+ value instanceof Int8Array ||
200
207
  Buffer.isBuffer(value) ||
201
208
  util.isDate(value) ||
202
209
  value instanceof Lob ||
@@ -833,6 +840,29 @@ class Connection extends EventEmitter {
833
840
  this._impl.setECID(value);
834
841
  }
835
842
 
843
+ //---------------------------------------------------------------------------
844
+ // decode()
845
+ //
846
+ // Decodes OSON Buffer to JS data type.
847
+ //---------------------------------------------------------------------------
848
+ decodeOSON(buf) {
849
+ errors.assertArgCount(arguments, 1, 1);
850
+ errors.assertParamValue(Buffer.isBuffer(buf), 1);
851
+ const decoder = new oson.OsonDecoder(buf);
852
+ return decoder.decode();
853
+ }
854
+
855
+
856
+ //---------------------------------------------------------------------------
857
+ // encode()
858
+ //
859
+ // Encodes the JS value into OSON bytes.
860
+ //---------------------------------------------------------------------------
861
+ encodeOSON(value) {
862
+ const encoder = new oson.OsonEncoder();
863
+ return encoder.encode(transformer.transformJsonValue(value));
864
+ }
865
+
836
866
  //---------------------------------------------------------------------------
837
867
  // execute()
838
868
  //
@@ -844,13 +874,24 @@ class Connection extends EventEmitter {
844
874
  let options = {};
845
875
 
846
876
  // 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);
877
+ if (nodbUtil.isObject(sql) && typeof sql.statement === 'string') {
878
+ errors.assertArgCount(arguments, 1, 2);
879
+ if (sql.values) {
880
+ binds = await this._processExecuteBinds(sql.values);
881
+ }
882
+ sql = sql.statement;
883
+ if (arguments.length == 2) {
884
+ options = this._verifyExecOpts(a2, false);
885
+ }
886
+ } else {
887
+ errors.assertArgCount(arguments, 1, 3);
888
+ errors.assertParamValue(typeof sql === 'string', 1);
889
+ if (arguments.length >= 2) {
890
+ binds = await this._processExecuteBinds(a2);
891
+ }
892
+ if (arguments.length == 3) {
893
+ options = this._verifyExecOpts(a3, false);
894
+ }
854
895
  }
855
896
  this._addDefaultsToExecOpts(options);
856
897
  errors.assert(this._impl, errors.ERR_INVALID_CONNECTION);
@@ -865,6 +906,11 @@ class Connection extends EventEmitter {
865
906
  throw err;
866
907
  }
867
908
 
909
+ // convert ORA errors to NJS
910
+ if (result.warning) {
911
+ result.warning = errors.transformErr(result.warning);
912
+ }
913
+
868
914
  // process queries; if a result set is not desired, fetch all of the rows
869
915
  // from the result set and then destroy the result set
870
916
  if (result.resultSet !== undefined) {
@@ -941,6 +987,11 @@ class Connection extends EventEmitter {
941
987
  const result = await this._impl.execute(sql, numIters, binds, options,
942
988
  true);
943
989
 
990
+ // convert ORA warnings to NJS
991
+ if (result.warning) {
992
+ result.warning = errors.transformErr(result.warning);
993
+ }
994
+
944
995
  // process output binds
945
996
  if (result.outBinds !== undefined) {
946
997
  for (let i = 0; i < result.outBinds.length; i++) {
@@ -971,6 +1022,24 @@ class Connection extends EventEmitter {
971
1022
  this._impl.setExternalName(value);
972
1023
  }
973
1024
 
1025
+ //---------------------------------------------------------------------------
1026
+ // dbDomain (READONLY)
1027
+ //
1028
+ // Property for identifying the dbDomain of the Oracle Database.
1029
+ //---------------------------------------------------------------------------
1030
+ get dbDomain() {
1031
+ return this._impl && this._impl.getDbDomain();
1032
+ }
1033
+
1034
+ //---------------------------------------------------------------------------
1035
+ // dbName (READONLY)
1036
+ //
1037
+ // Property for identifying the dbName of the Oracle Database.
1038
+ //---------------------------------------------------------------------------
1039
+ get dbName() {
1040
+ return this._impl && this._impl.getDbName();
1041
+ }
1042
+
974
1043
  //---------------------------------------------------------------------------
975
1044
  // getDbObjectClass()
976
1045
  //
@@ -1080,6 +1149,30 @@ class Connection extends EventEmitter {
1080
1149
  this._impl.isHealthy());
1081
1150
  }
1082
1151
 
1152
+ //---------------------------------------------------------------------------
1153
+ // maxOpenCursors
1154
+ //
1155
+ // Returns maximum number of cursors that can be opened in one session.
1156
+ //---------------------------------------------------------------------------
1157
+ get maxOpenCursors() {
1158
+ return this._impl && this._impl.getMaxOpenCursors();
1159
+ }
1160
+
1161
+ //---------------------------------------------------------------------------
1162
+ // warning
1163
+ //
1164
+ // Returns warningInfo.
1165
+ //---------------------------------------------------------------------------
1166
+ get warning() {
1167
+ let warning = this._impl.getWarning();
1168
+ if (warning) {
1169
+ // Make sure that warning code attribute is populated and ORA error
1170
+ // is converted to NJS, if required
1171
+ warning = errors.transformErr(warning);
1172
+ }
1173
+ return this._impl && warning;
1174
+ }
1175
+
1083
1176
  //---------------------------------------------------------------------------
1084
1177
  // module
1085
1178
  //
@@ -1117,6 +1210,25 @@ class Connection extends EventEmitter {
1117
1210
  return undefined;
1118
1211
  }
1119
1212
 
1213
+ //---------------------------------------------------------------------------
1214
+ // serviceName
1215
+ //
1216
+ // Returns the Oracle Database service name associated with the connection.
1217
+ //---------------------------------------------------------------------------
1218
+ get serviceName() {
1219
+ return this._impl && this._impl.getServiceName();
1220
+ }
1221
+
1222
+ //---------------------------------------------------------------------------
1223
+ // transactionInProgress
1224
+ //
1225
+ // Returns a boolean value based on the presence of an active transaction
1226
+ // on the connection
1227
+ //---------------------------------------------------------------------------
1228
+ get transactionInProgress() {
1229
+ return this._impl && this._impl.getTransactionInProgress();
1230
+ }
1231
+
1120
1232
  //---------------------------------------------------------------------------
1121
1233
  // ping()
1122
1234
  //
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"