]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the edit_cost_table= command to the spellfix1 virtual table, permitting
authordrh <drh@noemail.net>
Tue, 19 Feb 2013 11:51:27 +0000 (11:51 +0000)
committerdrh <drh@noemail.net>
Tue, 19 Feb 2013 11:51:27 +0000 (11:51 +0000)
the edit distance cost table to be changed at runtime.

FossilOrigin-Name: 89d6368250f9ba2f49e930bbe5524f3da615ce70

manifest
manifest.uuid
src/test_spellfix.c
test/spellfix.test

index e5a46828f7cfb69f67a4a89a1a181417c0f0d21e..3f6cdd5a933f08b12b353c4a13b13e5157ad0ad5 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\san\sunsafe\sVM\sregister\sdeallocation.
-D 2013-02-16T02:41:01.780
+C Add\sthe\sedit_cost_table=\scommand\sto\sthe\sspellfix1\svirtual\stable,\spermitting\nthe\sedit\sdistance\scost\stable\sto\sbe\schanged\sat\sruntime.
+D 2013-02-19T11:51:27.137
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -222,7 +222,7 @@ F src/test_regexp.c 58e0349f155bc307dfa209df4b03add0a7749866
 F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9
 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0
 F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f
-F src/test_spellfix.c 860eb723100d4e3cff846ba5d25e02815b2a5cac
+F src/test_spellfix.c 83abe9d8c364cdd5f93bc06eaf40a349ebbf6c5c
 F src/test_sqllog.c 8acb843ddb9928dea8962e31bb09f421a72ffccb
 F src/test_stat.c d1569c7a4839f13e80187e2c26b2ab4da2d03935
 F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd
@@ -734,7 +734,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523
 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715
 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa
 F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b
-F test/spellfix.test 2953e9da0e46dab5f83059ef6bfdebca66e13418
+F test/spellfix.test 52ae2680b1247c52b9e2b2116de3fd26a78e6bd2
 F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298
 F test/stat.test be8d477306006ec696bc86757cfb34bec79447ce
 F test/stmt.test 25d64e3dbf9a3ce89558667d7f39d966fe2a71b9
@@ -1034,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P 843e1c543aabab8cd62f28742d5818887d36bcb7
-R cbf020f2dfe84836eeb7827fde2edff0
+P cfba2c8dadbf1fa6f1602a327933570820a3b134
+R 9b9c12c2a5a4863f535d3439db5387d0
 U drh
-Z a30ad478221935586b899d8baf64a9ed
+Z 6e5d7f1f0806fdc66b4d3ab8e7314ebf
index 9d4a6ac1bf9b4ba7a2365764239294524c615507..77fe1f277acf909d4ee132ae9d50707cfbabdb6c 100644 (file)
@@ -1 +1 @@
-cfba2c8dadbf1fa6f1602a327933570820a3b134
\ No newline at end of file
+89d6368250f9ba2f49e930bbe5524f3da615ce70
\ No newline at end of file
index 543dccbf66bb4b5c3a83a19ae7785b6b65991d31..f294f48c61161b94edc8d772098a8e6d3d5106fb 100644 (file)
@@ -2681,6 +2681,18 @@ static int spellfix1Update(
         p->pConfig3 = 0;
         return SQLITE_OK;
       }
+      if( memcmp(zCmd,"edit_cost_table=",16)==0 ){
+        editDist3ConfigDelete(p->pConfig3);
+        p->pConfig3 = 0;
+        sqlite3_free(p->zCostTable);
+        p->zCostTable = spellfix1Dequote(zCmd+16);
+        if( p->zCostTable==0 ) return SQLITE_NOMEM;
+        if( p->zCostTable[0]==0 || sqlite3_stricmp(p->zCostTable,"null")==0 ){
+          sqlite3_free(p->zCostTable);
+          p->zCostTable = 0;
+        }
+        return SQLITE_OK;
+      }
       pVTab->zErrMsg = sqlite3_mprintf("unknown value for %s.command: \"%w\"",
                                        p->zTableName, zCmd);
       return SQLITE_ERROR;
index afef981d25c0313d447628409e2e5e8f6de0e9e5..6fb32b6d376cf4dd3bb585b68842b326bfdcb2ec 100644 (file)
@@ -136,16 +136,52 @@ do_test 3.2 {
   }
 } {}
 
-breakpoint
 foreach {tn word res} {
   1   kos*     {kosher 3 kiosk 4 kudo 2 kiss 3 kissed 3}
   2   kellj*   {killjoy 5 kill 4 killed 4 killer 4 killers 4}
   3   kellj    {kill 4 kills 5 killjoy 7 keel 4 killed 6}
 } {
-  do_execsql_test 1.2.$tn {
+  do_execsql_test 3.2.$tn {
     SELECT word, matchlen FROM t3 WHERE word MATCH $word
      ORDER BY score, word LIMIT 5
   } $res
-} 
+}
+
+do_execsql_test 4.0 {
+  INSERT INTO t3(command) VALUES('edit_cost_table=NULL');
+}
+foreach {tn word res} {
+  1   kosher     {kosher 0 kisser 51 kissers 76 kissed 126 kisses 126}
+  2   kellj      {keels 60 killjoy 68 kills 80 keel 120 kill 125}
+  3   kashar     {kosher 80 kisser 91 kissers 116 kissed 166 kisses 166}
+} {
+  do_execsql_test 4.1.$tn {
+    SELECT word, distance FROM t3 WHERE word MATCH $word
+     ORDER BY score, word LIMIT 5
+  } $res
+}
+do_execsql_test 5.0 {
+  CREATE TABLE costs2(iLang, cFrom, cTo, iCost);
+  INSERT INTO costs2 VALUES(0, 'a', 'o', 1);
+  INSERT INTO costs2 VALUES(0, 'e', 'o', 4);
+  INSERT INTO costs2 VALUES(0, 'i', 'o', 8);
+  INSERT INTO costs2 VALUES(0, 'u', 'o', 16);
+  INSERT INTO t3(command) VALUES('edit_cost_table="costs2"');
+}
+
+foreach {tn word res} {
+  1   kasher     {kosher 1}
+  2   kesher     {kosher 4}
+  3   kisher     {kosher 8}
+  4   kosher     {kosher 0}
+  5   kusher     {kosher 16}
+} {
+  do_execsql_test 5.1.$tn {
+    SELECT word, distance FROM t3 WHERE word MATCH $word
+     ORDER BY score, word LIMIT 1
+  } $res
+}
+
+
 
 finish_test