aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-oo1.c-pp.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2024-07-22 20:58:51 +0000
committerstephan <stephan@noemail.net>2024-07-22 20:58:51 +0000
commit71e2bdb2b45c03d4ed5b8cfe3998a18881afbd76 (patch)
treea3e18f9db811dc6c9af702ab1348945ebebfd160 /ext/wasm/api/sqlite3-api-oo1.c-pp.js
parent04416ddc519d89ca6263f269dbb3c3944a40ed3f (diff)
downloadsqlite-71e2bdb2b45c03d4ed5b8cfe3998a18881afbd76.tar.gz
sqlite-71e2bdb2b45c03d4ed5b8cfe3998a18881afbd76.zip
OPFS VFSes: remove the on-open() pragma calls, as those (A) already reflected the build-time default settings and (B) they made it illegal to run locking_mode=exclusive, which is a requirement for WAL mode without shared memory. Modify part of the test suite to demonstrate that the SAHPool VFS can run in WAL mode so long as locking_mode=exclusive is used.
FossilOrigin-Name: 19cd8e2b056d7842ee39afb7160c901c9dc55a5bac8049cb0b5246210f6b920d
Diffstat (limited to 'ext/wasm/api/sqlite3-api-oo1.c-pp.js')
-rw-r--r--ext/wasm/api/sqlite3-api-oo1.c-pp.js50
1 files changed, 31 insertions, 19 deletions
diff --git a/ext/wasm/api/sqlite3-api-oo1.c-pp.js b/ext/wasm/api/sqlite3-api-oo1.c-pp.js
index c579b5ddf..55d7356e2 100644
--- a/ext/wasm/api/sqlite3-api-oo1.c-pp.js
+++ b/ext/wasm/api/sqlite3-api-oo1.c-pp.js
@@ -79,14 +79,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
}
}.bind({counter: 0}));
- /**
- A map of sqlite3_vfs pointers to SQL code or a callback function
- to run when the DB constructor opens a database with the given
- VFS. In the latter case, the call signature is (theDbObject,sqlite3Namespace)
- and the callback is expected to throw on error.
- */
- const __vfsPostOpenSql = Object.create(null);
-
//#if enable-see
/**
Converts ArrayBuffer or Uint8Array ba into a string of hex
@@ -279,7 +271,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
// Check for per-VFS post-open SQL/callback...
const pVfs = capi.sqlite3_js_db_vfs(pDb)
|| toss3("Internal error: cannot get VFS for new db handle.");
- const postInitSql = __vfsPostOpenSql[pVfs];
+ const postInitSql = __vfsPostOpenCallback[pVfs];
if(postInitSql){
/**
Reminder: if this db is encrypted and the client did _not_ pass
@@ -302,19 +294,39 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
}
};
+
/**
- Sets SQL which should be exec()'d on a DB instance after it is
- opened with the given VFS pointer. The SQL may be any type
- supported by the "string:flexible" function argument conversion.
- Alternately, the 2nd argument may be a function, in which case it
- is called with (theOo1DbObject,sqlite3Namespace) at the end of
- the DB() constructor. The function must throw on error, in which
- case the db is closed and the exception is propagated. This
- function is intended only for use by DB subclasses or sqlite3_vfs
+ A map of sqlite3_vfs pointers to SQL code or a callback function
+ to run when the DB constructor opens a database with the given
+ VFS. In the latter case, the call signature is
+ (theDbObject,sqlite3Namespace) and the callback is expected to
+ throw on error.
+ */
+ const __vfsPostOpenCallback = Object.create(null);
+
+ /**
+ Sets a callback which should be called after a db is opened with
+ the given sqlite3_vfs pointer. The 2nd argument must be a
+ function, which gets called with
+ (theOo1DbObject,sqlite3Namespace) at the end of the DB()
+ constructor. The function must throw on error, in which case the
+ db is closed and the exception is propagated. This function is
+ intended only for use by DB subclasses or sqlite3_vfs
implementations.
+
+ Prior to 2024-07-22, it was legal to pass SQL code as the second
+ argument, but that can interfere with a client's ability to run
+ pragmas which must be run before anything else, namely (pragma
+ locking_mode=exclusive) for use with WAL mode. That capability
+ had only ever been used as an internal detail of the two OPFS
+ VFSes, and they no longer use it that way.
*/
- dbCtorHelper.setVfsPostOpenSql = function(pVfs, sql){
- __vfsPostOpenSql[pVfs] = sql;
+ dbCtorHelper.setVfsPostOpenCallback = function(pVfs, callback){
+ if( !(callback instanceof Function)){
+ toss3("dbCtorHelper.setVfsPostOpenCallback() should not be used with "+
+ "a non-function argument.",arguments);
+ }
+ __vfsPostOpenCallback[pVfs] = callback;
};
/**