From: dan Date: Mon, 20 Jun 2011 10:46:49 +0000 (+0000) Subject: Add tests for the "column:term" query syntax to fts3auto.test. X-Git-Tag: version-3.7.7~44 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b727d6794450ed4ce6fe18d3b34f6d3627d7ca49;p=thirdparty%2Fsqlite.git Add tests for the "column:term" query syntax to fts3auto.test. FossilOrigin-Name: d138b0e65953c529619d64e662bdb5478d7d79c3 --- diff --git a/manifest b/manifest index 1d5ddc2579..c252cb3b22 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\srun\stest\stkt-2d1a5c67d.test\sin\sthe\sinmemory_journal\spermutation\nsince\sthat\stest\srequires\sWAL\smode\swhich\sdoes\snot\swork\swith\sinmemory_journal. -D 2011-06-19T21:17:35.711 +C Add\stests\sfor\sthe\s"column:term"\squery\ssyntax\sto\sfts3auto.test. +D 2011-06-20T10:46:49.908 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -456,7 +456,7 @@ F test/fts3am.test 218aa6ba0dfc50c7c16b2022aac5c6be593d08d8 F test/fts3an.test a49ccadc07a2f7d646ec1b81bc09da2d85a85b18 F test/fts3ao.test b83f99f70e9eec85f27d75801a974b3f820e01f9 F test/fts3atoken.test 402ef2f7c2fb4b3d4fa0587df6441c1447e799b3 -F test/fts3auto.test b0d360b331ff68bd9fb497a6192d23dc0783637c +F test/fts3auto.test f1cb0a55130897013ca5850dbee2945c2908a45a F test/fts3aux1.test 0b02743955d56fc0d4d66236a26177bd1b726de0 F test/fts3b.test e93bbb653e52afde110ad53bbd793f14fe7a8984 F test/fts3c.test fc723a9cf10b397fdfc2b32e73c53c8b1ec02958 @@ -946,7 +946,7 @@ F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P 54492212af6c4be5d5546b370398ef771c16f430 -R dd08c420fef14e9aaef20168e7aef1b4 -U drh -Z ad3555b405ce175e6eb80427a259c9c5 +P 228c43c726e637daadc0c9b5a8b24243f239b1cf +R 7eddd2dd67b3d52dc8c6eb17ca4f485e +U dan +Z deeda911f2417117940e630ba55dce44 diff --git a/manifest.uuid b/manifest.uuid index 568bed9d24..9becdd1851 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -228c43c726e637daadc0c9b5a8b24243f239b1cf \ No newline at end of file +d138b0e65953c529619d64e662bdb5478d7d79c3 \ No newline at end of file diff --git a/test/fts3auto.test b/test/fts3auto.test index ed96129a70..484fd6ace2 100644 --- a/test/fts3auto.test +++ b/test/fts3auto.test @@ -148,14 +148,40 @@ proc mit {blob} { } db func mit mit -proc fix_near_expr {expr} { +proc fix_phrase_expr {cols expr colfiltervar} { + upvar $colfiltervar iColFilter + set out [list] - lappend out [lindex $expr 0] + 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 $b + lappend out [fix_phrase_expr $cols $b iColFilter] } return $out } @@ -165,7 +191,10 @@ proc get_single_near_results {tbl expr deferred arrayvar nullvar} { upvar $nullvar nullentry catch {array unset aMatchinfo} - set expr [fix_near_expr $expr] + 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: @@ -183,8 +212,12 @@ proc get_single_near_results {tbl expr deferred arrayvar nullvar} { set iCol 0 foreach col [lrange $d(*) 1 end] { set docid $d(docid) - set hit [fts3_near_match $d($col) $expr -p counts($docid,$iCol)] - if {$hit} { set hits($docid) 1 } + 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 } } @@ -536,9 +569,8 @@ foreach {tn create} { # set chunkconfig [fts3_configure_incr_load 1 1] foreach {tn create pending} { - 2 "fts4(a, b, order=ASC, prefix=1)" 1 - 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 @@ -587,6 +619,40 @@ foreach {tn create pending} { } 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