From: stephan Date: Fri, 20 Oct 2023 12:23:49 +0000 (+0000) Subject: Correct the opfs-sahpool VFS's xGetLastError() method to return the previous error... X-Git-Tag: version-3.44.0~79 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=11223e0cff820fc81ebe6cf00192aec4bd7be521;p=thirdparty%2Fsqlite.git Correct the opfs-sahpool VFS's xGetLastError() method to return the previous error code, not 0, on success. FossilOrigin-Name: 95a1dde63117d696323c775580b9c04f044a5b8d609e9174b739ac03ecc1336c --- 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 e76fbf028a..870073cc09 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){ @@ -252,10 +248,9 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ wasm.heap8u().subarray(pSrc, pSrc+n), { at: HEADER_OFFSET_DATA + Number(offset64) } ); - return nBytes === n ? 0 : capi.SQLITE_IOERR; + return n===nBytes ? 0 : toss("Unknown write() failure."); }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 fd7e4865c4..084765f3e7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\ssqlite3ParserAddCleanup()\sinstead\sof\scalling\ssqlite3ExprListDelete()\ndirectly\swhen\sdisposing\sof\san\sunused\sORDER\sBY\sin\san\saggregate\sfunction,\nto\savoid\sdisrupting\sALTER\sTABLE\sdata\sstructures. -D 2023-10-20T10:18:03.872 +C Correct\sthe\sopfs-sahpool\sVFS's\sxGetLastError()\smethod\sto\sreturn\sthe\sprevious\serror\scode,\snot\s0,\son\ssuccess. +D 2023-10-20T12:23:49.687 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -583,7 +583,7 @@ F ext/wasm/api/sqlite3-api-worker1.js f941382f21006b4a817754184e2661b0a63ce65020 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 f7c965cf9ac0b66a538cd8f6c156f3f2a235e089821ca78cabd7bce41ce16bf7 +F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 595953994aa3ae2287c889c4da39ab3d6f17b6461ecf4bec334b7a3faafddb02 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 46c4afa6c50d7369252c104f274ad977a97e91ccfafc38b400fe36e90bdda88e F ext/wasm/api/sqlite3-wasm.c c8c5b81b838cef2053b1eb6e7a79c44a2caedcf0c9e6b0d12a45d73ce0617be0 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bc06df0d599e625bde6a10a394e326dc68da9ff07fa5404354580f81566e591f @@ -2133,8 +2133,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 18e7c826f08bce51719ef045daa60200b33790f2fe312c6853f9ef6c7e9d5030 -R 116bd1e6425f8040f4b7884265787040 -U drh -Z 3ed7aa53fa4bab3e10246f808572c725 +P d083e42086733ecd79aba8c268e020b01782bfe1cfa9684ce1c277af9c8bf92a +R 6e8befaf01cb46d1b6ec065810ecbd1e +U stephan +Z d67ca77d259ff533bed4295ddbc6d176 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 51c9b3d467..825f6d5df0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d083e42086733ecd79aba8c268e020b01782bfe1cfa9684ce1c277af9c8bf92a \ No newline at end of file +95a1dde63117d696323c775580b9c04f044a5b8d609e9174b739ac03ecc1336c \ No newline at end of file