Skip to content

Commit 05f1645

Browse files
committed
Remove intermittent errors while fetching Large CLOBs
1 parent 8206eb6 commit 05f1645

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

doc/src/release_notes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ Common Changes
4545
Thin Mode Changes
4646
++++++++++++++++++
4747

48+
#) Fix for the intermittent error ``NJS-103`` seen while fetching large number
49+
of CLOB columns whose metadata is split across multiple packets.
50+
`Issue #1642 <https://github.com/oracle/node-oracledb/issues/1642>`__.
51+
4852
#) Fixed potential cursor issues when using DRCP.
4953

5054
#) Fixed bug in reading PLS_INTEGER type when used in PL/SQL records.

lib/thin/protocol/messages/withData.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,16 @@ class MessageWithData extends Message {
148148
buf.skipUB1();
149149
}
150150
resultSet.metadata = [];
151+
const metadata = [];
152+
const queryVars = [];
151153
for (let i = 0; i < statement.numQueryVars; i++) {
152154
const variable = this.processColumnInfo(buf, i + 1);
153155
if (prevQueryVars && i < prevQueryVars.length) {
154156
this._adjustFetchType(prevQueryVars[i], variable);
155157
}
156-
statement.queryVars.push(variable);
157-
resultSet.metadata.push(variable.fetchInfo);
158+
queryVars.push(variable);
159+
metadata.push(variable.fetchInfo);
158160
}
159-
160161
let numBytes = buf.readUB4();
161162
if (numBytes > 0) {
162163
buf.skipBytesChunked(); // current date
@@ -170,6 +171,13 @@ class MessageWithData extends Message {
170171
buf.skipBytesChunked();
171172
}
172173

174+
/*
175+
* The message state(resultSet) and statement state(queryVars) is modified
176+
* at end of the DescribeInfo function so that an OutOfPacketsError
177+
* won't cause partial information state to be stored.
178+
*/
179+
resultSet.metadata = metadata;
180+
statement.queryVars = queryVars;
173181
this.resultSetsToSetup.push(resultSet);
174182
}
175183

test/columnMetadata.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,22 +217,23 @@ describe('9. columnMetadata.js', function() {
217217
}); // 9.2
218218

219219
describe('9.3 Large number of columns', function() {
220-
function genColumns(size) {
220+
function genColumns(size, dbType) {
221221
const buffer = [];
222222
for (var i = 0; i < size; i++) {
223-
buffer[i] = " column_" + i + " NUMBER";
223+
buffer[i] = " column_" + i + dbType;
224224
}
225225
return buffer.join();
226226
}
227227

228228
it('9.10 works with a large number of columns', async function() {
229-
const column_size = 100;
230-
const columns_string = genColumns(column_size);
229+
const column_size = 300;
230+
let columns_string = genColumns(column_size, " NUMBER");
231231
const table_name = "nodb_large_columns";
232232
const sqlSelect = "SELECT * FROM " + table_name;
233233
const sqlDrop = "DROP TABLE " + table_name + " PURGE";
234234

235-
const proc = "BEGIN \n" +
235+
function generateProcedure() {
236+
return "BEGIN \n" +
236237
" DECLARE \n" +
237238
" e_table_missing EXCEPTION; \n" +
238239
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n " +
@@ -248,10 +249,25 @@ describe('9. columnMetadata.js', function() {
248249
" ) \n" +
249250
" '); \n" +
250251
"END; ";
252+
}
251253

252-
await connection.execute(proc);
253-
const result = await connection.execute(sqlSelect);
254-
for (var i = 0; i < column_size; i++) {
254+
// check NUMBER type column
255+
await connection.execute(generateProcedure());
256+
257+
// Dont cache statment as we re-run with different
258+
// column type with same table.
259+
let result = await connection.execute(sqlSelect, [],
260+
{ keepInStmtCache: false });
261+
for (let i = 0; i < column_size; i++) {
262+
assert.strictEqual(result.metaData[i].name, 'COLUMN_' + i);
263+
}
264+
await connection.execute(sqlDrop);
265+
266+
// check CLOB type (GH Issue 1642)
267+
columns_string = genColumns(column_size, " CLOB");
268+
await connection.execute(generateProcedure());
269+
result = await connection.execute(sqlSelect);
270+
for (let i = 0; i < column_size; i++) {
255271
assert.strictEqual(result.metaData[i].name, 'COLUMN_' + i);
256272
}
257273
await connection.execute(sqlDrop);

0 commit comments

Comments
 (0)