]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Minor internal cleanups in the JS-side fts5 cleanup steps.
authorstephan <stephan@noemail.net>
Thu, 3 Aug 2023 22:43:39 +0000 (22:43 +0000)
committerstephan <stephan@noemail.net>
Thu, 3 Aug 2023 22:43:39 +0000 (22:43 +0000)
FossilOrigin-Name: 2666f52e88691201a30dc0f27c294c498bba3f16d5d2dddcadcfac115a3cba20

ext/wasm/api/sqlite3-fts5-helper.js
ext/wasm/tester1.c-pp.js
manifest
manifest.uuid

index f1b169afde3847686ab927bcfc17df9163acaebc..bbabdc5ba6ba59d5b3bce2ab3fefbedf9ffb58ac 100644 (file)
@@ -72,9 +72,9 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
      uninstalled when the db they were installed for is closed... */
   const __addCleanupForFunc = function(sfapi, name, pDestroy){
     if(!sfapi.$$cleanup){
-      sfapi.$$cleanup = new Set;
+      sfapi.$$cleanup = [];
     }
-    sfapi.$$cleanup.add([name.toLowerCase(), pDestroy]);
+    sfapi.$$cleanup.push([name.toLowerCase(), pDestroy]);
   };
 
   /**
@@ -95,10 +95,18 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
           for(const [name, pDestroy] of sfapi.$$cleanup){
             try{
               /* Uninstall xFunctionArgAdapter's bindings via a
-                 roundabout approach... */
+                 roundabout approach: its scoping rules uninstall each
+                 new installation at the earliest opportunity, so we
+                 simply need to fake a call with a 0-pointer for the
+                 xFunction callback to uninstall the most recent
+                 one. */
               const zName = wasm.scopedAllocCString(name);
               const argv = [fapi, zName, 0, 0, 0];
-              xFunctionArgAdapter.convertArg(0, argv, 3);
+              xFunctionArgAdapter.convertArg(argv[3], argv, 3);
+              /* xDestroy, on the other hand, requires some
+                 hand-holding to ensure we don't prematurely
+                 uninstall these when a function is replaced
+                 (shadowed). */
               if(pDestroy) wasm.uninstallFunction(pDestroy);
             }catch(e){
               sqlite3.config.error("Error removing FTS func",name,e);
index 65e2be4a571242daeff7b668601065789dd64739..ee6696ea3bcf5645b0d14587a5d3f999fc268267 100644 (file)
@@ -2924,12 +2924,12 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
         fts.createFunction(db, {
           name: 'mymatch',
           xFunction: function(pFtsX, pFtsCx, pCtx, argv){
-            //log("mymatch!", argv.length, argv);
             // Both of these return-value approaches are equivalent:
+            const rv = "MY+"+argv.join(':');
             if(0){
-              return "MY+"+argv.join(':');
+              return rv;
             }else{
-              capi.sqlite3_result_text(pCtx, "MY+"+argv.join(':'), -1, 0);
+              capi.sqlite3_result_text(pCtx, rv, -1, capi.SQLITE_TRANSIENT);
               // implicit return of undefined
             }
           },
index 95724e0aeb5e356f0e3e35a2188cf40211865058..4029666b2085082212db5a32f85d3dfd49f2a23e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Retain\sall\sxDestroy\smethod\sWASM\sproxies\screated\sfor\sfts5_api::xCreateFunction()\suntil\sthe\sdb\sis\sclosed,\sthen\sfree\sthem\sall\sat\sonce.
-D 2023-08-03T21:14:58.401
+C Minor\sinternal\scleanups\sin\sthe\sJS-side\sfts5\scleanup\ssteps.
+D 2023-08-03T22:43:39.189
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -505,7 +505,7 @@ F ext/wasm/api/sqlite3-api-glue.js 861ff5ccfbaa50579c46618be53ac374202ad73cc27eb
 F ext/wasm/api/sqlite3-api-oo1.js 9678dc4d9a5d39632b6ffe6ea94a023119260815bf32f265bf5f6c36c9516db8
 F ext/wasm/api/sqlite3-api-prologue.js 76258e160bf6a89cc75a7d3c05646a054c8cab7219cd1e10bc20cacaad022131
 F ext/wasm/api/sqlite3-api-worker1.js 9f32af64df1a031071912eea7a201557fe39b1738645c0134562bb84e88e2fec
-F ext/wasm/api/sqlite3-fts5-helper.js c5da57d586f2689ea79f6c0d78f5b6a31af8c1234eee8e2ecc4ee5dee49e61d2
+F ext/wasm/api/sqlite3-fts5-helper.js 9cdc409db558b9321aa4eedffb30d62b5fe59ccd62c568f83d432d5f1d8f4c68
 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 8dc3da6e69d51f455b64cc88fec7977f528d79ec267cfcdd97b606c8cc4cd156
@@ -556,7 +556,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555
 F ext/wasm/test-opfs-vfs.js f09266873e1a34d9bdb6d3981ec8c9e382f31f215c9fd2f9016d2394b8ae9b7b
 F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c
 F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2
-F ext/wasm/tester1.c-pp.js 892d00acf7bf675e34766794dcc94bc26e5bf00abcfeeb9dbcc42eebac787bba
+F ext/wasm/tester1.c-pp.js 4ef8b4d4f369a0ad0975dbc3709dd4fd9d2d099f8053595f83ef58515b9656d2
 F ext/wasm/tests/opfs/concurrency/index.html 0802373d57034d51835ff6041cda438c7a982deea6079efd98098d3e42fbcbc1
 F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d
 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
@@ -2051,8 +2051,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 795f22421b96cea27b3883a580d8ce29cc50dfb7d4f852b3d36ede3766c7a24c
-R 1ffc481fbc423b6f11fdbf02fdf3e96b
+P f4b9743abd4fe24f1604cbcc7f9f95cadd1cefdc053eeabb35dc6773c99d1277
+R f44eb85aef02129cd0dbe3caa8ffb3ae
 U stephan
-Z eb3f6a64812695d4286c7946c1459803
+Z 71921d9fea535a9531daebace1ceec5c
 # Remove this line to create a well-formed Fossil manifest.
index 7951d5e1026d6a1673b083f82e43ba41c9b32365..46179932b7b6a84ca0c90fd28682ae87b89e0eec 100644 (file)
@@ -1 +1 @@
-f4b9743abd4fe24f1604cbcc7f9f95cadd1cefdc053eeabb35dc6773c99d1277
\ No newline at end of file
+2666f52e88691201a30dc0f27c294c498bba3f16d5d2dddcadcfac115a3cba20
\ No newline at end of file