Skip to content

Commit 616c4ad

Browse files
committed
Fixed bug in reading PLS_INTEGER type when used in PL/SQL records
1 parent 786c97c commit 616c4ad

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

doc/src/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Common Changes
3030
Thin Mode Changes
3131
++++++++++++++++++
3232

33+
#) Fixed bug in reading PLS_INTEGER type when used in PL/SQL records.
34+
3335
#) Error ``NJS-141: errors in array DML exceed 65535`` is now raised
3436
when the number of batch errors exceed 65535 when calling
3537
:meth:`connection.executeMany()` with the parameter ``batchErrors``

lib/thin/protocol/buffer.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,22 @@ class BaseBuffer {
321321
return this.parseBinaryFloat(buf);
322322
}
323323

324+
//---------------------------------------------------------------------------
325+
// readBinaryInteger()
326+
//
327+
// Reads a binary integer value from the buffer and returns a Number
328+
//---------------------------------------------------------------------------
329+
readBinaryInteger() {
330+
const buf = this.readBytesWithLength();
331+
if (!buf) {
332+
return 0;
333+
}
334+
if (buf.length > 4) {
335+
errors.throwErr(errors.ERR_INTEGER_TOO_LARGE, buf.length, 4, this.pos, this.packetNum);
336+
}
337+
return (buf.readIntBE(0, buf.length));
338+
}
339+
324340
//---------------------------------------------------------------------------
325341
// readBool()
326342
//

test/dbObject12.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('211. dbObject12.js', function() {
5353

5454
let plsql = `
5555
CREATE OR REPLACE PACKAGE ${PKG} AS
56-
TYPE ${TYPE} IS RECORD (name VARCHAR2(40), pos NUMBER);
56+
TYPE ${TYPE} IS RECORD (name VARCHAR2(40), pos NUMBER, force PLS_INTEGER);
5757
PROCEDURE myproc (p_in IN ${TYPE}, p_out OUT ${TYPE});
5858
END ${PKG};
5959
`;
@@ -65,6 +65,7 @@ describe('211. dbObject12.js', function() {
6565
BEGIN
6666
p_out := p_in;
6767
p_out.pos := p_out.pos * 2;
68+
p_out.force := p_out.pos * -1;
6869
END;
6970
END ${PKG};
7071
`;
@@ -101,6 +102,7 @@ describe('211. dbObject12.js', function() {
101102
assert.strictEqual(out.toString(), expect);
102103
assert.strictEqual(out.NAME, obj1.NAME);
103104
assert.strictEqual(out.POS, (obj1.POS * 2));
105+
assert.strictEqual(out.FORCE, (obj1.POS * -2));
104106

105107
// Binding the record values directly'
106108
const obj2 = { NAME: 'Plane', POS: 34 };
@@ -112,6 +114,7 @@ describe('211. dbObject12.js', function() {
112114
out = result2.outBinds.outbv;
113115
assert.strictEqual(out.NAME, obj2.NAME);
114116
assert.strictEqual(out.POS, (obj2.POS * 2));
117+
assert.strictEqual(out.FORCE, (obj2.POS * -2));
115118

116119
// Using the type name
117120
const obj3 = { NAME: 'Car', POS: 56 };
@@ -123,15 +126,18 @@ describe('211. dbObject12.js', function() {
123126
out = result3.outBinds.outbv;
124127
assert.strictEqual(out.NAME, obj3.NAME);
125128
assert.strictEqual(out.POS, (obj3.POS * 2));
129+
assert.strictEqual(out.FORCE, (obj3.POS * -2));
126130

127131
// Batch exeuction with executeMany()
128132
const obj4 = [
129133
{ NAME: 'Train', POS: 78 },
130-
{ NAME: 'Bike', POS: 83 }
134+
{ NAME: 'Bike', POS: 83 },
135+
{ NAME: 'Cycle', POS: -2 }
131136
];
132137
binds = [
133138
{ inbv: obj4[0] },
134-
{ inbv: obj4[1] }
139+
{ inbv: obj4[1] },
140+
{ inbv: obj4[2] }
135141
];
136142
const opts = {
137143
bindDefs: {
@@ -143,6 +149,8 @@ describe('211. dbObject12.js', function() {
143149
for (let i = 0, out = result4.outBinds; i < binds.length; i++) {
144150
assert.strictEqual(out[i].outbv.NAME, obj4[i].NAME);
145151
assert.strictEqual(out[i].outbv.POS, (obj4[i].POS * 2));
152+
assert.strictEqual(out[i].outbv.FORCE, (obj4[i].POS * -2));
153+
146154
}
147155
}); // 211.1
148156
});

0 commit comments

Comments
 (0)