Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a problem with prefix queries and the AND operator. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | fts5 |
Files: | files | file ages | folders |
SHA1: |
38b3c65e3ee95eb7afadb76e0110570f |
User & Date: | dan 2014-12-18 20:01:15.691 |
Context
2014-12-19
| ||
20:53 | Remove the fts5_test() aux function. Test aux functions using the tcl interface instead. (check-in: 67e3ffd950 user: dan tags: fts5) | |
2014-12-18
| ||
20:01 | Fix a problem with prefix queries and the AND operator. (check-in: 38b3c65e3e user: dan tags: fts5) | |
18:25 | Fix various problems in fts5 revealed by fault-injection tests. (check-in: e358c3de5c user: dan tags: fts5) | |
Changes
Changes to ext/fts5/fts5_index.c.
︙ | ︙ | |||
4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 | fts5DoclistIterNext(pIter->pDoclist); }else{ fts5BufferZero(&pIter->poslist); fts5MultiIterNext(pIter->pIndex, pIter->pMulti, 0, 0); } return fts5IndexReturn(pIter->pIndex); } /* ** Move to the next matching rowid that occurs at or after iMatch. The ** definition of "at or after" depends on whether this iterator iterates ** in ascending or descending rowid order. */ int sqlite3Fts5IterNextFrom(Fts5IndexIter *pIter, i64 iMatch){ if( pIter->pDoclist ){ | > > > > > > > > > > > > > > > < | | 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 | fts5DoclistIterNext(pIter->pDoclist); }else{ fts5BufferZero(&pIter->poslist); fts5MultiIterNext(pIter->pIndex, pIter->pMulti, 0, 0); } return fts5IndexReturn(pIter->pIndex); } /* ** Move the doclist-iter passed as the first argument to the next ** matching rowid that occurs at or after iMatch. The definition of "at ** or after" depends on whether this iterator iterates in ascending or ** descending rowid order. */ static void fts5DoclistIterNextFrom(Fts5DoclistIter *p, i64 iMatch){ do{ i64 iRowid = p->iRowid; if( p->bAsc!=0 && iRowid>=iMatch ) break; if( p->bAsc==0 && iRowid<=iMatch ) break; fts5DoclistIterNext(p); }while( p->aPoslist ); } /* ** Move to the next matching rowid that occurs at or after iMatch. The ** definition of "at or after" depends on whether this iterator iterates ** in ascending or descending rowid order. */ int sqlite3Fts5IterNextFrom(Fts5IndexIter *pIter, i64 iMatch){ if( pIter->pDoclist ){ fts5DoclistIterNextFrom(pIter->pDoclist, iMatch); }else{ fts5MultiIterNextFrom(pIter->pIndex, pIter->pMulti, iMatch); } return fts5IndexReturn(pIter->pIndex); } /* |
︙ | ︙ |
Changes to test/fts5ad.test.
︙ | ︙ | |||
175 176 177 178 179 180 181 | } { execsql { INSERT INTO t1(rowid, a, b) VALUES($rowid, $a, $b); } } } {} | | > > | | > | > > | > | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | } { execsql { INSERT INTO t1(rowid, a, b) VALUES($rowid, $a, $b); } } } {} proc prefix_query {prefixlist} { set ret [list] db eval {SELECT rowid, a, b FROM t1 ORDER BY rowid DESC} { set bMatch 1 foreach pref $prefixlist { if { [lsearch -glob $a $pref]<0 && [lsearch -glob $b $pref]<0 } { set bMatch 0 break } } if {$bMatch} { lappend ret $rowid } } return $ret } foreach {bAsc sql} { 0 {SELECT rowid FROM t1 WHERE t1 MATCH $prefix} 1 {SELECT rowid FROM t1 WHERE t1 MATCH $prefix ORDER BY rowid ASC} } { foreach {tn prefix} { 1 {a*} 2 {ab*} 3 {abc*} 4 {abcd*} 5 {abcde*} 6 {f*} 7 {fg*} 8 {fgh*} 9 {fghi*} 10 {fghij*} 11 {k*} 12 {kl*} 13 {klm*} 14 {klmn*} 15 {klmno*} 16 {p*} 17 {pq*} 18 {pqr*} 19 {pqrs*} 20 {pqrst*} 21 {u*} 22 {uv*} 23 {uvw*} 24 {uvwx*} 25 {uvwxy*} 26 {uvwxyz*} 27 {x*} 28 {a f*} 29 {a* f*} 30 {a* fghij*} } { set res [prefix_query $prefix] if {$bAsc} { set res [lsort -integer -increasing $res] } set n [llength $res] do_execsql_test $T.$bAsc.$tn.$n $sql $res } } } finish_test |
Changes to test/fts5fault1.test.
︙ | ︙ | |||
93 94 95 96 97 98 99 100 101 102 103 104 105 106 | 1 { dk } 7 2 { m f } 1 3 { f* } {10 9 8 6 5 4 3 1} 4 { m OR f } {10 9 8 5 4 1} 5 { sn + gh } {5} 6 { "sn gh" } {5} 7 { NEAR(r a, 5) } {9} } { do_faultsim_test 4.$tn -prep { faultsim_restore_and_reopen } -body " execsql { SELECT rowid FROM t2 WHERE t2 MATCH '$expr' } " -test " faultsim_test_result {[list 0 $res]} | > > | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | 1 { dk } 7 2 { m f } 1 3 { f* } {10 9 8 6 5 4 3 1} 4 { m OR f } {10 9 8 5 4 1} 5 { sn + gh } {5} 6 { "sn gh" } {5} 7 { NEAR(r a, 5) } {9} 8 { m* f* } {10 9 8 6 4 1} 9 { m* + f* } {8 1} } { do_faultsim_test 4.$tn -prep { faultsim_restore_and_reopen } -body " execsql { SELECT rowid FROM t2 WHERE t2 MATCH '$expr' } " -test " faultsim_test_result {[list 0 $res]} |
︙ | ︙ |