oracledb 5.5.0 → 6.0.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 (107) hide show
  1. package/CHANGELOG.md +1 -1875
  2. package/LICENSE.txt +8 -222
  3. package/NOTICE.txt +1 -1
  4. package/README.md +38 -30
  5. package/SECURITY.md +38 -0
  6. package/build/Release/oracledb-6.0.0-darwin-x64.node +0 -0
  7. package/build/Release/oracledb-6.0.0-darwin-x64.node-buildinfo.txt +1 -0
  8. package/build/Release/oracledb-6.0.0-js-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-6.0.0-linux-arm64.node +0 -0
  10. package/build/Release/oracledb-6.0.0-linux-arm64.node-buildinfo.txt +1 -0
  11. package/build/Release/oracledb-6.0.0-linux-x64.node +0 -0
  12. package/build/Release/oracledb-6.0.0-linux-x64.node-buildinfo.txt +1 -0
  13. package/build/Release/oracledb-6.0.0-win32-x64.node +0 -0
  14. package/build/Release/oracledb-6.0.0-win32-x64.node-buildinfo.txt +1 -0
  15. package/examples/README.md +113 -0
  16. package/examples/dbconfig.js +100 -0
  17. package/examples/example.js +156 -0
  18. package/index.js +26 -0
  19. package/lib/aqDeqOptions.js +146 -7
  20. package/lib/aqEnqOptions.js +59 -7
  21. package/lib/aqMessage.js +118 -7
  22. package/lib/aqQueue.js +242 -53
  23. package/lib/connection.js +1324 -465
  24. package/lib/constants.js +203 -0
  25. package/lib/dbObject.js +346 -32
  26. package/lib/errors.js +781 -0
  27. package/lib/impl/aqDeqOptions.js +197 -0
  28. package/lib/impl/aqEnqOptions.js +89 -0
  29. package/lib/impl/aqMessage.js +134 -0
  30. package/lib/impl/aqQueue.js +81 -0
  31. package/lib/impl/connection.js +529 -0
  32. package/lib/impl/dbObject.js +159 -0
  33. package/lib/impl/index.js +59 -0
  34. package/lib/impl/lob.js +85 -0
  35. package/lib/impl/pool.js +195 -0
  36. package/lib/impl/resultset.js +223 -0
  37. package/lib/impl/sodaCollection.js +174 -0
  38. package/lib/impl/sodaDatabase.js +81 -0
  39. package/lib/impl/sodaDocCursor.js +63 -0
  40. package/lib/impl/sodaDocument.js +98 -0
  41. package/lib/impl/sodaOperation.js +109 -0
  42. package/lib/lob.js +156 -68
  43. package/lib/oracledb.js +1047 -345
  44. package/lib/pool.js +654 -465
  45. package/lib/poolStatistics.js +23 -9
  46. package/lib/queryStream.js +14 -7
  47. package/lib/resultset.js +291 -183
  48. package/lib/settings.js +191 -0
  49. package/lib/sodaCollection.js +214 -201
  50. package/lib/sodaDatabase.js +107 -71
  51. package/lib/sodaDocCursor.js +44 -32
  52. package/lib/sodaDocument.js +76 -14
  53. package/lib/sodaOperation.js +131 -118
  54. package/lib/thin/connection.js +1038 -0
  55. package/lib/thin/dbObject.js +629 -0
  56. package/lib/thin/index.js +40 -0
  57. package/lib/thin/lob.js +188 -0
  58. package/lib/thin/pool.js +481 -0
  59. package/lib/thin/protocol/buffer.js +1040 -0
  60. package/lib/thin/protocol/capabilities.js +116 -0
  61. package/lib/thin/protocol/constants.js +764 -0
  62. package/lib/thin/protocol/encryptDecrypt.js +185 -0
  63. package/lib/thin/protocol/messages/auth.js +348 -0
  64. package/lib/thin/protocol/messages/base.js +475 -0
  65. package/lib/thin/protocol/messages/commit.js +56 -0
  66. package/lib/thin/protocol/messages/dataType.js +382 -0
  67. package/lib/thin/protocol/messages/execute.js +312 -0
  68. package/lib/thin/protocol/messages/fetch.js +60 -0
  69. package/lib/thin/protocol/messages/index.js +53 -0
  70. package/lib/thin/protocol/messages/lobOp.js +200 -0
  71. package/lib/thin/protocol/messages/logOff.js +53 -0
  72. package/lib/thin/protocol/messages/ping.js +56 -0
  73. package/lib/thin/protocol/messages/protocol.js +78 -0
  74. package/lib/thin/protocol/messages/rollback.js +56 -0
  75. package/lib/thin/protocol/messages/sessionRelease.js +60 -0
  76. package/lib/thin/protocol/messages/withData.js +811 -0
  77. package/lib/thin/protocol/oson.js +660 -0
  78. package/lib/thin/protocol/packet.js +520 -0
  79. package/lib/thin/protocol/protocol.js +202 -0
  80. package/lib/thin/protocol/utils.js +88 -0
  81. package/lib/thin/resultSet.js +122 -0
  82. package/lib/thin/sqlnet/connStrategy.js +175 -0
  83. package/lib/thin/sqlnet/constants.js +199 -0
  84. package/lib/thin/sqlnet/ezConnectResolver.js +488 -0
  85. package/lib/thin/sqlnet/navNodes.js +870 -0
  86. package/lib/thin/sqlnet/networkSession.js +620 -0
  87. package/lib/thin/sqlnet/ntTcp.js +525 -0
  88. package/lib/thin/sqlnet/nvStrToNvPair.js +783 -0
  89. package/lib/thin/sqlnet/packet.js +405 -0
  90. package/lib/thin/sqlnet/paramParser.js +205 -0
  91. package/lib/thin/sqlnet/sessionAtts.js +160 -0
  92. package/lib/thin/statement.js +301 -0
  93. package/lib/thin/util.js +289 -0
  94. package/lib/transformer.js +250 -0
  95. package/lib/types.js +357 -0
  96. package/lib/util.js +194 -110
  97. package/lib/version.js +36 -0
  98. package/package/README.md +33 -30
  99. package/package/install.js +89 -64
  100. package/package/prunebinaries.js +60 -12
  101. package/package.json +3 -3
  102. package/build/Release/oracledb-5.5.0-darwin-x64.node +0 -0
  103. package/build/Release/oracledb-5.5.0-darwin-x64.node-buildinfo.txt +0 -1
  104. package/build/Release/oracledb-5.5.0-linux-x64.node +0 -0
  105. package/build/Release/oracledb-5.5.0-linux-x64.node-buildinfo.txt +0 -1
  106. package/build/Release/oracledb-5.5.0-win32-x64.node +0 -0
  107. package/build/Release/oracledb-5.5.0-win32-x64.node-buildinfo.txt +0 -1
package/lib/lob.js CHANGED
@@ -1,17 +1,24 @@
1
- // Copyright (c) 2016, 2022, Oracle and/or its affiliates.
1
+ // Copyright (c) 2016, 2023, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
5
- // You may not use the identified files except in compliance with the Apache
6
- // License, Version 2.0 (the "License.")
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.
7
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.
8
15
  // You may obtain a copy of the License at
9
- // http://www.apache.org/licenses/LICENSE-2.0.
10
16
  //
11
- // Unless required by applicable law or agreed to in writing, software
12
- // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ // https://www.apache.org/licenses/LICENSE-2.0
14
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.
15
22
  // See the License for the specific language governing permissions and
16
23
  // limitations under the License.
17
24
  //
@@ -20,40 +27,10 @@
20
27
  'use strict';
21
28
 
22
29
  const { Duplex } = require('stream');
30
+ const constants = require('./constants.js');
31
+ const errors = require('./errors.js');
23
32
  const nodbUtil = require('./util.js');
24
-
25
- //-----------------------------------------------------------------------------
26
- // close()
27
- // Close the LOB and make it unusable for further operations. If the LOB is
28
- // already closed, nothing is done in order to support multiple close() calls.
29
- //
30
- // This method is deprecated and will be removed in a future version of the
31
- // node-oracledb driver. Use lob.destroy() instead. NOTE: this method will
32
- // emit a duplicate "close" event in order to be compatible with previous
33
- // versions of node-oracledb.
34
- //-----------------------------------------------------------------------------
35
- async function close() {
36
- nodbUtil.checkArgCount(arguments, 0, 0);
37
- if (this.valid) {
38
- try {
39
- await this._close();
40
- this.emit('close');
41
- } catch (err) {
42
- this.destroy(err);
43
- }
44
- }
45
- }
46
-
47
-
48
- //-----------------------------------------------------------------------------
49
- // getData()
50
- // Returns all of the data in the LOB as a single string or buffer.
51
- //-----------------------------------------------------------------------------
52
- async function getData() {
53
- nodbUtil.checkArgCount(arguments, 0, 0);
54
- return await this._getData();
55
- }
56
-
33
+ const types = require('./types.js');
57
34
 
58
35
  class Lob extends Duplex {
59
36
 
@@ -68,20 +45,17 @@ class Lob extends Duplex {
68
45
  });
69
46
  }
70
47
 
71
- _extend(oracledb) {
72
- this._oracledb = oracledb;
73
- this.close = nodbUtil.callbackify(nodbUtil.preventConcurrent(nodbUtil.serialize(close), 'NJS-023'));
74
- this.getData = nodbUtil.callbackify(nodbUtil.preventConcurrent(nodbUtil.serialize(getData), 'NJS-023'));
75
- this._serializedRead = nodbUtil.serialize(this.__read);
76
- this._serializedWrite = nodbUtil.serialize(this.__write);
77
- }
78
-
79
48
  // called by stream.destroy() and ensures that the LOB is closed if it has
80
49
  // not already been closed (never called directly)
81
50
  async _destroy(err, cb) {
82
- if (this.valid) {
51
+ // if LOB was already closed, nothing to do!
52
+ if (err && err.message.startsWith("NJS-108:"))
53
+ delete this._impl;
54
+ if (this._impl) {
55
+ const lobImpl = this._impl;
56
+ delete this._impl;
83
57
  try {
84
- await this._close();
58
+ await lobImpl.close();
85
59
  } catch (closeErr) {
86
60
  cb(closeErr);
87
61
  return;
@@ -90,19 +64,10 @@ class Lob extends Duplex {
90
64
  cb(err);
91
65
  }
92
66
 
93
- // return the connection associated with the LOB (used for serializing
94
- // accesses to the connection)
95
- _getConnection() {
96
- let connection = this._parentObj;
97
- while (!(connection instanceof this._oracledb.Connection))
98
- connection = connection._parentObj;
99
- return connection;
100
- }
101
-
102
- // implementation of streaming read; if lob is set to auto-close, the lob is
103
- // automatically closed within the C code when an error occurs or when there
104
- // are no more bytes to transfer; all that needs to be done in the JS layer
105
- // is to destroy the streaming LOB
67
+ // implementation of streaming read; if LOB is set to auto-close, the lob is
68
+ // automatically closed when an error occurs or when there are no more bytes
69
+ // to transfer; all that needs to be done here is to destroy the streaming
70
+ // LOB
106
71
  async _read() {
107
72
  try {
108
73
  const data = await this._serializedRead(this.offset);
@@ -116,19 +81,44 @@ class Lob extends Duplex {
116
81
  }
117
82
  }
118
83
  } catch (err) {
119
- this.destroy(err);
84
+ if (this._autoCloseLob)
85
+ this.destroy(err);
86
+ throw err;
87
+ }
88
+ }
89
+
90
+ // simple wrapper so that serialization can take place on a JavaScript fn
91
+ async _readData(offset) {
92
+ errors.assert(this._impl, errors.ERR_INVALID_LOB);
93
+ try {
94
+ return await this._impl.read(offset);
95
+ } catch (err) {
96
+ throw errors.transformErr(err, this._readData);
97
+ }
98
+ }
99
+
100
+ // called to associate a LOB implementation with this user facing object
101
+ _setup(lobImpl, autoCloseLob) {
102
+ this._impl = lobImpl;
103
+ this._chunkSize = lobImpl.getChunkSize();
104
+ this._pieceSize = lobImpl.getPieceSize();
105
+ this._length = lobImpl.getLength();
106
+ this._type = lobImpl.getType();
107
+ if (typeof this._type === 'number') {
108
+ this._type = types.getTypeByNum(this._type);
120
109
  }
110
+ this._autoCloseLob = autoCloseLob;
121
111
  }
122
112
 
123
- // implementation of streaming write; if lob is set to auto-close, the lob is
113
+ // implementation of streaming write; if LOB is set to auto-close, the lob is
124
114
  // automatically closed in the "finish" event; all that needs to be done here
125
115
  // is to destroy the streaming LOB
126
116
  async _write(data, encoding, cb) {
127
117
 
128
118
  // convert data if needed
129
- if (this.type == this._oracledb.DB_TYPE_BLOB && !Buffer.isBuffer(data)) {
119
+ if (this.type == constants.DB_TYPE_BLOB && !Buffer.isBuffer(data)) {
130
120
  data = Buffer.from(data);
131
- } else if (this.type == this._oracledb.DB_TYPE_CLOB &&
121
+ } else if (this.type == constants.DB_TYPE_CLOB &&
132
122
  Buffer.isBuffer(data)) {
133
123
  data = data.toString();
134
124
  }
@@ -136,8 +126,9 @@ class Lob extends Duplex {
136
126
  try {
137
127
  await this._serializedWrite(this.offset, data);
138
128
  } catch (err) {
129
+ if (this._autoCloseLob)
130
+ this.destroy(err);
139
131
  cb(err);
140
- this.destroy(err);
141
132
  return;
142
133
  }
143
134
  this.offset += data.length;
@@ -145,6 +136,103 @@ class Lob extends Duplex {
145
136
 
146
137
  }
147
138
 
139
+ // simple wrapper so that serialization can take place on a JavaScript fn
140
+ async _writeData(offset, data) {
141
+ errors.assert(this._impl, errors.ERR_INVALID_LOB);
142
+ try {
143
+ await this._impl.write(offset, data);
144
+ } catch (err) {
145
+ throw errors.transformErr(err, this._writeData);
146
+ }
147
+ }
148
+
149
+ //---------------------------------------------------------------------------
150
+ // chunkSize
151
+ //
152
+ // Property for the chunk size of the LOB.
153
+ //---------------------------------------------------------------------------
154
+ get chunkSize() {
155
+ return this._chunkSize;
156
+ }
157
+
158
+ //---------------------------------------------------------------------------
159
+ // close()
160
+ //
161
+ // Close the LOB and make it unusable for further operations. If the LOB is
162
+ // already closed, nothing is done in order to support multiple close()
163
+ // calls.
164
+ //
165
+ // This method is deprecated and will be removed in a future version of the
166
+ // node-oracledb driver. Use lob.destroy() instead. NOTE: this method will
167
+ // emit a duplicate "close" event in order to be compatible with previous
168
+ // versions of node-oracledb.
169
+ //---------------------------------------------------------------------------
170
+ async close() {
171
+ errors.assertArgCount(arguments, 0, 0);
172
+ if (this._impl) {
173
+ const lobImpl = this._impl;
174
+ delete this._impl;
175
+ try {
176
+ await lobImpl.close();
177
+ this.emit('close');
178
+ } catch (err) {
179
+ this.destroy(err);
180
+ }
181
+ }
182
+ }
183
+
184
+ //---------------------------------------------------------------------------
185
+ // getData()
186
+ //
187
+ // Returns all of the data in the LOB as a single string or buffer.
188
+ //---------------------------------------------------------------------------
189
+ async getData() {
190
+ errors.assertArgCount(arguments, 0, 0);
191
+ errors.assert(this._impl, errors.ERR_INVALID_LOB);
192
+ return await this._impl.getData();
193
+ }
194
+
195
+ //---------------------------------------------------------------------------
196
+ // length
197
+ //
198
+ // Property for the length of the LOB.
199
+ //---------------------------------------------------------------------------
200
+ get length() {
201
+ return this._length;
202
+ }
203
+
204
+ //---------------------------------------------------------------------------
205
+ // pieceSize
206
+ //
207
+ // Property for the size to use for each piece that is transferred when
208
+ // reading from the LOB.
209
+ //---------------------------------------------------------------------------
210
+ get pieceSize() {
211
+ return this._pieceSize;
212
+ }
213
+
214
+ set pieceSize(value) {
215
+ errors.assertPropValue(Number.isInteger(value) && value >= 0, "pieceSize");
216
+ errors.assert(this._impl, errors.ERR_INVALID_LOB);
217
+ this._impl.setPieceSize(value);
218
+ this._pieceSize = value;
219
+ }
220
+
221
+ //---------------------------------------------------------------------------
222
+ // type
223
+ //
224
+ // Property for the type of the LOB.
225
+ //---------------------------------------------------------------------------
226
+ get type() {
227
+ return this._type;
228
+ }
229
+
148
230
  }
149
231
 
232
+ nodbUtil.wrapFns(Lob.prototype, errors.ERR_BUSY_LOB,
233
+ "close",
234
+ "getData");
235
+ Lob.prototype._serializedRead = nodbUtil.serialize(Lob.prototype._readData);
236
+ Lob.prototype._serializedWrite = nodbUtil.serialize(Lob.prototype._writeData);
237
+
150
238
  module.exports = Lob;