]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a problem in fts3/4 that was causing it to discard data cached in-memory if an...
authordan <dan@noemail.net>
Wed, 9 Mar 2016 18:17:42 +0000 (18:17 +0000)
committerdan <dan@noemail.net>
Wed, 9 Mar 2016 18:17:42 +0000 (18:17 +0000)
FossilOrigin-Name: 79338b991bf01e81d336790ca87a0fa747da4ff3

ext/fts3/fts3_write.c
manifest
manifest.uuid
test/fts4opt.test

index 24039aef30d8e29ace7a4a01fd4a74d256072bb5..3ff481b0b081cdc70a18ee89b70cbb0a6189941e 100644 (file)
@@ -3195,7 +3195,7 @@ static int fts3SegmentMerge(
     ** segment. The level of the new segment is equal to the numerically
     ** greatest segment level currently present in the database for this
     ** index. The idx of the new segment is always 0.  */
-    if( csr.nSegment==1 ){
+    if( csr.nSegment==1 && 0==fts3SegReaderIsPending(csr.apSegment[0]) ){
       rc = SQLITE_DONE;
       goto finished;
     }
index 5189ebea8e56e8e4e21bfce6be5bac40662119fc..6d3b9274dde92cc8627140553d2b9c722824833c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Slight\ssimplification\sto\sthe\squery\soptimizer\slogic\sassociated\swith\sIN\s(SELECT).
-D 2016-03-09T15:34:51.959
+C Fix\sa\sproblem\sin\sfts3/4\sthat\swas\scausing\sit\sto\sdiscard\sdata\scached\sin-memory\sif\san\s'optimize'\scommand\sis\srun\swhen\sthere\sis\sno\sdata\son\sdisk.\sThe\susual\sway\sthis\swould\shappen\sis\sif\sthe\svery\sfirst\stransaction\sthat\swrites\sto\sthe\sfts3/4\stable\salso\sincludes\san\s'optimize'\scommand.
+D 2016-03-09T18:17:42.821
 F Makefile.in f53429fb2f313c099283659d0df6f20f932c861f
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc df0bf9ff7f8b3f4dd9fb4cc43f92fe58f6ec5c66
@@ -88,7 +88,7 @@ F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3
 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004
 F ext/fts3/fts3_unicode.c a93f5edc0aff44ef8b06d7cb55b52026541ca145
 F ext/fts3/fts3_unicode2.c c3d01968d497bd7001e7dc774ba75b372738c057
-F ext/fts3/fts3_write.c fb0456fa1407758f82458417c76fe4b06c86be98
+F ext/fts3/fts3_write.c c3863f23b6b4623c8b9d5cf31c12ce4469f78ca9
 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9
 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100
 F ext/fts3/tool/fts3view.c 5d78b668f4e9598af9147f8999632599fb0d9dd5
@@ -755,7 +755,7 @@ F test/fts4merge3.test 8d9ccb4a3d41c4c617a149d6c4b13ad02de797d0
 F test/fts4merge4.test d895b1057a7798b67e03455d0fa50e9ea836c47b
 F test/fts4noti.test 5553d7bb2e20bf4a06b23e849352efc022ce6309
 F test/fts4onepass.test 7319d61a2ed1325fc54afd0c060a0513b462303a
-F test/fts4opt.test 1901f696214c4e16a995dd7fdd70576fc5c41dbe
+F test/fts4opt.test fd6a11684b965e1999564ae763797b7fb9e34c96
 F test/fts4unicode.test 27378af76394542cf490cf001d8d1505fe55f6a9
 F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d
 F test/func.test ae97561957aba6ca9e3a7b8a13aac41830d701ef
@@ -1455,7 +1455,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P d91e57e49f23414ec9211b775eb11cd6230a4f96
-R c1ca42221fb7dbc6b010dbeefd096918
-U drh
-Z 8017c7a46c10555b3cc0af7ce0a6b14d
+P 2c55c3c2950cafdc256ab540f60dc4609b9c354b
+R b4dbf73ab3865664cce5c88a4214186d
+U dan
+Z a31e8746a8bf8afd08aed0fea525a7d3
index 41eb62d74803a344f72bdc07aa983c1341934482..190da3e5edd98a1ce06c7c4773c3b360643ff09b 100644 (file)
@@ -1 +1 @@
-2c55c3c2950cafdc256ab540f60dc4609b9c354b
\ No newline at end of file
+79338b991bf01e81d336790ca87a0fa747da4ff3
\ No newline at end of file
index 1933c57b1bbb3901c3be62ff47930a6891e3d507..0d0ed9f4f0c87aaa618529744e110feaab085cca 100644 (file)
@@ -166,4 +166,48 @@ do_execsql_test 2.8 {
   SELECT level, count(*) FROM t2_segdir GROUP BY level;
 } {0 2 1024 2 2048 2 3072 2}
 
+#-------------------------------------------------------------------------
+# Check that 'optimize' works when there is data in the in-memory hash
+# table, but no segments at all on disk.
+#
+do_execsql_test 3.1 {
+  CREATE VIRTUAL TABLE fts USING fts4 (t);
+  INSERT INTO fts (fts) VALUES ('optimize');
+}
+do_execsql_test 3.2 {
+  INSERT INTO fts(fts) VALUES('integrity-check');
+  SELECT count(*) FROM fts_segdir;
+} {0}
+do_execsql_test 3.3 {
+  BEGIN;
+  INSERT INTO fts (rowid, t) VALUES (2, 'test');
+  INSERT INTO fts (fts) VALUES ('optimize');
+  COMMIT;
+  SELECT level, idx FROM fts_segdir;
+} {0 0}
+do_execsql_test 3.4 {
+  INSERT INTO fts(fts) VALUES('integrity-check');
+  SELECT rowid FROM fts WHERE fts MATCH 'test';
+} {2}
+do_execsql_test 3.5 {
+  INSERT INTO fts (fts) VALUES ('optimize');
+  INSERT INTO fts(fts) VALUES('integrity-check');
+}
+do_test 3.6 {
+  set c1 [db total_changes]
+  execsql { INSERT INTO fts (fts) VALUES ('optimize') }
+  expr {[db total_changes] - $c1}
+} {1}
+do_test 3.7 {
+  execsql { INSERT INTO fts (rowid, t) VALUES (3, 'xyz') }
+  set c1 [db total_changes]
+  execsql { INSERT INTO fts (fts) VALUES ('optimize') }
+  expr {([db total_changes] - $c1) > 1}
+} {1}
+do_test 3.8 {
+  set c1 [db total_changes]
+  execsql { INSERT INTO fts (fts) VALUES ('optimize') }
+  expr {[db total_changes] - $c1}
+} {1}
+
 finish_test