SQLite

Check-in [956de051f4]
Login

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

Overview
Comment:Fix a problem in FTS3 phrase queries. Add tests to check that it really is fixed.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 956de051f43dfc2f178a7820981da4bf69927190
User & Date: dan 2009-12-20 15:00:19.000
Context
2009-12-21
08:53
Change many comments in e_fkey.test to include the full text of the corresponding statement in foreignkeys.html. (check-in: 4b489ecb25 user: dan tags: trunk)
2009-12-20
15:00
Fix a problem in FTS3 phrase queries. Add tests to check that it really is fixed. (check-in: 956de051f4 user: dan tags: trunk)
2009-12-17
22:17
Modified statement machine in sqlite3_complete() to return 0 on empty string. Added/updated tests for same. Ticket [356c885b0b]. (check-in: 76eca7295c user: shaneh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/fts3/fts3.c.
1306
1307
1308
1309
1310
1311
1312

1313
1314
1315
1316
1317
1318
1319
  assert( mergetype==MERGE_OR     || mergetype==MERGE_POS_OR 
       || mergetype==MERGE_AND    || mergetype==MERGE_NOT
       || mergetype==MERGE_PHRASE || mergetype==MERGE_POS_PHRASE
       || mergetype==MERGE_NEAR   || mergetype==MERGE_POS_NEAR
  );

  if( !aBuffer ){

    return SQLITE_NOMEM;
  }

  /* Read the first docid from each doclist */
  fts3GetDeltaVarint2(&p1, pEnd1, &i1);
  fts3GetDeltaVarint2(&p2, pEnd2, &i2);








>







1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
  assert( mergetype==MERGE_OR     || mergetype==MERGE_POS_OR 
       || mergetype==MERGE_AND    || mergetype==MERGE_NOT
       || mergetype==MERGE_PHRASE || mergetype==MERGE_POS_PHRASE
       || mergetype==MERGE_NEAR   || mergetype==MERGE_POS_NEAR
  );

  if( !aBuffer ){
    *pnBuffer = 0;
    return SQLITE_NOMEM;
  }

  /* Read the first docid from each doclist */
  fts3GetDeltaVarint2(&p1, pEnd1, &i1);
  fts3GetDeltaVarint2(&p2, pEnd2, &i2);

1674
1675
1676
1677
1678
1679
1680

1681
1682
1683
1684
1685
1686
1687
      if( ii==pPhrase->nToken-1 && !isReqPos ){
        mergetype = MERGE_PHRASE;
      }
      fts3DoclistMerge(mergetype, 0, 0, pList, &nOut, pOut, nOut, pList, nList);
      sqlite3_free(pOut);
      pOut = pList;
    }

  }

  if( rc==SQLITE_OK ){
    *paOut = pOut;
    *pnOut = nOut;
  }else{
    sqlite3_free(pOut);







>







1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
      if( ii==pPhrase->nToken-1 && !isReqPos ){
        mergetype = MERGE_PHRASE;
      }
      fts3DoclistMerge(mergetype, 0, 0, pList, &nOut, pOut, nOut, pList, nList);
      sqlite3_free(pOut);
      pOut = pList;
    }
    assert( nOut==0 || pOut!=0 );
  }

  if( rc==SQLITE_OK ){
    *paOut = pOut;
    *pnOut = nOut;
  }else{
    sqlite3_free(pOut);
Added test/fts3query.test.


























































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
# 2009 December 20
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains tests of fts3 queries that have been useful during
# the development process as well as some that have been useful in tracking
# down bugs. They are not focused on any particular functionality.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# If this build does not include FTS3, skip the tests in this file.
#
ifcapable !fts3 { finish_test ; return }
source $testdir/fts3_common.tcl
set DO_MALLOC_TEST 0

do_test fts3query-1.1 {
  execsql {
    CREATE VIRTUAL TABLE t1 USING fts3(x);
    BEGIN;
      INSERT INTO t1 VALUES('The source code for SQLite is in the public');
  }
} {}

do_select_test fts3query-1.2 {
  SELECT * FROM t1;
} {{The source code for SQLite is in the public}}
do_select_test fts3query-1.3 {
  SELECT * FROM t1 WHERE t1 MATCH 'sqlite'
} {{The source code for SQLite is in the public}}

do_test fts3query-1.4 { execsql {COMMIT} } {}

do_select_test fts3query-1.5 {
  SELECT * FROM t1;
} {{The source code for SQLite is in the public}}
do_select_test fts3query-1.6 {
  SELECT * FROM t1 WHERE t1 MATCH 'sqlite'
} {{The source code for SQLite is in the public}}


set sqlite_fts3_enable_parentheses 1
do_test fts3query-2.1 {
  execsql {
    CREATE VIRTUAL TABLE zoink USING fts3;
    INSERT INTO zoink VALUES('The apple falls far from the tree');
  }
} {}
do_test fts3query-2.2 {
  execsql {
    SELECT docid FROM zoink WHERE zoink MATCH '(apple oranges) AND apple'
  }
} {}
do_test fts3query-2.3 {
  execsql {
    SELECT docid FROM zoink WHERE zoink MATCH 'apple AND (oranges apple)'
  }
} {}
set sqlite_fts3_enable_parentheses 0

do_test fts3query-3.1 {
  execsql {
    CREATE VIRTUAL TABLE foobar using FTS3(description, tokenize porter);
    INSERT INTO foobar (description) values ('
      Filed under: Emerging Technologies, EV/Plug-in, Hybrid, Chevrolet, GM, 
      ZENN 2011 Chevy Volt - Click above for high-res image gallery There are 
      16 days left in the month of December. Besides being time for most 
      Americans to kick their Christmas shopping sessions into high gear and
      start planning their resolutions for 2010, it also means that there''s
      precious little time for EEStor to "deliver functional technology" to
      Zenn Motors as promised. Still, the promises held out by the secretive
      company are too great for us to forget about entirely. We''d love for
      EEStor''s claims to be independently verified and proven accurate, as
      would just about anyone else looking to break free of petroleum in fav
    '); 
  }
} {}

do_test fts3query-3.2 {
  execsql { SELECT docid FROM foobar WHERE description MATCH '"high sp d"' }
} {}

finish_test