/ Check-in [7268119f]
Login

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

Overview
Comment:Fix a problem to do with loading the value of the FTS automerge setting from the database.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fts4-experimental
Files: files | file ages | folders
SHA1: 7268119f74602929b372b88eca7b3c3b4964f7d5
User & Date: dan 2014-05-14 18:45:27
Context
2014-05-14
19:49
Do not search for promotable segments following an FTS 'optimize' operation or creation of a new segment on the oldest existing level. check-in: 34f6b4b8 user: dan tags: fts4-experimental
18:45
Fix a problem to do with loading the value of the FTS automerge setting from the database. check-in: 7268119f user: dan tags: fts4-experimental
15:58
Fix various problems to do with segment promotion. Add test file fts4growth2.test, containing tests to check that the FTS index does not grow indefinitely as the table is updated. Allow the user to configure the number of segments merged simultaneously by the automerge option. check-in: 21491a9b user: dan tags: fts4-experimental
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to ext/fts3/fts3_write.c.

  3225   3225      && p->nAutoincrmerge==0xff && p->nLeafAdd>0
  3226   3226     ){
  3227   3227       sqlite3_stmt *pStmt = 0;
  3228   3228       rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);
  3229   3229       if( rc==SQLITE_OK ){
  3230   3230         sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);
  3231   3231         rc = sqlite3_step(pStmt);
  3232         -      p->nAutoincrmerge = (rc==SQLITE_ROW && sqlite3_column_int(pStmt, 0));
         3232  +      if( rc==SQLITE_ROW ){
         3233  +        p->nAutoincrmerge = sqlite3_column_int(pStmt, 0);
  3233   3234         if( p->nAutoincrmerge==1 ) p->nAutoincrmerge = 8;
         3235  +      }
  3234   3236         rc = sqlite3_reset(pStmt);
  3235   3237       }
  3236   3238     }
  3237   3239     return rc;
  3238   3240   }
  3239   3241   
  3240   3242   /*

Changes to test/fts4growth2.test.

    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is testing the FTS4 module.
    13     13   #
    14     14   #
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18         -set testprefix fts4growth
           18  +set testprefix fts4growth2
    19     19   
    20     20   # If SQLITE_ENABLE_FTS3 is defined, omit this file.
    21     21   ifcapable !fts3 {
    22     22     finish_test
    23     23     return
    24     24   }
    25     25   
................................................................................
    26     26   source $testdir/genesis.tcl
    27     27   
    28     28   do_execsql_test 1.0 { CREATE TABLE t1(docid, words); }
    29     29   fts_kjv_genesis 
    30     30   
    31     31   proc tt {val} {
    32     32     execsql {
    33         -    BEGIN;
    34     33         DELETE FROM x1 
    35     34           WHERE docid IN (SELECT docid FROM t1 WHERE (rowid-1)%4==$val+0);
    36     35         INSERT INTO x1(docid, content) 
    37     36           SELECT docid, words FROM t1 WHERE (rowid%4)==$val+0;
    38         -    COMMIT;
    39     37     }
           38  +  #puts [db eval {SELECT level, idx, end_block FROM x1_segdir}]
    40     39   }
    41     40   
    42     41   do_execsql_test 1.1 {
    43     42     CREATE VIRTUAL TABLE x1 USING fts4;
    44     43     INSERT INTO x1(x1) VALUES('automerge=2');
    45     44   }
    46     45   
    47     46   do_test 1.2 {
    48         -  for {set i 0} {$i < 100} {incr i} {
           47  +  for {set i 0} {$i < 40} {incr i} {
    49     48       tt 0 ; tt 1 ; tt 2 ; tt 3
    50     49     }
    51     50     execsql { 
    52     51       SELECT max(level) FROM x1_segdir; 
    53         -    SELECT count(*) FROM x1_segdir WHERE level=4;
           52  +    SELECT count(*) FROM x1_segdir WHERE level=3;
    54     53     }
    55         -} {4 1}
           54  +} {3 1}
    56     55   
    57     56   do_test 1.3 {
    58         -  for {set i 0} {$i < 100} {incr i} {
           57  +  for {set i 0} {$i < 40} {incr i} {
    59     58       tt 0 ; tt 1 ; tt 2 ; tt 3
    60     59     }
    61     60     execsql { 
    62     61       SELECT max(level) FROM x1_segdir; 
    63         -    SELECT count(*) FROM x1_segdir WHERE level=4;
           62  +    SELECT count(*) FROM x1_segdir WHERE level=2;
    64     63     }
    65         -} {4 1}
           64  +} {2 1}
    66     65   
    67     66   #-------------------------------------------------------------------------
    68     67   #
    69     68   do_execsql_test 2.1 {
    70     69     DELETE FROM t1 WHERE rowid>16;
    71     70     DROP TABLE IF EXISTS x1;
    72     71     CREATE VIRTUAL TABLE x1 USING fts4;

Changes to test/fts4merge4.test.

    49     49       execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}
    50     50     }
    51     51   } {}
    52     52   do_execsql_test 2.2 { SELECT count(*) FROM t1_segdir; } 35
    53     53   do_execsql_test 2.3 { INSERT INTO t1(t1) VALUES('optimize') } {}
    54     54   do_execsql_test 2.4 { SELECT count(*) FROM t1_segdir; } 1
    55     55   
           56  +#-------------------------------------------------------------------------
           57  +# Now test that the automerge=? option appears to work.
           58  +#
           59  +do_execsql_test 2.1 { CREATE VIRTUAL TABLE t2 USING fts4; }
           60  +
           61  +set doc ""
           62  +foreach c1 "a b c d e f g h i j" {
           63  +  foreach c2 "a b c d e f g h i j" {
           64  +    foreach c3 "a b c d e f g h i j" {
           65  +      lappend doc "$c1$c2$c3"
           66  +    }
           67  +  }
           68  +}
           69  +set doc [string repeat $doc 10]
           70  +
           71  +foreach {tn am expected} {
           72  +  1 {automerge=2} {1 1   2 1   4 1   6 1}
           73  +  2 {automerge=4} {1 2   2 1   3 1}
           74  +  3 {automerge=8} {0 4   1 3   2 1}
           75  +  4 {automerge=1} {0 4   1 3   2 1}
           76  +} {
           77  +  foreach {tn2 openclose} {1 {} 2 { db close ; sqlite3 db test.db }} {
           78  +    do_test 2.2.$tn.$tn2 {
           79  +      execsql { DELETE FROM t2 }
           80  +      execsql { INSERT INTO t2(t2) VALUES($am) };
           81  +
           82  +      eval $openclose
           83  +  
           84  +      for {set i 0} {$i < 100} {incr i} {
           85  +        execsql { 
           86  +          BEGIN;
           87  +            INSERT INTO t2 VALUES($doc);
           88  +            INSERT INTO t2 VALUES($doc);
           89  +            INSERT INTO t2 VALUES($doc);
           90  +            INSERT INTO t2 VALUES($doc);
           91  +            INSERT INTO t2 VALUES($doc);
           92  +          COMMIT;
           93  +        }
           94  +      }
           95  +  
           96  +      execsql { SELECT level, count(*) FROM t2_segdir GROUP BY level }
           97  +    } [list {*}$expected]
           98  +  }
           99  +}
    56    100   
    57    101   sqlite3_enable_shared_cache $::enable_shared_cache
    58    102   finish_test

Changes to test/permutations.test.

   108    108     savepoint4.test savepoint6.test select9.test 
   109    109     speed1.test speed1p.test speed2.test speed3.test speed4.test 
   110    110     speed4p.test sqllimits1.test tkt2686.test thread001.test thread002.test
   111    111     thread003.test thread004.test thread005.test trans2.test vacuum3.test 
   112    112     incrvacuum_ioerr.test autovacuum_crash.test btree8.test shared_err.test
   113    113     vtab_err.test walslow.test walcrash.test walcrash3.test
   114    114     walthread.test rtree3.test indexfault.test securedel2.test
   115         -  fts3growth2.test
          115  +  fts4growth.test fts4growth2.test
   116    116   }]
   117    117   if {[info exists ::env(QUICKTEST_INCLUDE)]} {
   118    118     set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
   119    119   }
   120    120   
   121    121   #############################################################################
   122    122   # Start of tests