dan | eb26672 | 2013-10-02 08:04:27 +0000 | [diff] [blame] | 1 | # 2012 March 26 |
| 2 | # |
| 3 | # The author disclaims copyright to this source code. In place of |
| 4 | # a legal notice, here is a blessing: |
| 5 | # |
| 6 | # May you do good and not evil. |
| 7 | # May you find forgiveness for yourself and forgive others. |
| 8 | # May you share freely, never taking more than you give. |
| 9 | # |
| 10 | #************************************************************************* |
| 11 | # |
| 12 | |
| 13 | set testdir [file dirname $argv0] |
| 14 | source $testdir/tester.tcl |
| 15 | source $testdir/fts3_common.tcl |
dan | 9211f8a | 2013-10-03 19:27:14 +0000 | [diff] [blame] | 16 | set ::testprefix fts4incr |
dan | eb26672 | 2013-10-02 08:04:27 +0000 | [diff] [blame] | 17 | |
| 18 | # If SQLITE_ENABLE_FTS3 is defined, omit this file. |
| 19 | ifcapable !fts3 { |
| 20 | finish_test |
| 21 | return |
| 22 | } |
| 23 | |
| 24 | # Create the fts_kjv_genesis procedure which fills and FTS3/4 table |
| 25 | # with the complete text of the Book of Genesis. |
| 26 | # |
| 27 | source $testdir/genesis.tcl |
| 28 | |
| 29 | do_test 1.0 { |
dan | 9211f8a | 2013-10-03 19:27:14 +0000 | [diff] [blame] | 30 | execsql { CREATE VIRTUAL TABLE t1 USING fts4(words) } |
dan | eb26672 | 2013-10-02 08:04:27 +0000 | [diff] [blame] | 31 | fts_kjv_genesis |
| 32 | } {} |
| 33 | |
| 34 | do_execsql_test 1.1 { |
| 35 | SELECT min(docid), max(docid) FROM t1; |
| 36 | } {1001001 1050026} |
| 37 | |
| 38 | foreach {tn q res} { |
| 39 | 1 { SELECT count(*) FROM t1 WHERE t1 MATCH 'and' AND docid < 1010000} 224 |
| 40 | 2 { SELECT count(*) FROM t1 WHERE t1 MATCH '"in the"' AND docid < 1010000} 47 |
| 41 | 3 { SELECT count(*) FROM t1 WHERE t1 MATCH '"And God"' AND docid < 1010000} 33 |
| 42 | 4 { SELECT count(*) FROM t1 WHERE t1 |
| 43 | MATCH '"land of canaan"' AND docid < 1030000 } 7 |
| 44 | } { |
| 45 | foreach s {0 1} { |
| 46 | execsql "INSERT INTO t1(t1) VALUES('test-no-incr-doclist=$s')" |
| 47 | do_execsql_test 2.$tn.$s $q $res |
| 48 | set t($s) [lindex [time [list execsql $q] 100] 0] |
| 49 | } |
mistachkin | 7b96f2f | 2015-06-10 22:51:02 +0000 | [diff] [blame] | 50 | if {0} { |
| 51 | puts "with optimization: $t(0) without: $t(1)" |
| 52 | } |
dan | eb26672 | 2013-10-02 08:04:27 +0000 | [diff] [blame] | 53 | } |
| 54 | |
dan | 362d216 | 2013-10-14 20:30:51 +0000 | [diff] [blame] | 55 | do_test 2.1 { |
| 56 | execsql { |
| 57 | CREATE VIRTUAL TABLE t2 USING fts4(order=DESC); |
| 58 | } |
| 59 | set num [list one two three four five six seven eight nine ten] |
| 60 | execsql BEGIN |
| 61 | for {set i 0} {$i < 10000} {incr i} { |
| 62 | set x "[lindex $num [expr $i%10]] zero" |
| 63 | execsql { INSERT INTO t2(docid, content) VALUES($i, $x) } |
| 64 | } |
| 65 | execsql COMMIT |
| 66 | execsql { INSERT INTO t2(t2) VALUES('optimize') } |
| 67 | } {} |
| 68 | |
| 69 | do_execsql_test 2.2 { |
| 70 | SELECT count(*) FROM t2 WHERE t2 MATCH '"never zero"' |
| 71 | } {0} |
| 72 | |
| 73 | do_execsql_test 2.3 { |
| 74 | SELECT count(*) FROM t2 WHERE t2 MATCH '"two zero"' |
| 75 | } {1000} |
| 76 | |
dan | eb26672 | 2013-10-02 08:04:27 +0000 | [diff] [blame] | 77 | finish_test |