]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add fts4merge3.test, for testing that older versions of FTS4 may interoperate with...
authordan <dan@noemail.net>
Wed, 21 Mar 2012 14:34:23 +0000 (14:34 +0000)
committerdan <dan@noemail.net>
Wed, 21 Mar 2012 14:34:23 +0000 (14:34 +0000)
FossilOrigin-Name: 903ec5126dd981da6d7bab45c568f34b99446159

manifest
manifest.uuid
test/backcompat.test
test/bc_common.tcl [new file with mode: 0644]
test/fts3_common.tcl
test/fts4merge3.test [new file with mode: 0644]

index 7d1a25eb351348849625446781a6f3dd261907f0..13ef1aed2cdcc03871c7911b0002d4590a58c8f2 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Merge\strunk\schanges\sinto\sthe\sfts4-incr-merge\sbranch.
-D 2012-03-20T17:04:17.255
+C Add\sfts4merge3.test,\sfor\stesting\sthat\solder\sversions\sof\sFTS4\smay\sinteroperate\swith\sincr-merge\scapable\sversions.
+D 2012-03-21T14:34:23.781
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -288,13 +288,14 @@ F test/autoindex1.test 058d0b331ae6840a61bbee910d8cbae27bfd5991
 F test/autovacuum.test fcaf4616ae5bb18098db1cb36262565e5c841c3c
 F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4
 F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85
-F test/backcompat.test 71eeb75ea567c060774c4e8db4b0e703f21c7677
+F test/backcompat.test 94778872ed9f6158ba1b8534264d3413ae7e27f8
 F test/backup.test 717346db953e9e435c2a94916e4af177330d60d3
 F test/backup2.test 34986ef926ea522911a51dfdb2f8e99b7b75ebcf
 F test/backup_ioerr.test 40d208bc9224b666ee3ed423f49bc9062a36a9d0
 F test/backup_malloc.test 7162d604ec2b4683c4b3799a48657fb8b5e2d450
 F test/badutf.test d5360fc31f643d37a973ab0d8b4fb85799c3169f
 F test/badutf2.test f5bc7f2d280670ecd79b9cf4f0f1760c607fe51f
+F test/bc_common.tcl df4c51ae0de0cb414a18027be2abb2bd7693ce7a
 F test/between.test 16b1776c6323faadb097a52d673e8e3d8be7d070
 F test/bigfile.test 82dfe93ee7eb9e2e05641afa2b39ffd947a92ff1
 F test/bigfile2.test 852f948cb492aadab45b58f4d2f3b0832a115cb0
@@ -448,7 +449,7 @@ F test/fts2q.test b2fbbe038b7a31a52a6079b215e71226d8c6a682
 F test/fts2r.test b154c30b63061d8725e320fba1a39e2201cadd5e
 F test/fts2token.test d8070b241a15ff13592a9ae4a8b7c171af6f445a
 F test/fts3.test 672a040ea57036fb4b6fdc09027c18d7d24ab654
-F test/fts3_common.tcl d65de7e21c2b933bf17152830eb924356f197c8f
+F test/fts3_common.tcl 52423d0f15bca1d1d2f2b432f0542c4036d655c7
 F test/fts3aa.test 909d5f530d30a8e36b9328d67285eae6537c79c0
 F test/fts3ab.test 09aeaa162aee6513d9ff336b6932211008b9d1f9
 F test/fts3ac.test 636ed7486043055d4f126a0e385f2d5a82ebbf63
@@ -499,6 +500,7 @@ F test/fts4content.test 17b2360f7d1a9a7e5aa8022783f5c5731b6dfd4f
 F test/fts4langid.test 24a6e41063b416bbdf371ff6b4476fa41c194aa7
 F test/fts4merge.test 1c3389a3be18498934baf76afe67663d8b4b5e42
 F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891
+F test/fts4merge3.test 2d2008772f45afc617fc34d10bcafbc8de1ca2ae
 F test/func.test 6c5ce11e3a0021ca3c0649234e2d4454c89110ca
 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f
 F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a
@@ -994,7 +996,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
-P 7aabb62c8ccbd2b8d216e25226f06e5820dec38a 0fb26c7bfa7a4bb1503f90fd6f5b9c70f444665b
-R 58077ce5e1cbaecc58d15ee0d3722b1c
-U drh
-Z 8e670a9384f5fc62996e59150aae6127
+P f61d5fb0281381228eb1a12a233bacaeb26b12a3
+R 0ef159b3f0bfab79746087f966c7f8a3
+U dan
+Z 5c824893eaa42ecaf0e347109e073f8a
index 88dba24d9ffc581c891ffb922a716e51e8f7f8ff..4039183245145074ae649c718428313dae820d00 100644 (file)
@@ -1 +1 @@
-f61d5fb0281381228eb1a12a233bacaeb26b12a3
\ No newline at end of file
+903ec5126dd981da6d7bab45c568f34b99446159
\ No newline at end of file
index e8e2f61581c4b5333c3787062e16b90f1f002931..6a0f91ae9734fd04d1c38fadc458404f89786772 100644 (file)
@@ -27,37 +27,13 @@ set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 source $testdir/lock_common.tcl
 source $testdir/malloc_common.tcl
+source $testdir/bc_common.tcl
 db close
 
-# Search for binaries to test against. Any executable files that match
-# our naming convention are assumed to be testfixture binaries to test
-# against.
-#
-set binaries [list]
-set pattern "[file tail [info nameofexec]]?*"
-if {$tcl_platform(platform)=="windows"} {
-  set pattern [string map {\.exe {}} $pattern]
-}
-foreach file [glob -nocomplain $pattern] {
-  if {[file executable $file] && [file isfile $file]} {lappend binaries $file}
-}
-if {[llength $binaries]==0} {
-  puts "WARNING: No historical binaries to test against."
-  puts "WARNING: No backwards-compatibility tests have been run."
+if {"" == [bc_find_binaries backcompat.test]} {
   finish_test
   return
 }
-proc get_version {binary} {
-  set chan [launch_testfixture $binary]
-  set v [testfixture $chan { sqlite3 -version }]
-  close $chan
-  set v
-}
-foreach bin $binaries {
-  puts -nonewline "Testing against $bin - "
-  flush stdout
-  puts "version [get_version $bin]"
-}
 
 proc do_backcompat_test {rv bin1 bin2 script} {
 
@@ -93,7 +69,7 @@ proc do_backcompat_test {rv bin1 bin2 script} {
 array set ::incompatible [list]
 proc do_allbackcompat_test {script} {
 
-  foreach bin $::binaries {
+  foreach bin $::BC(binaries) {
     set nErr [set_test_counter errors]
     foreach dir {0 1} {
 
diff --git a/test/bc_common.tcl b/test/bc_common.tcl
new file mode 100644 (file)
index 0000000..8bba024
--- /dev/null
@@ -0,0 +1,76 @@
+
+
+
+proc bc_find_binaries {zCaption} {
+  # Search for binaries to test against. Any executable files that match
+  # our naming convention are assumed to be testfixture binaries to test
+  # against.
+  #
+  set binaries [list]
+  set pattern "[file tail [info nameofexec]]?*"
+  if {$::tcl_platform(platform)=="windows"} {
+    set pattern [string map {\.exe {}} $pattern]
+  }
+  foreach file [glob -nocomplain $pattern] {
+    if {[file executable $file] && [file isfile $file]} {lappend binaries $file}
+  }
+
+  if {[llength $binaries]==0} {
+    puts "WARNING: No historical binaries to test against."
+    puts "WARNING: Omitting backwards-compatibility tests $zFile"
+  }
+
+  foreach bin $binaries {
+    puts -nonewline "Testing against $bin - "
+    flush stdout
+    puts "version [get_version $bin]"
+  }
+
+  set ::BC(binaries) $binaries
+  return $binaries
+}
+
+proc get_version {binary} {
+  set chan [launch_testfixture $binary]
+  set v [testfixture $chan { sqlite3 -version }]
+  close $chan
+  set v
+}
+
+proc do_bc_test {bin script} {
+
+  forcedelete test.db
+  set ::bc_chan [launch_testfixture $bin]
+
+  proc code1 {tcl} { uplevel #0 $tcl }
+  proc code2 {tcl} { testfixture $::bc_chan $tcl }
+  proc sql1 sql { code1 [list db eval $sql] }
+  proc sql2 sql { code2 [list db eval $sql] }
+
+  code1 { sqlite3 db test.db }
+  code2 { sqlite3 db test.db }
+
+  set bintag [string map {testfixture {}} $bin]
+  set bintag [string map {\.exe {}} $bintag]
+  if {$bintag == ""} {set bintag self}
+  set saved_prefix $::testprefix
+  append ::testprefix ".$bintag"
+
+  uplevel $script
+
+  set ::testprefix $saved_prefix
+
+  catch { code1 { db close } }
+  catch { code2 { db close } }
+  catch { close $::bc_chan }
+}
+
+proc do_all_bc_test {script} {
+  foreach bin $::BC(binaries) {
+    uplevel [list do_bc_test $bin $script]
+  }
+}
+
+
+
+
index f031f927d65c7d17b090f77668439cc26e3aa518..d36ca10989ae837cd87a381cbccafd5dc27a036e 100644 (file)
 # to use Tcl.
 #
 
+#-------------------------------------------------------------------------
+# INSTRUCTIONS
+#
+# The following commands are available:
+#
+#   fts3_build_db_1 N
+#     Using database handle [db] create an FTS4 table named t1 and populate
+#     it with N rows of data. N must be less than 10,000. Refer to the
+#     header comments above the proc implementation below for details.
+#
+#   fts3_build_db_2 N
+#     Using database handle [db] create an FTS4 table named t2 and populate
+#     it with N rows of data. N must be less than 100,000. Refer to the
+#     header comments above the proc implementation below for details.
+#
+#   fts3_integrity_check TBL
+#     TBL must be an FTS table in the database currently opened by handle
+#     [db]. This proc loads and tokenizes all documents within the table,
+#     then checks that the current contents of the FTS index matches the
+#     results.
+#
+#   fts3_terms TBL WHERE
+#     Todo.
+#
+#   fts3_doclist TBL TERM WHERE
+#     Todo.
+#
+#
+#
 
 #-------------------------------------------------------------------------
 # USAGE: fts3_build_db_1 N
@@ -51,16 +80,19 @@ proc fts3_build_db_1 {n} {
 }
 
 #-------------------------------------------------------------------------
-# USAGE: fts3_build_db_2 N
+# USAGE: fts3_build_db_2 N ARGS
 #
 # Build a sample FTS table in the database opened by database connection 
 # [db]. The name of the new table is "t2".
 #
-proc fts3_build_db_2 {n} {
+proc fts3_build_db_2 {n args} {
 
   if {$n > 100000} {error "n must be <= 100000"}
 
-  db eval { CREATE VIRTUAL TABLE t2 USING fts4 }
+  set sql "CREATE VIRTUAL TABLE t2 USING fts4(content"
+  foreach a $args { append sql ", " $a }
+  append sql ")"
+  db eval $sql
 
   set chars [list a b c d e f g h  i j k l m n o p  q r s t u v w x  y z ""]
 
diff --git a/test/fts4merge3.test b/test/fts4merge3.test
new file mode 100644 (file)
index 0000000..30ea92c
--- /dev/null
@@ -0,0 +1,96 @@
+# 2012 March 06
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library.  The
+# focus of this script is testing the incremental merge function.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/fts3_common.tcl
+source $testdir/lock_common.tcl
+source $testdir/bc_common.tcl
+
+set ::testprefix fts4merge3
+
+if {"" == [bc_find_binaries backcompat.test]} {
+  finish_test
+  return
+}
+
+do_all_bc_test {
+
+  sql2 { PRAGMA page_size = 512 }
+  if { 0==[catch { sql2 { CREATE VIRTUAL TABLE x USING fts4 } } ] } {
+
+    # Build a large database.
+    set msg "this takes around 12 seconds"
+    do_test "1.1 ($msg)" { fts3_build_db_2 20000 } {}
+
+    # Run some queries on it, using the old and new versions.
+    do_test 1.2 { sql1 "SELECT docid FROM t2 WHERE t2 MATCH 'abc'" } {1485}
+    do_test 1.3 { sql2 "SELECT docid FROM t2 WHERE t2 MATCH 'abc'" } {1485}
+
+    do_test 1.4 { sql2 "PRAGMA page_count" } {1286}
+    do_test 1.5 { sql2 { 
+      SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1
+    } } [list 0 15    1 1     2 14    3 4]
+
+    # Run some incr-merge operations on the db.
+    for {set i 0} {$i<10} {incr i} {
+      do_test 1.6.$i.1 { sql1 { INSERT INTO t2(t2) VALUES('merge=2,2') } } {}
+      do_test 1.6.$i.2 { 
+        sql2 "SELECT docid FROM t2 WHERE t2 MATCH 'abc'" 
+      } {1485}
+    }
+
+    do_test 1.7 { sql2 { 
+      SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1
+    } } [list 0 15 1 1 2 14 3 4 4 1]
+
+    # Using the old connection, insert many rows. 
+    do_test 1.8 {
+      for {set i 0} {$i < 1500} {incr i} {
+        sql2 "INSERT INTO t2 SELECT content FROM t2 WHERE docid = $i"
+      }
+    } {}
+
+    do_test 1.9 { sql2 { 
+      SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1
+    } } {0 11 1 15 2 3 3 5 4 1}
+
+    # Run a big incr-merge operation on the db.
+    do_test 1.10 { sql1 { INSERT INTO t2(t2) VALUES('merge=2000,2') } } {}
+    do_test 1.11 { 
+      sql2 "SELECT docid FROM t2 WHERE t2 MATCH 'abc'" 
+    } {1485 21485}
+
+    do_test 1.12 {
+      for {set i 0} {$i < 1500} {incr i} {
+        sql2 "INSERT INTO t2 SELECT content FROM t2 WHERE docid = $i"
+      }
+    } {}
+    do_test 1.13 { 
+      sql2 "SELECT docid FROM t2 WHERE t2 MATCH 'abc'" 
+    } {1485 21485 22985}
+
+    do_test 1.14 { 
+      sql2 "INSERT INTO t2(t2) VALUES('optimize')"
+      sql2 "SELECT docid FROM t2 WHERE t2 MATCH 'abc'" 
+    } {1485 21485 22985}
+
+    do_test 1.15 { sql2 { 
+      SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1
+    } } {5 1}
+  }
+}
+
+
+finish_test