1# 2012 May 11 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# This file implements regression tests for SQLite library. 12# 13# This file implements tests to verify that ticket [bdc6bbbb38] has been 14# fixed. 15# 16 17set testdir [file dirname $argv0] 18source $testdir/tester.tcl 19set testprefix tkt-bdc6bbbb38 20 21# If SQLITE_ENABLE_FTS3 is defined, omit this file. 22ifcapable !fts3 { finish_test ; return } 23set sqlite_fts3_enable_parentheses 1 24 25foreach {tn idxdir} {1 ASC 2 DESC} { 26 execsql { DROP TABLE IF EXISTS t2 } 27 28 do_execsql_test $tn.1.1 "CREATE VIRTUAL TABLE t2 USING fts4(x, order=$idxdir)" 29 do_execsql_test $tn.1.2 { INSERT INTO t2 VALUES('a b c') } 30 31 do_execsql_test $tn.1.3 { 32 SELECT offsets(t2) FROM t2 WHERE t2 MATCH 'a AND d OR b' ORDER BY docid ASC 33 } { 34 {0 0 0 1 0 2 2 1} 35 } 36 do_execsql_test $tn.1.4 { 37 SELECT snippet(t2,'[',']') FROM t2 WHERE t2 MATCH 'a AND d OR b' 38 ORDER BY docid ASC 39 } { 40 {[a] [b] c} 41 } 42 do_execsql_test $tn.1.5 { INSERT INTO t2 VALUES('a c d') } 43 do_execsql_test $tn.1.6 { 44 SELECT offsets(t2) FROM t2 WHERE t2 MATCH 'a AND d OR b' ORDER BY docid ASC 45 } { 46 {0 0 0 1 0 2 2 1} 47 {0 0 0 1 0 1 4 1} 48 } 49 do_execsql_test $tn.1.7 { 50 SELECT snippet(t2,'[',']') FROM t2 WHERE t2 MATCH 'a AND d OR b' 51 ORDER BY docid ASC 52 } { 53 {[a] [b] c} 54 {[a] c [d]} 55 } 56 57 execsql { DROP TABLE IF EXISTS t3 } 58 do_execsql_test $tn.2.1 "CREATE VIRTUAL TABLE t3 USING fts4(x, order=$idxdir)" 59 do_execsql_test $tn.2.2 { INSERT INTO t3 VALUES('a c d') } 60 do_execsql_test $tn.2.3 { 61 SELECT offsets(t3) FROM t3 WHERE t3 MATCH 'a AND d OR b' ORDER BY docid DESC 62 } { 63 {0 0 0 1 0 1 4 1} 64 } 65 do_execsql_test $tn.2.4 { 66 SELECT snippet(t3,'[',']') FROM t3 WHERE t3 MATCH 'a AND d OR b' 67 ORDER BY docid DESC 68 } { 69 {[a] c [d]} 70 } 71 do_execsql_test $tn.2.5 { 72 INSERT INTO t3 VALUES('a b c'); 73 } 74 do_execsql_test $tn.2.6 { 75 SELECT offsets(t3) FROM t3 WHERE t3 MATCH 'a AND d OR b' ORDER BY docid DESC 76 } { 77 {0 0 0 1 0 2 2 1} 78 {0 0 0 1 0 1 4 1} 79 } 80 do_execsql_test $tn.2.7 { 81 SELECT snippet(t3,'[',']') FROM t3 WHERE t3 MATCH 'a AND d OR b' 82 ORDER BY docid DESC 83 } { 84 {[a] [b] c} 85 {[a] c [d]} 86 } 87} 88 89set sqlite_fts3_enable_parentheses 0 90finish_test 91