Skip to content

Commit c568e23

Browse files
committed
Ensure getStatementInfo executes statement only when needed to
1 parent ae623d1 commit c568e23

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/thin/protocol/messages/execute.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class ExecuteMessage extends MessageWithData {
275275
// no rows have yet been sent so the header information needs to be sent
276276
if (this.currentRow === 0) {
277277
let stmt = this.statement;
278-
if (stmt.cursorId !== 0 && !stmt.requiresFullExecute && !stmt.requiresDefine && !stmt.isDdl) {
278+
if (stmt.cursorId !== 0 && !stmt.requiresFullExecute && !this.parseOnly && !stmt.requiresDefine && !stmt.isDdl && !this.batchErrors) {
279279
if (stmt.isQuery && !stmt.requiresDefine && this.options.prefetchRows > 0) {
280280
this.functionCode = constants.TNS_FUNC_REEXECUTE_AND_FETCH;
281281
} else {

test/getStmtInfo.js

+9
Original file line numberDiff line numberDiff line change
@@ -471,4 +471,13 @@ describe('162. getStmtInfo.js', function() {
471471
assert.deepStrictEqual(result.rows[0], ['HELLO']);
472472
});
473473

474+
it('162.35 Parse and Execute twice ', async function() {
475+
const sql = "insert into nodb_number (num, content) values (:num, :val)";
476+
let key = 555;
477+
for (let i = 0; i < 2; i++) {
478+
await conn.getStatementInfo(sql);
479+
await conn.execute(sql, {num:key, val:1234});
480+
key = key + 1;
481+
}
482+
});
474483
});

0 commit comments

Comments
 (0)