Skip to content

Commit f7b336d

Browse files
committed
Fix for Issue #1576 to fetch data correctly when a chunk spans multiple packets
1 parent f8f7da7 commit f7b336d

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ node-oracledb `v6.0.2 <https://github.com/oracle/node-oracledb/compare/v6.0.1...
1111
Thin Mode Changes
1212
+++++++++++++++++
1313

14+
#) Fixed bug when the length of a chunk inside a chunked read spans packets.
15+
`Issue #1576 <https://github.com/oracle/node-oracledb/issues/1576>`__.
16+
1417
#) Fixed bug when fetching rows containing data duplicated from a previous
1518
row that spans multiple network packets.
1619
`Issue #1566 <https://github.com/oracle/node-oracledb/issues/1566>`__ and

lib/thin/protocol/packet.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,17 @@ class ReadPacket extends BaseBuffer {
220220
}
221221

222222
// the requested bytes are split across multiple packets; if a chunked read
223-
// is not in progress one is implicitly started; copy the bytes from the
224-
// end of this packet
225-
if (!inChunkedRead) {
226-
this.chunkedBytesBuf.startChunkedRead();
223+
// is in progress, a chunk is acquired that will accommodate the requested
224+
// bytes; otherwise, a separate buffer will be allocated to accommodate the
225+
// requested bytes
226+
let buf;
227+
if (inChunkedRead) {
228+
buf = this.chunkedBytesBuf.getBuf(numBytes);
229+
} else {
230+
buf = Buffer.alloc(numBytes);
227231
}
228-
const buf = this.chunkedBytesBuf.getBuf(numBytes);
232+
233+
// copy the bytes to the buffer from the remainder of this packet
229234
let offset = 0;
230235
this.buf.copy(buf, offset, this.pos, this.pos + numBytesLeft);
231236
offset += numBytesLeft;
@@ -241,10 +246,7 @@ class ReadPacket extends BaseBuffer {
241246
numBytes -= numSplitBytes;
242247
}
243248

244-
// if not in a chunked bytes read, return the buffer directly
245-
if (!inChunkedRead) {
246-
return this.chunkedBytesBuf.endChunkedRead();
247-
}
249+
return buf;
248250

249251
}
250252

0 commit comments

Comments
 (0)