1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

OPFS VFS now lazily opens its sync access handle, as a step towards experimenting with relinquishing it during idle times to help avoid cross-tab and page-reload locking issues.

FossilOrigin-Name: a984e1ba435731413a541f86c50232bc7d6e33aff6ba4cca90f89188e7b82a2c
This commit is contained in:
stephan
2022-10-03 09:21:37 +00:00
parent bdfd7ea03a
commit 7ff8da876d
5 changed files with 72 additions and 60 deletions

View File

@ -24,27 +24,32 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
self.WhWasmUtilInstaller(capi.wasm);
delete self.WhWasmUtilInstaller;
/**
Install JS<->C struct bindings for the non-opaque struct types we
need... */
sqlite3.StructBinder = self.Jaccwabyt({
heap: 0 ? wasm.memory : wasm.heap8u,
alloc: wasm.alloc,
dealloc: wasm.dealloc,
functionTable: wasm.functionTable,
bigIntEnabled: wasm.bigIntEnabled,
memberPrefix: '$'
});
delete self.Jaccwabyt;
if(0){
/* "The problem" is that the following isn't type-safe.
OTOH, nothing about WASM pointers is. */
/**
Add the `.pointer` xWrap() signature entry to extend the
`pointer` arg handler to check for a `pointer` property. This
can be used to permit, e.g., passing an sqlite3.oo1.DB instance
to a C-style sqlite3_xxx function which takes an `sqlite3*`
argument.
*/
const xPointer = wasm.xWrap.argAdapter('pointer');
const adapter = function(v){
if(v && v.constructor){
const x = v.pointer;
if(Number.isInteger(x)) return x;
else toss("Invalid (object) type for .pointer-type argument.");
/* "The problem" is that the following isn't even remotely
type-safe. OTOH, nothing about WASM pointers is. */
const argPointer = wasm.xWrap.argAdapter('*');
wasm.xWrap.argAdapter('StructType', (v)=>{
if(v && v.constructor && v instanceof StructBinder.StructType){
v = v.pointer;
}
return xPointer(v);
};
wasm.xWrap.argAdapter('.pointer', adapter);
} /* ".pointer" xWrap() argument adapter */
return (v === (v | 0) /* v is a 32-bit integer */)
? argPointer(v)
: toss("Invalid (object) type for StructType-type argument.");
});
}
if(1){/* Convert Arrays and certain TypedArrays to strings for
'flexible-string'-type arguments */
@ -605,19 +610,6 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
};
}/*wasm.pstack filler*/
/**
Install JS<->C struct bindings for the non-opaque struct types we
need... */
sqlite3.StructBinder = self.Jaccwabyt({
heap: 0 ? wasm.memory : wasm.heap8u,
alloc: wasm.alloc,
dealloc: wasm.dealloc,
functionTable: wasm.functionTable,
bigIntEnabled: wasm.bigIntEnabled,
memberPrefix: '$'
});
delete self.Jaccwabyt;
{/* Import C-level constants and structs... */
const cJson = wasm.xCall('sqlite3_wasm_enum_json');
if(!cJson){