Skip to content

Commit ddd16d9

Browse files
committed
Fix for Issues #1565 and #1566 and Improved Database Object support in Thin mode
1 parent ad864d5 commit ddd16d9

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

doc/src/release_notes.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ Thin Mode Changes
1212
+++++++++++++++++
1313

1414
#) Fixed bug when fetching rows containing data duplicated from a previous
15-
row that spans multiple packets.
15+
row that spans multiple network packets.
1616
`Issue #1566 <https://github.com/oracle/node-oracledb/issues/1566>`__ and
1717
`Issue #1565 <https://github.com/oracle/node-oracledb/issues/1565>`__.
1818

19+
#) Fixed bug when fetching database objects with large embedded database
20+
objects.
21+
22+
#) Fixed bug when fetching a large number of database objects.
23+
1924

2025
node-oracledb `v6.0.1 <https://github.com/oracle/node-oracledb/compare/v6.0.0...v6.0.1>`__ (07 Jun 2023)
2126
--------------------------------------------------------------------------------------------------------

lib/thin/dbObject.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ const { GrowableBuffer } = require('./protocol/buffer.js');
3535

3636
class DbObjectPickleBuffer extends GrowableBuffer {
3737

38+
//---------------------------------------------------------------------------
39+
// _readBytesWithLength()
40+
//
41+
// Helper function that processes the number of bytes (if needed) and then
42+
// acquires the specified number of bytes from the buffer.
43+
//---------------------------------------------------------------------------
44+
_readBytesWithLength(numBytes) {
45+
if (numBytes === constants.TNS_LONG_LENGTH_INDICATOR) {
46+
numBytes = this.readUInt32BE();
47+
}
48+
return this.readBytes(numBytes);
49+
}
50+
3851
//---------------------------------------------------------------------------
3952
// getIsAtomicNull()
4053
//
@@ -354,7 +367,7 @@ class ThinDbObjectImpl extends DbObjectImpl {
354367
case types.DB_TYPE_NCHAR:
355368
return buf.readStr(constants.TNS_CS_NCHAR);
356369
case types.DB_TYPE_RAW:
357-
return buf.readBytesWithLength();
370+
return Buffer.from(buf.readBytesWithLength());
358371
case types.DB_TYPE_BINARY_DOUBLE:
359372
return buf.readBinaryDouble();
360373
case types.DB_TYPE_BINARY_FLOAT:
@@ -374,7 +387,7 @@ class ThinDbObjectImpl extends DbObjectImpl {
374387
return null;
375388
obj = new ThinDbObjectImpl(typeClass);
376389
if (obj._objType.isCollection || this._objType.isCollection) {
377-
obj.packedData = buf.readBytesWithLength();
390+
obj.packedData = Buffer.from(buf.readBytesWithLength());
378391
} else {
379392
obj._unpackDataFromBuf(buf);
380393
}

lib/thin/protocol/buffer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,18 +375,18 @@ class BaseBuffer {
375375
const obj = {};
376376
let numBytes = this.readUB4();
377377
if (numBytes > 0)
378-
obj.toid = this.readBytesWithLength();
378+
obj.toid = Buffer.from(this.readBytesWithLength());
379379
numBytes = this.readUB4();
380380
if (numBytes > 0)
381-
obj.oid = this.readBytesWithLength();
381+
obj.oid = Buffer.from(this.readBytesWithLength());
382382
numBytes = this.readUB4();
383383
if (numBytes > 0)
384-
obj.snapshot = this.readBytesWithLength();
384+
obj.snapshot = Buffer.from(this.readBytesWithLength());
385385
this.skipUB2(); // version
386386
numBytes = this.readUB4();
387387
this.skipUB2(); // flags
388388
if (numBytes > 0)
389-
obj.packedData = this.readBytesWithLength();
389+
obj.packedData = Buffer.from(this.readBytesWithLength());
390390
return obj;
391391
}
392392

lib/thin/protocol/messages/withData.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class MessageWithData extends Message {
173173
let oid;
174174
let numBytes = buf.readUB4(); // OID
175175
if (numBytes > 0) {
176-
oid = buf.readBytesWithLength();
176+
oid = Buffer.from(buf.readBytesWithLength());
177177
}
178178
buf.skipUB2(); // version
179179
buf.skipUB2(); // character set id
@@ -378,7 +378,7 @@ class MessageWithData extends Message {
378378
const useLocalTime = (oraTypeNum === constants.TNS_DATA_TYPE_DATE ||
379379
oraTypeNum === constants.TNS_DATA_TYPE_TIMESTAMP);
380380
colValue = buf.readOracleDate(useLocalTime);
381-
} else if (oraTypeNum === constants.TNS_DATA_TYPE_ROWID) {
381+
} else if (oraTypeNum === constants.TNS_DATA_TYPE_ROWID) {
382382
if (!this.inFetch) {
383383
colValue = buf.readStr(constants.TNS_CS_IMPLICIT);
384384
} else {
@@ -563,7 +563,7 @@ class MessageWithData extends Message {
563563

564564
if (this.statement.isQuery) {
565565
this.inFetch = true;
566-
if (this.statement.queryVars) {
566+
if (this.statement.queryVars) {
567567
this.outVariables = [];
568568
for (let i = 0; i < this.statement.queryVars.length; i++) {
569569
this.outVariables.push(this.statement.queryVars[i]);

0 commit comments

Comments
 (0)