SQLite

Check-in [b53c0c41f9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add a few more tests for the fts4 notindexed option.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | fts4-notindexed
Files: files | file ages | folders
SHA1: b53c0c41f97c7ddaeea61f0e6035d1c4747db3f7
User & Date: dan 2013-06-21 18:18:23.327
Context
2013-06-21
18:29
Merge the fts4-notindexed branch with the trunk. (check-in: 361084e1eb user: dan tags: trunk)
18:18
Add a few more tests for the fts4 notindexed option. (Closed-Leaf check-in: b53c0c41f9 user: dan tags: fts4-notindexed)
17:30
Add the "notindexed" option to fts4. (check-in: 8ff2b8f594 user: dan tags: fts4-notindexed)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/fts3malloc.test.
58
59
60
61
62
63
64



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

84
85
86
87
88
89
90
}
do_error_test fts3_malloc-1.5 {
  CREATE VIRTUAL TABLE ft5 USING fts3(a, b, tokenize unknown)
} {unknown tokenizer: unknown}
do_write_test fts3_malloc-1.6 sqlite_master {
  CREATE VIRTUAL TABLE ft6 USING fts3(a, b, tokenize porter)
}




# Test the xConnect/xDisconnect methods:
#db eval { ATTACH 'test2.db' AS aux }
#do_write_test fts3_malloc-1.6 aux.sqlite_master {
#  CREATE VIRTUAL TABLE aux.ft7 USING fts3(a, b, c);
#}
#do_write_test fts3_malloc-1.6 aux.sqlite_master {
#  CREATE VIRTUAL TABLE aux.ft7 USING fts3(a, b, c);
#}



do_test fts3_malloc-2.0 {
  execsql { 
    DROP TABLE ft1;
    DROP TABLE ft2;
    DROP TABLE ft3;
    DROP TABLE ft4;
    DROP TABLE ft6;

  }
  execsql { CREATE VIRTUAL TABLE ft USING fts3(a, b) }
  for {set ii 1} {$ii < 32} {incr ii} {
    set a [list]
    set b [list]
    if {$ii & 0x01} {lappend a one   ; lappend b neung}
    if {$ii & 0x02} {lappend a two   ; lappend b song }







>
>
>



















>







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
}
do_error_test fts3_malloc-1.5 {
  CREATE VIRTUAL TABLE ft5 USING fts3(a, b, tokenize unknown)
} {unknown tokenizer: unknown}
do_write_test fts3_malloc-1.6 sqlite_master {
  CREATE VIRTUAL TABLE ft6 USING fts3(a, b, tokenize porter)
}
do_write_test fts3_malloc-1.7 sqlite_master {
  CREATE VIRTUAL TABLE ft7 USING fts4(a, b, notindexed=b)
}

# Test the xConnect/xDisconnect methods:
#db eval { ATTACH 'test2.db' AS aux }
#do_write_test fts3_malloc-1.6 aux.sqlite_master {
#  CREATE VIRTUAL TABLE aux.ft7 USING fts3(a, b, c);
#}
#do_write_test fts3_malloc-1.6 aux.sqlite_master {
#  CREATE VIRTUAL TABLE aux.ft7 USING fts3(a, b, c);
#}



do_test fts3_malloc-2.0 {
  execsql { 
    DROP TABLE ft1;
    DROP TABLE ft2;
    DROP TABLE ft3;
    DROP TABLE ft4;
    DROP TABLE ft6;
    DROP TABLE ft7;
  }
  execsql { CREATE VIRTUAL TABLE ft USING fts3(a, b) }
  for {set ii 1} {$ii < 32} {incr ii} {
    set a [list]
    set b [list]
    if {$ii & 0x01} {lappend a one   ; lappend b neung}
    if {$ii & 0x02} {lappend a two   ; lappend b song }
Changes to test/fts4noti.test.
35
36
37
38
39
40
41


42
43
44
45
46
47
48
49
50
51
52

53
54



55
56

57




58
59
60


61
62
63
64
65
66
67







68
69
70
71
72
73
74
75
76
77
78
79
80

81

82
83
84
85
86
87
88
  3 "(a, b, notindexed=a, notindexed=a)"                     {0 {}}
  4 "(notindexed=a, a, b)"                                   {0 {}}
  5 "(notindexed=a, notindexed=b, notindexed=c, a, b, c, d)" {0 {}}
  6 "(notindexed=a, notindexed=B, notindexed=c, a, b, c, d)" {0 {}}
  7 "(notindexed=a, notindexed=b, notindexed=c, a, B, c, d)" {0 {}}
  8 "(notindexed=d, content=cc)" {1 {no such column: d}}
  9 "(notindexed=a, content=cc)" {0 {}}


} {
  do_catchsql_test 1.$tn "CREATE VIRTUAL TABLE t1 USING fts4 $arg" $res
  if {[lindex $res 0]==0} { execsql "DROP TABLE t1" }
}

do_execsql_test 1.x { SELECT name FROM sqlite_master } {cc}


#-------------------------------------------------------------------------
# Test that notindexed columns are not indexed.
#

do_execsql_test 2.1 {
  CREATE VIRTUAL TABLE t1 USING fts4(a, b, c, notindexed=b);



  INSERT INTO t1 VALUES('one two', 'three four', 'five six');
  INSERT INTO t1 VALUES('three four', 'five six', 'one two');

}




do_execsql_test 2.2 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
do_execsql_test 2.3 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
do_execsql_test 2.4 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}



do_execsql_test 2.5 { INSERT INTO t1(t1) VALUES('optimize') }

do_execsql_test 2.6 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
do_execsql_test 2.7 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
do_execsql_test 2.8 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}








do_execsql_test 2.9 { INSERT INTO t1(t1) VALUES('rebuild') }

do_execsql_test 2.10 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
do_execsql_test 2.11 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
do_execsql_test 2.12 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}

do_execsql_test 2.13 { 
  SELECT * FROM t1 WHERE docid=1
} {{one two} {three four} {five six}}
do_execsql_test 2.14 { 
  SELECT * FROM t1 WHERE docid=2
} {{three four} {five six} {one two}}


do_execsql_test 2.x { DROP TABLE t1 }


#-------------------------------------------------------------------------
# Test that notindexed columns are not scanned for deferred tokens.
#

do_execsql_test 3.1 {
  CREATE VIRTUAL TABLE t2 USING fts4(x, y, notindexed=x);







>
>











>
|
|
>
>
>
|
|
>
|
>
>
>
>
|
|
|
>
>
|
<

|
|
|

>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|
>







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
  3 "(a, b, notindexed=a, notindexed=a)"                     {0 {}}
  4 "(notindexed=a, a, b)"                                   {0 {}}
  5 "(notindexed=a, notindexed=b, notindexed=c, a, b, c, d)" {0 {}}
  6 "(notindexed=a, notindexed=B, notindexed=c, a, b, c, d)" {0 {}}
  7 "(notindexed=a, notindexed=b, notindexed=c, a, B, c, d)" {0 {}}
  8 "(notindexed=d, content=cc)" {1 {no such column: d}}
  9 "(notindexed=a, content=cc)" {0 {}}
  10 "(notindexed=a, notindexed=b, a)" {1 {no such column: b}}
  11 "(notindexed=a, notindexed=b, b)" {1 {no such column: a}}
} {
  do_catchsql_test 1.$tn "CREATE VIRTUAL TABLE t1 USING fts4 $arg" $res
  if {[lindex $res 0]==0} { execsql "DROP TABLE t1" }
}

do_execsql_test 1.x { SELECT name FROM sqlite_master } {cc}


#-------------------------------------------------------------------------
# Test that notindexed columns are not indexed.
#
foreach {tn schema} {
  1 { 
    CREATE VIRTUAL TABLE t1 USING fts4(a, b, c, notindexed=b); 
  }
  2 { 
    CREATE TABLE c1(a, b, c);
    INSERT INTO c1 VALUES('one two', 'three four', 'five six');
    INSERT INTO c1 VALUES('three four', 'five six', 'one two');
    CREATE VIRTUAL TABLE t1 USING fts4(content=c1, notindexed=b); 
  }
  3 { 
    CREATE VIRTUAL TABLE t1 USING fts4(content="", a, b, c, notindexed=b); 
  }
} {
  execsql $schema

  do_execsql_test 2.$tn.1 {
    INSERT INTO t1(docid,a,b,c) VALUES(1, 'one two', 'three four', 'five six');
    INSERT INTO t1(docid,a,b,c) VALUES(2, 'three four', 'five six', 'one two');
  }


  do_execsql_test 2.$tn.2 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
  do_execsql_test 2.$tn.3 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
  do_execsql_test 2.$tn.4 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}

  do_execsql_test 2.$tn.5 { INSERT INTO t1(t1) VALUES('optimize') }

  do_execsql_test 2.$tn.6 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
  do_execsql_test 2.$tn.7 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
  do_execsql_test 2.$tn.8 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}

  if {$tn!=3} {
    do_execsql_test 2.$tn.9 { INSERT INTO t1(t1) VALUES('rebuild') }
  
    do_execsql_test 2.$tn.10 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
    do_execsql_test 2.$tn.11 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
    do_execsql_test 2.$tn.12 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}
  
    do_execsql_test 2.$tn.13 { 
      SELECT a,b,c FROM t1 WHERE docid=1
    } {{one two} {three four} {five six}}
    do_execsql_test 2.$tn.14 { 
      SELECT a,b,c FROM t1 WHERE docid=2
    } {{three four} {five six} {one two}}
  }

  do_execsql_test 2.x { DROP TABLE t1 }
}

#-------------------------------------------------------------------------
# Test that notindexed columns are not scanned for deferred tokens.
#

do_execsql_test 3.1 {
  CREATE VIRTUAL TABLE t2 USING fts4(x, y, notindexed=x);
101
102
103
104
105
106
107
108

109


110

































111



  }
} {}

do_execsql_test 3.3 { SELECT x FROM t2 WHERE t2 MATCH '2' } {}
do_execsql_test 3.4 { SELECT x FROM t2 WHERE t2 MATCH '1' } {2 3 4 5 6}
do_execsql_test 3.5 { SELECT x FROM t2 WHERE t2 MATCH 'x' } {1 2}
do_execsql_test 3.6 { SELECT x FROM t2 WHERE t2 MATCH 'x 1' } {2}
  






































finish_test










|
>
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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
  }
} {}

do_execsql_test 3.3 { SELECT x FROM t2 WHERE t2 MATCH '2' } {}
do_execsql_test 3.4 { SELECT x FROM t2 WHERE t2 MATCH '1' } {2 3 4 5 6}
do_execsql_test 3.5 { SELECT x FROM t2 WHERE t2 MATCH 'x' } {1 2}
do_execsql_test 3.6 { SELECT x FROM t2 WHERE t2 MATCH 'x 1' } {2}

do_execsql_test 3.x { DROP TABLE t2 }
  
#-------------------------------------------------------------------------
# Test that the types of notindexed columns are not modified.
#
do_execsql_test 4.1 {
  CREATE VIRTUAL TABLE t2 USING fts4(poi, addr, notindexed=poi);
  INSERT INTO t2 VALUES(114, 'x x x');
  INSERT INTO t2 VALUES(X'1234', 'y y y');
  INSERT INTO t2 VALUES(NULL, 'z z z');
  INSERT INTO t2 VALUES(113.2, 'w w w');
  INSERT INTO t2 VALUES('poi', 'v v v');
}
do_execsql_test 4.2 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'x' } {integer}
do_execsql_test 4.3 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'y' } {blob}
do_execsql_test 4.4 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'z' } {null}
do_execsql_test 4.5 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'w' } {real}
do_execsql_test 4.6 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'v' } {text}

do_execsql_test 4.x { DROP TABLE t2 }

#-------------------------------------------------------------------------
# Test that multiple notindexed options on a single table work as expected.
#
do_execsql_test 5.1 {
  CREATE VIRTUAL TABLE t2 USING fts4(
      notindexed="three", one, two, three, notindexed="one",
  );
  INSERT INTO t2 VALUES('a', 'b', 'c');
  INSERT INTO t2 VALUES('c', 'a', 'b');
  INSERT INTO t2 VALUES('b', 'c', 'a');
}
do_execsql_test 5.2 { SELECT docid FROM t2 WHERE t2 MATCH 'a' } {2}
do_execsql_test 5.3 { SELECT docid FROM t2 WHERE t2 MATCH 'b' } {1}
do_execsql_test 5.4 { SELECT docid FROM t2 WHERE t2 MATCH 'c' } {3}

do_execsql_test 5.x { DROP TABLE t2 }

finish_test