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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Copyright (c) 2022, 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 AqDeqOptionsImpl = require('./aqDeqOptions.js');
|
|
30
|
+
const AqEnqOptionsImpl = require('./aqEnqOptions.js');
|
|
31
|
+
const AqMessageImpl = require('./aqMessage.js');
|
|
32
|
+
const AqQueueImpl = require('./aqQueue.js');
|
|
33
|
+
const DbObjectImpl = require('./dbObject.js');
|
|
34
|
+
const ConnectionImpl = require('./connection.js');
|
|
35
|
+
const LobImpl = require('./lob.js');
|
|
36
|
+
const PoolImpl = require('./pool.js');
|
|
37
|
+
const ResultSetImpl = require('./resultset.js');
|
|
38
|
+
const SodaCollectionImpl = require('./sodaCollection.js');
|
|
39
|
+
const SodaDatabaseImpl = require('./sodaDatabase.js');
|
|
40
|
+
const SodaDocCursorImpl = require('./sodaDocCursor.js');
|
|
41
|
+
const SodaDocumentImpl = require('./sodaDocument.js');
|
|
42
|
+
const SodaOperationImpl = require('./sodaOperation.js');
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
AqDeqOptionsImpl,
|
|
46
|
+
AqEnqOptionsImpl,
|
|
47
|
+
AqMessageImpl,
|
|
48
|
+
AqQueueImpl,
|
|
49
|
+
DbObjectImpl,
|
|
50
|
+
ConnectionImpl,
|
|
51
|
+
LobImpl,
|
|
52
|
+
PoolImpl,
|
|
53
|
+
ResultSetImpl,
|
|
54
|
+
SodaCollectionImpl,
|
|
55
|
+
SodaDatabaseImpl,
|
|
56
|
+
SodaDocCursorImpl,
|
|
57
|
+
SodaDocumentImpl,
|
|
58
|
+
SodaOperationImpl
|
|
59
|
+
};
|
package/lib/impl/lob.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Copyright (c) 2022, 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 ConnectionImpl = require('./connection.js');
|
|
30
|
+
const errors = require('../errors.js');
|
|
31
|
+
|
|
32
|
+
class LobImpl {
|
|
33
|
+
|
|
34
|
+
//---------------------------------------------------------------------------
|
|
35
|
+
// _getConnImpl()
|
|
36
|
+
//
|
|
37
|
+
// Common method on all classes that make use of a connection -- used to
|
|
38
|
+
// ensure serialization of all use of the connection.
|
|
39
|
+
//---------------------------------------------------------------------------
|
|
40
|
+
_getConnImpl() {
|
|
41
|
+
let parentObj = this._parentObj;
|
|
42
|
+
while (!(parentObj instanceof ConnectionImpl))
|
|
43
|
+
parentObj = parentObj._parentObj;
|
|
44
|
+
return parentObj;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//---------------------------------------------------------------------------
|
|
48
|
+
// close()
|
|
49
|
+
//
|
|
50
|
+
// Close the LOB.
|
|
51
|
+
//---------------------------------------------------------------------------
|
|
52
|
+
close() {
|
|
53
|
+
errors.throwNotImplemented("closing a LOB");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//---------------------------------------------------------------------------
|
|
57
|
+
// getData()
|
|
58
|
+
//
|
|
59
|
+
// Returns all of the data in the LOB.
|
|
60
|
+
//---------------------------------------------------------------------------
|
|
61
|
+
getData() {
|
|
62
|
+
errors.throwNotImplemented("getting all of the data from a LOB");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//---------------------------------------------------------------------------
|
|
66
|
+
// read()
|
|
67
|
+
//
|
|
68
|
+
// Reads data from the LOB at the specified offset.
|
|
69
|
+
//---------------------------------------------------------------------------
|
|
70
|
+
read() {
|
|
71
|
+
errors.throwNotImplemented("reading from a LOB");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//---------------------------------------------------------------------------
|
|
75
|
+
// write()
|
|
76
|
+
//
|
|
77
|
+
// Writes data to the LOB at the specified offset.
|
|
78
|
+
//---------------------------------------------------------------------------
|
|
79
|
+
write() {
|
|
80
|
+
errors.throwNotImplemented("writing to a LOB");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
module.exports = LobImpl;
|
package/lib/impl/pool.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// Copyright (c) 2022, 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 errors = require('../errors.js');
|
|
30
|
+
const nodbUtil = require('../util.js');
|
|
31
|
+
|
|
32
|
+
class PoolImpl {
|
|
33
|
+
|
|
34
|
+
//---------------------------------------------------------------------------
|
|
35
|
+
// _accessTokenHandler()
|
|
36
|
+
//
|
|
37
|
+
// Access token handler callback function which wraps the user callback and
|
|
38
|
+
// returns the token to the implementation.
|
|
39
|
+
//---------------------------------------------------------------------------
|
|
40
|
+
async _accessTokenHandler(userFn, externalObj, refresh) {
|
|
41
|
+
let accessToken;
|
|
42
|
+
try {
|
|
43
|
+
let result = userFn(refresh);
|
|
44
|
+
if (result instanceof Promise) {
|
|
45
|
+
result = await result;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!nodbUtil.isTokenValid(result)) {
|
|
49
|
+
errors.throwErr(errors.ERR_TOKEN_HAS_EXPIRED);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
accessToken = result;
|
|
53
|
+
} finally {
|
|
54
|
+
this.returnAccessToken(externalObj, accessToken);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//---------------------------------------------------------------------------
|
|
59
|
+
// close()
|
|
60
|
+
//
|
|
61
|
+
// Close the pool.
|
|
62
|
+
//---------------------------------------------------------------------------
|
|
63
|
+
close() {
|
|
64
|
+
errors.throwNotImplemented("closing the pool");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//---------------------------------------------------------------------------
|
|
68
|
+
// create()
|
|
69
|
+
//
|
|
70
|
+
// Creates the pool and makes it available for use.
|
|
71
|
+
//---------------------------------------------------------------------------
|
|
72
|
+
create() {
|
|
73
|
+
errors.throwNotImplemented("creating the pool");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//---------------------------------------------------------------------------
|
|
77
|
+
// getConnection()
|
|
78
|
+
//
|
|
79
|
+
// Returns a connection from the pool.
|
|
80
|
+
//---------------------------------------------------------------------------
|
|
81
|
+
getConnection() {
|
|
82
|
+
errors.throwNotImplemented("getting a connection from the pool");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//---------------------------------------------------------------------------
|
|
86
|
+
// getConnectionsInUse()
|
|
87
|
+
//
|
|
88
|
+
// Returns the number of connections in use in the pool.
|
|
89
|
+
//---------------------------------------------------------------------------
|
|
90
|
+
getConnectionsInUse() {
|
|
91
|
+
errors.throwNotImplemented("getting num connection in use");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//---------------------------------------------------------------------------
|
|
95
|
+
// getConnectionsOpen()
|
|
96
|
+
//
|
|
97
|
+
// Returns the number of connections opened by the pool.
|
|
98
|
+
//---------------------------------------------------------------------------
|
|
99
|
+
getConnectionsOpen() {
|
|
100
|
+
errors.throwNotImplemented("getting num connection open");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//---------------------------------------------------------------------------
|
|
104
|
+
// getPoolIncrement()
|
|
105
|
+
//
|
|
106
|
+
// Returns the number of connections to create when the pool needs to grow.
|
|
107
|
+
//---------------------------------------------------------------------------
|
|
108
|
+
getPoolIncrement() {
|
|
109
|
+
errors.throwNotImplemented("getting the pool increment");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//---------------------------------------------------------------------------
|
|
113
|
+
// getPoolMax()
|
|
114
|
+
//
|
|
115
|
+
// Returns the maximum number of connections allowed in the pool.
|
|
116
|
+
//---------------------------------------------------------------------------
|
|
117
|
+
getPoolMax() {
|
|
118
|
+
errors.throwNotImplemented("getting the pool max");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//---------------------------------------------------------------------------
|
|
122
|
+
// getPoolMaxPerShard()
|
|
123
|
+
//
|
|
124
|
+
// Returns the maximum number of connections allowed per shard in the pool.
|
|
125
|
+
//---------------------------------------------------------------------------
|
|
126
|
+
getPoolMaxPerShard() {
|
|
127
|
+
errors.throwNotImplemented("getting the pool max per shard");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//---------------------------------------------------------------------------
|
|
131
|
+
// getPoolMin()
|
|
132
|
+
//
|
|
133
|
+
// Returns the minimum number of connections allowed in the pool.
|
|
134
|
+
//---------------------------------------------------------------------------
|
|
135
|
+
getPoolMin() {
|
|
136
|
+
errors.throwNotImplemented("getting the pool min");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
//---------------------------------------------------------------------------
|
|
140
|
+
// getPoolPingInterval()
|
|
141
|
+
//
|
|
142
|
+
// Returns the pool ping interval (seconds).
|
|
143
|
+
//---------------------------------------------------------------------------
|
|
144
|
+
getPoolPingInterval() {
|
|
145
|
+
errors.throwNotImplemented("getting the pool ping interval");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
//---------------------------------------------------------------------------
|
|
149
|
+
// getPoolTimeout()
|
|
150
|
+
//
|
|
151
|
+
// Returns the pool timeout.
|
|
152
|
+
//---------------------------------------------------------------------------
|
|
153
|
+
getPoolTimeout() {
|
|
154
|
+
errors.throwNotImplemented("getting the pool timeout");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//---------------------------------------------------------------------------
|
|
158
|
+
// getStmtCacheSize()
|
|
159
|
+
//
|
|
160
|
+
// Returns the statement cache size associate with the pool.
|
|
161
|
+
//---------------------------------------------------------------------------
|
|
162
|
+
getStmtCacheSize() {
|
|
163
|
+
errors.throwNotImplemented("getting the pool statement cache size");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
//---------------------------------------------------------------------------
|
|
167
|
+
// getSodaMetaDataCache()
|
|
168
|
+
//
|
|
169
|
+
// Returns whether the SODA metadata cache is enabled or not.
|
|
170
|
+
//---------------------------------------------------------------------------
|
|
171
|
+
getSodaMetaDataCache() {
|
|
172
|
+
errors.throwNotImplemented("getting the SODA metadata cache flag");
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
//---------------------------------------------------------------------------
|
|
176
|
+
// reconfigure()
|
|
177
|
+
//
|
|
178
|
+
// Reconfigures the pool with new parameters.
|
|
179
|
+
//---------------------------------------------------------------------------
|
|
180
|
+
reconfigure() {
|
|
181
|
+
errors.throwNotImplemented("reconfiguring the pool");
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
//---------------------------------------------------------------------------
|
|
185
|
+
// setAccessToken()
|
|
186
|
+
//
|
|
187
|
+
// Sets the access token to use with the pool.
|
|
188
|
+
//---------------------------------------------------------------------------
|
|
189
|
+
setAccessToken() {
|
|
190
|
+
errors.throwNotImplemented("sets the access token");
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
module.exports = PoolImpl;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// Copyright (c) 2022, 2023, 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 constants = require('../constants.js');
|
|
30
|
+
const errors = require('../errors.js');
|
|
31
|
+
const nodbUtil = require('../util.js');
|
|
32
|
+
const settings = require('../settings.js');
|
|
33
|
+
const types = require('../types.js');
|
|
34
|
+
|
|
35
|
+
// define implementation class
|
|
36
|
+
class ResultSetImpl {
|
|
37
|
+
|
|
38
|
+
//---------------------------------------------------------------------------
|
|
39
|
+
// _determineFetchType()
|
|
40
|
+
//
|
|
41
|
+
// Determine the fetch type to use for the specified metadata.
|
|
42
|
+
//---------------------------------------------------------------------------
|
|
43
|
+
_determineFetchType(metadata, options) {
|
|
44
|
+
|
|
45
|
+
// clear any previous fetch type and converter functions that may have been
|
|
46
|
+
// retained
|
|
47
|
+
delete metadata.fetchType;
|
|
48
|
+
delete metadata.converter;
|
|
49
|
+
|
|
50
|
+
// if a fetch type handler is specified, call it; if no value (undefined)
|
|
51
|
+
// is returned, the normal processing takes place
|
|
52
|
+
if (options.fetchTypeHandler) {
|
|
53
|
+
const result = options.fetchTypeHandler(metadata);
|
|
54
|
+
if (result !== undefined) {
|
|
55
|
+
errors.assert(typeof result === 'object',
|
|
56
|
+
errors.ERR_FETCH_TYPE_HANDLER_RETURN_VALUE);
|
|
57
|
+
if (result.type !== undefined) {
|
|
58
|
+
errors.assert(result.type instanceof types.DbType,
|
|
59
|
+
errors.ERR_FETCH_TYPE_HANDLER_TYPE);
|
|
60
|
+
}
|
|
61
|
+
if (result.converter !== undefined) {
|
|
62
|
+
errors.assert(typeof result.converter === 'function',
|
|
63
|
+
errors.ERR_FETCH_TYPE_HANDLER_CONVERTER);
|
|
64
|
+
}
|
|
65
|
+
metadata.fetchType = result.type;
|
|
66
|
+
metadata.converter = result.converter;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// continue processing if no fetch type was specified or no fetch type
|
|
71
|
+
// handler was supplied
|
|
72
|
+
if (!metadata.fetchType) {
|
|
73
|
+
|
|
74
|
+
// if the fetchTypeMap exists (calculated from the fetchInfo argument),
|
|
75
|
+
// use it to determine the fetch type
|
|
76
|
+
if (options.fetchTypeMap && options.fetchTypeMap.has(metadata.name)) {
|
|
77
|
+
metadata.fetchType = options.fetchTypeMap.get(metadata.name);
|
|
78
|
+
if (metadata.fetchType === constants.DEFAULT) {
|
|
79
|
+
metadata.fetchType =
|
|
80
|
+
types.DB_TYPE_FETCH_TYPE_MAP.get(metadata.dbType);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// otherwise, use the default fetch type map (calculated from the
|
|
84
|
+
// fetchAsString and fetchAsBuffer settings
|
|
85
|
+
} else {
|
|
86
|
+
metadata.fetchType = settings.fetchTypeMap.get(metadata.dbType);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// if the types do not match, verify that the conversion is supported and
|
|
92
|
+
// adjust the final fetch type to match what the database expects
|
|
93
|
+
if (metadata.fetchType !== metadata.dbType) {
|
|
94
|
+
const map = types.DB_TYPE_CONVERSION_MAP.get(metadata.dbType);
|
|
95
|
+
const actualFetchType = map && map.get(metadata.fetchType);
|
|
96
|
+
if (!actualFetchType) {
|
|
97
|
+
errors.throwErr(errors.ERR_UNSUPPORTED_CONVERSION,
|
|
98
|
+
metadata.dbType.name, metadata.fetchType.name);
|
|
99
|
+
}
|
|
100
|
+
metadata.fetchType = actualFetchType;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// in thin mode, Oracle NUMBER values are internally fetched as string in
|
|
104
|
+
// order to preserve precision so must be converted to JavaScript Number
|
|
105
|
+
// when needed; other numeric and date types are fetched natively as
|
|
106
|
+
// JavaScript Number and Date values and are converted to string using
|
|
107
|
+
// toString() when desired
|
|
108
|
+
if (settings.thin) {
|
|
109
|
+
let converter;
|
|
110
|
+
const userConverter = metadata.converter;
|
|
111
|
+
if (metadata.dbType === types.DB_TYPE_NUMBER &&
|
|
112
|
+
metadata.fetchType === types.DB_TYPE_NUMBER) {
|
|
113
|
+
converter = (v) => (v === null) ? null : parseFloat(v);
|
|
114
|
+
} else if (metadata.fetchType === types.DB_TYPE_VARCHAR &&
|
|
115
|
+
(metadata.dbType === types.DB_TYPE_BINARY_DOUBLE ||
|
|
116
|
+
metadata.dbType === types.DB_TYPE_BINARY_FLOAT ||
|
|
117
|
+
metadata.dbType === types.DB_TYPE_DATE ||
|
|
118
|
+
metadata.dbType === types.DB_TYPE_TIMESTAMP ||
|
|
119
|
+
metadata.dbType === types.DB_TYPE_TIMESTAMP_LTZ ||
|
|
120
|
+
metadata.dbType === types.DB_TYPE_TIMESTAMP_TZ)) {
|
|
121
|
+
converter = (v) => (v === null) ? null : v.toString();
|
|
122
|
+
}
|
|
123
|
+
if (userConverter && converter) {
|
|
124
|
+
const internalConverter = converter;
|
|
125
|
+
converter = (v) => userConverter(internalConverter(v));
|
|
126
|
+
}
|
|
127
|
+
if (converter) {
|
|
128
|
+
metadata.converter = converter;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
//---------------------------------------------------------------------------
|
|
135
|
+
// _getConnImpl()
|
|
136
|
+
//
|
|
137
|
+
// Common method on all classes that make use of a connection -- used to
|
|
138
|
+
// ensure serialization of all use of the connection.
|
|
139
|
+
//---------------------------------------------------------------------------
|
|
140
|
+
_getConnImpl() {
|
|
141
|
+
return this._parentObj;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//---------------------------------------------------------------------------
|
|
145
|
+
// _setup()
|
|
146
|
+
//
|
|
147
|
+
// Setup a result set. The metadata is examined to to determine if any
|
|
148
|
+
// columns need to be manipulated before being returned to the caller. If the
|
|
149
|
+
// rows fetched from the result set are expected to be objects, a unique set
|
|
150
|
+
// of attribute names are also determined.
|
|
151
|
+
//---------------------------------------------------------------------------
|
|
152
|
+
_setup(options, metaData) {
|
|
153
|
+
this._parentObj = options.connection._impl;
|
|
154
|
+
this.metaData = metaData;
|
|
155
|
+
this.lobIndices = [];
|
|
156
|
+
this.dbObjectIndices = [];
|
|
157
|
+
this.nestedCursorIndices = [];
|
|
158
|
+
this.converterIndices = [];
|
|
159
|
+
this.outFormat = options.outFormat;
|
|
160
|
+
this.fetchArraySize = options.fetchArraySize;
|
|
161
|
+
this.dbObjectAsPojo = options.dbObjectAsPojo;
|
|
162
|
+
this.maxRows = options.maxRows;
|
|
163
|
+
const names = new Map();
|
|
164
|
+
for (let i = 0; i < metaData.length; i++) {
|
|
165
|
+
const name = metaData[i].name;
|
|
166
|
+
if (!names.has(name)) {
|
|
167
|
+
names.set(name, i);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
for (let i = 0; i < metaData.length; i++) {
|
|
171
|
+
const info = metaData[i];
|
|
172
|
+
if (info.dbTypeClass) {
|
|
173
|
+
const cls = options.connection._getDbObjectClass(info.dbTypeClass);
|
|
174
|
+
info.dbTypeClass = cls;
|
|
175
|
+
}
|
|
176
|
+
nodbUtil.addTypeProperties(info, "dbType");
|
|
177
|
+
this._determineFetchType(info, options);
|
|
178
|
+
if (info.fetchType === types.DB_TYPE_CURSOR) {
|
|
179
|
+
this.nestedCursorIndices.push(i);
|
|
180
|
+
} else if (info.fetchType === types.DB_TYPE_CLOB ||
|
|
181
|
+
info.fetchType === types.DB_TYPE_NCLOB ||
|
|
182
|
+
info.fetchType === types.DB_TYPE_BLOB) {
|
|
183
|
+
this.lobIndices.push(i);
|
|
184
|
+
} else if (info.fetchType === types.DB_TYPE_OBJECT) {
|
|
185
|
+
this.dbObjectIndices.push(i);
|
|
186
|
+
}
|
|
187
|
+
if (info.converter) {
|
|
188
|
+
this.converterIndices.push(i);
|
|
189
|
+
}
|
|
190
|
+
let name = info.name;
|
|
191
|
+
if (names.get(name) !== i) {
|
|
192
|
+
let seqNum = 0;
|
|
193
|
+
while (names.has(name)) {
|
|
194
|
+
seqNum = seqNum + 1;
|
|
195
|
+
name = `${info.name}_${seqNum}`;
|
|
196
|
+
}
|
|
197
|
+
names.set(name, i);
|
|
198
|
+
info.name = name;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
//---------------------------------------------------------------------------
|
|
204
|
+
// close()
|
|
205
|
+
//
|
|
206
|
+
// Closes the result set.
|
|
207
|
+
//---------------------------------------------------------------------------
|
|
208
|
+
close() {
|
|
209
|
+
errors.throwNotImplemented("closing a result set");
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
//---------------------------------------------------------------------------
|
|
213
|
+
// getRows()
|
|
214
|
+
//
|
|
215
|
+
// Returns rows from a result set.
|
|
216
|
+
//---------------------------------------------------------------------------
|
|
217
|
+
getRows() {
|
|
218
|
+
errors.throwNotImplemented("getting rows");
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
module.exports = ResultSetImpl;
|