oracledb 6.1.0 → 6.2.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.
- package/README.md +2 -2
- package/build/Release/oracledb-6.2.0-darwin-x64.node +0 -0
- package/build/Release/oracledb-6.2.0-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-6.2.0-js-buildinfo.txt +1 -0
- package/build/Release/oracledb-6.2.0-linux-arm64.node +0 -0
- package/build/Release/oracledb-6.2.0-linux-arm64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-6.2.0-linux-x64.node +0 -0
- package/build/Release/oracledb-6.2.0-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-6.2.0-win32-x64.node +0 -0
- package/build/Release/oracledb-6.2.0-win32-x64.node-buildinfo.txt +1 -0
- package/examples/dbconfig.js +7 -14
- package/lib/connection.js +1 -1
- package/lib/dbObject.js +9 -0
- package/lib/errors.js +7 -7
- package/lib/oracledb.js +11 -6
- package/lib/sodaCollection.js +11 -0
- package/lib/sodaOperation.js +16 -0
- package/lib/thin/connection.js +138 -153
- package/lib/thin/dbObject.js +4 -1
- package/lib/thin/protocol/buffer.js +64 -63
- package/lib/thin/protocol/messages/base.js +7 -0
- package/lib/thin/protocol/messages/withData.js +9 -4
- package/lib/thin/protocol/oson.js +13 -10
- package/lib/thin/protocol/packet.js +6 -5
- package/lib/thin/protocol/utils.js +1 -1
- package/lib/thin/sqlnet/ezConnectResolver.js +10 -43
- package/lib/thin/sqlnet/navNodes.js +2 -2
- package/lib/thin/sqlnet/networkSession.js +13 -19
- package/lib/thin/sqlnet/packet.js +1 -1
- package/lib/thin/statement.js +345 -113
- package/lib/thin/util.js +20 -82
- package/lib/util.js +4 -0
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/build/Release/oracledb-6.1.0-darwin-x64.node +0 -0
- package/build/Release/oracledb-6.1.0-darwin-x64.node-buildinfo.txt +0 -1
- package/build/Release/oracledb-6.1.0-js-buildinfo.txt +0 -1
- package/build/Release/oracledb-6.1.0-linux-arm64.node +0 -0
- package/build/Release/oracledb-6.1.0-linux-arm64.node-buildinfo.txt +0 -1
- package/build/Release/oracledb-6.1.0-linux-x64.node +0 -0
- package/build/Release/oracledb-6.1.0-linux-x64.node-buildinfo.txt +0 -1
- package/build/Release/oracledb-6.1.0-win32-x64.node +0 -0
- package/build/Release/oracledb-6.1.0-win32-x64.node-buildinfo.txt +0 -1
|
@@ -49,7 +49,7 @@ class BaseBuffer {
|
|
|
49
49
|
this.buf = Buffer.alloc(initializer);
|
|
50
50
|
this.size = 0;
|
|
51
51
|
this.maxSize = initializer;
|
|
52
|
-
} else {
|
|
52
|
+
} else if (initializer) {
|
|
53
53
|
this.buf = initializer;
|
|
54
54
|
this.size = this.maxSize = initializer.length;
|
|
55
55
|
}
|
|
@@ -548,11 +548,12 @@ class BaseBuffer {
|
|
|
548
548
|
// remain in the buffer, the buffer is grown.
|
|
549
549
|
//---------------------------------------------------------------------------
|
|
550
550
|
reserveBytes(numBytes) {
|
|
551
|
-
if (numBytes > this.numBytesLeft())
|
|
551
|
+
if (numBytes > this.numBytesLeft()) {
|
|
552
552
|
this._grow(this.pos + numBytes);
|
|
553
|
-
|
|
553
|
+
}
|
|
554
|
+
const pos = this.pos;
|
|
554
555
|
this.pos += numBytes;
|
|
555
|
-
return
|
|
556
|
+
return pos;
|
|
556
557
|
}
|
|
557
558
|
|
|
558
559
|
//---------------------------------------------------------------------------
|
|
@@ -618,20 +619,20 @@ class BaseBuffer {
|
|
|
618
619
|
//---------------------------------------------------------------------------
|
|
619
620
|
writeBinaryDouble(n) {
|
|
620
621
|
this.writeUInt8(8);
|
|
621
|
-
const
|
|
622
|
-
buf.writeDoubleBE(n);
|
|
623
|
-
if ((buf[
|
|
624
|
-
buf[
|
|
622
|
+
const pos = this.reserveBytes(8);
|
|
623
|
+
this.buf.writeDoubleBE(n, pos);
|
|
624
|
+
if ((this.buf[pos] & 0x80) === 0) {
|
|
625
|
+
this.buf[pos] |= 0x80;
|
|
625
626
|
} else {
|
|
626
627
|
// We complement the bits for a negative number
|
|
627
|
-
buf[
|
|
628
|
-
buf[1] ^= 0xff;
|
|
629
|
-
buf[2] ^= 0xff;
|
|
630
|
-
buf[3] ^= 0xff;
|
|
631
|
-
buf[4] ^= 0xff;
|
|
632
|
-
buf[5] ^= 0xff;
|
|
633
|
-
buf[6] ^= 0xff;
|
|
634
|
-
buf[7] ^= 0xff;
|
|
628
|
+
this.buf[pos] ^= 0xff;
|
|
629
|
+
this.buf[pos + 1] ^= 0xff;
|
|
630
|
+
this.buf[pos + 2] ^= 0xff;
|
|
631
|
+
this.buf[pos + 3] ^= 0xff;
|
|
632
|
+
this.buf[pos + 4] ^= 0xff;
|
|
633
|
+
this.buf[pos + 5] ^= 0xff;
|
|
634
|
+
this.buf[pos + 6] ^= 0xff;
|
|
635
|
+
this.buf[pos + 7] ^= 0xff;
|
|
635
636
|
}
|
|
636
637
|
}
|
|
637
638
|
|
|
@@ -642,16 +643,16 @@ class BaseBuffer {
|
|
|
642
643
|
//---------------------------------------------------------------------------
|
|
643
644
|
writeBinaryFloat(n) {
|
|
644
645
|
this.writeUInt8(4);
|
|
645
|
-
const
|
|
646
|
-
buf.writeFloatBE(n);
|
|
647
|
-
if ((buf[
|
|
648
|
-
buf[
|
|
646
|
+
const pos = this.reserveBytes(4);
|
|
647
|
+
this.buf.writeFloatBE(n, pos);
|
|
648
|
+
if ((this.buf[pos] & 0x80) === 0) {
|
|
649
|
+
this.buf[pos] |= 0x80;
|
|
649
650
|
} else {
|
|
650
651
|
// We complement the bits for a negative number
|
|
651
|
-
buf[
|
|
652
|
-
buf[1] ^= 0xff;
|
|
653
|
-
buf[2] ^= 0xff;
|
|
654
|
-
buf[3] ^= 0xff;
|
|
652
|
+
this.buf[pos] ^= 0xff;
|
|
653
|
+
this.buf[pos + 1] ^= 0xff;
|
|
654
|
+
this.buf[pos + 2] ^= 0xff;
|
|
655
|
+
this.buf[pos + 3] ^= 0xff;
|
|
655
656
|
}
|
|
656
657
|
}
|
|
657
658
|
|
|
@@ -745,31 +746,31 @@ class BaseBuffer {
|
|
|
745
746
|
if (writeLength) {
|
|
746
747
|
this.writeUInt8(length);
|
|
747
748
|
}
|
|
748
|
-
const
|
|
749
|
+
const pos = this.reserveBytes(length);
|
|
749
750
|
if (type === types.DB_TYPE_DATE || type == types.DB_TYPE_TIMESTAMP) {
|
|
750
751
|
const year = date.getFullYear();
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
752
|
+
this.buf[pos] = Math.trunc(year / 100) + 100;
|
|
753
|
+
this.buf[pos + 1] = year % 100 + 100;
|
|
754
|
+
this.buf[pos + 2] = date.getMonth() + 1;
|
|
755
|
+
this.buf[pos + 3] = date.getDate();
|
|
756
|
+
this.buf[pos + 4] = date.getHours() + 1;
|
|
757
|
+
this.buf[pos + 5] = date.getMinutes() + 1;
|
|
758
|
+
this.buf[pos + 6] = date.getSeconds() + 1;
|
|
758
759
|
} else {
|
|
759
760
|
const year = date.getUTCFullYear();
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
761
|
+
this.buf[pos] = Math.trunc(year / 100) + 100;
|
|
762
|
+
this.buf[pos + 1] = year % 100 + 100;
|
|
763
|
+
this.buf[pos + 2] = date.getUTCMonth() + 1;
|
|
764
|
+
this.buf[pos + 3] = date.getUTCDate();
|
|
765
|
+
this.buf[pos + 4] = date.getUTCHours() + 1;
|
|
766
|
+
this.buf[pos + 5] = date.getUTCMinutes() + 1;
|
|
767
|
+
this.buf[pos + 6] = date.getUTCSeconds() + 1;
|
|
767
768
|
}
|
|
768
769
|
if (length > 7) {
|
|
769
|
-
|
|
770
|
+
this.buf.writeInt32BE(fsec, pos + 7);
|
|
770
771
|
if (length > 11) {
|
|
771
|
-
|
|
772
|
-
|
|
772
|
+
this.buf[pos + 11] = constants.TZ_HOUR_OFFSET;
|
|
773
|
+
this.buf[pos + 12] = constants.TZ_MINUTE_OFFSET;
|
|
773
774
|
}
|
|
774
775
|
}
|
|
775
776
|
}
|
|
@@ -843,19 +844,19 @@ class BaseBuffer {
|
|
|
843
844
|
} else if (value.length === 0 && exponent === 0) {
|
|
844
845
|
exponentOnWire = 128;
|
|
845
846
|
}
|
|
846
|
-
|
|
847
|
-
buf[
|
|
848
|
-
buf[
|
|
849
|
-
for (let i = 0
|
|
847
|
+
let pos = this.reserveBytes(numPairs + 2 + appendSentinel);
|
|
848
|
+
this.buf[pos++] = numPairs + 1 + appendSentinel;
|
|
849
|
+
this.buf[pos++] = exponentOnWire;
|
|
850
|
+
for (let i = 0; i < value.length; i += 2) {
|
|
850
851
|
const base100Digit = Number(value.substring(i, i + 2));
|
|
851
852
|
if (isNegative) {
|
|
852
|
-
buf[pos] = 101 - base100Digit;
|
|
853
|
+
this.buf[pos++] = 101 - base100Digit;
|
|
853
854
|
} else {
|
|
854
|
-
buf[pos] = base100Digit + 1;
|
|
855
|
+
this.buf[pos++] = base100Digit + 1;
|
|
855
856
|
}
|
|
856
857
|
}
|
|
857
858
|
if (appendSentinel) {
|
|
858
|
-
buf[
|
|
859
|
+
this.buf[pos] = 102;
|
|
859
860
|
}
|
|
860
861
|
|
|
861
862
|
}
|
|
@@ -898,8 +899,8 @@ class BaseBuffer {
|
|
|
898
899
|
// Writes a signed 32-bit integer to the buffer in big endian order.
|
|
899
900
|
//---------------------------------------------------------------------------
|
|
900
901
|
writeInt32BE(n) {
|
|
901
|
-
const
|
|
902
|
-
buf.writeInt32BE(n);
|
|
902
|
+
const pos = this.reserveBytes(4);
|
|
903
|
+
this.buf.writeInt32BE(n, pos);
|
|
903
904
|
}
|
|
904
905
|
|
|
905
906
|
//---------------------------------------------------------------------------
|
|
@@ -971,8 +972,8 @@ class BaseBuffer {
|
|
|
971
972
|
// Writes an unsigned 8-bit integer to the buffer.
|
|
972
973
|
//---------------------------------------------------------------------------
|
|
973
974
|
writeUInt8(n) {
|
|
974
|
-
const
|
|
975
|
-
buf[
|
|
975
|
+
const pos = this.reserveBytes(1);
|
|
976
|
+
this.buf[pos] = n;
|
|
976
977
|
}
|
|
977
978
|
|
|
978
979
|
//---------------------------------------------------------------------------
|
|
@@ -981,8 +982,8 @@ class BaseBuffer {
|
|
|
981
982
|
// Writes an unsigned 16-bit integer to the buffer in big endian order.
|
|
982
983
|
//---------------------------------------------------------------------------
|
|
983
984
|
writeUInt16BE(n) {
|
|
984
|
-
const
|
|
985
|
-
buf.writeUInt16BE(n);
|
|
985
|
+
const pos = this.reserveBytes(2);
|
|
986
|
+
this.buf.writeUInt16BE(n, pos);
|
|
986
987
|
}
|
|
987
988
|
|
|
988
989
|
//---------------------------------------------------------------------------
|
|
@@ -991,8 +992,8 @@ class BaseBuffer {
|
|
|
991
992
|
// Writes an unsigned 32-bit integer to the buffer in big endian order.
|
|
992
993
|
//---------------------------------------------------------------------------
|
|
993
994
|
writeUInt32BE(n) {
|
|
994
|
-
const
|
|
995
|
-
buf.writeUInt32BE(n);
|
|
995
|
+
const pos = this.reserveBytes(4);
|
|
996
|
+
this.buf.writeUInt32BE(n, pos);
|
|
996
997
|
}
|
|
997
998
|
|
|
998
999
|
//---------------------------------------------------------------------------
|
|
@@ -1003,9 +1004,9 @@ class BaseBuffer {
|
|
|
1003
1004
|
// higher order bits are simply written as 0.
|
|
1004
1005
|
//---------------------------------------------------------------------------
|
|
1005
1006
|
writeUInt64BE(n) {
|
|
1006
|
-
const
|
|
1007
|
-
buf.writeUInt32BE(0);
|
|
1008
|
-
buf.writeUInt32BE(n, 4);
|
|
1007
|
+
const pos = this.reserveBytes(8);
|
|
1008
|
+
this.buf.writeUInt32BE(0, pos);
|
|
1009
|
+
this.buf.writeUInt32BE(n, pos + 4);
|
|
1009
1010
|
}
|
|
1010
1011
|
|
|
1011
1012
|
//---------------------------------------------------------------------------
|
|
@@ -1014,8 +1015,8 @@ class BaseBuffer {
|
|
|
1014
1015
|
// Writes an unsigned 16-bit integer to the buffer in little endian order.
|
|
1015
1016
|
//---------------------------------------------------------------------------
|
|
1016
1017
|
writeUInt16LE(n) {
|
|
1017
|
-
const
|
|
1018
|
-
buf.writeUInt16LE(n);
|
|
1018
|
+
const pos = this.reserveBytes(2);
|
|
1019
|
+
this.buf.writeUInt16LE(n, pos);
|
|
1019
1020
|
}
|
|
1020
1021
|
|
|
1021
1022
|
}
|
|
@@ -1048,7 +1049,7 @@ class GrowableBuffer extends BaseBuffer {
|
|
|
1048
1049
|
if (remainder > 0) {
|
|
1049
1050
|
numBytes += (constants.BUFFER_CHUNK_SIZE - remainder);
|
|
1050
1051
|
}
|
|
1051
|
-
const buf = Buffer.
|
|
1052
|
+
const buf = Buffer.allocUnsafe(numBytes);
|
|
1052
1053
|
this.buf.copy(buf);
|
|
1053
1054
|
this.buf = buf;
|
|
1054
1055
|
this.maxSize = this.size = numBytes;
|
|
@@ -448,6 +448,13 @@ class Message {
|
|
|
448
448
|
}
|
|
449
449
|
return writtenBytes;
|
|
450
450
|
}
|
|
451
|
+
|
|
452
|
+
// Called when an error is encountered during decode of RPC
|
|
453
|
+
saveDeferredErr() {
|
|
454
|
+
if (!this.deferredErr) {
|
|
455
|
+
this.deferredErr = errors.getErr(...arguments);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
451
458
|
}
|
|
452
459
|
|
|
453
460
|
module.exports = Message;
|
|
@@ -57,6 +57,7 @@ class MessageWithData extends Message {
|
|
|
57
57
|
this.inFetch = false;
|
|
58
58
|
this.parseOnly = false;
|
|
59
59
|
this.resultSetsToSetup = [];
|
|
60
|
+
this.deferredErr = null;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
/**
|
|
@@ -116,8 +117,8 @@ class MessageWithData extends Message {
|
|
|
116
117
|
this.errorOccurred = false;
|
|
117
118
|
this.statement.moreRowsToFetch = false;
|
|
118
119
|
} else if (this.errorInfo.num !== 0 && this.errorInfo.cursorId !== 0) {
|
|
119
|
-
this.connection._addCursorToClose(this.statement.cursorId);
|
|
120
120
|
this.connection.statementCache.delete(this.statement.sql);
|
|
121
|
+
this.statement.returnToCache = false;
|
|
121
122
|
}
|
|
122
123
|
if (this.errorInfo.batchErrors) {
|
|
123
124
|
this.errorOccurred = false;
|
|
@@ -472,7 +473,7 @@ class MessageWithData extends Message {
|
|
|
472
473
|
if (actualNumBytes < 0 && oraTypeNum === constants.TNS_DATA_TYPE_BOOLEAN) {
|
|
473
474
|
colValue = null;
|
|
474
475
|
} else if (actualNumBytes !== 0 && colValue !== null) {
|
|
475
|
-
|
|
476
|
+
this.saveDeferredErr(errors.ERR_INSUFFICIENT_BUFFER_FOR_BINDS);
|
|
476
477
|
}
|
|
477
478
|
} else if (oraTypeNum === constants.TNS_DATA_TYPE_LONG || oraTypeNum === constants.TNS_DATA_TYPE_LONG_RAW || variable.maxSize > buf.caps.maxStringSize) {
|
|
478
479
|
buf.skipSB4(); // null indicator
|
|
@@ -525,11 +526,15 @@ class MessageWithData extends Message {
|
|
|
525
526
|
}
|
|
526
527
|
|
|
527
528
|
async postProcess() {
|
|
529
|
+
if (this.deferredErr) {
|
|
530
|
+
throw this.deferredErr;
|
|
531
|
+
}
|
|
532
|
+
|
|
528
533
|
if (this.outVariables) {
|
|
529
534
|
for (const variable of this.outVariables) {
|
|
530
535
|
if (variable.isArray) {
|
|
531
|
-
|
|
532
|
-
|
|
536
|
+
if (variable.outConverter) {
|
|
537
|
+
for (let pos = 0; pos < variable.numElementsInArray; pos++) {
|
|
533
538
|
variable.values[0][pos] = await variable.outConverter(variable.values[0][pos]);
|
|
534
539
|
}
|
|
535
540
|
}
|
|
@@ -416,10 +416,11 @@ class OsonTreeSegment extends GrowableBuffer {
|
|
|
416
416
|
//---------------------------------------------------------------------------
|
|
417
417
|
_encodeArray(value, fnamesSeg) {
|
|
418
418
|
this._encodeContainer(constants.TNS_JSON_TYPE_ARRAY, value.length);
|
|
419
|
-
|
|
420
|
-
const
|
|
419
|
+
const len = value.length * 4;
|
|
420
|
+
const pos = this.reserveBytes(len);
|
|
421
|
+
let offsetsBufPos = pos;
|
|
421
422
|
for (const element of value) {
|
|
422
|
-
|
|
423
|
+
this.buf.writeUInt32BE(this.pos, offsetsBufPos);
|
|
423
424
|
offsetsBufPos += 4;
|
|
424
425
|
this.encodeNode(element, fnamesSeg);
|
|
425
426
|
}
|
|
@@ -456,19 +457,21 @@ class OsonTreeSegment extends GrowableBuffer {
|
|
|
456
457
|
_encodeObject(value, fnamesSeg) {
|
|
457
458
|
const numChildren = value.values.length;
|
|
458
459
|
this._encodeContainer(constants.TNS_JSON_TYPE_OBJECT, numChildren);
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
460
|
+
const len = numChildren * (fnamesSeg.fieldIdSize + 4);
|
|
461
|
+
const pos = this.reserveBytes(len);
|
|
462
|
+
let fieldIdOffset = pos;
|
|
463
|
+
let valueOffset = pos + (numChildren * fnamesSeg.fieldIdSize);
|
|
464
|
+
|
|
462
465
|
for (let i = 0; i < value.fields.length; i++) {
|
|
463
466
|
const fieldName = fnamesSeg.fieldNamesMap.get(value.fields[i]);
|
|
464
467
|
if (fnamesSeg.fieldIdSize == 1) {
|
|
465
|
-
buf[fieldIdOffset] = fieldName.fieldId;
|
|
468
|
+
this.buf[fieldIdOffset] = fieldName.fieldId;
|
|
466
469
|
} else if (fnamesSeg.fieldIdSize == 2) {
|
|
467
|
-
buf.writeUInt16BE(fieldName.fieldId, fieldIdOffset);
|
|
470
|
+
this.buf.writeUInt16BE(fieldName.fieldId, fieldIdOffset);
|
|
468
471
|
} else {
|
|
469
|
-
buf.writeUInt32BE(fieldName.fieldId, fieldIdOffset);
|
|
472
|
+
this.buf.writeUInt32BE(fieldName.fieldId, fieldIdOffset);
|
|
470
473
|
}
|
|
471
|
-
buf.writeUInt32BE(this.pos, valueOffset);
|
|
474
|
+
this.buf.writeUInt32BE(this.pos, valueOffset);
|
|
472
475
|
fieldIdOffset += fnamesSeg.fieldIdSize;
|
|
473
476
|
valueOffset += 4;
|
|
474
477
|
this.encodeNode(value.values[i], fnamesSeg);
|
|
@@ -35,7 +35,6 @@ const errors = require("../../errors.js");
|
|
|
35
35
|
|
|
36
36
|
const TNS_BASE64_ALPHABET_ARRAY = Buffer.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 'utf8');
|
|
37
37
|
|
|
38
|
-
|
|
39
38
|
/**
|
|
40
39
|
* Class used for byte chunks used in the ChunkedBytesBuffer.
|
|
41
40
|
*/
|
|
@@ -52,7 +51,7 @@ class BytesChunk {
|
|
|
52
51
|
if (remainder > 0) {
|
|
53
52
|
this.allocLen += (constants.CHUNKED_BYTES_CHUNK_SIZE - remainder);
|
|
54
53
|
}
|
|
55
|
-
this.buf = Buffer.
|
|
54
|
+
this.buf = Buffer.allocUnsafe(this.allocLen);
|
|
56
55
|
this.actualLen = 0;
|
|
57
56
|
}
|
|
58
57
|
|
|
@@ -133,6 +132,7 @@ class ChunkedBytesBuffer {
|
|
|
133
132
|
*
|
|
134
133
|
* @class ReadPacket
|
|
135
134
|
*/
|
|
135
|
+
|
|
136
136
|
class ReadPacket extends BaseBuffer {
|
|
137
137
|
|
|
138
138
|
/**
|
|
@@ -140,8 +140,9 @@ class ReadPacket extends BaseBuffer {
|
|
|
140
140
|
* @param {Object} adapter used for sending/receiving data
|
|
141
141
|
* @param {Object} capabilities
|
|
142
142
|
*/
|
|
143
|
+
|
|
143
144
|
constructor(nsi, caps) {
|
|
144
|
-
super(
|
|
145
|
+
super();
|
|
145
146
|
this.nsi = nsi;
|
|
146
147
|
this.caps = caps;
|
|
147
148
|
this.chunkedBytesBuf = new ChunkedBytesBuffer();
|
|
@@ -228,7 +229,7 @@ class ReadPacket extends BaseBuffer {
|
|
|
228
229
|
if (inChunkedRead) {
|
|
229
230
|
buf = this.chunkedBytesBuf.getBuf(numBytes);
|
|
230
231
|
} else {
|
|
231
|
-
buf = Buffer.
|
|
232
|
+
buf = Buffer.allocUnsafe(numBytes);
|
|
232
233
|
}
|
|
233
234
|
|
|
234
235
|
// copy the bytes to the buffer from the remainder of this packet
|
|
@@ -341,7 +342,7 @@ class ReadPacket extends BaseBuffer {
|
|
|
341
342
|
outputLen += 3;
|
|
342
343
|
}
|
|
343
344
|
|
|
344
|
-
const outputValue = Buffer.
|
|
345
|
+
const outputValue = Buffer.allocUnsafe(outputLen);
|
|
345
346
|
inputLen -= 1;
|
|
346
347
|
outputValue[0] = 42;
|
|
347
348
|
outputOffset += 1;
|
|
@@ -43,7 +43,7 @@ function _convertBase64(result, value, size, offset) {
|
|
|
43
43
|
function encodeRowID(rowID) {
|
|
44
44
|
let offset = 0;
|
|
45
45
|
if (rowID.rba !== 0 || rowID.partitionID !== 0 || rowID.blockNum !== 0 || rowID.slotNum != 0) {
|
|
46
|
-
const result = Buffer.
|
|
46
|
+
const result = Buffer.allocUnsafe(constants.TNS_MAX_ROWID_LENGTH);
|
|
47
47
|
offset = _convertBase64(result, rowID.rba, 6, offset);
|
|
48
48
|
offset = _convertBase64(result, rowID.partitionID, 3, offset);
|
|
49
49
|
offset = _convertBase64(result, rowID.blockNum, 6, offset);
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
|
|
27
27
|
'use strict';
|
|
28
28
|
|
|
29
|
-
const {lookup} = require('dns').promises;
|
|
30
29
|
const errors = require("../../errors.js");
|
|
31
30
|
|
|
32
31
|
// The host information pattern of the EZConnect URL format.
|
|
@@ -71,14 +70,7 @@ const DESCRIPTION_PARAMS = ["ENABLE", "FAILOVER", "LOAD_BALANCE",
|
|
|
71
70
|
class EZConnectResolver {
|
|
72
71
|
constructor(url) {
|
|
73
72
|
this.URL_PROPS_ALIAS = this.initializeUrlAlias();
|
|
74
|
-
|
|
75
|
-
if (jdbcUrlPrefix != -1) {
|
|
76
|
-
this.url = url.substring(jdbcUrlPrefix + 1);
|
|
77
|
-
this.urlPrefix = url.substring(0, jdbcUrlPrefix + 1);
|
|
78
|
-
} else {
|
|
79
|
-
this.url = url;
|
|
80
|
-
this.urlPrefix = "";
|
|
81
|
-
}
|
|
73
|
+
this.url = url;
|
|
82
74
|
this.resolvedUrl = '';
|
|
83
75
|
this.connectionProps = new Map();
|
|
84
76
|
this.urlProps = new Map();
|
|
@@ -89,8 +81,8 @@ class EZConnectResolver {
|
|
|
89
81
|
* Returns the resolved long TNS String.
|
|
90
82
|
* @return Resolved TNS URL.
|
|
91
83
|
*/
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
getResolvedUrl() {
|
|
85
|
+
this.parse();
|
|
94
86
|
return this.resolvedUrl;
|
|
95
87
|
}
|
|
96
88
|
|
|
@@ -99,29 +91,22 @@ class EZConnectResolver {
|
|
|
99
91
|
* After parsing the extended settings if the remaining part of the URL is in
|
|
100
92
|
* EZConnectURL format then resolve it to long TNS url format.
|
|
101
93
|
*/
|
|
102
|
-
|
|
94
|
+
parse() {
|
|
103
95
|
// First try to parse the extended settings part of the URL.
|
|
104
96
|
let parsedUrl = this.parseExtendedSettings(this.url);
|
|
105
97
|
if (this.connectionProps.size === 0 && this.urlProps.size === 0) {
|
|
106
98
|
// If we have not parsed anything then use the received url as is.
|
|
107
99
|
parsedUrl = this.url;
|
|
108
100
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// Skip resolve the URL if it is in TNS format,
|
|
112
|
-
// TNS format starts with '('
|
|
113
|
-
this.resolvedUrl = this.urlPrefix + parsedUrl;
|
|
114
|
-
} else {
|
|
115
|
-
// Try to resolve the EZConnectURL to Long TNS URL.
|
|
116
|
-
this.resolvedUrl = this.urlPrefix + await this.resolveToLongURLFormat(parsedUrl);
|
|
117
|
-
}
|
|
101
|
+
// Try to resolve the EZConnectURL to Long TNS URL.
|
|
102
|
+
this.resolvedUrl = this.resolveToLongURLFormat(parsedUrl);
|
|
118
103
|
}
|
|
119
104
|
/**
|
|
120
105
|
* Translate the given ezconnect url format to Long TNS format.
|
|
121
106
|
* @param url EZConnect URL
|
|
122
107
|
* @return Returns resolved TNS url.
|
|
123
108
|
*/
|
|
124
|
-
|
|
109
|
+
resolveToLongURLFormat(url) {
|
|
125
110
|
// URL is in the following format
|
|
126
111
|
// [protocol://]host1[,host13][:port1][,host2:port2][/service_name][:server][/instance_name]
|
|
127
112
|
|
|
@@ -151,7 +136,7 @@ class EZConnectResolver {
|
|
|
151
136
|
const proxyHost = this.urlProps.get("HTTPS_PROXY");
|
|
152
137
|
const proxyPort = this.urlProps.get("HTTPS_PROXY_PORT");
|
|
153
138
|
const addressInfo =
|
|
154
|
-
|
|
139
|
+
this.buildAddressList(hostInfo, protocol, proxyHost, proxyPort);
|
|
155
140
|
|
|
156
141
|
const connectionIdPrefix =
|
|
157
142
|
this.urlProps.get("CONNECTION_ID_PREFIX");
|
|
@@ -210,10 +195,8 @@ class EZConnectResolver {
|
|
|
210
195
|
* @param proxyPort proxy server port [optional].
|
|
211
196
|
* @return address information of the DESCRIPTION node.
|
|
212
197
|
*/
|
|
213
|
-
|
|
198
|
+
buildAddressList(hostInfo, protocol,
|
|
214
199
|
proxyHost, proxyPort) {
|
|
215
|
-
let shost = '';
|
|
216
|
-
let ipcnt = 0;
|
|
217
200
|
const builder = new Array();
|
|
218
201
|
let proxyInfo = '';
|
|
219
202
|
if (proxyHost != null) {
|
|
@@ -235,11 +218,10 @@ class EZConnectResolver {
|
|
|
235
218
|
const hostnames = (match.groups.hostnames).split(',');
|
|
236
219
|
let port = match.groups.port;
|
|
237
220
|
if (port == null) {
|
|
238
|
-
port = '1521'
|
|
221
|
+
port = '1521'; //default port
|
|
239
222
|
}
|
|
240
223
|
for (const hname in hostnames) {
|
|
241
224
|
addressListBuilder.push(this.getAddrStr(hostnames[hname], port, protocol, proxyInfo));
|
|
242
|
-
shost = hostnames[hname];
|
|
243
225
|
addressNodeCount++;
|
|
244
226
|
}
|
|
245
227
|
}
|
|
@@ -253,21 +235,6 @@ class EZConnectResolver {
|
|
|
253
235
|
else
|
|
254
236
|
builder.push(parts.join(''));
|
|
255
237
|
}
|
|
256
|
-
if (naddr == 1) {
|
|
257
|
-
shost = shost.trim();
|
|
258
|
-
// If it is IPV6 format address then remove the enclosing '[' and ']'
|
|
259
|
-
if (shost.startsWith("[") && shost.endsWith("]"))
|
|
260
|
-
shost = shost.substring(1, shost.length - 1);
|
|
261
|
-
try {
|
|
262
|
-
await lookup(shost);
|
|
263
|
-
ipcnt++;
|
|
264
|
-
} catch {
|
|
265
|
-
// nothing
|
|
266
|
-
}
|
|
267
|
-
if (ipcnt == 0) {
|
|
268
|
-
errors.throwErr(errors.ERR_INVALID_EZCONNECT_SYNTAX, 'could not resolve hostname', shost);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
238
|
|
|
272
239
|
if (addressLists.length < 2 && naddr > 1) {
|
|
273
240
|
this.lb = true;
|
|
@@ -77,7 +77,7 @@ class Address {
|
|
|
77
77
|
const httpsProxyPortNVP = findNVPairRecurse(nvp, 'https_proxy_port');
|
|
78
78
|
|
|
79
79
|
if (portnvp)
|
|
80
|
-
this.port = portnvp.atom;
|
|
80
|
+
this.port = Number(portnvp.atom);
|
|
81
81
|
|
|
82
82
|
if (hostnvp)
|
|
83
83
|
this.host = hostnvp.atom;
|
|
@@ -88,7 +88,7 @@ class Address {
|
|
|
88
88
|
if (httpsProxyNVP)
|
|
89
89
|
this.httpsProxy = httpsProxyNVP.atom;
|
|
90
90
|
if (httpsProxyPortNVP)
|
|
91
|
-
this.httpsProxyPort = httpsProxyPortNVP.atom;
|
|
91
|
+
this.httpsProxyPort = Number(httpsProxyPortNVP.atom);
|
|
92
92
|
|
|
93
93
|
this.addr = nvp.toString();
|
|
94
94
|
}
|
|
@@ -71,29 +71,23 @@ async function resolveConnectStr(connectString, configDir) {
|
|
|
71
71
|
const connStr = connectString.trim();
|
|
72
72
|
let resolvedVal = connStr;
|
|
73
73
|
if ((connStr.indexOf(')') == -1) || (connStr.indexOf('(') != 0)) {
|
|
74
|
-
|
|
75
|
-
/* Try through ezconnect */
|
|
74
|
+
if ((connStr.indexOf(':') != -1) || (connStr.indexOf('/') != -1)) {
|
|
76
75
|
const ezcnObj = new EzConnect(connStr);
|
|
77
|
-
resolvedVal =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
} catch (err1) {
|
|
88
|
-
if ((connStr.indexOf(':') != -1) || (connStr.indexOf('/') != -1)) {
|
|
89
|
-
throw err;
|
|
90
|
-
} else {
|
|
91
|
-
throw err1;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
76
|
+
resolvedVal = ezcnObj.getResolvedUrl();
|
|
77
|
+
return resolvedVal;
|
|
78
|
+
} else {
|
|
79
|
+
//try tns alias
|
|
80
|
+
const namesFilePath = tnsnamesFilePath(configDir);
|
|
81
|
+
const p = await nlParamParser.initializeNlpa(namesFilePath);
|
|
82
|
+
resolvedVal = p.get(connStr.toUpperCase());
|
|
83
|
+
if (!resolvedVal)
|
|
84
|
+
errors.throwErr(errors.ERR_TNS_ENTRY_NOT_FOUND, connStr, configDir ? configDir + '/tnsnames.ora' : process.env.TNS_ADMIN + '/tnsnames.ora');
|
|
85
|
+
resolvedVal = resolvedVal.getListElement(0);
|
|
94
86
|
}
|
|
87
|
+
|
|
95
88
|
}
|
|
96
89
|
return resolvedVal;
|
|
90
|
+
|
|
97
91
|
}
|
|
98
92
|
|
|
99
93
|
async function resolveAddress(connStr, configDir) {
|
|
@@ -299,7 +299,7 @@ function RedirectPacket(packet) {
|
|
|
299
299
|
*/
|
|
300
300
|
function MarkerPacket(isLargeSDU) {
|
|
301
301
|
this.len = constants.NSPMKDAT + 1; /* Packet length */
|
|
302
|
-
this.buf = Buffer.
|
|
302
|
+
this.buf = Buffer.allocUnsafe(constants.NSPMKDAT + 1); /* Packet Buffer */
|
|
303
303
|
|
|
304
304
|
if (isLargeSDU) {
|
|
305
305
|
this.buf.writeUInt32BE(this.len, constants.NSPHDLEN);
|