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.
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.1-darwin-x64.node +0 -0
  7. package/build/Release/oracledb-6.0.1-darwin-x64.node-buildinfo.txt +1 -0
  8. package/build/Release/oracledb-6.0.1-js-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-6.0.1-linux-arm64.node +0 -0
  10. package/build/Release/oracledb-6.0.1-linux-arm64.node-buildinfo.txt +1 -0
  11. package/build/Release/oracledb-6.0.1-linux-x64.node +0 -0
  12. package/build/Release/oracledb-6.0.1-linux-x64.node-buildinfo.txt +1 -0
  13. package/build/Release/oracledb-6.0.1-win32-x64.node +0 -0
  14. package/build/Release/oracledb-6.0.1-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 +148 -8
  20. package/lib/aqEnqOptions.js +59 -7
  21. package/lib/aqMessage.js +118 -7
  22. package/lib/aqQueue.js +243 -53
  23. package/lib/connection.js +1326 -465
  24. package/lib/constants.js +203 -0
  25. package/lib/dbObject.js +346 -32
  26. package/lib/errors.js +785 -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 +157 -68
  43. package/lib/oracledb.js +1047 -345
  44. package/lib/pool.js +654 -465
  45. package/lib/poolStatistics.js +24 -9
  46. package/lib/queryStream.js +16 -8
  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 +108 -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 +1043 -0
  55. package/lib/thin/dbObject.js +630 -0
  56. package/lib/thin/index.js +40 -0
  57. package/lib/thin/lob.js +189 -0
  58. package/lib/thin/pool.js +481 -0
  59. package/lib/thin/protocol/buffer.js +1043 -0
  60. package/lib/thin/protocol/capabilities.js +121 -0
  61. package/lib/thin/protocol/constants.js +765 -0
  62. package/lib/thin/protocol/encryptDecrypt.js +185 -0
  63. package/lib/thin/protocol/messages/auth.js +349 -0
  64. package/lib/thin/protocol/messages/base.js +476 -0
  65. package/lib/thin/protocol/messages/commit.js +56 -0
  66. package/lib/thin/protocol/messages/dataType.js +391 -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 +201 -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 +812 -0
  77. package/lib/thin/protocol/oson.js +661 -0
  78. package/lib/thin/protocol/packet.js +519 -0
  79. package/lib/thin/protocol/protocol.js +202 -0
  80. package/lib/thin/protocol/utils.js +89 -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 +621 -0
  87. package/lib/thin/sqlnet/ntTcp.js +527 -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 +206 -0
  91. package/lib/thin/sqlnet/sessionAtts.js +160 -0
  92. package/lib/thin/statement.js +300 -0
  93. package/lib/thin/util.js +289 -0
  94. package/lib/transformer.js +252 -0
  95. package/lib/types.js +357 -0
  96. package/lib/util.js +196 -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
@@ -0,0 +1,312 @@
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 MessageWithData = require("./withData.js");
30
+ const constants = require("../constants.js");
31
+ const errors = require("../../../errors.js");
32
+
33
+ /**
34
+ *
35
+ * Executes OALL8 RPC function
36
+ *
37
+ * @class ExecuteMessage
38
+ * @extends {MessageWithData}
39
+ */
40
+ class ExecuteMessage extends MessageWithData {
41
+ /**
42
+ *
43
+ * @param {object} statement
44
+ * @param {object} options
45
+ */
46
+ constructor(connection, statement, options, resultSet) {
47
+ super(connection, statement, options);
48
+ if (!resultSet && statement.isQuery) {
49
+ resultSet = connection._createResultSet(options, statement);
50
+ }
51
+ this.resultSet = resultSet;
52
+ this.functionCode = constants.TNS_FUNC_EXECUTE;
53
+ this.bindParams = undefined;
54
+ this.currentRow = 0;
55
+ }
56
+
57
+ //-------------------------------------------------------------------------
58
+ // writeReExecuteMessage()
59
+ //
60
+ // Write the message for a full execute.
61
+ //-------------------------------------------------------------------------
62
+ writeExecuteMessage(buf) {
63
+ let options = 0x0;
64
+ let dmlOptions = 0;
65
+ let numParams = 0;
66
+ let numIters = 1;
67
+ // Configuring the options field thats send to the server
68
+ let stmt = this.statement;
69
+ let params = stmt.bindInfoList;
70
+
71
+ if (!stmt.requiresDefine && !this.parseOnly && params) {
72
+ numParams = params.length;
73
+ }
74
+ if (stmt.requiresDefine) {
75
+ options |= constants.TNS_EXEC_OPTION_DEFINE;
76
+ } else if (!this.parseOnly && stmt.sql) {
77
+ dmlOptions = constants.TNS_EXEC_OPTION_IMPLICIT_RESULTSET;
78
+ options |= constants.TNS_EXEC_OPTION_EXECUTE;
79
+ }
80
+ if (stmt.cursorId == 0 || stmt.isDdl) {
81
+ options |= constants.TNS_EXEC_OPTION_PARSE;
82
+ }
83
+ if (stmt.isQuery) {
84
+ if (this.parseOnly) {
85
+ options |= constants.TNS_EXEC_OPTION_DESCRIBE;
86
+ } else {
87
+ if (this.options.prefetchRows > 0) {
88
+ options |= constants.TNS_EXEC_OPTION_FETCH;
89
+ }
90
+ if (stmt.cursorId === 0 || stmt.requiresDefine) {
91
+ numIters = this.options.prefetchRows;
92
+ } else {
93
+ numIters = this.options.fetchArraySize;
94
+ }
95
+ }
96
+ }
97
+ if (!stmt.isPlSql && !this.parseOnly) {
98
+ options |= constants.TNS_EXEC_OPTION_NOT_PLSQL;
99
+ } else if (stmt.isPlSql && numParams > 0) {
100
+ options |= constants.TNS_EXEC_OPTION_PLSQL_BIND;
101
+ }
102
+ if (numParams > 0) {
103
+ options |= constants.TNS_EXEC_OPTION_BIND;
104
+ }
105
+ if (this.batchErrors) {
106
+ options |= constants.TNS_EXEC_OPTION_BATCH_ERRORS;
107
+ }
108
+ if (this.arrayDmlRowCounts) {
109
+ dmlOptions = constants.TNS_EXEC_OPTION_DML_ROWCOUNTS;
110
+ }
111
+ if (this.options.autoCommit) {
112
+ options |= constants.TNS_EXEC_OPTION_COMMIT;
113
+ }
114
+ this.writePiggybacks(buf);
115
+ this.writeFunctionHeader(buf);
116
+ buf.writeUB4(options); // execute options
117
+ buf.writeUB4(stmt.cursorId); // cursor id
118
+ if (stmt.cursorId === 0 || stmt.isDdl) {
119
+ buf.writeUInt8(1); // pointer (cursor id)
120
+ buf.writeUB4(stmt.sqlLength);
121
+ } else {
122
+ buf.writeUInt8(0); // pointer (cursor id)
123
+ buf.writeUB4(0);
124
+ }
125
+ buf.writeUInt8(1); // pointer (vector)
126
+ buf.writeUB4(13); // al8i4 array length
127
+ buf.writeUInt8(0); // pointer (al8o4)
128
+ buf.writeUInt8(0); // pointer (al8o4l)
129
+ buf.writeUInt8(0); // prefetc buffer size
130
+ buf.writeUB4(numIters); // prefetch num rows
131
+ buf.writeUB4(constants.TNS_MAX_LONG_LENGTH); // maximum long size
132
+ if (numParams === 0) {
133
+ buf.writeUInt8(0); // pointer (binds)
134
+ buf.writeUB4(0); // number of binds
135
+ } else {
136
+ buf.writeUInt8(1); // pointer (binds)
137
+ buf.writeUB4(numParams); // number of binds
138
+ }
139
+ buf.writeUInt8(0); // pointer (al8pp)
140
+ buf.writeUInt8(0); // pointer (al8txn)
141
+ buf.writeUInt8(0); // pointer (al8txl)
142
+ buf.writeUInt8(0); // pointer (al8kv)
143
+ buf.writeUInt8(0); // pointer (al8kvl)
144
+ if (stmt.requiresDefine) {
145
+ buf.writeUInt8(1); // pointer (al8doac)
146
+ buf.writeUB4(this.statement.queryVars.length); // number of defines
147
+ } else {
148
+ buf.writeUInt8(0);
149
+ buf.writeUB4(0);
150
+ }
151
+ buf.writeUB4(0); // registration id
152
+ buf.writeUInt8(0); // pointer (al8objlist)
153
+ buf.writeUInt8(1); // pointer (al8objlen)
154
+ buf.writeUInt8(0); // pointer (al8blv)
155
+ buf.writeUB4(0); // al8blv
156
+ buf.writeUInt8(0); // pointer (al8dnam)
157
+ buf.writeUB4(0); // al8dnaml
158
+ buf.writeUB4(0); // al8regid_msb
159
+ if (this.arrayDmlRowCounts) {
160
+ buf.writeUInt8(1); // pointer (al8pidmlrc)
161
+ buf.writeUB4(this.numExecs); // al8pidmlrcbl
162
+ buf.writeUInt8(1); // pointer (al8pidmlrcl)
163
+ } else {
164
+ buf.writeUInt8(0); // pointer (al8pidmlrc)
165
+ buf.writeUB4(0); // al8pidmlrcbl
166
+ buf.writeUInt8(0); // pointer (al8pidmlrcl)
167
+ }
168
+ if (buf.caps.ttcFieldVersion >= constants.TNS_CCAP_FIELD_VERSION_12_2) {
169
+ buf.writeUInt8(0); // pointer (al8sqlsig)
170
+ buf.writeUB4(0); // SQL signature length
171
+ buf.writeUInt8(0); // pointer (SQL ID)
172
+ buf.writeUB4(0); // allocated size of SQL ID
173
+ buf.writeUInt8(0); // pointer (length of SQL ID)
174
+ if (buf.caps.ttcFieldVersion >= constants.TNS_CCAP_FIELD_VERSION_12_2_EXT1) {
175
+ buf.writeUInt8(0); // pointer (chunk ids)
176
+ buf.writeUB4(0); // number of chunk ids
177
+ }
178
+ }
179
+ if (stmt.cursorId === 0 || stmt.isDdl) {
180
+ if (stmt.sql) {
181
+ buf.writeBytesWithLength(stmt.sqlBytes);
182
+ buf.writeUB4(1); // al8i4[0] parse
183
+ } else {
184
+ errors.throwErr(errors.ERR_INVALID_REF_CURSOR);
185
+ }
186
+ } else {
187
+ buf.writeUB4(0); // al8i4[0] parse
188
+ }
189
+ if (stmt.isQuery) {
190
+ if (stmt.cursorId === 0) {
191
+ buf.writeUB4(0); // al8i4[1] execution count
192
+ } else {
193
+ buf.writeUB4(numIters);
194
+ }
195
+ } else {
196
+ buf.writeUB4(this.numExecs); // al8i4[1] execution count
197
+ }
198
+ buf.writeUB4(0); // al8i4[2]
199
+ buf.writeUB4(0); // al8i4[3]
200
+ buf.writeUB4(0); // al8i4[4]
201
+ buf.writeUB4(0); // al8i4[5] SCN (part 1)
202
+ buf.writeUB4(0); // al8i4[6] SCN (part 2)
203
+ buf.writeUB4((stmt.isQuery) ? 1 : 0); // al8i4[7] is query
204
+ buf.writeUB4(0); // al8i4[8]
205
+ buf.writeUB4(dmlOptions); // al8i4[9] DML row counts/implicit
206
+ buf.writeUB4(0); // al8i4[10]
207
+ buf.writeUB4(0); // al8i4[11]
208
+ buf.writeUB4(0); // al8i4[12]
209
+
210
+ /*
211
+ * write column metadata and bind params
212
+ */
213
+ if (stmt.requiresDefine) {
214
+ this.writeColumnMetadata(buf, this.statement.queryVars);
215
+ } else if (numParams > 0) {
216
+ return this.processBindParams(buf, params);
217
+ }
218
+ }
219
+
220
+ //-------------------------------------------------------------------------
221
+ // writeReExecuteMessage()
222
+ //
223
+ // Write the message header for a re-execute and return the bind parameters.
224
+ //-------------------------------------------------------------------------
225
+ writeReExecuteMessage(buf) {
226
+ let stmt = this.statement;
227
+ let params = stmt.bindInfoList;
228
+ let execFlag1 = 0, execFlag2 = 0, numIters;
229
+ if (params !== undefined) {
230
+ if (!stmt.isQuery) {
231
+ this.outVariables = [];
232
+ params.forEach(info => {
233
+ if (info.bindDir !== constants.TNS_BIND_DIR_INPUT) {
234
+ this.outVariables.push(info.bindVar);
235
+ }
236
+ });
237
+ }
238
+
239
+ let tmpparams = [];
240
+ params.forEach(info => {
241
+ if (info.bindDir !== constants.TNS_BIND_DIR_OUTPUT && !info.isReturnBind) {
242
+ tmpparams.push(info);
243
+ }
244
+ });
245
+ params = tmpparams;
246
+ }
247
+
248
+ if (this.functionCode === constants.TNS_FUNC_REEXECUTE_AND_FETCH) {
249
+ execFlag1 |= constants.TNS_EXEC_OPTION_EXECUTE;
250
+ numIters = this.options.prefetchRows;
251
+ } else {
252
+ if (this.options.autoCommit) {
253
+ execFlag2 |= constants.TNS_EXEC_OPTION_COMMIT_REEXECUTE;
254
+ }
255
+ numIters = this.numExecs;
256
+ }
257
+ this.writePiggybacks(buf);
258
+ this.writeFunctionHeader(buf);
259
+ buf.writeUB4(stmt.cursorId);
260
+ buf.writeUB4(numIters);
261
+ buf.writeUB4(execFlag1);
262
+ buf.writeUB4(execFlag2);
263
+ return params;
264
+ }
265
+
266
+ //-------------------------------------------------------------------------
267
+ // encode()
268
+ //
269
+ // Write the execute message to the buffer. Two types of execute messages
270
+ // are possible: one for a full execute and the second, simpler message,
271
+ // for when an existing cursor is being re-executed.
272
+ //-------------------------------------------------------------------------
273
+ encode(buf) {
274
+
275
+ // no rows have yet been sent so the header information needs to be sent
276
+ if (this.currentRow === 0) {
277
+ let stmt = this.statement;
278
+ if (stmt.cursorId !== 0 && !stmt.requiresFullExecute && !this.parseOnly && !stmt.requiresDefine && !stmt.isDdl && !this.batchErrors) {
279
+ if (stmt.isQuery && !stmt.requiresDefine && this.options.prefetchRows > 0) {
280
+ this.functionCode = constants.TNS_FUNC_REEXECUTE_AND_FETCH;
281
+ } else {
282
+ this.functionCode = constants.TNS_FUNC_REEXECUTE;
283
+ }
284
+ this.bindParams = this.writeReExecuteMessage(buf);
285
+ } else {
286
+ this.functionCode = constants.TNS_FUNC_EXECUTE;
287
+ this.bindParams = this.writeExecuteMessage(buf);
288
+ }
289
+ }
290
+
291
+ // if any bind parameters need to be sent, do that
292
+ // after each row is sent, check to see whether a pause should be performed
293
+ if (this.bindParams && this.bindParams.length > 0) {
294
+ const adapter = buf.nsi.ntAdapter;
295
+ while (this.currentRow < this.numExecs) {
296
+ buf.writeUInt8(constants.TNS_MSG_TYPE_ROW_DATA);
297
+ this.writeBindParamsRow(buf, this.bindParams, this.currentRow);
298
+ this.currentRow++;
299
+ if (this.currentRow < this.numExecs && adapter.shouldPauseWrite())
300
+ return true;
301
+ }
302
+ }
303
+
304
+ // reset state in case message is resent
305
+ this.currentRow = 0;
306
+ this.bindParams = undefined;
307
+
308
+ }
309
+
310
+ }
311
+
312
+ module.exports = ExecuteMessage;
@@ -0,0 +1,60 @@
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 MessageWithData = require("./withData.js");
31
+
32
+ /**
33
+ * Executes OFETCH RPC
34
+ *
35
+ * @class FetchMessage
36
+ * @extends {MessageWithData}
37
+ */
38
+ class FetchMessage extends MessageWithData {
39
+
40
+ constructor(connection, statement, options, resultSet) {
41
+ super(connection, statement, options);
42
+ this.resultSet = resultSet;
43
+ this.functionCode = constants.TNS_FUNC_FETCH;
44
+ }
45
+
46
+ //-------------------------------------------------------------------------
47
+ // encode()
48
+ //
49
+ // Write the cursor ID and the number of rows to be fetched in the
50
+ // Fetch Message RPC
51
+ //-------------------------------------------------------------------------
52
+ encode(buf) {
53
+ this.writeFunctionHeader(buf);
54
+ buf.writeUB4(this.statement.cursorId);
55
+ buf.writeUB4(this.options.fetchArraySize);
56
+ }
57
+
58
+ }
59
+
60
+ module.exports = FetchMessage;
@@ -0,0 +1,53 @@
1
+ // Copyright (c) 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 AuthMessage = require('./auth.js');
30
+ const CommitMessage = require('./commit.js');
31
+ const DataTypeMessage = require('./dataType.js');
32
+ const ExecuteMessage = require('./execute.js');
33
+ const FetchMessage = require('./fetch.js');
34
+ const LobOpMessage = require('./lobOp.js');
35
+ const LogOffMessage = require('./logOff.js');
36
+ const PingMessage = require('./ping.js');
37
+ const ProtocolMessage = require('./protocol.js');
38
+ const RollbackMessage = require('./rollback.js');
39
+ const SessionReleaseMessage = require('./sessionRelease.js');
40
+
41
+ module.exports = {
42
+ AuthMessage,
43
+ CommitMessage,
44
+ DataTypeMessage,
45
+ ExecuteMessage,
46
+ FetchMessage,
47
+ LobOpMessage,
48
+ LogOffMessage,
49
+ PingMessage,
50
+ ProtocolMessage,
51
+ RollbackMessage,
52
+ SessionReleaseMessage
53
+ };
@@ -0,0 +1,201 @@
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 { Buffer } = require('buffer');
30
+ const constants = require('../constants.js');
31
+ const Message = require('./base.js');
32
+
33
+ /**
34
+ * Abstracts all LOB operations.
35
+ *
36
+ * @class LobOpMessage
37
+ * @extends {Message}
38
+ */
39
+ class LobOpMessage extends Message {
40
+
41
+ constructor(connImpl, options) {
42
+ super(connImpl);
43
+ /*
44
+ * source LOB locator. Reading data from it.
45
+ */
46
+ this.sourceLobImpl = options.sourceLobImpl || null;
47
+ this.operation = options.operation;
48
+ /*
49
+ * Destination LOB locator. For copy, append operations,...
50
+ */
51
+ this.destLobImpl = options.destLobImpl || null;
52
+ /*
53
+ * Offset from where sourceLob operation to start
54
+ */
55
+ this.sourceOffset = options.sourceOffset || 0;
56
+ /*
57
+ * Offset from where destLob operation to start
58
+ */
59
+ this.destOffset = options.destOffset || 0;
60
+ this.boolFlag = false;
61
+ if (options.data) { // data available For Writes
62
+ this.data = options.data;
63
+ }
64
+ this.functionCode = constants.TNS_FUNC_LOB_OP;
65
+ this.sendAmount = options.sendAmount;
66
+ this.amount = options.amount || 0; // LOB length
67
+ }
68
+
69
+ encode(buf) {
70
+ this.writeFunctionHeader(buf);
71
+ if (this.sourceLobImpl === null) {
72
+ buf.writeUInt8(0);
73
+ buf.writeUB4(0);
74
+ } else {
75
+ buf.writeUInt8(1);
76
+ buf.writeUB4(this.sourceLobImpl._locator.length);
77
+ }
78
+ if (this.destLobImpl === null) {
79
+ buf.writeUInt8(0);
80
+ buf.writeUB4(0);
81
+ } else {
82
+ buf.writeUInt8(1);
83
+ buf.writeUB4(this.destLobImpl._locator.length);
84
+ }
85
+ buf.writeUB4(0);
86
+ buf.writeUB4(0);
87
+ if (this.operation === constants.TNS_LOB_OP_CREATE_TEMP) {
88
+ buf.writeUInt8(1);
89
+ } else {
90
+ buf.writeUInt8(0);
91
+ }
92
+ buf.writeUInt8(0);
93
+ if (this.operation === constants.TNS_LOB_OP_CREATE_TEMP
94
+ || this.operation === constants.TNS_LOB_OP_IS_OPEN) {
95
+ buf.writeUInt8(1);
96
+ } else {
97
+ buf.writeUInt8(0);
98
+ }
99
+ buf.writeUB4(this.operation);
100
+ buf.writeUInt8(0);
101
+ buf.writeUInt8(0);
102
+ buf.writeUB8(this.sourceOffset);
103
+ buf.writeUB8(this.destOffset);
104
+ if (this.sendAmount) {
105
+ buf.writeUInt8(1);
106
+ } else {
107
+ buf.writeUInt8(0);
108
+ }
109
+ for (let i = 0; i < 3; i++) {
110
+ buf.writeUInt16BE(0);
111
+ }
112
+ if (this.sourceLobImpl) {
113
+ buf.writeBytes(this.sourceLobImpl._locator);
114
+ }
115
+ if (this.destLobImpl) {
116
+ buf.writeBytes(this.destLobImpl._locator);
117
+ }
118
+ if (this.operation === constants.TNS_LOB_OP_CREATE_TEMP) {
119
+ if (this.sourceLobImpl.dbType._csfrm === constants.TNS_CS_NCHAR) {
120
+ buf.caps.checkNCharsetId();
121
+ buf.writeUB4(constants.TNS_CHARSET_UTF16);
122
+ } else {
123
+ buf.writeUB4(constants.TNS_CHARSET_UTF8);
124
+ }
125
+ }
126
+ if (this.data) {
127
+ let data;
128
+ buf.writeUInt8(constants.TNS_MSG_TYPE_LOB_DATA);
129
+ if (this.sourceLobImpl.dbType._oraTypeNum === constants.TNS_DATA_TYPE_BLOB) {
130
+ data = this.data;
131
+ } else if (this.sourceLobImpl.getCsfrm() === constants.TNS_CS_NCHAR) {
132
+ data = this.data;
133
+ // TODO: avoid conversion back to string, if possible
134
+ // this is since bind data is converted to buffer automatically, but if
135
+ // it exceeds 32K for PL/SQL it must be written as a temporary LOB
136
+ if (Buffer.isBuffer(this.data)) {
137
+ data = data.toString();
138
+ }
139
+ data = Buffer.from(data, constants.TNS_ENCODING_UTF16).swap16();
140
+ } else {
141
+ data = Buffer.from(this.data);
142
+ }
143
+ buf.writeBytesWithLength(data);
144
+ }
145
+ if (this.sendAmount) {
146
+ buf.writeUB8(this.amount);
147
+ }
148
+ }
149
+
150
+ processMessage(buf, messageType) {
151
+ if (messageType === constants.TNS_MSG_TYPE_LOB_DATA) {
152
+ const oraTypeNum = this.sourceLobImpl.dbType._oraTypeNum;
153
+ let data = buf.readBytesWithLength();
154
+ if (data !== null) {
155
+ if (oraTypeNum === constants.TNS_DATA_TYPE_BLOB) {
156
+ data = Buffer.from(data);
157
+ } else if (this.sourceLobImpl.getCsfrm() === constants.TNS_CS_NCHAR) {
158
+ data = Buffer.from(data).swap16().toString('utf16le');
159
+ } else {
160
+ data = data.toString();
161
+ }
162
+ }
163
+ this.data = data;
164
+ } else {
165
+ super.processMessage(buf, messageType);
166
+ }
167
+ }
168
+
169
+ processReturnParameter(buf) {
170
+ let lobArray;
171
+ let locator;
172
+ let temp16;
173
+ let numBytes;
174
+ if (this.sourceLobImpl !== null) {
175
+ numBytes = this.sourceLobImpl._locator.length;
176
+ lobArray = buf.readBytes(numBytes);
177
+ locator = lobArray.slice(0, numBytes);
178
+ locator.copy(this.sourceLobImpl._locator);
179
+ }
180
+ if (this.destLobImpl !== null) {
181
+ numBytes = this.destLobImpl._locator.length;
182
+ lobArray = buf.readBytes(numBytes);
183
+ locator = lobArray.slice(0, numBytes);
184
+ locator.copy(this.destLobImpl._locator);
185
+ }
186
+ if (this.operation === constants.TNS_LOB_OP_CREATE_TEMP) {
187
+ buf.skipUB2();
188
+ }
189
+ if (this.sendAmount) {
190
+ this.amount = buf.readSB8();
191
+ }
192
+ if (this.operation === constants.TNS_LOB_OP_CREATE_TEMP
193
+ || this.operation === constants.TNS_LOB_OP_IS_OPEN) {
194
+ temp16 = buf.readUB2();
195
+ this.boolFlag = temp16 > 0;
196
+ }
197
+ }
198
+
199
+ }
200
+
201
+ module.exports = LobOpMessage;
@@ -0,0 +1,53 @@
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 Message = require("./base.js");
30
+ const constants = require("../constants.js");
31
+
32
+ /**
33
+ * Executes Logoff RPC
34
+ *
35
+ * @class LogOffMessage
36
+ * @extends {Message}
37
+ *
38
+ */
39
+ class LogOffMessage extends Message {
40
+
41
+ constructor(connImpl) {
42
+ super(connImpl);
43
+ this.functionCode = constants.TNS_FUNC_LOGOFF;
44
+ }
45
+
46
+ encode(buf) {
47
+ this.writePiggybacks(buf);
48
+ this.writeFunctionHeader(buf);
49
+ }
50
+
51
+ }
52
+
53
+ module.exports = LogOffMessage;