oracledb 5.4.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 (108) hide show
  1. package/CHANGELOG.md +1 -1849
  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/THIRD_PARTY_LICENSES.txt +1 -1
  7. package/build/Release/oracledb-6.0.0-darwin-x64.node +0 -0
  8. package/build/Release/oracledb-6.0.0-darwin-x64.node-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-6.0.0-js-buildinfo.txt +1 -0
  10. package/build/Release/oracledb-6.0.0-linux-arm64.node +0 -0
  11. package/build/Release/oracledb-6.0.0-linux-arm64.node-buildinfo.txt +1 -0
  12. package/build/Release/oracledb-6.0.0-linux-x64.node +0 -0
  13. package/build/Release/oracledb-6.0.0-linux-x64.node-buildinfo.txt +1 -0
  14. package/build/Release/oracledb-6.0.0-win32-x64.node +0 -0
  15. package/build/Release/oracledb-6.0.0-win32-x64.node-buildinfo.txt +1 -0
  16. package/examples/README.md +113 -0
  17. package/examples/dbconfig.js +100 -0
  18. package/examples/example.js +156 -0
  19. package/index.js +26 -0
  20. package/lib/aqDeqOptions.js +146 -7
  21. package/lib/aqEnqOptions.js +59 -7
  22. package/lib/aqMessage.js +118 -7
  23. package/lib/aqQueue.js +242 -53
  24. package/lib/connection.js +1324 -465
  25. package/lib/constants.js +203 -0
  26. package/lib/dbObject.js +346 -32
  27. package/lib/errors.js +781 -0
  28. package/lib/impl/aqDeqOptions.js +197 -0
  29. package/lib/impl/aqEnqOptions.js +89 -0
  30. package/lib/impl/aqMessage.js +134 -0
  31. package/lib/impl/aqQueue.js +81 -0
  32. package/lib/impl/connection.js +529 -0
  33. package/lib/impl/dbObject.js +159 -0
  34. package/lib/impl/index.js +59 -0
  35. package/lib/impl/lob.js +85 -0
  36. package/lib/impl/pool.js +195 -0
  37. package/lib/impl/resultset.js +223 -0
  38. package/lib/impl/sodaCollection.js +174 -0
  39. package/lib/impl/sodaDatabase.js +81 -0
  40. package/lib/impl/sodaDocCursor.js +63 -0
  41. package/lib/impl/sodaDocument.js +98 -0
  42. package/lib/impl/sodaOperation.js +109 -0
  43. package/lib/lob.js +156 -68
  44. package/lib/oracledb.js +1051 -257
  45. package/lib/pool.js +654 -465
  46. package/lib/poolStatistics.js +23 -9
  47. package/lib/queryStream.js +14 -7
  48. package/lib/resultset.js +292 -171
  49. package/lib/settings.js +191 -0
  50. package/lib/sodaCollection.js +214 -201
  51. package/lib/sodaDatabase.js +107 -71
  52. package/lib/sodaDocCursor.js +44 -32
  53. package/lib/sodaDocument.js +76 -14
  54. package/lib/sodaOperation.js +131 -118
  55. package/lib/thin/connection.js +1038 -0
  56. package/lib/thin/dbObject.js +629 -0
  57. package/lib/thin/index.js +40 -0
  58. package/lib/thin/lob.js +188 -0
  59. package/lib/thin/pool.js +481 -0
  60. package/lib/thin/protocol/buffer.js +1040 -0
  61. package/lib/thin/protocol/capabilities.js +116 -0
  62. package/lib/thin/protocol/constants.js +764 -0
  63. package/lib/thin/protocol/encryptDecrypt.js +185 -0
  64. package/lib/thin/protocol/messages/auth.js +348 -0
  65. package/lib/thin/protocol/messages/base.js +475 -0
  66. package/lib/thin/protocol/messages/commit.js +56 -0
  67. package/lib/thin/protocol/messages/dataType.js +382 -0
  68. package/lib/thin/protocol/messages/execute.js +312 -0
  69. package/lib/thin/protocol/messages/fetch.js +60 -0
  70. package/lib/thin/protocol/messages/index.js +53 -0
  71. package/lib/thin/protocol/messages/lobOp.js +200 -0
  72. package/lib/thin/protocol/messages/logOff.js +53 -0
  73. package/lib/thin/protocol/messages/ping.js +56 -0
  74. package/lib/thin/protocol/messages/protocol.js +78 -0
  75. package/lib/thin/protocol/messages/rollback.js +56 -0
  76. package/lib/thin/protocol/messages/sessionRelease.js +60 -0
  77. package/lib/thin/protocol/messages/withData.js +811 -0
  78. package/lib/thin/protocol/oson.js +660 -0
  79. package/lib/thin/protocol/packet.js +520 -0
  80. package/lib/thin/protocol/protocol.js +202 -0
  81. package/lib/thin/protocol/utils.js +88 -0
  82. package/lib/thin/resultSet.js +122 -0
  83. package/lib/thin/sqlnet/connStrategy.js +175 -0
  84. package/lib/thin/sqlnet/constants.js +199 -0
  85. package/lib/thin/sqlnet/ezConnectResolver.js +488 -0
  86. package/lib/thin/sqlnet/navNodes.js +870 -0
  87. package/lib/thin/sqlnet/networkSession.js +620 -0
  88. package/lib/thin/sqlnet/ntTcp.js +525 -0
  89. package/lib/thin/sqlnet/nvStrToNvPair.js +783 -0
  90. package/lib/thin/sqlnet/packet.js +405 -0
  91. package/lib/thin/sqlnet/paramParser.js +205 -0
  92. package/lib/thin/sqlnet/sessionAtts.js +160 -0
  93. package/lib/thin/statement.js +301 -0
  94. package/lib/thin/util.js +289 -0
  95. package/lib/transformer.js +250 -0
  96. package/lib/types.js +357 -0
  97. package/lib/util.js +194 -108
  98. package/lib/version.js +36 -0
  99. package/package/README.md +33 -30
  100. package/package/install.js +89 -64
  101. package/package/prunebinaries.js +60 -12
  102. package/package.json +3 -3
  103. package/build/Release/oracledb-5.4.0-darwin-x64.node +0 -0
  104. package/build/Release/oracledb-5.4.0-darwin-x64.node-buildinfo.txt +0 -1
  105. package/build/Release/oracledb-5.4.0-linux-x64.node +0 -0
  106. package/build/Release/oracledb-5.4.0-linux-x64.node-buildinfo.txt +0 -1
  107. package/build/Release/oracledb-5.4.0-win32-x64.node +0 -0
  108. package/build/Release/oracledb-5.4.0-win32-x64.node-buildinfo.txt +0 -1
@@ -0,0 +1,475 @@
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
+
32
+ class OracleErrorInfo {
33
+ constructor() {
34
+ this.num = 0;
35
+ this.cursorId = 0;
36
+ this.pos = 0;
37
+ this.rowCount = 0;
38
+ this.message = "";
39
+ this.rowID = null;
40
+ this.batchErrors;
41
+ }
42
+ }
43
+
44
+ class Error {
45
+ constructor(num, message = "", context = "", isRecoverable = false, isWarning = false, code = 0, offset = 0) {
46
+ this.num = num;
47
+ this.message = message;
48
+ this.context = context;
49
+ this.isRecoverable = isRecoverable;
50
+ this.isWarning = isWarning;
51
+ this.code = code;
52
+ this.offset = offset;
53
+ }
54
+ }
55
+
56
+ /**
57
+ *
58
+ * Base class for all the RPC messages to support encode/decode functions
59
+ */
60
+ class Message {
61
+ constructor(connection) {
62
+ this.errorInfo = new OracleErrorInfo();
63
+ this.connection = connection;
64
+ this.messageType = constants.TNS_MSG_TYPE_FUNCTION;
65
+ this.functionCode = 0;
66
+ this.callStatus = 0;
67
+ this.flushOutBinds = false;
68
+ this.endToEndSeqNum = 0;
69
+ this.errorOccurred = false;
70
+ this.isWarning = false;
71
+ this.flushOutBinds = false;
72
+ this.processedError = false;
73
+ }
74
+
75
+ preProcess() { }
76
+ async postProcess() { }
77
+
78
+ writeFunctionHeader(buf) {
79
+ buf.writeUInt8(this.messageType);
80
+ buf.writeUInt8(this.functionCode);
81
+ buf.writeSeqNum();
82
+ if (buf.caps.ttcFieldVersion >= constants.TNS_CCAP_FIELD_VERSION_23_1_EXT_1) {
83
+ buf.writeUB8(0); // token number
84
+ }
85
+ }
86
+
87
+ processErrorInfo(buf) {
88
+ this.callStatus = buf.readUB4(); // end of call status
89
+ buf.skipUB2(); // end to end seq number
90
+ buf.skipUB4(); // current row number
91
+ buf.skipUB2(); // error number
92
+ buf.skipUB2(); // array elem error
93
+ buf.skipUB2(); // array elem error
94
+ this.errorInfo.cursorId = buf.readUB2(); // cursor id
95
+ this.errorInfo.pos = buf.readUB2(); // error position
96
+ buf.skipUB1(); // sql type
97
+ buf.skipUB1(); // fatal ?
98
+ buf.skipUB2(); // flags
99
+ buf.skipUB2(); // user cursor options
100
+ buf.skipUB1(); // UPI parameter
101
+ buf.skipUB1(); // warning flag
102
+ this.errorInfo.rowID = buf.readRowID(); // rowid
103
+ buf.skipUB4(); // OS error
104
+ buf.skipUB1(); // statement error
105
+ buf.skipUB1(); // call number
106
+ buf.skipUB2(); // padding
107
+ buf.skipUB4(); // success iters
108
+ let numBytes = buf.readUB4(); // oerrdd (logical rowid)
109
+ if (numBytes > 0) {
110
+ buf.skipBytesChunked();
111
+ }
112
+ // batch error codes
113
+ let numEntries = buf.readUB2(); // batch error codes array
114
+ if (numEntries > 0) {
115
+ this.errorInfo.batchErrors = [];
116
+ let firstByte = buf.readUInt8();
117
+ for (let i = 0; i < numEntries; i++) {
118
+ if (firstByte === constants.TNS_LONG_LENGTH_INDICATOR) {
119
+ buf.skipUB4(); // chunk length ignored
120
+ }
121
+ let errorCode = buf.readUB2();
122
+ this.errorInfo.batchErrors.push(new Error(errorCode));
123
+ }
124
+ if (firstByte === constants.TNS_LONG_LENGTH_INDICATOR) {
125
+ buf.skipBytes(1); // ignore end marker
126
+ }
127
+ }
128
+
129
+ // batch error offset
130
+ numEntries = buf.readUB2(); // batch error row offset array
131
+ if (numEntries > 0) {
132
+ let firstByte = buf.readUInt8();
133
+ for (let i = 0; i < numEntries; i++) {
134
+ if (firstByte === constants.TNS_LONG_LENGTH_INDICATOR) {
135
+ buf.skipUB4(); // chunk length ignored
136
+ }
137
+ this.errorInfo.batchErrors[i].offset = buf.readUB4();
138
+ }
139
+ if (firstByte === constants.TNS_LONG_LENGTH_INDICATOR) {
140
+ buf.skipBytes(1); // ignore end marker
141
+ }
142
+ }
143
+
144
+ // batch error messages
145
+ numEntries = buf.readUB2(); // batch error messages array
146
+ if (numEntries > 0) {
147
+ buf.skipBytes(1); // ignore packed size
148
+ for (let i = 0; i < numEntries; i++) {
149
+ buf.skipUB2(); // skip chunk length
150
+
151
+ this.errorInfo.batchErrors[i].message = buf.readStr(constants.TNS_CS_IMPLICIT);
152
+ buf.skipBytes(2); // ignore end marker
153
+ }
154
+ }
155
+
156
+ this.errorInfo.num = buf.readUB4(); // error number (extended)
157
+ this.errorInfo.rowCount = buf.readUB8(); // row number (extended)
158
+ if (this.errorInfo.num !== 0) {
159
+ this.errorOccurred = true;
160
+ this.errorInfo.message = buf.readStr(constants.TNS_CS_IMPLICIT);
161
+ /*
162
+ * Remove ending newline from ORA error message
163
+ */
164
+ this.errorInfo.message = this.errorInfo.message.replace(/\n+$/, "");
165
+ }
166
+ this.errorInfo.isWarning = false;
167
+ this.processedError = true;
168
+ }
169
+
170
+ processReturnParameter() { }
171
+
172
+ processWarningInfo(buf) {
173
+ this.errorInfo.num = buf.readUB2(); // error number
174
+ let numBytes = buf.readUB2(); // length of error message
175
+ buf.skipUB2(); // flags
176
+ if (this.errorInfo.num != 0 && numBytes > 0) {
177
+ this.errorInfo.message = buf.readStr(constants.TNS_CS_IMPLICIT);
178
+ }
179
+ this.errorInfo.isWarning = true;
180
+ }
181
+
182
+ hasMoreData(buf) {
183
+ return buf.numBytesLeft() > 0 && !this.flushOutBinds;
184
+ }
185
+
186
+ decode(buf) {
187
+ this.process(buf);
188
+ }
189
+
190
+ process(buf) {
191
+ this.flushOutBinds = false;
192
+ this.processedError = false;
193
+ do {
194
+ this.savePoint(buf);
195
+ const messageType = buf.readUInt8();
196
+ this.processMessage(buf, messageType);
197
+ } while (this.hasMoreData(buf));
198
+ }
199
+
200
+ savePoint(buf) {
201
+ buf.savePoint();
202
+ }
203
+
204
+ processMessage(buf, messageType) {
205
+ if (messageType === constants.TNS_MSG_TYPE_ERROR) {
206
+ this.processErrorInfo(buf);
207
+ } else if (messageType === constants.TNS_MSG_TYPE_WARNING) {
208
+ this.processWarningInfo(buf);
209
+ } else if (messageType === constants.TNS_MSG_TYPE_STATUS) {
210
+ this.callStatus = buf.readUB4();
211
+ this.endToEndSeqNum = buf.readUB2();
212
+ } else if (messageType === constants.TNS_MSG_TYPE_PARAMETER) {
213
+ this.processReturnParameter(buf);
214
+ } else if (messageType === constants.TNS_MSG_TYPE_SERVER_SIDE_PIGGYBACK) {
215
+ this.processServerSidePiggyBack(buf);
216
+ } else {
217
+ errors.throwErr(errors.ERR_UNEXPECTED_MESSAGE_TYPE, messageType);
218
+ }
219
+ }
220
+
221
+ processServerSidePiggyBack(buf) {
222
+ const opcode = buf.readUInt8();
223
+ if (opcode === constants.TNS_SERVER_PIGGYBACK_LTXID) {
224
+ const num_bytes = buf.readUB4();
225
+ if (num_bytes > 0) {
226
+ buf.skipBytes(num_bytes);
227
+ }
228
+ } else if ((opcode === constants.TNS_SERVER_PIGGYBACK_QUERY_CACHE_INVALIDATION)
229
+ || (opcode === constants.TNS_SERVER_PIGGYBACK_TRACE_EVENT)) {
230
+ // pass
231
+ } else if (opcode === constants.TNS_SERVER_PIGGYBACK_OS_PID_MTS) {
232
+ const nb = buf.readUB2();
233
+ buf.skipBytes(nb + 1);
234
+ } else if (opcode === constants.TNS_SERVER_PIGGYBACK_SYNC) {
235
+ buf.skipUB2(); // skip number of DTYs
236
+ buf.skipUB1(); // skip length of DTYs
237
+ const num_elements = buf.readUB2();
238
+ buf.skipBytes(1); // skip length
239
+ for (let i = 0; i < num_elements; i++) {
240
+ let temp16 = buf.readUB2();
241
+ if (temp16 > 0) { // skip key
242
+ buf.skipBytes(temp16 + 1);
243
+ }
244
+ temp16 = buf.readUB2();
245
+ if (temp16 > 0) { // skip value
246
+ buf.skipBytes(temp16 + 1);
247
+ }
248
+ buf.skipUB2(); // skip flags
249
+ buf.skipUB4(); // skip overall flags
250
+ }
251
+ } else if (opcode === constants.TNS_SERVER_PIGGYBACK_EXT_SYNC) {
252
+ buf.skipUB2();
253
+ buf.skipUB1();
254
+ } else if (opcode === constants.TNS_SERVER_PIGGYBACK_AC_REPLAY_CONTEXT) {
255
+ buf.skipUB2(); // skip number of DTYs
256
+ buf.skipUB1(1); // skip length of DTYs
257
+ buf.skipUB4(); // skip flags
258
+ buf.skipUB4(); // skip error code
259
+ buf.skipUB1(); // skip queue
260
+ const num_bytes = buf.readUB4(); // skip replay context
261
+ if (num_bytes > 0) {
262
+ buf.skipBytes(num_bytes);
263
+ }
264
+ } else if (opcode === constants.TNS_SERVER_PIGGYBACK_SESS_RET) {
265
+ buf.skipUB2();
266
+ buf.skipUB1();
267
+ const num_elements = buf.readUB2();
268
+ if (num_elements > 0) {
269
+ buf.skipUB1();
270
+ for (let i = 0; i < num_elements; ++i) {
271
+ let temp16 = buf.readUB2();
272
+ if (temp16 > 0) { // skip key
273
+ buf.skipBytes(temp16 + 1);
274
+ }
275
+ temp16 = buf.readUB2();
276
+ if (temp16 > 0) { // skip value
277
+ buf.skipBytes(temp16 + 1);
278
+ }
279
+ buf.skipUB2(); // skip flags
280
+ }
281
+ }
282
+ const flags = buf.readUB4(); // session flags
283
+ if (flags & constants.TNS_SESSGET_SESSION_CHANGED) {
284
+ if (this.connection._drcpEstablishSession) {
285
+ this.connection.resetStatmentCache();
286
+ }
287
+ }
288
+ this.connection._drcpEstablishSession = false;
289
+ buf.skipUB4(); // session id
290
+ buf.skipUB2(); // serial number
291
+ } else {
292
+ errors.throwErr(errors.ERR_UNKOWN_SERVER_SIDE_PIGGYBACK, opcode);
293
+ }
294
+ }
295
+
296
+ writePiggybacks(buf) {
297
+ if (this.connection._currentSchemaModified) {
298
+ this._writeCurrentSchemaPiggyback(buf);
299
+ }
300
+ if (this.connection._cursorsToClose.size > 0 && !this.connection._drcpEstablishSession) {
301
+ this.writeCloseCursorsPiggyBack(buf);
302
+ }
303
+ if (
304
+ this.connection._actionModified ||
305
+ this.connection._clientIdentifierModified ||
306
+ this.connection._dbopModified ||
307
+ this.connection._clientInfoModified ||
308
+ this.connection._moduleModified
309
+ ) {
310
+ this._writeEndToEndPiggybacks(buf);
311
+ }
312
+ if (this.connection._tempLobsTotalSize > 0) {
313
+ this.writeCloseTempLobsPiggyback(buf);
314
+ }
315
+ }
316
+
317
+ writePiggybackHeader(buf, functionCode) {
318
+ buf.writeUInt8(constants.TNS_MSG_TYPE_PIGGYBACK);
319
+ buf.writeUInt8(functionCode);
320
+ buf.writeSeqNum();
321
+ if (buf.caps.ttcFieldVersion >= constants.TNS_CCAP_FIELD_VERSION_23_1_EXT_1) {
322
+ buf.writeUB8(0); // token number
323
+ }
324
+ }
325
+
326
+ writeCloseCursorsPiggyBack(buf) {
327
+ this.writePiggybackHeader(buf, constants.TNS_FUNC_CLOSE_CURSORS);
328
+ buf.writeUInt8(1);
329
+ buf.writeUB4(this.connection._cursorsToClose.size);
330
+ for (const cursorNum of this.connection._cursorsToClose.keys()) {
331
+ buf.writeUB4(cursorNum);
332
+ }
333
+ this.connection._cursorsToClose.clear();
334
+ }
335
+
336
+ writeCloseTempLobsPiggyback(buf) {
337
+ let lobsToClose = this.connection._tempLobsToClose;
338
+ let opCode = constants.TNS_LOB_OP_FREE_TEMP | constants.TNS_LOB_OP_ARRAY;
339
+
340
+ this.writePiggybackHeader(buf, constants.TNS_FUNC_LOB_OP);
341
+
342
+ buf.writeUInt8(1); // pointer
343
+ buf.writeUB4(this.connection._tempLobsTotalSize);
344
+ buf.writeUInt8(0); // dest LOB locator
345
+ buf.writeUB4(0);
346
+ buf.writeUB4(0); // source LOB locator
347
+ buf.writeUB4(0);
348
+ buf.writeUInt8(0); // source LOB offset
349
+ buf.writeUInt8(0); // dest LOB offset
350
+ buf.writeUInt8(0); // charset
351
+ buf.writeUB4(opCode);
352
+ buf.writeUInt8(0); // scn
353
+ buf.writeUB4(0); // LOB scn
354
+ buf.writeUB8(0); // LOB scnl
355
+ buf.writeUB8(0);
356
+ buf.writeUInt8(0);
357
+
358
+ // array LOB fields
359
+ buf.writeUInt8(0);
360
+ buf.writeUB4(0);
361
+ buf.writeUInt8(0);
362
+ buf.writeUB4(0);
363
+ buf.writeUInt8(0);
364
+ buf.writeUB4(0);
365
+ for (const val of lobsToClose) {
366
+ buf.writeBytes(val);
367
+ }
368
+
369
+ // Reset Values
370
+ this.connection._tempLobsToClose = [];
371
+ this.connection._tempLobsTotalSize = 0;
372
+ }
373
+
374
+ _writeCurrentSchemaPiggyback(buf) {
375
+ this.writePiggybackHeader(buf, constants.TNS_FUNC_SET_SCHEMA);
376
+ buf.writeUInt8(1);
377
+ const bytes = Buffer.byteLength(this.connection.currentSchema);
378
+ buf.writeUB4(bytes);
379
+ buf.writeBytesWithLength(Buffer.from(this.connection.currentSchema));
380
+ }
381
+
382
+ _writeEndToEndPiggybacks(buf) {
383
+ let flags = 0;
384
+
385
+ // determine which flags to send
386
+ if (this.connection._actionModified) {
387
+ flags |= constants.TNS_END_TO_END_ACTION;
388
+ }
389
+ if (this.connection._clientIdentifierModified) {
390
+ flags |= constants.TNS_END_TO_END_CLIENT_IDENTIFIER;
391
+ }
392
+ if (this.connection._clientInfoModified) {
393
+ flags |= constants.TNS_END_TO_END_CLIENT_INFO;
394
+ }
395
+ if (this.connection._moduleModified) {
396
+ flags |= constants.TNS_END_TO_END_MODULE;
397
+ }
398
+ if (this.connection._dbOpModified) {
399
+ flags |= constants.TNS_END_TO_END_DBOP;
400
+ }
401
+
402
+ // write initial packet data
403
+ this.writePiggybackHeader(buf, constants.TNS_FUNC_SET_END_TO_END_ATTR);
404
+ buf.writeUInt8(0); // pointer (cidnam)
405
+ buf.writeUInt8(0); // pointer (cidser)
406
+ buf.writeUB4(flags);
407
+
408
+ let clientIdentifierBytes = this.writeEndEndTraceValue(buf, this.connection._clientIdentifier, this.connection._clientIdentifierModified);
409
+ let moduleBytes = this.writeEndEndTraceValue(buf, this.connection._module, this.connection._moduleModified);
410
+ let actionBytes = this.writeEndEndTraceValue(buf, this.connection._action, this.connection._actionModified);
411
+
412
+ // write unsupported bits
413
+ buf.writeUInt8(0); // pointer (cideci)
414
+ buf.writeUB4(0); // length (cideci)
415
+ buf.writeUInt8(0); // cidcct
416
+ buf.writeUB4(0); // cidecs
417
+
418
+ let clientInfoBytes = this.writeEndEndTraceValue(buf, this.connection._clientInfo, this.connection._clientInfoModified);
419
+ // write unsupported bits
420
+ buf.writeUInt8(0); // pointer (cideci)
421
+ buf.writeUB4(0); // length (cideci)
422
+ buf.writeUInt8(0); // cidcct
423
+ buf.writeUB4(0); // cidecs
424
+ let dbOpBytes = this.writeEndEndTraceValue(buf, this.connection._dbOp, this.connection._dbOpModified);
425
+
426
+ // write strings
427
+ if (this.connection._clientIdentifierModified && this.connection._clientIdentifier) {
428
+ buf.writeBytesWithLength(clientIdentifierBytes);
429
+ }
430
+ if (this.connection._moduleModified && this.connection._module) {
431
+ buf.writeBytesWithLength(moduleBytes);
432
+ }
433
+ if (this.connection._actionModified && this.connection._action) {
434
+ buf.writeBytesWithLength(actionBytes);
435
+ }
436
+ if (this.connection._clientInfoModified && this.connection._clientInfo) {
437
+ buf.writeBytesWithLength(clientInfoBytes);
438
+ }
439
+ if (this.connection._dbOpModified && this.connection._dbOp) {
440
+ buf.writeBytesWithLength(dbOpBytes);
441
+ }
442
+
443
+ // reset flags and values
444
+ this.connection._actionModified = false;
445
+ this.connection._action = "";
446
+ this.connection._clientIdentifierModified = false;
447
+ this.connection._clientIdentifier = "";
448
+ this.connection._clientInfoModified = false;
449
+ this.connection._clientInfo = "";
450
+ this.connection._dbOpModified = false;
451
+ this.connection._dbOp = "";
452
+ this.connection._moduleModified = false;
453
+ this.connection._module = "";
454
+ }
455
+
456
+ writeEndEndTraceValue(buf, value, modified) {
457
+ // write client identifier header info
458
+ let writtenBytes;
459
+ if (modified) {
460
+ buf.writeUInt8(1); // pointer (client identifier)
461
+ if (value) {
462
+ writtenBytes = Buffer.from(value);
463
+ buf.writeUB4(writtenBytes.length);
464
+ } else {
465
+ buf.writeUB4(0);
466
+ }
467
+ } else {
468
+ buf.writeUInt8(0); // pointer (client identifier)
469
+ buf.writeUB4(0); // length of client identifier
470
+ }
471
+ return writtenBytes;
472
+ }
473
+ }
474
+
475
+ module.exports = Message;
@@ -0,0 +1,56 @@
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 Commit RPC
34
+ *
35
+ * @class CommitMessage
36
+ * @extends {Message}
37
+ */
38
+ class CommitMessage extends Message {
39
+
40
+ constructor(connImpl) {
41
+ super(connImpl);
42
+ this.functionCode = constants.TNS_FUNC_COMMIT;
43
+ }
44
+
45
+ //-------------------------------------------------------------------------
46
+ // encode()
47
+ //
48
+ // Write the RPC to perform commit operation in the database
49
+ //-------------------------------------------------------------------------
50
+ encode(pkt) {
51
+ this.writeFunctionHeader(pkt);
52
+ }
53
+
54
+ }
55
+
56
+ module.exports = CommitMessage;