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