mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
sqlite: reset statement immediately in run()
This commit updates StatementSync.prototype.run() to reset the prepared statement immediately after calling sqlite3_step() to return the correct change metadata. Fixes: https://github.com/nodejs/node/issues/57344 PR-URL: https://github.com/nodejs/node/pull/57350 Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
This commit is contained in:
1 parent
a9a6891b0b
commit
4e24456a1a
2 files changed
+22
-7
No files matched your search
+3
-7
@@ -1887,13 +1887,9 @@ void StatementSync::Run(const FunctionCallbackInfo<Value>& args) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto reset = OnScopeLeave([&]() { sqlite3_reset(stmt->statement_); });
|
||||
r = sqlite3_step(stmt->statement_);
|
||||
if (r != SQLITE_ROW && r != SQLITE_DONE) {
|
||||
THROW_ERR_SQLITE_ERROR(env->isolate(), stmt->db_.get());
|
||||
return;
|
||||
}
|
||||
|
||||
sqlite3_step(stmt->statement_);
|
||||
r = sqlite3_reset(stmt->statement_);
|
||||
CHECK_ERROR_OR_THROW(env->isolate(), stmt->db_.get(), r, SQLITE_OK, void());
|
||||
Local<Object> result = Object::New(env->isolate());
|
||||
sqlite3_int64 last_insert_rowid =
|
||||
sqlite3_last_insert_rowid(stmt->db_->Connection());
|
||||
|
||||
Reference in new issue
Block a user