Skip to content

Commit d8031c5

Browse files
committed
Improve handling of maxArraySize and maxSize errors
1 parent 6b69b47 commit d8031c5

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/njs/src/njsConnection.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,13 @@ void Connection::GetBindUnit (Local<Value> val, Bind* bind,
719719
{
720720
Local<Array>arr = Local<Array>::Cast (element);
721721

722+
// For INOUT bind, maxArraySize is required
723+
if ( dir == BIND_INOUT && ( arr->Length () > 0 && !bind->maxArraySize ) )
724+
{
725+
executeBaton->error = NJSMessages::getErrorMsg ( errReqdMaxArraySize );
726+
goto exitGetBindUnit;
727+
}
728+
722729
if ( dir == BIND_INOUT && ( arr->Length() > bind->maxArraySize ) )
723730
{
724731
executeBaton->error = NJSMessages::getErrorMsg ( errInvalidArraySize );
@@ -1168,7 +1175,8 @@ void Connection::GetInBindParamsArray(Local<Array> va8vals, Bind *bind,
11681175
// am actual element largen than the maxSize argument
11691176
if (arrayElementSize > static_cast<size_t>(bind->maxSize))
11701177
{
1171-
executeBaton->error = NJSMessages::getErrorMsg(errInvalidArraySize);
1178+
executeBaton->error = NJSMessages::getErrorMsg(
1179+
errInsufficientBufferForBinds);
11721180
goto exitGetInBindParamsArray;
11731181
}
11741182
else
@@ -1331,7 +1339,8 @@ bool Connection::AllocateBindArray(unsigned short dataType, Bind* bind,
13311339
// an actual element largen than the maxSize argument
13321340
if (*arrayElementSize > static_cast<size_t>(bind->maxSize))
13331341
{
1334-
executeBaton->error = NJSMessages::getErrorMsg(errInvalidArraySize);
1342+
executeBaton->error = NJSMessages::getErrorMsg(
1343+
errInsufficientBufferForBinds);
13351344
goto exitAllocateBindArray;
13361345
}
13371346
else

test/plsqlBinding1.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ describe('43. plsqlBinding1.js', function() {
456456
bindvars,
457457
function(err, result) {
458458
should.exist(err);
459-
(err.message).should.startWith('NJS-036');
460-
// NJS-036: Property maxArraySize is required for INOUT Array binds.
459+
(err.message).should.startWith('NJS-035');
460+
// NJS-035: maxArraySize is required for IN OUT array bind
461461
should.not.exist(result);
462462
done();
463463
}
@@ -870,8 +870,8 @@ describe('43. plsqlBinding1.js', function() {
870870
bindvars,
871871
function(err, result) {
872872
should.exist(err);
873-
(err.message).should.startWith('NJS-036');
874-
// NJS-036: given array is of size greater than maxArraySize
873+
(err.message).should.startWith('NJS-035');
874+
// NJS-035: maxArraySize is required for IN OUT array bind
875875
should.not.exist(result);
876876
done();
877877
}
@@ -950,8 +950,8 @@ describe('43. plsqlBinding1.js', function() {
950950
bindvars,
951951
function(err, result) {
952952
should.exist(err);
953-
(err.message).should.startWith('NJS-036');
954-
// NJS-036: given array is of size greater than maxArraySize
953+
(err.message).should.startWith('NJS-035');
954+
// NJS-035: maxArraySize is required for IN OUT array bind
955955
done();
956956
}
957957
);

0 commit comments

Comments
 (0)