/ Check-in [a4e55f73]
Login

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

Overview
Comment:Fix a problem with the xPhraseFirstColumn() API in detail=col mode. Remove some unused test code from fts5ac.test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fts5-offsets
Files: files | file ages | folders
SHA1:a4e55f73b3c81e28b917395089c0201f9a2c9178
User & Date: dan 2016-01-06 10:17:26
Context
2016-01-06
18:53
Fix an fts5 problem involving detail=none, "ORDER BY rowid DESC" and deleted items. Also add tests to verify that the documented operator precedences are correct. check-in: 8d05cfd4 user: dan tags: fts5-offsets
10:17
Fix a problem with the xPhraseFirstColumn() API in detail=col mode. Remove some unused test code from fts5ac.test. check-in: a4e55f73 user: dan tags: fts5-offsets
2016-01-05
21:04
Rationalize and extend some fts5 test code. Fix bugs revealed by the same. check-in: fd217fdb user: dan tags: fts5-offsets
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/fts5/fts5_expr.c.

2451
2452
2453
2454
2455
2456
2457

2458


2459
2460
2461
2462
2463
2464
2465
2466
  const u8 **ppCollist, 
  int *pnCollist
){
  Fts5ExprPhrase *pPhrase = pExpr->apExprPhrase[iPhrase];
  Fts5ExprNode *pNode = pPhrase->pNode;
  assert( iPhrase>=0 && iPhrase<pExpr->nPhrase );


  if( pNode->bEof==0 && pNode->iRowid==pExpr->pRoot->iRowid ){


    sqlite3Fts5IterCollist(pPhrase->aTerm[0].pIter, ppCollist, pnCollist);
  }else{
    *ppCollist = 0;
    *pnCollist = 0;
  }
  return SQLITE_OK;
}








>
|
>
>








2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
  const u8 **ppCollist, 
  int *pnCollist
){
  Fts5ExprPhrase *pPhrase = pExpr->apExprPhrase[iPhrase];
  Fts5ExprNode *pNode = pPhrase->pNode;
  assert( iPhrase>=0 && iPhrase<pExpr->nPhrase );

  if( pNode->bEof==0 
   && pNode->iRowid==pExpr->pRoot->iRowid 
   && pPhrase->poslist.n>0
  ){
    sqlite3Fts5IterCollist(pPhrase->aTerm[0].pIter, ppCollist, pnCollist);
  }else{
    *ppCollist = 0;
    *pnCollist = 0;
  }
  return SQLITE_OK;
}

Changes to ext/fts5/test/fts5ac.test.

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
172
173
174
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
    95  {h b n j t k i h o q u}             {w n g i t o k c a m y p f l x c p}
    96  {f c x p y r b m o l m o a}         {p c a q s u n n x d c f a o}
    97  {u h h k m n k}                     {u b v n u a o c}
    98  {s p e t c z d f n w f}             {l s f j b l c e s h}
    99  {r c v w i v h a t a c v c r e}     {h h u m g o f b a e o}
}

# Argument $expr is an FTS5 match expression designed to be executed against
# an FTS5 table with the following schema:
# 
#   CREATE VIRTUAL TABLE xy USING fts5(x, y);
#
# Assuming the table contains the same records as stored in the global 
# $::data array (see above), this function returns a list containing two
# elements for each matching row in the dataset. The first element of each
# pair is the rowid. The second is a list of phrase matches, where each 
# phrase match is of the form:
#
#   <phrase-number>.<column-number>.<offset>
#
# The list of phrase matches is in the same format as that returned by the
# fts5_test_poslist() auxiliary scalara function.
#
proc poslist_data {bPos expr {bAsc 1}} {

  set tclexpr [db one {
    SELECT fts5_expr_tcl($expr, 'nearset $cols -pc ::pc', 'x', 'y')
  }]
  set res [list]

  #puts $tclexpr
  foreach {id x y} $::data {
    set cols [list $x $y]
    set ::pc 0
    #set hits [lsort -command instcompare [eval $tclexpr]]
    set hits [eval $tclexpr]
    if {[llength $hits]>0} {
      if {$bPos} {
        lappend res [list $id $hits]
      } else {
        lappend res $id
      }
    }
  }

  if {$bAsc} {
    set res [lsort -integer -increasing -index 0 $res]
  } else {
    set res [lsort -integer -decreasing -index 0 $res]
  }

  set res [concat {*}$res]
  return $res
}

proc collist_elem_compare {a b} {
  foreach {a1 a2} [split $a .] {}
  foreach {b1 b2} [split $b .] {}

  if {$a1==$b1} {
    return [expr $a2 - $b2]
  }
  return [expr $a1 - $b1]
}

proc poslist2collist {poslist} {
  set res [list]
  foreach h $poslist {
    regexp {(.*)\.[1234567890]+} $h -> cand
    lappend res $cand
  }
  set res [lsort -command collist_elem_compare -unique $res]
  return $res
}

proc collist_data {expr} {
  set res [list]
  foreach {rowid poslist} [poslist_data 1 $expr] {
    lappend res $rowid [poslist2collist $poslist]
  }
  set res
}

#
# End of test code
#-------------------------------------------------------------------------

foreach {tn2 sql} {
  1  {}
  2  {BEGIN}
} {
if {[detail_is_full]} continue
  reset_db
  fts5_aux_test_functions db

  do_execsql_test 1.$tn2.0 {
    CREATE VIRTUAL TABLE xx USING fts5(x,y, detail=%DETAIL%);
    INSERT INTO xx(xx, rank) VALUES('pgsz', 32);
  }







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




<







123
124
125
126
127
128
129
















































































130
131
132
133

134
135
136
137
138
139
140
    95  {h b n j t k i h o q u}             {w n g i t o k c a m y p f l x c p}
    96  {f c x p y r b m o l m o a}         {p c a q s u n n x d c f a o}
    97  {u h h k m n k}                     {u b v n u a o c}
    98  {s p e t c z d f n w f}             {l s f j b l c e s h}
    99  {r c v w i v h a t a c v c r e}     {h h u m g o f b a e o}
}

















































































foreach {tn2 sql} {
  1  {}
  2  {BEGIN}
} {

  reset_db
  fts5_aux_test_functions db

  do_execsql_test 1.$tn2.0 {
    CREATE VIRTUAL TABLE xx USING fts5(x,y, detail=%DETAIL%);
    INSERT INTO xx(xx, rank) VALUES('pgsz', 32);
  }