Skip to content

Commit 8206eb6

Browse files
committed
Throw NJS-003 error instead of NJS-108 when attempting a LOB operation on a closed connection
1 parent 6491597 commit 8206eb6

File tree

9 files changed

+17
-16
lines changed

9 files changed

+17
-16
lines changed

doc/src/release_notes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ Common Changes
3737
now raised when the size constraints are violated.
3838
`Issue #1630 <https://github.com/oracle/node-oracledb/issues/1630>`__.
3939

40+
#) Error ``NJS-003`` is now raised when an attempt is made to perform an
41+
operation using a closed connection. Error ``NJS-108``, which was
42+
earlier used to flag errors when LOB operations were attempted on a closed
43+
or invalid connection, is now removed.
44+
4045
Thin Mode Changes
4146
++++++++++++++++++
4247

lib/errors.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ const ERR_POOL_HAS_BUSY_CONNECTIONS = 104;
107107
const ERR_NAN_VALUE = 105;
108108
const ERR_INTERNAL = 106;
109109
const ERR_INVALID_REF_CURSOR = 107;
110-
const ERR_LOB_CLOSED = 108;
111110
const ERR_INVALID_TYPE_NUM = 109;
112111
const ERR_INVALID_ORACLE_TYPE_NUM = 110;
113112
const ERR_UNEXPECTED_NEGATIVE_INTEGER = 111;
@@ -173,9 +172,8 @@ const WRN_COMPILATION_CREATE = 700;
173172
// define mapping for ODPI-C, OCI & ORA errors that need to be wrapped
174173
// with NJS errors
175174
const adjustErrorXref = new Map();
176-
adjustErrorXref.set("DPI-1010", ERR_CONNECTION_CLOSED);
175+
adjustErrorXref.set("DPI-1010", ERR_INVALID_CONNECTION);
177176
adjustErrorXref.set("DPI-1024", [ERR_INVALID_COLL_INDEX_GET, 'at index ([0-9]+) does']);
178-
adjustErrorXref.set("DPI-1040", ERR_LOB_CLOSED);
179177
adjustErrorXref.set("DPI-1044", ERR_ORACLE_NUMBER_NO_REPR);
180178
adjustErrorXref.set("DPI-1055", ERR_NAN_VALUE);
181179
adjustErrorXref.set("DPI-1063", ERR_EXEC_MODE_ONLY_FOR_DML);
@@ -195,7 +193,7 @@ const messages = new Map();
195193
messages.set(ERR_INVALID_POOL, // NJS-002
196194
'invalid pool');
197195
messages.set(ERR_INVALID_CONNECTION, // NJS-003
198-
'invalid connection');
196+
'invalid or closed connection');
199197
messages.set(ERR_INVALID_PROPERTY_VALUE, // NJS-004
200198
'invalid value for property "%s"');
201199
messages.set(ERR_INVALID_PARAMETER_VALUE, // NJS-005
@@ -346,8 +344,6 @@ messages.set(ERR_INTERNAL, // NJS-106
346344
'internal error: %s');
347345
messages.set(ERR_INVALID_REF_CURSOR, // NJS-107
348346
'invalid cursor');
349-
messages.set(ERR_LOB_CLOSED, // NJS-108
350-
'LOB was already closed');
351347
messages.set(ERR_INVALID_TYPE_NUM, // NJS-109
352348
'invalid type number %d');
353349
messages.set(ERR_INVALID_ORACLE_TYPE_NUM, // NJS-110
@@ -771,7 +767,6 @@ module.exports = {
771767
ERR_INVALID_REF_CURSOR,
772768
ERR_UNSUPPORTED_VERIFIER_TYPE,
773769
ERR_NAN_VALUE,
774-
ERR_LOB_CLOSED,
775770
ERR_ORACLE_NUMBER_NO_REPR,
776771
ERR_INVALID_SERVICE_NAME,
777772
ERR_INVALID_SID,

lib/lob.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Lob extends Duplex {
5050
// not already been closed (never called directly)
5151
async _destroy(err, cb) {
5252
// if LOB was already closed, nothing to do!
53-
if (err && err.message.startsWith("NJS-108:"))
53+
if (err && err.message.startsWith("NJS-003:"))
5454
delete this._impl;
5555
if (this._impl) {
5656
const lobImpl = this._impl;

lib/thin/lob.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class ThinLobImpl extends LobImpl {
157157

158158
checkConn() {
159159
if (!this.conn.nscon.connected)
160-
errors.throwErr(errors.ERR_LOB_CLOSED);
160+
errors.throwErr(errors.ERR_INVALID_CONNECTION);
161161
}
162162

163163
close() {

lib/thin/protocol/packet.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2024, Oracle and/or its affiliates.
22

33
//-----------------------------------------------------------------------------
44
//
@@ -496,6 +496,9 @@ class WritePacket extends BaseBuffer {
496496
buf = Buffer.from(buf);
497497
this.startPacket();
498498
}
499+
if (!this.nsi.ntAdapter) {
500+
errors.throwErr(errors.ERR_INVALID_CONNECTION);
501+
}
499502
this.nsi.ntAdapter.send(buf);
500503
}
501504

src/njsVariable.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2019, 2024, Oracle and/or its affiliates.
22

33
//-----------------------------------------------------------------------------
44
//
@@ -758,10 +758,8 @@ bool njsVariable_setScalarValue(njsVariable *var, uint32_t pos, napi_env env,
758758
njsLob *lob;
759759
bool check;
760760
napi_value arrBuf;
761-
napi_value dVal;
762761
napi_typedarray_type type;
763762
void *rawdata = NULL;
764-
bool isTyped = false;
765763
size_t numElem = 0;
766764
size_t byteOffset = 0;
767765

test/dbObject18.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ describe('242. dbObject18.js', () => {
423423
} else {
424424
assert.throws(
425425
() => row.TEAM[0],
426-
/NJS-500:/
426+
/NJS-003:/
427427
);
428428
}
429429

test/lobClose.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ describe('54. lobClose.js', function() {
101101
lob2.on('finish', resolve);
102102
});
103103
},
104-
/NJS-108:/
104+
/NJS-003:/
105105
);
106106
}); // 54.4
107107

test/poolDrain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('170. poolDrain.js', () => {
102102

103103
await assert.rejects(
104104
async () => await conn.execute('select (7+8) from dual'),
105-
/NJS-500:/
105+
/NJS-003:/
106106
);
107107
}); // 170.5
108108

0 commit comments

Comments
 (0)