Annotation of embedaddon/sqlite3/test/fts3defer.test, revision 1.1
1.1 ! misho 1: # 2010 October 15
! 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: set testdir [file dirname $argv0]
! 13: source $testdir/tester.tcl
! 14: source $testdir/malloc_common.tcl
! 15:
! 16: ifcapable !fts3 {
! 17: finish_test
! 18: return
! 19: }
! 20:
! 21: set sqlite_fts3_enable_parentheses 1
! 22:
! 23: set fts3_simple_deferred_tokens_only 1
! 24:
! 25: set ::testprefix fts3defer
! 26:
! 27: #--------------------------------------------------------------------------
! 28: # Test cases fts3defer-1.* are the "warm body" cases. The database contains
! 29: # one row with 15000 instances of the token "a". This makes the doclist for
! 30: # "a" so large that FTS3 will avoid loading it in most cases.
! 31: #
! 32: # To show this, test cases fts3defer-1.2.* execute a bunch of FTS3 queries
! 33: # involving token "a". Then, fts3defer-1.3.* replaces the doclist for token
! 34: # "a" with all zeroes and fts3defer-1.4.* repeats the tests from 1.2. If
! 35: # the tests still work, we can conclude that the doclist for "a" was not
! 36: # used.
! 37: #
! 38:
! 39: set aaa [string repeat "a " 15000]
! 40:
! 41: do_execsql_test 1.1 {
! 42: CREATE VIRTUAL TABLE t1 USING fts4;
! 43: BEGIN;
! 44: INSERT INTO t1 VALUES('this is a dog');
! 45: INSERT INTO t1 VALUES('an instance of a phrase');
! 46: INSERT INTO t1 VALUES('an instance of a longer phrase');
! 47: INSERT INTO t1 VALUES($aaa);
! 48: COMMIT;
! 49: } {}
! 50:
! 51: set tests {
! 52: 1 {SELECT rowid FROM t1 WHERE t1 MATCH '"a dog"'} {1}
! 53: 2 {SELECT rowid FROM t1 WHERE t1 MATCH '"is a dog"'} {1}
! 54: 3 {SELECT rowid FROM t1 WHERE t1 MATCH '"a longer phrase"'} {3}
! 55: 4 {SELECT snippet(t1) FROM t1 WHERE t1 MATCH '"a longer phrase"'}
! 56: {"an instance of <b>a</b> <b>longer</b> <b>phrase</b>"}
! 57: 5 {SELECT rowid FROM t1 WHERE t1 MATCH 'a dog'} {1}
! 58: }
! 59:
! 60: do_select_tests 1.2 $tests
! 61:
! 62: do_execsql_test 1.3 {
! 63: SELECT count(*) FROM t1_segments WHERE length(block)>10000;
! 64: UPDATE t1_segments
! 65: SET block = zeroblob(length(block))
! 66: WHERE length(block)>10000;
! 67: } {1}
! 68:
! 69: do_select_tests 1.4 $tests
! 70:
! 71: # Drop the table. It is corrupt now anyhow, so not useful for subsequent tests.
! 72: #
! 73: do_execsql_test 1.5 { DROP TABLE t1 }
! 74:
! 75: #--------------------------------------------------------------------------
! 76: # These tests - fts3defer-2.* - are more rigorous. They test that for a
! 77: # variety of queries, FTS3 and FTS4 return the same results. And that
! 78: # zeroing the very large doclists that FTS4 does not load does not change
! 79: # the results.
! 80: #
! 81: # They use the following pseudo-randomly generated document data. The
! 82: # tokens "zm" and "jk" are especially common in this dataset. Additionally,
! 83: # two documents are added to the pseudo-random data before it is loaded
! 84: # into FTS4 containing 100,000 instances of the "zm" and "jk" tokens. This
! 85: # makes the doclists for those tokens so large that FTS4 avoids loading them
! 86: # into memory if possible.
! 87: #
! 88: set data [list]
! 89: lappend data [string repeat "zm " 100000]
! 90: lappend data [string repeat "jk " 100000]
! 91: lappend data {*}{
! 92: "zm zm agmckuiu uhzq nsab jk rrkx duszemmzl hyq jk"
! 93: "jk uhzq zm zm rgpzmlnmd zm zk jk jk zm"
! 94: "duszemmzl zm jk xldlpy zm jk sbptoa xh jk xldlpy"
! 95: "zm xh zm xqf azavwm jk jk trqd rgpzmlnmd jk"
! 96: "zm vwq urvysbnykk ubwrfqnbjf zk lsz jk doiwavhwwo jk jk"
! 97: "jk xduvfhk orpfawpx zkhdvkw jk mjpavjuhw zm jk duszemmzl zm"
! 98: "jk igju jk jk zm hmjf xh zm gwdfhwurx zk"
! 99: "vgsld jk jk zm hrlipdm jn zm zsmhnf vgsld duszemmzl"
! 100: "gtuiexzsu aayxpmve zm zm zm drir scpgna xh azavwm uhzq"
! 101: "farlehdhq hkfoudzftq igju duszemmzl xnxhf ewle zm hrlipdm urvysbnykk kn"
! 102: "xnxhf jk jk agmckuiu duszemmzl jk zm zm jk vgsld"
! 103: "zm zm zm jk jk urvysbnykk ogttbykvt zm zm jk"
! 104: "iasrqgqv zm azavwm zidhxhbtv jk jk mjpavjuhw zm zm ajmvcydy"
! 105: "rgpzmlnmd tmt mjpavjuhw xh igju jk azavwm fibokdry vgsld ofm"
! 106: "zm jk vgsld jk xh jk csjqxhgj drir jk pmrb"
! 107: "xh jk jk zm rrkx duszemmzl mjpavjuhw xldlpy igju zm"
! 108: "jk hkfoudzftq zf rrkx wdmy jupk jk zm urvysbnykk npywgdvgz"
! 109: "zm jk zm zm zhbrzadb uenvbm aayxpmve urvysbnykk duszemmzl jk"
! 110: "uenvbm jk zm fxw xh bdilwmjw mjpavjuhw uv jk zm"
! 111: "nk jk bnhc pahlds jk igju dzadnqzprr jk jk jk"
! 112: "uhzq uv zm duszemmzl tlqix jk jk xh jk zm"
! 113: "jk zm agmckuiu urvysbnykk jk jk zm zm jk jk"
! 114: "azavwm mjpavjuhw lsgshn trqd xldlpy ogyavjvv agmckuiu ryvwwhlbc jk jk"
! 115: "tmt jk zk zm azavwm ofm acpgim bvgimjik iasrqgqv wuvajhwqz"
! 116: "igju ogyavjvv xrbdak rrkx fibokdry zf ujfhmrllq jk zm hxgwvib"
! 117: "zm pahlds jk uenvbm aayxpmve iaf hmjf xph vnlyvtkgx zm"
! 118: "jk xnxhf igju jk xh jk nvfasfh zm js jk"
! 119: "zm zm rwaj igju xr rrkx xnxhf nvfasfh skxbsqzvmt xatbxeqq"
! 120: "vgsld zm ujfhmrllq uhzq ogyavjvv nsab azavwm zm vgsld jmfiqhwnjg"
! 121: "ymjoym duszemmzl urvysbnykk azavwm jk jmfiqhwnjg bu qcdziqomqk vnlyvtkgx"
! 122: "zm nbilqcnz dzadnqzprr xh bkfgzsxn urvysbnykk xrujfzxqf zm zf agmckuiu"
! 123: "jk urvysbnykk nvfasfh zf xh zm zm qcdziqomqk qvxtclg wdmy"
! 124: "fibokdry jk urvysbnykk jk xr osff zm cvnnsl zm vgsld"
! 125: "jk mjpavjuhw hkfoudzftq jk zm xh xqf urvysbnykk jk iasrqgqv"
! 126: "jk csjqxhgj duszemmzl iasrqgqv aayxpmve zm brsuoqww jk qpmhtvl wluvgsw"
! 127: "jk mj azavwm jk zm jn dzadnqzprr zm jk uhzq"
! 128: "zk xqf jupk fxw nbilqcnz zm jk jcpiwj tznlvbfcv nvfasfh"
! 129: "jk jcpiwj zm xnxhf zm mjpavjuhw mj drir pa pvjrjlas"
! 130: "duszemmzl dzadnqzprr jk swc duszemmzl tmt jk jk pahlds jk"
! 131: "zk zm jk zm zm eczkjblu zm hi pmrb jk"
! 132: "azavwm zm iz agmckuiu jk sntk jk duszemmzl duszemmzl zm"
! 133: "jk zm jk eczkjblu urvysbnykk sk gnl jk ttvgf hmjf"
! 134: "jk bnhc jjrxpjkb mjpavjuhw fibokdry igju jk zm zm xh"
! 135: "wxe ogttbykvt uhzq xr iaf zf urvysbnykk aayxpmve oacaxgjoo mjpavjuhw"
! 136: "gazrt jk ephknonq myjp uenvbm wuvajhwqz jk zm xnxhf nvfasfh"
! 137: "zm aayxpmve csjqxhgj xnxhf xr jk aayxpmve xnxhf zm zm"
! 138: "sokcyf zm ogyavjvv jk zm fibokdry zm jk igju igju"
! 139: "vgsld bvgimjik xuprtlyle jk akmikrqyt jk aayxpmve hkfoudzftq ddjj ithtir"
! 140: "zm uhzq ovkyevlgv zk uenvbm csjqxhgj jk vgsld pgybs jk"
! 141: "zm agmckuiu zexh fibokdry jk uhzq bu tugflixoex xnxhf sk"
! 142: "zm zf uenvbm jk azavwm zm zm agmckuiu zm jk"
! 143: "rrkx jk zf jt zm oacaxgjoo fibokdry wdmy igju csjqxhgj"
! 144: "hi igju zm jk zidhxhbtv dzadnqzprr jk jk trqd duszemmzl"
! 145: "zm zm mjpavjuhw xrbdak qrvbjruc jk qzzqdxq guwq cvnnsl zm"
! 146: "ithtir jk jk qcdziqomqk zm farlehdhq zm zm xrbdak jk"
! 147: "ixfipk csjqxhgj azavwm sokcyf ttvgf vgsld jk sk xh zk"
! 148: "nvfasfh azavwm zm zm zm fxw nvfasfh zk gnl trqd"
! 149: "zm fibokdry csjqxhgj ofm dzadnqzprr jk akmikrqyt orpfawpx duszemmzl vwq"
! 150: "csjqxhgj jk jk vgsld urvysbnykk jk nxum jk jk nxum"
! 151: "zm hkfoudzftq jk ryvwwhlbc mjpavjuhw ephknonq jk zm ogyavjvv zm"
! 152: "lwa hi xnxhf qdyerbws zk njtc jk uhzq zm jk"
! 153: "trqd zm dzadnqzprr zm urvysbnykk jk lsz jk mjpavjuhw cmnnkna"
! 154: "duszemmzl zk jk jk fibokdry jseuhjnzo zm aayxpmve zk jk"
! 155: "fibokdry jk sviq qvxtclg wdmy jk doiwavhwwo zexh jk zm"
! 156: "jupk zm xh jk mjpavjuhw zm jk nsab npywgdvgz duszemmzl"
! 157: "zm igju zm zm nvfasfh eh hkfoudzftq fibokdry fxw xkblf"
! 158: "jk zm jk jk zm xh zk abthnzcv zf csjqxhgj"
! 159: "zm zm jk nkaotm urvysbnykk sbptoa bq jk ktxdty ubwrfqnbjf"
! 160: "nvfasfh aayxpmve xdcuz zm tugflixoex jcpiwj zm mjpavjuhw fibokdry doiwavhwwo"
! 161: "iaf jk mjpavjuhw zm duszemmzl jk jk uhzq pahlds fibokdry"
! 162: "ddjj zk azavwm jk swc zm gjtexkv jk xh jk"
! 163: "igju jk csjqxhgj zm jk dzadnqzprr duszemmzl ulvcbv jk jk"
! 164: "jk fibokdry zm csjqxhgj jn zm zm zm zf uhzq"
! 165: "duszemmzl jk xkblf zk hrlipdm aayxpmve uenvbm uhzq jk zf"
! 166: "dzadnqzprr jk zm zdu nvfasfh zm jk urvysbnykk hmjf jk"
! 167: "jk aayxpmve aserrdxm acpgim fibokdry jk drir wxe brsuoqww rrkx"
! 168: "uhzq csjqxhgj nvfasfh jk rrkx qbamok trqd uenvbm sntk zm"
! 169: "ps azavwm zkhdvkw jk zm jk jk zm csjqxhgj xedlrcfo"
! 170: "jk jk ogyavjvv jk zm farlehdhq duszemmzl jk agitgxamxe jk"
! 171: "qzzqdxq rwaj jk jk zm xqf jk uenvbm jk zk"
! 172: "zm hxgwvib akmikrqyt zf agmckuiu uenvbm bq npywgdvgz azavwm jk"
! 173: "zf jmfiqhwnjg js igju zm aayxpmve zm mbxnljomiv csjqxhgj nvfasfh"
! 174: "zm jk jk gazrt jk jk lkc jk nvfasfh jk"
! 175: "xldlpy orpfawpx zkhdvkw jk zm igju zm urvysbnykk dzadnqzprr mbxnljomiv"
! 176: "urvysbnykk jk zk igju zm uenvbm jk zm ithtir jk"
! 177: "zm zk zm zf ofm zm xdcuz dzadnqzprr zm vgsld"
! 178: "sbptoa jk tugflixoex jk zm zm vgsld zm xh zm"
! 179: "uhzq jk zk evvivo vgsld vniqnuynvf agmckuiu jk zm zm"
! 180: "zm nvfasfh zm zm zm abthnzcv uenvbm jk zk dzadnqzprr"
! 181: "zm azavwm igju qzzqdxq jk xnxhf abthnzcv jk nvfasfh zm"
! 182: "qbamok fxw vgsld igju cmnnkna xnxhf vniqnuynvf zk xh zm"
! 183: "nvfasfh zk zm mjpavjuhw dzadnqzprr jk jk duszemmzl xldlpy nvfasfh"
! 184: "xnxhf sviq nsab npywgdvgz osff vgsld farlehdhq fibokdry wjbkhzsa hhac"
! 185: "zm azavwm scpgna jk jk bq jk duszemmzl fibokdry ovkyevlgv"
! 186: "csjqxhgj zm jk jk duszemmzl zk xh zm jk zf"
! 187: "urvysbnykk dzadnqzprr csjqxhgj mjpavjuhw ubwrfqnbjf nkaotm jk jk zm drir"
! 188: "nvfasfh xh igju zm wluvgsw jk zm srwwnezqk ewle ovnq"
! 189: "jk nvfasfh eh ktxdty urvysbnykk vgsld zm jk eh uenvbm"
! 190: "orpfawpx pahlds jk uhzq hi zm zm zf jk dzadnqzprr"
! 191: "srwwnezqk csjqxhgj rbwzuf nvfasfh jcpiwj xldlpy nvfasfh jk vgsld wjybxmieki"
! 192: }
! 193:
! 194: proc add_empty_records {n} {
! 195: execsql BEGIN
! 196: for {set i 0} {$i < $n} {incr i} {
! 197: execsql { INSERT INTO t1 VALUES('') }
! 198: }
! 199: execsql COMMIT
! 200: }
! 201:
! 202:
! 203: #set e [list]
! 204: #foreach d $data {set e [concat $e $d]}
! 205: #puts [lsort -unique $e]
! 206: #exit
! 207:
! 208: set zero_long_doclists {
! 209: UPDATE t1_segments SET block=zeroblob(length(block)) WHERE length(block)>10000
! 210: }
! 211:
! 212: foreach {tn setup} {
! 213: 1 {
! 214: set dmt_modes 0
! 215: execsql { CREATE VIRTUAL TABLE t1 USING FTS3 }
! 216: foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }
! 217: }
! 218: 2 {
! 219: set dmt_modes 0
! 220: execsql { CREATE VIRTUAL TABLE t1 USING FTS4 }
! 221: foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }
! 222: }
! 223: 3 {
! 224: set dmt_modes {0 1 2}
! 225: execsql { CREATE VIRTUAL TABLE t1 USING FTS4 }
! 226: foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }
! 227: add_empty_records 1000
! 228: execsql $zero_long_doclists
! 229: }
! 230: 4 {
! 231: set dmt_modes 0
! 232: execsql { CREATE VIRTUAL TABLE t1 USING FTS4 }
! 233: foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }
! 234: add_empty_records 1000
! 235: execsql "INSERT INTO t1(t1) VALUES('optimize')"
! 236: execsql $zero_long_doclists
! 237: }
! 238: 5 {
! 239: set dmt_modes 0
! 240: execsql { CREATE VIRTUAL TABLE t1 USING FTS4(matchinfo=fts3) }
! 241: foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }
! 242: add_empty_records 1000
! 243: execsql $zero_long_doclists
! 244: }
! 245: } {
! 246:
! 247: execsql { DROP TABLE IF EXISTS t1 }
! 248: eval $setup
! 249: set ::testprefix fts3defer-2.$tn
! 250: set DO_MALLOC_TEST 0
! 251:
! 252: do_execsql_test 0 {
! 253: SELECT count(*) FROM t1_segments WHERE length(block)>10000
! 254: } {2}
! 255:
! 256: do_select_test 1.1 {
! 257: SELECT rowid FROM t1 WHERE t1 MATCH 'jk xnxhf'
! 258: } {13 29 40 47 48 52 63 92}
! 259: do_select_test 1.2 {
! 260: SELECT rowid FROM t1 WHERE t1 MATCH 'jk eh'
! 261: } {100}
! 262: do_select_test 1.3 {
! 263: SELECT rowid FROM t1 WHERE t1 MATCH 'jk ubwrfqnbjf'
! 264: } {7 70 98}
! 265: do_select_test 1.4 {
! 266: SELECT rowid FROM t1 WHERE t1 MATCH 'duszemmzl jk'
! 267: } {3 5 8 10 13 18 20 23 32 37 41 43 55 60 65 67 72 74 76 81 94 96 97}
! 268: do_select_test 1.5 {
! 269: SELECT rowid FROM t1 WHERE t1 MATCH 'ubwrfqnbjf jk'
! 270: } {7 70 98}
! 271: do_select_test 1.6 {
! 272: SELECT rowid FROM t1 WHERE t1 MATCH 'jk ubwrfqnbjf jk jk jk jk'
! 273: } {7 70 98}
! 274: do_select_test 1.7 {
! 275: SELECT rowid FROM t1 WHERE t1 MATCH 'zm xnxhf'
! 276: } {12 13 29 30 40 47 48 52 63 92 93}
! 277: do_select_test 1.8 {
! 278: SELECT rowid FROM t1 WHERE t1 MATCH 'zm eh'
! 279: } {68 100}
! 280: do_select_test 1.9 {
! 281: SELECT rowid FROM t1 WHERE t1 MATCH 'zm ubwrfqnbjf'
! 282: } {7 70 98}
! 283: do_select_test 1.10 {
! 284: SELECT rowid FROM t1 WHERE t1 MATCH 'z* vgsld'
! 285: } {10 13 17 31 35 51 58 88 89 90 93 100}
! 286:
! 287: if { $fts3_simple_deferred_tokens_only==0 } {
! 288: do_select_test 1.11 {
! 289: SELECT rowid FROM t1
! 290: WHERE t1 MATCH '(
! 291: zdu OR zexh OR zf OR zhbrzadb OR zidhxhbtv OR
! 292: zk OR zkhdvkw OR zm OR zsmhnf
! 293: ) vgsld'
! 294: } {10 13 17 31 35 51 58 88 89 90 93 100}
! 295: }
! 296:
! 297: do_select_test 2.1 {
! 298: SELECT rowid FROM t1 WHERE t1 MATCH '"zm agmckuiu"'
! 299: } {3 24 52 53}
! 300: do_select_test 2.2 {
! 301: SELECT rowid FROM t1 WHERE t1 MATCH '"zm zf"'
! 302: } {33 53 75 88 101}
! 303: do_select_test 2.3 {
! 304: SELECT rowid FROM t1 WHERE t1 MATCH '"zm aayxpmve"'
! 305: } {48 65 84}
! 306: do_select_test 2.4 {
! 307: SELECT rowid FROM t1 WHERE t1 MATCH '"aayxpmve zm"'
! 308: } {11 37 84}
! 309: do_select_test 2.5 {
! 310: SELECT rowid FROM t1 WHERE t1 MATCH '"jk azavwm"'
! 311: } {16 53}
! 312: do_select_test 2.6 {
! 313: SELECT rowid FROM t1 WHERE t1 MATCH '"xh jk jk"'
! 314: } {18}
! 315: do_select_test 2.7 {
! 316: SELECT rowid FROM t1 WHERE t1 MATCH '"zm jk vgsld"'
! 317: } {13 17}
! 318: do_select_test 2.8 {
! 319: SELECT rowid FROM t1 WHERE t1 MATCH '"zm jk vgsld lkjlkjlkj"'
! 320: } {}
! 321:
! 322: do_select_test 3.1 {
! 323: SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH '"zm agmckuiu"'
! 324: } {
! 325: {zm [zm] [agmckuiu] uhzq nsab jk rrkx duszemmzl hyq jk}
! 326: {jk [zm] [agmckuiu] urvysbnykk jk jk zm zm jk jk}
! 327: {[zm] [agmckuiu] zexh fibokdry jk uhzq bu tugflixoex xnxhf sk}
! 328: {zm zf uenvbm jk azavwm zm [zm] [agmckuiu] zm jk}
! 329: }
! 330:
! 331: do_select_test 3.2 {
! 332: SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH 'xnxhf jk'
! 333: } {
! 334: {[xnxhf] [jk] [jk] agmckuiu duszemmzl [jk] zm zm [jk] vgsld}
! 335: {[jk] [xnxhf] igju [jk] xh [jk] nvfasfh zm js [jk]}
! 336: {[jk] jcpiwj zm [xnxhf] zm mjpavjuhw mj drir pa pvjrjlas}
! 337: {gazrt [jk] ephknonq myjp uenvbm wuvajhwqz [jk] zm [xnxhf] nvfasfh}
! 338: {zm aayxpmve csjqxhgj [xnxhf] xr [jk] aayxpmve [xnxhf] zm zm}
! 339: {zm agmckuiu zexh fibokdry [jk] uhzq bu tugflixoex [xnxhf] sk}
! 340: {lwa hi [xnxhf] qdyerbws zk njtc [jk] uhzq zm [jk]}
! 341: {zm azavwm igju qzzqdxq [jk] [xnxhf] abthnzcv [jk] nvfasfh zm}
! 342: }
! 343:
! 344: do_select_test 4.1 {
! 345: SELECT offsets(t1) FROM t1 WHERE t1 MATCH '"jk uenvbm"'
! 346: } {
! 347: {0 0 10 2 0 1 13 6} {0 0 26 2 0 1 29 6}
! 348: }
! 349:
! 350: do_select_test 4.2 {
! 351: SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'duszemmzl jk fibokdry'
! 352: } {
! 353: {0 2 3 8 0 1 36 2 0 0 58 9}
! 354: {0 0 0 9 0 1 13 2 0 1 16 2 0 2 19 8 0 1 53 2}
! 355: {0 1 4 2 0 0 20 9 0 1 30 2 0 1 33 2 0 2 48 8}
! 356: {0 1 17 2 0 1 20 2 0 1 26 2 0 0 29 9 0 2 39 8}
! 357: }
! 358:
! 359: do_select_test 4.3 {
! 360: SELECT offsets(t1) FROM t1
! 361: WHERE t1 MATCH 'vgsld (hrlipdm OR (aapmve NEAR duszemmzl))'
! 362: } {{0 0 0 5 0 1 15 7 0 0 36 5}}
! 363:
! 364: # The following block of tests runs normally with FTS3 or FTS4 without the
! 365: # long doclists zeroed. And with OOM-injection for FTS4 with long doclists
! 366: # zeroed. Change this by messing with the [set dmt_modes] commands above.
! 367: #
! 368: foreach DO_MALLOC_TEST $dmt_modes {
! 369:
! 370: # Phrase search.
! 371: #
! 372: do_select_test 5.$DO_MALLOC_TEST.1 {
! 373: SELECT rowid FROM t1 WHERE t1 MATCH '"jk mjpavjuhw"'
! 374: } {8 15 36 64 67 72}
! 375:
! 376: # Multiple tokens search.
! 377: do_select_test 5.$DO_MALLOC_TEST.2 {
! 378: SELECT rowid FROM t1 WHERE t1 MATCH 'duszemmzl zm'
! 379: } {3 5 8 10 12 13 18 20 23 37 43 55 60 65 67 72 74 81 94 96 97}
! 380:
! 381: # snippet() function with phrase.
! 382: do_select_test 5.$DO_MALLOC_TEST.3 {
! 383: SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH '"zm aayxpmve"'
! 384: } {
! 385: {[zm] [aayxpmve] csjqxhgj xnxhf xr jk aayxpmve xnxhf zm zm}
! 386: {duszemmzl zk jk jk fibokdry jseuhjnzo [zm] [aayxpmve] zk jk}
! 387: {zf jmfiqhwnjg js igju [zm] [aayxpmve] zm mbxnljomiv csjqxhgj nvfasfh}
! 388: }
! 389:
! 390: # snippet() function with multiple tokens.
! 391: do_select_test 5.$DO_MALLOC_TEST.4 {
! 392: SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH 'zm zhbrzadb'
! 393: } {
! 394: {[zm] jk [zm] [zm] [zhbrzadb] uenvbm aayxpmve urvysbnykk duszemmzl jk}
! 395: }
! 396:
! 397: # snippet() function with phrase.
! 398: do_select_test 5.$DO_MALLOC_TEST.5 {
! 399: SELECT offsets(t1) FROM t1 WHERE t1 MATCH '"zm aayxpmve"'
! 400: } {
! 401: {0 0 0 2 0 1 3 8} {0 0 38 2 0 1 41 8} {0 0 22 2 0 1 25 8}
! 402: }
! 403:
! 404: # snippet() function with multiple tokens.
! 405: do_select_test 5.$DO_MALLOC_TEST.6 {
! 406: SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'zm zhbrzadb'
! 407: } {
! 408: {0 0 0 2 0 0 6 2 0 0 9 2 0 1 12 8}
! 409: }
! 410:
! 411: set DO_MALLOC_TEST 0
! 412: }
! 413:
! 414: do_select_test 6.1 {
! 415: SELECT rowid FROM t1
! 416: WHERE t1 MATCH 'vgsld (hrlipdm OR (aayxpmve duszemmzl))'
! 417: } {10}
! 418: do_select_test 6.2.1 {
! 419: SELECT rowid FROM t1 WHERE t1 MATCH '"jk xduvfhk"'
! 420: } {8}
! 421: do_select_test 6.2.2 {
! 422: SELECT rowid FROM t1 WHERE t1 MATCH '"zm azavwm"'
! 423: } {15 26 92 96}
! 424: if {$fts3_simple_deferred_tokens_only==0} {
! 425: do_select_test 6.2.3 {
! 426: SELECT rowid FROM t1 WHERE t1 MATCH '"jk xduvfhk" OR "zm azavwm"'
! 427: } {8 15 26 92 96}
! 428: }
! 429:
! 430: if {$tn>1} {
! 431: # These tests will not work with $tn==1, as in this case table t1 is
! 432: # created using FTS3. The ^ syntax is only available with FTS4 tables.
! 433: #
! 434: do_select_test 7.1 {
! 435: SELECT rowid FROM t1 WHERE t1 MATCH '^zm mjpavjuhw'
! 436: } {56 62}
! 437: do_select_test 7.2 {
! 438: SELECT rowid FROM t1 WHERE t1 MATCH '^azavwm zm'
! 439: } {43}
! 440: }
! 441: }
! 442:
! 443: set testprefix fts3defer
! 444:
! 445: do_execsql_test 3.1 {
! 446: CREATE VIRTUAL TABLE x1 USING fts4(a, b);
! 447: INSERT INTO x1 VALUES('a b c', 'd e f');
! 448: INSERT INTO x1 SELECT * FROM x1;
! 449: INSERT INTO x1 SELECT * FROM x1;
! 450: INSERT INTO x1 SELECT * FROM x1;
! 451: INSERT INTO x1 SELECT * FROM x1;
! 452: }
! 453: do_execsql_test 3.2 "
! 454: INSERT INTO x1 VALUES(
! 455: '[string repeat {d } 3000]', '[string repeat {f } 30000]'
! 456: );
! 457: INSERT INTO x1(x1) VALUES('optimize');
! 458: "
! 459:
! 460: do_execsql_test 3.3 {
! 461: SELECT count(*) FROM x1 WHERE x1 MATCH '"d e f"'
! 462: } {16}
! 463:
! 464: # At one point the following was causing a floating-point exception.
! 465: #
! 466: do_execsql_test 4.1 {
! 467: CREATE VIRTUAL TABLE x2 USING FTS4(x);
! 468: BEGIN;
! 469: INSERT INTO x2 VALUES('m m m m m m m m m m m m m m m m m m m m m m m m m m');
! 470: INSERT INTO x2 SELECT * FROM x2;
! 471: INSERT INTO x2 SELECT * FROM x2;
! 472: INSERT INTO x2 SELECT * FROM x2;
! 473: INSERT INTO x2 SELECT * FROM x2;
! 474: INSERT INTO x2 SELECT * FROM x2;
! 475: INSERT INTO x2 SELECT * FROM x2;
! 476: INSERT INTO x2 SELECT * FROM x2;
! 477: INSERT INTO x2 SELECT * FROM x2;
! 478: INSERT INTO x2 SELECT * FROM x2;
! 479: INSERT INTO x2 SELECT * FROM x2;
! 480: INSERT INTO x2 SELECT * FROM x2;
! 481: INSERT INTO x2 SELECT * FROM x2;
! 482: INSERT INTO x2 SELECT * FROM x2;
! 483: INSERT INTO x2 SELECT * FROM x2;
! 484: INSERT INTO x2 SELECT * FROM x2;
! 485: INSERT INTO x2 VALUES('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 m');
! 486: COMMIT;
! 487: }
! 488: do_execsql_test 4.2 {
! 489: SELECT * FROM x2 WHERE x2 MATCH 'a b c d e f g h i j k l m n o p q r s';
! 490: } {{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 m}}
! 491:
! 492:
! 493: finish_test
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>