aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-oo1.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-10-20 21:28:31 +0000
committerstephan <stephan@noemail.net>2022-10-20 21:28:31 +0000
commit96b6371d709a91015204b14e4b83e61a209bbde2 (patch)
tree00e7ca3dc7a33227b5540dc266ebbe4c7a2a3931 /ext/wasm/api/sqlite3-api-oo1.js
parent875b95d4f5759c78f69e70496f84fb797702304d (diff)
downloadsqlite-96b6371d709a91015204b14e4b83e61a209bbde2.tar.gz
sqlite-96b6371d709a91015204b14e4b83e61a209bbde2.zip
Add more JS tests. Flesh out the aggregate UDF tests to use sqlite3_aggregate_context() so that they can each be used multiple times in the same statement. Add sqlite3_js_aggregate_context() convenience helper.
FossilOrigin-Name: 9d034ef5e1bab7c9651c2450dc85765fa6365d3f1414c711550de858ff8b3ece
Diffstat (limited to 'ext/wasm/api/sqlite3-api-oo1.js')
-rw-r--r--ext/wasm/api/sqlite3-api-oo1.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js
index c2e7eb14f..d101bc17f 100644
--- a/ext/wasm/api/sqlite3-api-oo1.js
+++ b/ext/wasm/api/sqlite3-api-oo1.js
@@ -149,9 +149,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
if( flagsStr.indexOf('w')>=0 ) oflags |= capi.SQLITE_OPEN_READWRITE;
if( 0===oflags ) oflags |= capi.SQLITE_OPEN_READONLY;
oflags |= capi.SQLITE_OPEN_EXRESCODE;
- const scope = wasm.scopedAllocPush();
+ const stack = wasm.pstack.pointer;
try {
- const pPtr = wasm.allocPtr() /* output (sqlite3**) arg */;
+ const pPtr = wasm.pstack.allocPtr() /* output (sqlite3**) arg */;
const pVfsName = vfsName ? (
('number'===typeof vfsName ? vfsName : wasm.scopedAllocCString(vfsName))
): 0;
@@ -163,21 +163,19 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
__dbTraceToConsole, 0);
}
// Check for per-VFS post-open SQL...
- wasm.setPtrValue(pPtr, 0);
- if(0===capi.sqlite3_file_control(
- pDb, "main", capi.SQLITE_FCNTL_VFS_POINTER, pPtr
- )){
- const postInitSql = __vfsPostOpenSql[wasm.getPtrValue(pPtr)];
- if(postInitSql){
- rc = capi.sqlite3_exec(pDb, postInitSql, 0, 0, 0);
- checkSqlite3Rc(pDb, rc);
- }
+ const pVfs = capi.sqlite3_js_db_vfs(pDb);
+ //console.warn("Opened db",fn,"with vfs",vfsName,pVfs);
+ if(!pVfs) toss3("Internal error: cannot get VFS for new db handle.");
+ const postInitSql = __vfsPostOpenSql[pVfs];
+ if(postInitSql){
+ rc = capi.sqlite3_exec(pDb, postInitSql, 0, 0, 0);
+ checkSqlite3Rc(pDb, rc);
}
}catch( e ){
if( pDb ) capi.sqlite3_close_v2(pDb);
throw e;
}finally{
- wasm.scopedAllocPop(scope);
+ wasm.pstack.restore(stack);
}
this.filename = fnJs;
__ptrMap.set(this, pDb);