aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-oo1.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2023-05-19 18:23:53 +0000
committerstephan <stephan@noemail.net>2023-05-19 18:23:53 +0000
commita6ab50bc42c09e373efb441916fb2793c6fe8054 (patch)
treeabef19e6504712cc78fcdd4b8746cf4f611b1987 /ext/wasm/api/sqlite3-api-oo1.js
parent02be13cea6071bdc7bf7a0aa78b3b05f64890db8 (diff)
downloadsqlite-a6ab50bc42c09e373efb441916fb2793c6fe8054.tar.gz
sqlite-a6ab50bc42c09e373efb441916fb2793c6fe8054.zip
Extend detection of the INSERT...RETURNING locking case to the DB.selectValue(s)/selectArray/selectObject() family of functions. Add tests for INSERT/UPDATE...RETURNING with those functions.
FossilOrigin-Name: 3181c50540df0eff6cb5db79bb477c469bb7b73b0692260ba600db200fcef4ac
Diffstat (limited to 'ext/wasm/api/sqlite3-api-oo1.js')
-rw-r--r--ext/wasm/api/sqlite3-api-oo1.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js
index 2f5b9fc1c..4677b8976 100644
--- a/ext/wasm/api/sqlite3-api-oo1.js
+++ b/ext/wasm/api/sqlite3-api-oo1.js
@@ -478,7 +478,9 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
const __selectFirstRow = (db, sql, bind, ...getArgs)=>{
const stmt = db.prepare(sql);
try {
- return stmt.bind(bind).step() ? stmt.get(...getArgs) : undefined;
+ const rc = stmt.bind(bind).step() ? stmt.get(...getArgs) : undefined;
+ stmt.reset(/*for INSERT...RETURNING locking case*/);
+ return rc;
}finally{
stmt.finalize();
}
@@ -1133,6 +1135,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
try {
stmt.bind(bind);
while(stmt.step()) rc.push(stmt.get(0,asType));
+ stmt.reset(/*for INSERT...RETURNING locking case*/);
}finally{
stmt.finalize();
}
@@ -1686,7 +1689,9 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
*/
stepFinalize: function(){
try{
- return this.step();
+ const rc = this.step();
+ this.reset(/*for INSERT...RETURNING locking case*/);
+ return rc;
}finally{
try{this.finalize()}
catch(e){/*ignored*/}