1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Rework how JS's oo1.DB.exec() flags its Stmt objects to make certain Stmt APIs illegal (i.e. throwing) if called while that Stmt is being step()ped by DB.exec() (which can happen via client-provided per-result-row callbacks). This is an internal change only - the API is unaffected. Remove some unrelated dead code.

FossilOrigin-Name: 8c187140a60b62dc3b6066b8615766d52b7a29a5de992cbb6d312dbb225a980b
This commit is contained in:
stephan
2025-06-21 14:38:53 +00:00
parent a0c6de56ba
commit 0cdde5b44f
5 changed files with 68 additions and 19 deletions

View File

@ -3323,6 +3323,44 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
db.close();
})
/**
Ensure that certain Stmt members throw when called
via DB.exec().
*/
.t('locked-by-exec() APIs', function(sqlite3){
const db = new sqlite3.oo1.DB();
db.exec("create table t(a);insert into t(a) values(1);");
let checkCount = 0;
const checkOp = function(op){
++checkCount;
T.mustThrowMatching(() => {
db.exec({
sql: "select ?1",
bind: op,
callback: (row, stmt) => {
switch (row[0]) {
case 'bind': stmt.bind(1); break;
case 'finalize':
case 'clearBindings':
case 'reset':
case 'step': stmt[op](); break;
}
}
});
}, /^Operation is illegal when statement is locked.*/)
};
try{
checkOp('bind');
checkOp('finalize');
checkOp('clearBindings');
checkOp('reset');
checkOp('step');
T.assert(5===checkCount);
}finally{
db.close();
}
})
////////////////////////////////////////////////////////////////////
.t("Misc. stmt_...", function(sqlite3){
const db = new sqlite3.oo1.DB();