Annotation of embedaddon/sqlite3/test/fts3defer2.test, revision 1.1
1.1 ! misho 1: # 2010 October 23
! 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:
! 13: set testdir [file dirname $argv0]
! 14: source $testdir/tester.tcl
! 15: source $testdir/malloc_common.tcl
! 16: ifcapable !fts3 { finish_test ; return }
! 17:
! 18: set testprefix fts3defer2
! 19:
! 20: proc mit {blob} {
! 21: set scan(littleEndian) i*
! 22: set scan(bigEndian) I*
! 23: binary scan $blob $scan($::tcl_platform(byteOrder)) r
! 24: return $r
! 25: }
! 26: db func mit mit
! 27:
! 28: #-----------------------------------------------------------------------------
! 29: # This block of tests - fts3defer2-1.* - test the interaction of deferred NEAR
! 30: # expressions and the snippet, offsets and matchinfo functions.
! 31: #
! 32: do_execsql_test 1.1.1 {
! 33: CREATE VIRTUAL TABLE t1 USING fts4;
! 34: }
! 35: do_execsql_test 1.1.2 "INSERT INTO t1 VALUES('[string repeat {a } 20000]')"
! 36: do_execsql_test 1.1.3 "INSERT INTO t1 VALUES('[string repeat {z } 20000]')"
! 37: do_execsql_test 1.1.4 {
! 38: INSERT INTO t1 VALUES('a b c d e f a x y');
! 39: INSERT INTO t1 VALUES('');
! 40: INSERT INTO t1 VALUES('');
! 41: INSERT INTO t1 VALUES('');
! 42: INSERT INTO t1 VALUES('');
! 43: INSERT INTO t1 VALUES('');
! 44: INSERT INTO t1(t1) VALUES('optimize');
! 45: }
! 46: do_execsql_test 1.1.4 {
! 47: SELECT count(*) FROM t1_segments WHERE length(block)>10000;
! 48: UPDATE t1_segments SET block = zeroblob(length(block)) WHERE length(block)>10000;
! 49: } {2}
! 50:
! 51: do_execsql_test 1.2.0 {
! 52: SELECT content FROM t1 WHERE t1 MATCH 'f (e a)';
! 53: } {{a b c d e f a x y}}
! 54:
! 55: do_execsql_test 1.2.1 {
! 56: SELECT content FROM t1 WHERE t1 MATCH 'f (e NEAR/2 a)';
! 57: } {{a b c d e f a x y}}
! 58:
! 59: do_execsql_test 1.2.2 {
! 60: SELECT snippet(t1, '[', ']'), offsets(t1), mit(matchinfo(t1, 'pcxnal'))
! 61: FROM t1 WHERE t1 MATCH 'f (e NEAR/2 a)';
! 62: } [list \
! 63: {a b c d [e] [f] [a] x y} \
! 64: {0 1 8 1 0 0 10 1 0 2 12 1} \
! 65: [list 3 1 1 1 1 1 1 1 1 1 1 8 5001 9]
! 66: ]
! 67:
! 68: do_execsql_test 1.2.3 {
! 69: SELECT snippet(t1, '[', ']'), offsets(t1), mit(matchinfo(t1, 'pcxnal'))
! 70: FROM t1 WHERE t1 MATCH 'f (e NEAR/3 a)';
! 71: } [list \
! 72: {[a] b c d [e] [f] [a] x y} \
! 73: {0 2 0 1 0 1 8 1 0 0 10 1 0 2 12 1} \
! 74: [list 3 1 1 1 1 1 1 1 2 2 1 8 5001 9]
! 75: ]
! 76:
! 77: do_execsql_test 1.3.1 { DROP TABLE t1 }
! 78:
! 79: #-----------------------------------------------------------------------------
! 80: # Test cases fts3defer2-2.* focus specifically on the matchinfo function.
! 81: #
! 82: do_execsql_test 2.1.1 "CREATE VIRTUAL TABLE t2 USING fts4"
! 83: do_execsql_test 2.1.2 "INSERT INTO t2 VALUES('[string repeat {a } 10000]')"
! 84: do_execsql_test 2.1.3 "INSERT INTO t2 VALUES('b [string repeat {z } 10000]')"
! 85: do_execsql_test 2.1.4 [string repeat "INSERT INTO t2 VALUES('x');" 50]
! 86: do_execsql_test 2.1.5 {
! 87: INSERT INTO t2 VALUES('a b c d e f g z');
! 88: INSERT INTO t2 VALUES('a b c d e f g');
! 89: }
! 90: foreach {tn sql} {
! 91: 1 {}
! 92: 2 { INSERT INTO t2(t2) VALUES('optimize') }
! 93: 3 { UPDATE t2_segments SET block = zeroblob(length(block))
! 94: WHERE length(block)>10000;
! 95: }
! 96: } {
! 97: execsql $sql
! 98:
! 99: do_execsql_test 2.2.$tn.1 {
! 100: SELECT mit(matchinfo(t2, 'pcxnal')) FROM t2 WHERE t2 MATCH 'a b';
! 101: } [list \
! 102: [list 2 1 1 54 54 1 3 3 54 372 8] \
! 103: [list 2 1 1 54 54 1 3 3 54 372 7] \
! 104: ]
! 105:
! 106: do_execsql_test 2.2.$tn.2 {
! 107: SELECT mit(matchinfo(t2, 'x')) FROM t2 WHERE t2 MATCH 'g z';
! 108: } [list \
! 109: [list 1 2 2 1 54 54] \
! 110: ]
! 111:
! 112: set sqlite_fts3_enable_parentheses 1
! 113: do_execsql_test 2.2.$tn.3 {
! 114: SELECT mit(matchinfo(t2, 'x')) FROM t2 WHERE t2 MATCH 'g OR (g z)';
! 115: } [list \
! 116: [list 1 2 2 1 2 2 1 54 54] \
! 117: [list 1 2 2 1 2 2 0 54 54] \
! 118: ]
! 119: set sqlite_fts3_enable_parentheses 0
! 120: }
! 121:
! 122: do_execsql_test 2.3.1 {
! 123: CREATE VIRTUAL TABLE t3 USING fts4;
! 124: INSERT INTO t3 VALUES('a b c d e f');
! 125: INSERT INTO t3 VALUES('x b c d e f');
! 126: INSERT INTO t3 VALUES('d e f a b c');
! 127: INSERT INTO t3 VALUES('b c d e f');
! 128: INSERT INTO t3 VALUES('');
! 129: INSERT INTO t3 VALUES('');
! 130: INSERT INTO t3 VALUES('');
! 131: INSERT INTO t3 VALUES('');
! 132: INSERT INTO t3 VALUES('');
! 133: INSERT INTO t3 VALUES('');
! 134: }
! 135: do_execsql_test 2.3.2 "
! 136: INSERT INTO t3 VALUES('f e d c b [string repeat {a } 10000]')
! 137: "
! 138: foreach {tn sql} {
! 139: 1 {}
! 140: 2 { INSERT INTO t3(t3) VALUES('optimize') }
! 141: 3 { UPDATE t3_segments SET block = zeroblob(length(block))
! 142: WHERE length(block)>10000;
! 143: }
! 144: } {
! 145: execsql $sql
! 146: do_execsql_test 2.4.$tn {
! 147: SELECT docid, mit(matchinfo(t3, 'pcxnal')) FROM t3 WHERE t3 MATCH '"a b c"';
! 148: } {1 {1 1 1 4 4 11 912 6} 3 {1 1 1 4 4 11 912 6}}
! 149: }
! 150:
! 151:
! 152: finish_test
! 153:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>