1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Remove some dead JS code. Improve the exception-to-C-result-code conversion to account for the case of a file disappearing while the OPFS VFS is waiting to acquire a lock on it.

FossilOrigin-Name: 5bd9fd5f61e7cd1ed3b44c5cabc759c154c98eb40ad10d29e61f142aaa062ddf
This commit is contained in:
stephan
2024-06-12 22:15:25 +00:00
parent 063a2b338c
commit 709cb313cf
4 changed files with 35 additions and 36 deletions

View File

@@ -265,23 +265,34 @@ const installAsyncProxy = function(){
this.name = 'GetSyncHandleError'; this.name = 'GetSyncHandleError';
} }
}; };
/**
Attempts to find a suitable SQLITE_xyz result code for Error
object e. Returns either such a translation or rc if if it does
not know how to translate the exception.
*/
GetSyncHandleError.convertRc = (e,rc)=>{ GetSyncHandleError.convertRc = (e,rc)=>{
if(1){ if( e instanceof GetSyncHandleError ){
return ( if( e.cause.name==='NoModificationAllowedError'
e instanceof GetSyncHandleError
&& ((e.cause.name==='NoModificationAllowedError')
/* Inconsistent exception.name from Chrome/ium with the /* Inconsistent exception.name from Chrome/ium with the
same exception.message text: */ same exception.message text: */
|| (e.cause.name==='DOMException' || (e.cause.name==='DOMException'
&& 0===e.cause.message.indexOf('Access Handles cannot'))) && 0===e.cause.message.indexOf('Access Handles cannot')) ){
) ? ( return state.sq3Codes.SQLITE_BUSY;
/*console.warn("SQLITE_BUSY",e),*/ }else if( 'NotFoundError'===e.cause.name ){
state.sq3Codes.SQLITE_BUSY /**
) : rc; Maintenance reminder: SQLITE_NOTFOUND, though it looks like
}else{ a good match, has different semantics than NotFoundError
and is not suitable here.
*/
return state.sq3Codes.SQLITE_CANTOPEN;
}
}else if( 'NotFoundError'===e?.name ){
return state.sq3Codes.SQLITE_CANTOPEN;
}
return rc; return rc;
} };
}
/** /**
Returns the sync access handle associated with the given file Returns the sync access handle associated with the given file
handle object (which must be a valid handle object, as created by handle object (which must be a valid handle object, as created by
@@ -600,19 +611,6 @@ const installAsyncProxy = function(){
fh.releaseImplicitLocks = fh.releaseImplicitLocks =
(opfsFlags & state.opfsFlags.OPFS_UNLOCK_ASAP) (opfsFlags & state.opfsFlags.OPFS_UNLOCK_ASAP)
|| state.opfsFlags.defaultUnlockAsap; || state.opfsFlags.defaultUnlockAsap;
if(0 /* this block is modelled after something wa-sqlite
does but it leads to immediate contention on journal files.
Update: this approach reportedly only works for DELETE journal
mode. */
&& (0===(flags & state.sq3Codes.SQLITE_OPEN_MAIN_DB))){
/* sqlite does not lock these files, so go ahead and grab an OPFS
lock. */
fh.xLock = "xOpen"/* Truthy value to keep entry from getting
flagged as auto-locked. String value so
that we can easily distinguish is later
if needed. */;
await getSyncHandle(fh,'xOpen');
}
__openFiles[fid] = fh; __openFiles[fid] = fh;
storeAndNotify(opName, 0); storeAndNotify(opName, 0);
}catch(e){ }catch(e){

View File

@@ -390,6 +390,7 @@ const installOpfsVfs = function callee(options){
'SQLITE_ACCESS_EXISTS', 'SQLITE_ACCESS_EXISTS',
'SQLITE_ACCESS_READWRITE', 'SQLITE_ACCESS_READWRITE',
'SQLITE_BUSY', 'SQLITE_BUSY',
'SQLITE_CANTOPEN',
'SQLITE_ERROR', 'SQLITE_ERROR',
'SQLITE_IOERR', 'SQLITE_IOERR',
'SQLITE_IOERR_ACCESS', 'SQLITE_IOERR_ACCESS',

View File

@@ -1,5 +1,5 @@
C Remove\ssome\sJS\sdocs\swhich\sno\slonger\sapply.\sNo\scode\schanges. C Remove\ssome\sdead\sJS\scode.\sImprove\sthe\sexception-to-C-result-code\sconversion\sto\saccount\sfor\sthe\scase\sof\sa\sfile\sdisappearing\swhile\sthe\sOPFS\sVFS\sis\swaiting\sto\sacquire\sa\slock\son\sit.
D 2024-06-12T21:01:44.271 D 2024-06-12T22:15:25.519
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -615,10 +615,10 @@ F ext/wasm/api/sqlite3-api-oo1.js c373cc04625a96bd3f01ce8ebeac93a5d38dbda6215818
F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63 F ext/wasm/api/sqlite3-api-prologue.js b347a0c5350247f90174a0ad9b9e72a99a5f837f31f78f60fcdb829b2ca30b63
F ext/wasm/api/sqlite3-api-worker1.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-api-worker1.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d
F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89
F ext/wasm/api/sqlite3-opfs-async-proxy.js a77fe462e87bb18dcf51574750db89bbec9b95b390dfd01e3b055e7a7813c93d F ext/wasm/api/sqlite3-opfs-async-proxy.js 881af4643f037b6590c491cef5fac8bcdd4118993197a1fa222ccb8b01e3504a
F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d
F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78 F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 8433ee332d5f5e39fb19427fccb7bad7f44aa99b5504daad3343fc128c311e78
F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 4672142c5ebde2f36cfb54ade66beff393c8ceba819fbe3e6d4d16ed28454314 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 9e7600f0e97dc4f5ec33089b60c6b931df73e347653bf273cf6864f9f9501d7d
F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js a2fcbc3fecdd0eea229283584ebc122f29d98194083675dbe5cb2cf3a17fe309
F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c F ext/wasm/api/sqlite3-wasm.c 9267174b9b0591b4f71193542ab57adf95bb9415f7d3453acf4a8ca8052f5e6c
F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b
@@ -2195,8 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P a44703135e8dd3cc67e548e1aa3c42e71df127fb7b593ccfc06025ec42a501fd P f253cab3359270045a3ae9f5e9eadc1cfc8844181db127165bfdf49d5f99efb1
R f8258a841d7785f7bd34691642a97b21 R 63f255ea2e5c09516862fb8ffb235ee5
U stephan U stephan
Z 80db9b86bc6469d927101c39e3244f61 Z 1022f5b3521399d57e698263f497769f
# Remove this line to create a well-formed Fossil manifest. # Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
f253cab3359270045a3ae9f5e9eadc1cfc8844181db127165bfdf49d5f99efb1 5bd9fd5f61e7cd1ed3b44c5cabc759c154c98eb40ad10d29e61f142aaa062ddf