SQLite

Check-in [5808f30fae]
Login

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

Overview
Comment:Fix a problem with position list processing for OR queries.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | fts5
Files: files | file ages | folders
SHA1: 5808f30fae0d844c52a785bf18872be371d4af68
User & Date: dan 2014-07-17 15:14:07.541
Context
2014-07-18
19:59
Fix issues with position lists and NEAR constraints. (check-in: 16352d3654 user: dan tags: fts5)
2014-07-17
15:14
Fix a problem with position list processing for OR queries. (check-in: 5808f30fae user: dan tags: fts5)
2014-07-16
20:07
Fixes for tcl list generation in fts5_test(). (check-in: c1f9a4b76c user: dan tags: fts5)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/fts5/fts5_expr.c.
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403

1404
1405
1406



1407
1408
}

/*
** This function is used to access the current position list for phrase
** iPhrase.
*/
int sqlite3Fts5ExprPoslist(Fts5Expr *pExpr, int iPhrase, const u8 **pa){
  if( iPhrase<0 || iPhrase>=pExpr->nPhrase ){
    *pa = 0;
    return 0;
  }else{
    Fts5ExprPhrase *pPhrase = pExpr->apPhrase[iPhrase];

    *pa = pPhrase->poslist.p;
    return pPhrase->poslist.n;
  }



}








|
<
<
<

>
|
|
|
>
>
>


1392
1393
1394
1395
1396
1397
1398
1399



1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
}

/*
** This function is used to access the current position list for phrase
** iPhrase.
*/
int sqlite3Fts5ExprPoslist(Fts5Expr *pExpr, int iPhrase, const u8 **pa){
  if( iPhrase>=0 && iPhrase<pExpr->nPhrase ){



    Fts5ExprPhrase *pPhrase = pExpr->apPhrase[iPhrase];
    if( sqlite3Fts5IterRowid(pPhrase->aTerm[0].pIter)==pExpr->pRoot->iRowid ){
      *pa = pPhrase->poslist.p;
      return pPhrase->poslist.n;
    }
  }
  *pa = 0;
  return 0;
}

Changes to test/fts5ac.test.
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
  if {$nOpt<0} { error "no -- option" }

  foreach {k v} [lrange $args 0 [expr $nOpt-1]] {
    if {[info exists O($k)]==0} { error "unrecognized option $k" }
    set O($k) $v
  }

  # Set phraselist to be a list of phrases. nPhrase its length.
  set phraselist [lrange $args [expr $nOpt+1] end]
  set nPhrase [llength $phraselist]

  for {set j 0} {$j < [llength $aCol]} {incr j} {
    for {set i 0} {$i < $nPhrase} {incr i} { 
      set A($j,$i) [list]
    }







|







149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
  if {$nOpt<0} { error "no -- option" }

  foreach {k v} [lrange $args 0 [expr $nOpt-1]] {
    if {[info exists O($k)]==0} { error "unrecognized option $k" }
    set O($k) $v
  }

  # Set $phraselist to be a list of phrases. $nPhrase its length.
  set phraselist [lrange $args [expr $nOpt+1] end]
  set nPhrase [llength $phraselist]

  for {set j 0} {$j < [llength $aCol]} {incr j} {
    for {set i 0} {$i < $nPhrase} {incr i} { 
      set A($j,$i) [list]
    }
295
296
297
298
299
300
301
302
303
304
305






306
307
308
309
310
311
312
  } $res
}

#-------------------------------------------------------------------------
# Test some AND and OR queries.
#
foreach {tn expr} {
  1 "a   AND b"
  2 "a+b AND c"
  3 "d+c AND u"
  4 "d+c AND u+d"






} {
  set res [matchdata 1 $expr]
  do_execsql_test 2.1.$tn.[llength $res] { 
    SELECT rowid, fts5_test(xx, 'poslist') FROM xx WHERE xx match $expr
  } $res
}








|
|
|
|
>
>
>
>
>
>







295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
  } $res
}

#-------------------------------------------------------------------------
# Test some AND and OR queries.
#
foreach {tn expr} {
  1.1 "a   AND b"
  1.2 "a+b AND c"
  1.3 "d+c AND u"
  1.4 "d+c AND u+d"

  2.1 "a   OR b"
  2.2 "a+b OR c"
  2.3 "d+c OR u"
  2.4 "d+c OR u+d"

} {
  set res [matchdata 1 $expr]
  do_execsql_test 2.1.$tn.[llength $res] { 
    SELECT rowid, fts5_test(xx, 'poslist') FROM xx WHERE xx match $expr
  } $res
}