diff options
author | stephan <stephan@noemail.net> | 2023-05-19 16:34:56 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2023-05-19 16:34:56 +0000 |
commit | 7fe416fae1b5265c53cda46e0c2dbf4a83bc649a (patch) | |
tree | a51e4a89b3f05637226a17616ef7703ff0cf23b8 /ext/wasm/api/sqlite3-api-oo1.js | |
parent | 416aeb16ee4ff07149801f88ebb34e2ffa01785f (diff) | |
download | sqlite-7fe416fae1b5265c53cda46e0c2dbf4a83bc649a.tar.gz sqlite-7fe416fae1b5265c53cda46e0c2dbf4a83bc649a.zip |
sqlite3.oo1.Stmt.reset() now throws if sqlite3_reset() returns non-zero, analog to [f23eb5c6d365].
FossilOrigin-Name: 487ae12c9a21e5862bd590bbb1030c39734657d52136cf67b98c7545e6ecbe1c
Diffstat (limited to 'ext/wasm/api/sqlite3-api-oo1.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-oo1.js | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js index f0f0e6397..d46ee8dd4 100644 --- a/ext/wasm/api/sqlite3-api-oo1.js +++ b/ext/wasm/api/sqlite3-api-oo1.js @@ -1431,12 +1431,12 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ This method always throws if called when it is illegal to do so, e.g. from a per-row callback handler of a DB.exec() call. - As of version 3.43, this method will throw if - sqlite3_finalize() returns an error code, which can happen in - certain unusual cases involving locking. When it throws for - this reason, throwing is delayed until after all resources are - cleaned up. That is, the finalization still runs to - completion. + As of versions 3.42.1 and 3.43, this method will throw by + default if sqlite3_finalize() returns an error code, which can + happen in certain unusual cases involving locking. When it + throws for this reason, throwing is delayed until after all + resources are cleaned up. That is, the finalization still runs + to completion. */ finalize: function(){ if(this.pointer){ @@ -1465,19 +1465,25 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return this; }, /** - Resets this statement so that it may be step()ed again - from the beginning. Returns this object. Throws if this - statement has been finalized. + Resets this statement so that it may be step()ed again from the + beginning. Returns this object. Throws if this statement has + been finalized or if it may not legally be reset because it is + currently being used from a DB.exec() callback. If passed a truthy argument then this.clearBindings() is also called, otherwise any existing bindings, along with any memory allocated for them, are retained. + + As of versions 3.42.1 and 3.43, this function throws if the + underlying call to sqlite3_reset() returns non-0. That is + necessary for catching errors in certain locking-related cases. */ reset: function(alsoClearBinds){ affirmUnlocked(this,'reset()'); if(alsoClearBinds) this.clearBindings(); - capi.sqlite3_reset(affirmStmtOpen(this).pointer); + const rc = capi.sqlite3_reset(affirmStmtOpen(this).pointer); this._mayGet = false; + checkSqlite3Rc(this.db, rc); return this; }, /** @@ -1661,11 +1667,9 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return this.reset(); }, /** - Functions like step() except that it finalizes this statement - immediately after stepping unless the step cannot be performed - because the statement is locked. Throws on error, but any error - other than the statement-is-locked case will also trigger - finalization of this statement. + Functions like step() except that it calls finalize() on this + statement immediately after stepping, even if the step() call + throws. On success, it returns true if the step indicated that a row of data was available, else it returns false. @@ -1677,8 +1681,19 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ``` */ stepFinalize: function(){ - const rc = this.step(); - this.finalize(); + let rc, err; + try{ + rc = this.step(); + }catch(e){ + err = e; + } + if(err){ + try{this.finalize()} + catch(x){/*ignored*/} + throw err; + }else{ + this.finalize(); + } return rc; }, /** |