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