From: stephan Date: Mon, 2 Oct 2023 15:37:55 +0000 (+0000) Subject: Revisit the opfs-sahpool's handling of sqlite3_vfs::xGetLastError(). This impl seems... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=03c7db8cd43d392e06d5cac3533912e8be1919b8;p=thirdparty%2Fsqlite.git Revisit the opfs-sahpool's handling of sqlite3_vfs::xGetLastError(). This impl seems to be in line with what the library internal expects but it requires more testing (via purposely-induced I/O errors) before merging. FossilOrigin-Name: c53fd21f68d5fc89ce7781d49e75a143d5d6232ab0f5e73f6b5b8e2b10fb3a49 --- diff --git a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js index 327b6a95ad..7374112daf 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js @@ -155,8 +155,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ pool.deletePath(file.path); } }catch(e){ - pool.storeErr(e); - return capi.SQLITE_IOERR; + return pool.storeErr(e, capi.SQLITE_IOERR); } } return 0; @@ -200,8 +199,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ } return 0; }catch(e){ - pool.storeErr(e); - return capi.SQLITE_IOERR; + return pool.storeErr(e, capi.SQLITE_IOERR); } }, xSectorSize: function(pFile){ @@ -217,8 +215,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ file.sah.flush(); return 0; }catch(e){ - pool.storeErr(e); - return capi.SQLITE_IOERR; + return pool.storeErr(e, capi.SQLITE_IOERR); } }, xTruncate: function(pFile,sz64){ @@ -231,8 +228,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ file.sah.truncate(HEADER_OFFSET_DATA + Number(sz64)); return 0; }catch(e){ - pool.storeErr(e); - return capi.SQLITE_IOERR; + return pool.storeErr(e, capi.SQLITE_IOERR); } }, xUnlock: function(pFile,lockType){ @@ -254,8 +250,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ); return nBytes === n ? 0 : capi.SQLITE_IOERR; }catch(e){ - pool.storeErr(e); - return capi.SQLITE_IOERR; + return pool.storeErr(e, capi.SQLITE_IOERR); } } }/*ioMethods*/; @@ -314,8 +309,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ }, xGetLastError: function(pVfs,nOut,pOut){ const pool = getPoolForVfs(pVfs); - pool.log(`xGetLastError ${nOut}`); const e = pool.popErr(); + pool.log(`xGetLastError ${nOut} e =`,e); if(e){ const scope = wasm.scopedAllocPush(); try{ @@ -328,7 +323,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ wasm.scopedAllocPop(scope); } } - return 0; + return e ? (e.sqlite3Rc || capi.SQLITE_IOERR) : 0; }, //xSleep is optionally defined below xOpen: function f(pVfs, zName, pFile, flags, pOutFlags){ @@ -762,12 +757,20 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ } /** - Sets e as this object's current error. Pass a falsy - (or no) value to clear it. + Sets e (an Error object) as this object's current error. Pass a + falsy (or no) value to clear it. If code is truthy it is + assumed to be an SQLITE_xxx result code, defaulting to + SQLITE_IOERR if code is falsy. + + Returns the 2nd argument. */ - storeErr(e){ - if(e) this.error(e); - return this.$error = e; + storeErr(e,code){ + if(e){ + e.sqlite3Rc = code || capi.SQLITE_IOERR; + this.error(e); + } + this.$error = e; + return code; } /** Pops this object's Error object and returns diff --git a/manifest b/manifest index 86a145f0d2..3a62eaa988 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Pointer-casting-related\sfixes\sfor\sJNI\son\s32-bit\sARM\s(pi4\sarmv7l). -D 2023-10-02T14:44:28.216 +C Revisit\sthe\sopfs-sahpool's\shandling\sof\ssqlite3_vfs::xGetLastError().\sThis\simpl\sseems\sto\sbe\sin\sline\swith\swhat\sthe\slibrary\sinternal\sexpects\sbut\sit\srequires\smore\stesting\s(via\spurposely-induced\sI/O\serrors)\sbefore\smerging. +D 2023-10-02T15:37:55.924 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -575,7 +575,7 @@ F ext/wasm/api/sqlite3-api-worker1.js 9f32af64df1a031071912eea7a201557fe39b17386 F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379 F ext/wasm/api/sqlite3-v-helper.js 7daa0eab0a513a25b05e9abae7b5beaaa39209b3ed12f86aeae9ef8d2719ed25 -F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 327a8c363a8c84c61770dc3c46cc83d7cc0eb6b59a3b29728bddf087651d3b77 +F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 537620185958adaa7f3175ef8fb1d0c17b8cf07d5689594cb76ac1bea02e4bc8 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 46c4afa6c50d7369252c104f274ad977a97e91ccfafc38b400fe36e90bdda88e F ext/wasm/api/sqlite3-wasm.c 65d60439671e24d50d9119ca805ac1c68fb36129e164377eb46f8d037bd88b07 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bc06df0d599e625bde6a10a394e326dc68da9ff07fa5404354580f81566e591f @@ -2122,8 +2122,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2532e5662a2bbb3e6b4c4be3fad035734b684bdf59b178cb64b444ca6d8b956b -R a83650bf5f7797eddfc74482addb44c4 +P 54441039ae3ebe39e42f008f77ce1be117cbda6daeed8b01739ad42a3c1f0754 +R 39ee253208408e390f1544305ad866da +T *branch * wasm-xGetLastError +T *sym-wasm-xGetLastError * +T -sym-trunk * Cancelled\sby\sbranch. U stephan -Z c1992b9ab6d0229ceafa8f585205277d +Z d4859ccc3c97fee14c139b7fed420589 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 84af8afc75..bfe0d47b61 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -54441039ae3ebe39e42f008f77ce1be117cbda6daeed8b01739ad42a3c1f0754 \ No newline at end of file +c53fd21f68d5fc89ce7781d49e75a143d5d6232ab0f5e73f6b5b8e2b10fb3a49 \ No newline at end of file