| OLD | NEW |
| 1 # 2006 October 31 (scaaarey) | 1 # 2006 October 31 |
| 2 # | 2 # |
| 3 # The author disclaims copyright to this source code. | 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. |
| 4 # | 9 # |
| 5 #************************************************************************* | 10 #************************************************************************* |
| 6 # This file implements regression tests for SQLite library. The focus | 11 # This file implements regression tests for SQLite library. The focus |
| 7 # here is testing correct handling of excessively long terms. | 12 # here is testing correct handling of very long terms. |
| 8 # | |
| 9 # $Id: fts3ah.test,v 1.1 2007/08/20 17:38:42 shess Exp $ | |
| 10 # | 13 # |
| 11 | 14 |
| 12 set testdir [file dirname $argv0] | 15 set testdir [file dirname $argv0] |
| 13 source $testdir/tester.tcl | 16 source $testdir/tester.tcl |
| 14 | 17 |
| 15 # If SQLITE_ENABLE_FTS3 is defined, omit this file. | 18 # If SQLITE_ENABLE_FTS3 is not defined, omit this file. |
| 16 ifcapable !fts3 { | 19 ifcapable !fts3 { |
| 17 finish_test | 20 finish_test |
| 18 return | 21 return |
| 19 } | 22 } |
| 20 | 23 |
| 21 # Generate a term of len copies of char. | |
| 22 proc bigterm {char len} { | |
| 23 for {set term ""} {$len>0} {incr len -1} { | |
| 24 append term $char | |
| 25 } | |
| 26 return $term | |
| 27 } | |
| 28 | |
| 29 # Generate a document of bigterms based on characters from the list | 24 # Generate a document of bigterms based on characters from the list |
| 30 # chars. | 25 # chars. |
| 31 proc bigtermdoc {chars len} { | 26 proc bigtermdoc {chars len} { |
| 32 set doc "" | 27 set doc "" |
| 33 foreach char $chars { | 28 foreach char $chars { |
| 34 append doc " " [bigterm $char $len] | 29 append doc " " [string repeat $char $len] |
| 35 } | 30 } |
| 36 return $doc | 31 return $doc |
| 37 } | 32 } |
| 38 | 33 |
| 39 set len 5000 | 34 set len 5000 |
| 40 set doc1 [bigtermdoc {a b c d} $len] | 35 set doc1 [bigtermdoc {a b c d} $len] |
| 41 set doc2 [bigtermdoc {b d e f} $len] | 36 set doc2 [bigtermdoc {b d e f} $len] |
| 42 set doc3 [bigtermdoc {a c e} $len] | 37 set doc3 [bigtermdoc {a c e} $len] |
| 43 | 38 |
| 44 set aterm [bigterm a $len] | 39 set aterm [string repeat a $len] |
| 45 set bterm [bigterm b $len] | 40 set bterm [string repeat b $len] |
| 46 set xterm [bigterm x $len] | 41 set xterm [string repeat x $len] |
| 47 | 42 |
| 48 db eval { | 43 db eval { |
| 49 CREATE VIRTUAL TABLE t1 USING fts3(content); | 44 CREATE VIRTUAL TABLE t1 USING fts3(content); |
| 50 INSERT INTO t1 (rowid, content) VALUES(1, $doc1); | 45 INSERT INTO t1 (rowid, content) VALUES(1, $doc1); |
| 51 INSERT INTO t1 (rowid, content) VALUES(2, $doc2); | 46 INSERT INTO t1 (rowid, content) VALUES(2, $doc2); |
| 52 INSERT INTO t1 (rowid, content) VALUES(3, $doc3); | 47 INSERT INTO t1 (rowid, content) VALUES(3, $doc3); |
| 53 } | 48 } |
| 54 | 49 |
| 55 # No hits at all. Returns empty doclists from termSelect(). | 50 # No hits at all. Returns empty doclists from termSelect(). |
| 56 do_test fts3ah-1.1 { | 51 do_test fts3ah-1.1 { |
| 57 execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'} | 52 execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'} |
| 58 } {} | 53 } {} |
| 59 | 54 |
| 60 do_test fts3ah-1.2 { | 55 do_test fts3ah-1.2 { |
| 61 execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm} | 56 execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm} |
| 62 } {1 3} | 57 } {1 3} |
| 63 | 58 |
| 64 do_test fts3ah-1.2 { | 59 do_test fts3ah-1.3 { |
| 65 execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm} | 60 execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm} |
| 66 } {} | 61 } {} |
| 67 | 62 |
| 68 do_test fts3ah-1.3 { | 63 do_test fts3ah-1.4 { |
| 69 execsql "SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'" | 64 execsql "SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'" |
| 70 } {1 3} | 65 } {1 3} |
| 71 | 66 |
| 72 do_test fts3ah-1.4 { | 67 do_test fts3ah-1.5 { |
| 73 execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"$aterm $bterm\"'" | 68 execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"$aterm $bterm\"'" |
| 74 } {1} | 69 } {1} |
| 75 | 70 |
| 76 finish_test | 71 finish_test |
| OLD | NEW |