Annotation of embedaddon/sqlite3/test/fts3aa.test, revision 1.1
1.1 ! misho 1: # 2006 September 9
! 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. The
! 12: # focus of this script is testing the FTS3 module.
! 13: #
! 14: # $Id: fts3aa.test,v 1.1 2007/08/20 17:38:42 shess Exp $
! 15: #
! 16:
! 17: set testdir [file dirname $argv0]
! 18: source $testdir/tester.tcl
! 19:
! 20: # If SQLITE_ENABLE_FTS3 is defined, omit this file.
! 21: ifcapable !fts3 {
! 22: finish_test
! 23: return
! 24: }
! 25:
! 26: # Construct a full-text search table containing five keywords:
! 27: # one, two, three, four, and five, in various combinations. The
! 28: # rowid for each will be a bitmask for the elements it contains.
! 29: #
! 30: db eval {
! 31: CREATE VIRTUAL TABLE t1 USING fts3(content);
! 32: INSERT INTO t1(content) VALUES('one');
! 33: INSERT INTO t1(content) VALUES('two');
! 34: INSERT INTO t1(content) VALUES('one two');
! 35: INSERT INTO t1(content) VALUES('three');
! 36: INSERT INTO t1(content) VALUES('one three');
! 37: INSERT INTO t1(content) VALUES('two three');
! 38: INSERT INTO t1(content) VALUES('one two three');
! 39: INSERT INTO t1(content) VALUES('four');
! 40: INSERT INTO t1(content) VALUES('one four');
! 41: INSERT INTO t1(content) VALUES('two four');
! 42: INSERT INTO t1(content) VALUES('one two four');
! 43: INSERT INTO t1(content) VALUES('three four');
! 44: INSERT INTO t1(content) VALUES('one three four');
! 45: INSERT INTO t1(content) VALUES('two three four');
! 46: INSERT INTO t1(content) VALUES('one two three four');
! 47: INSERT INTO t1(content) VALUES('five');
! 48: INSERT INTO t1(content) VALUES('one five');
! 49: INSERT INTO t1(content) VALUES('two five');
! 50: INSERT INTO t1(content) VALUES('one two five');
! 51: INSERT INTO t1(content) VALUES('three five');
! 52: INSERT INTO t1(content) VALUES('one three five');
! 53: INSERT INTO t1(content) VALUES('two three five');
! 54: INSERT INTO t1(content) VALUES('one two three five');
! 55: INSERT INTO t1(content) VALUES('four five');
! 56: INSERT INTO t1(content) VALUES('one four five');
! 57: INSERT INTO t1(content) VALUES('two four five');
! 58: INSERT INTO t1(content) VALUES('one two four five');
! 59: INSERT INTO t1(content) VALUES('three four five');
! 60: INSERT INTO t1(content) VALUES('one three four five');
! 61: INSERT INTO t1(content) VALUES('two three four five');
! 62: INSERT INTO t1(content) VALUES('one two three four five');
! 63: }
! 64:
! 65: do_test fts3aa-1.1 {
! 66: execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
! 67: } {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
! 68: do_test fts3aa-1.2 {
! 69: execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two'}
! 70: } {3 7 11 15 19 23 27 31}
! 71: do_test fts3aa-1.3 {
! 72: execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one'}
! 73: } {3 7 11 15 19 23 27 31}
! 74: do_test fts3aa-1.4 {
! 75: execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two three'}
! 76: } {7 15 23 31}
! 77: do_test fts3aa-1.5 {
! 78: execsql {SELECT rowid FROM t1 WHERE content MATCH 'one three two'}
! 79: } {7 15 23 31}
! 80: do_test fts3aa-1.6 {
! 81: execsql {SELECT rowid FROM t1 WHERE content MATCH 'two three one'}
! 82: } {7 15 23 31}
! 83: do_test fts3aa-1.7 {
! 84: execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one three'}
! 85: } {7 15 23 31}
! 86: do_test fts3aa-1.8 {
! 87: execsql {SELECT rowid FROM t1 WHERE content MATCH 'three one two'}
! 88: } {7 15 23 31}
! 89: do_test fts3aa-1.9 {
! 90: execsql {SELECT rowid FROM t1 WHERE content MATCH 'three two one'}
! 91: } {7 15 23 31}
! 92: do_test fts3aa-1.10 {
! 93: execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two THREE'}
! 94: } {7 15 23 31}
! 95: do_test fts3aa-1.11 {
! 96: execsql {SELECT rowid FROM t1 WHERE content MATCH ' ONE Two three '}
! 97: } {7 15 23 31}
! 98:
! 99: do_test fts3aa-2.1 {
! 100: execsql {SELECT rowid FROM t1 WHERE content MATCH '"one"'}
! 101: } {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
! 102: do_test fts3aa-2.2 {
! 103: execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two"'}
! 104: } {3 7 11 15 19 23 27 31}
! 105: do_test fts3aa-2.3 {
! 106: execsql {SELECT rowid FROM t1 WHERE content MATCH '"two one"'}
! 107: } {}
! 108: do_test fts3aa-2.4 {
! 109: execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three"'}
! 110: } {7 15 23 31}
! 111: do_test fts3aa-2.5 {
! 112: execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two"'}
! 113: } {}
! 114: do_test fts3aa-2.6 {
! 115: execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two three four"'}
! 116: } {15 31}
! 117: do_test fts3aa-2.7 {
! 118: execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three two four"'}
! 119: } {}
! 120: do_test fts3aa-2.8 {
! 121: execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three five"'}
! 122: } {21}
! 123: do_test fts3aa-2.9 {
! 124: execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" five'}
! 125: } {21 29}
! 126: do_test fts3aa-2.10 {
! 127: execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three"'}
! 128: } {21 29}
! 129: do_test fts3aa-2.11 {
! 130: execsql {SELECT rowid FROM t1 WHERE content MATCH 'five "one three" four'}
! 131: } {29}
! 132: do_test fts3aa-2.12 {
! 133: execsql {SELECT rowid FROM t1 WHERE content MATCH 'five four "one three"'}
! 134: } {29}
! 135: do_test fts3aa-2.13 {
! 136: execsql {SELECT rowid FROM t1 WHERE content MATCH '"one three" four five'}
! 137: } {29}
! 138:
! 139: do_test fts3aa-3.1 {
! 140: execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
! 141: } {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}
! 142: do_test fts3aa-3.2 {
! 143: execsql {SELECT rowid FROM t1 WHERE content MATCH 'one -two'}
! 144: } {1 5 9 13 17 21 25 29}
! 145: do_test fts3aa-3.3 {
! 146: execsql {SELECT rowid FROM t1 WHERE content MATCH '-two one'}
! 147: } {1 5 9 13 17 21 25 29}
! 148:
! 149: breakpoint
! 150: do_test fts3aa-4.1 {
! 151: execsql {SELECT rowid FROM t1 WHERE content MATCH 'one OR two'}
! 152: } {1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 21 22 23 25 26 27 29 30 31}
! 153: do_test fts3aa-4.2 {
! 154: execsql {SELECT rowid FROM t1 WHERE content MATCH '"one two" OR three'}
! 155: } {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
! 156: do_test fts3aa-4.3 {
! 157: execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR "one two"'}
! 158: } {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
! 159: do_test fts3aa-4.4 {
! 160: execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three'}
! 161: } {3 5 7 11 13 15 19 21 23 27 29 31}
! 162: do_test fts3aa-4.5 {
! 163: execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR two one'}
! 164: } {3 5 7 11 13 15 19 21 23 27 29 31}
! 165: do_test fts3aa-4.6 {
! 166: execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three OR four'}
! 167: } {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
! 168: do_test fts3aa-4.7 {
! 169: execsql {SELECT rowid FROM t1 WHERE content MATCH 'two OR three OR four one'}
! 170: } {3 5 7 9 11 13 15 19 21 23 25 27 29 31}
! 171:
! 172: # Test the ability to handle NULL content
! 173: #
! 174: do_test fts3aa-5.1 {
! 175: execsql {INSERT INTO t1(content) VALUES(NULL)}
! 176: } {}
! 177: do_test fts3aa-5.2 {
! 178: set rowid [db last_insert_rowid]
! 179: execsql {SELECT content FROM t1 WHERE rowid=$rowid}
! 180: } {{}}
! 181: do_test fts3aa-5.3 {
! 182: execsql {SELECT rowid FROM t1 WHERE content MATCH NULL}
! 183: } {}
! 184:
! 185: # Test the ability to handle non-positive rowids
! 186: #
! 187: do_test fts3aa-6.0 {
! 188: execsql {INSERT INTO t1(rowid, content) VALUES(0, 'four five')}
! 189: } {}
! 190: do_test fts3aa-6.1 {
! 191: execsql {SELECT content FROM t1 WHERE rowid = 0}
! 192: } {{four five}}
! 193: do_test fts3aa-6.2 {
! 194: execsql {INSERT INTO t1(rowid, content) VALUES(-1, 'three four')}
! 195: } {}
! 196: do_test fts3aa-6.3 {
! 197: execsql {SELECT content FROM t1 WHERE rowid = -1}
! 198: } {{three four}}
! 199: do_test fts3aa-6.4 {
! 200: execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'four'}
! 201: } {-1 0 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31}
! 202:
! 203: # Test creation of FTS3 and FTS4 tables with columns that contain
! 204: # an "=" character.
! 205: #
! 206: do_execsql_test fts3aa-7.1 {
! 207: CREATE VIRTUAL TABLE t2 USING fts3(xyz=abc);
! 208: SELECT xyz FROM t2;
! 209: } {}
! 210: do_catchsql_test fts3aa-7.2 {
! 211: CREATE VIRTUAL TABLE t3 USING fts4(xyz=abc);
! 212: } {1 {unrecognized parameter: xyz=abc}}
! 213: do_catchsql_test fts3aa-7.3 {
! 214: CREATE VIRTUAL TABLE t3 USING fts4(xyz = abc);
! 215: } {1 {unrecognized parameter: xyz = abc}}
! 216:
! 217: do_execsql_test fts3aa-7.4 {
! 218: CREATE VIRTUAL TABLE t3 USING fts3(tokenize=simple, tokenize=simple);
! 219: SELECT tokenize FROM t3;
! 220: } {}
! 221: do_catchsql_test fts3aa-7.5 {
! 222: CREATE VIRTUAL TABLE t4 USING fts4(tokenize=simple, tokenize=simple);
! 223: } {1 {unrecognized parameter: tokenize=simple}}
! 224:
! 225:
! 226: finish_test
! 227:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>