Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add tests for the "column:term" query syntax to fts3auto.test. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
d138b0e65953c529619d64e662bdb547 |
User & Date: | dan 2011-06-20 10:46:49.908 |
Context
2011-06-20
| ||
11:15 | Fix a problem where FTS test code was not being included in the testfixture build when SQLITE_ENABLE_FTS4 was defined. (check-in: e539d08a4d user: dan tags: trunk) | |
10:46 | Add tests for the "column:term" query syntax to fts3auto.test. (check-in: d138b0e659 user: dan tags: trunk) | |
2011-06-19
| ||
21:17 | Do not run test tkt-2d1a5c67d.test in the inmemory_journal permutation since that test requires WAL mode which does not work with inmemory_journal. (check-in: 228c43c726 user: drh tags: trunk) | |
Changes
Changes to test/fts3auto.test.
︙ | ︙ | |||
144 145 146 147 148 149 150 | set scan(littleEndian) i* set scan(bigEndian) I* binary scan $blob $scan($::tcl_platform(byteOrder)) r return $r } db func mit mit | > > | > > > > > > > > > > > > | > > > > > > > > > > > > | > > > | > | | > > > | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | set scan(littleEndian) i* set scan(bigEndian) I* binary scan $blob $scan($::tcl_platform(byteOrder)) r return $r } db func mit mit proc fix_phrase_expr {cols expr colfiltervar} { upvar $colfiltervar iColFilter set out [list] foreach t $expr { if {[string match *:* $t]} { set col [lindex [split $t :] 0] set t [lindex [split $t :] 1] set iCol [lsearch $cols $col] if {$iCol<0} { error "unknown column: $col" } if {$iColFilter < 0} { set iColFilter $iCol } elseif {$iColFilter != $iCol} { set iColFilter [llength $cols] } } lappend out $t } return $out } proc fix_near_expr {cols expr colfiltervar} { upvar $colfiltervar iColFilter set iColFilter -1 set out [list] lappend out [fix_phrase_expr $cols [lindex $expr 0] iColFilter] foreach {a b} [lrange $expr 1 end] { if {[string match -nocase near $a]} { set a 10 } if {[string match -nocase near/* $a]} { set a [string range $a 5 end] } lappend out $a lappend out [fix_phrase_expr $cols $b iColFilter] } return $out } proc get_single_near_results {tbl expr deferred arrayvar nullvar} { upvar $arrayvar aMatchinfo upvar $nullvar nullentry catch {array unset aMatchinfo} set cols [list] set miss [list] db eval "PRAGMA table_info($tbl)" A { lappend cols $A(name) ; lappend miss 0 } set expr [fix_near_expr $cols $expr iColFilter] # Calculate the expected results using [fts3_near_match]. The following # loop populates the "hits" and "counts" arrays as follows: # # 1. For each document in the table that matches the NEAR expression, # hits($docid) is set to 1. The set of docids that match the expression # can therefore be found using [array names hits]. # # 2. For each column of each document in the table, counts($docid,$iCol) # is set to the -phrasecountvar output. # set res [list] catch { array unset hits } db eval "SELECT docid, * FROM $tbl" d { set iCol 0 foreach col [lrange $d(*) 1 end] { set docid $d(docid) if {$iColFilter<0 || $iCol==$iColFilter} { set hit [fts3_near_match $d($col) $expr -p counts($docid,$iCol)] if {$hit} { set hits($docid) 1 } } else { set counts($docid,$iCol) $miss } incr iCol } } set nPhrase [expr ([llength $expr]+1)/2] set nCol $iCol # This block populates the nHit and nDoc arrays. For each phrase/column |
︙ | ︙ | |||
532 533 534 535 536 537 538 | } #-------------------------------------------------------------------------- # The following test cases - fts3auto-5.* - focus on using prefix indexes. # set chunkconfig [fts3_configure_incr_load 1 1] foreach {tn create pending} { | < < > | 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | } #-------------------------------------------------------------------------- # The following test cases - fts3auto-5.* - focus on using prefix indexes. # set chunkconfig [fts3_configure_incr_load 1 1] foreach {tn create pending} { 1 "fts4(a, b)" 1 2 "fts4(a, b, order=ASC, prefix=1)" 1 3 "fts4(a, b, order=ASC, prefix=1,3)" 0 4 "fts4(a, b, order=DESC, prefix=2,4)" 0 5 "fts4(a, b, order=DESC, prefix=1)" 0 6 "fts4(a, b, order=ASC, prefix=1,3)" 0 } { execsql [subst { |
︙ | ︙ | |||
582 583 584 585 586 587 588 589 590 591 592 | do_fts3query_test 5.$tn.1.5 t1 {a*} do_fts3query_test 5.$tn.1.6 t1 {th* NEAR/5 a* NEAR/5 w*} do_fts3query_test 5.$tn.1.7 t1 {"b* th* art* fair*"} if {$pending} {execsql COMMIT} } eval fts3_configure_incr_load $chunkconfig set sqlite_fts3_enable_parentheses $sfep finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | do_fts3query_test 5.$tn.1.5 t1 {a*} do_fts3query_test 5.$tn.1.6 t1 {th* NEAR/5 a* NEAR/5 w*} do_fts3query_test 5.$tn.1.7 t1 {"b* th* art* fair*"} if {$pending} {execsql COMMIT} } eval fts3_configure_incr_load $chunkconfig foreach {tn pending create} { 1 0 "fts4(a, b, c, d)" 2 1 "fts4(a, b, c, d)" 3 0 "fts4(a, b, c, d, order=DESC)" 4 1 "fts4(a, b, c, d, order=DESC)" } { execsql [subst { DROP TABLE IF EXISTS t1; CREATE VIRTUAL TABLE t1 USING $create; }] if {$pending} { execsql BEGIN } foreach {a b c d} { "A B C" "D E F" "G H I" "J K L" "B C D" "E F G" "H I J" "K L A" "C D E" "F G H" "I J K" "L A B" "D E F" "G H I" "J K L" "A B C" "E F G" "H I J" "K L A" "B C D" "F G H" "I J K" "L A B" "C D E" } { execsql { INSERT INTO t1 VALUES($a, $b, $c, $d) } } do_fts3query_test 6.$tn.1 t1 {b:G} do_fts3query_test 6.$tn.2 t1 {b:G AND c:I} do_fts3query_test 6.$tn.3 t1 {b:G NEAR c:I} do_fts3query_test 6.$tn.4 t1 {a:C OR b:G OR c:K OR d:C} do_fts3query_test 6.$tn.5 t1 {a:G OR b:G} catchsql { COMMIT } } set sqlite_fts3_enable_parentheses $sfep finish_test |