/ 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 Unified Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3_write.c.

3225
3226
3227
3228
3229
3230
3231

3232
3233

3234
3235
3236
3237
3238
3239
3240
   && p->nAutoincrmerge==0xff && p->nLeafAdd>0
  ){
    sqlite3_stmt *pStmt = 0;
    rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);
    if( rc==SQLITE_OK ){
      sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);
      rc = sqlite3_step(pStmt);

      p->nAutoincrmerge = (rc==SQLITE_ROW && sqlite3_column_int(pStmt, 0));
      if( p->nAutoincrmerge==1 ) p->nAutoincrmerge = 8;

      rc = sqlite3_reset(pStmt);
    }
  }
  return rc;
}

/*







>
|
|
>







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

/*

Changes to test/fts4growth2.test.

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
# This file implements regression tests for SQLite library.  The
# focus of this script is testing the FTS4 module.
#
#

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

# If SQLITE_ENABLE_FTS3 is defined, omit this file.
ifcapable !fts3 {
  finish_test
  return
}

................................................................................
source $testdir/genesis.tcl

do_execsql_test 1.0 { CREATE TABLE t1(docid, words); }
fts_kjv_genesis 

proc tt {val} {
  execsql {
    BEGIN;
      DELETE FROM x1 
        WHERE docid IN (SELECT docid FROM t1 WHERE (rowid-1)%4==$val+0);
      INSERT INTO x1(docid, content) 
        SELECT docid, words FROM t1 WHERE (rowid%4)==$val+0;
    COMMIT;
  }

}

do_execsql_test 1.1 {
  CREATE VIRTUAL TABLE x1 USING fts4;
  INSERT INTO x1(x1) VALUES('automerge=2');
}

do_test 1.2 {
  for {set i 0} {$i < 100} {incr i} {
    tt 0 ; tt 1 ; tt 2 ; tt 3
  }
  execsql { 
    SELECT max(level) FROM x1_segdir; 
    SELECT count(*) FROM x1_segdir WHERE level=4;
  }
} {4 1}

do_test 1.3 {
  for {set i 0} {$i < 100} {incr i} {
    tt 0 ; tt 1 ; tt 2 ; tt 3
  }
  execsql { 
    SELECT max(level) FROM x1_segdir; 
    SELECT count(*) FROM x1_segdir WHERE level=4;
  }
} {4 1}

#-------------------------------------------------------------------------
#
do_execsql_test 2.1 {
  DELETE FROM t1 WHERE rowid>16;
  DROP TABLE IF EXISTS x1;
  CREATE VIRTUAL TABLE x1 USING fts4;







|







 







<
|
|
|
|
<

>








|




|

|


|




|

|







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
# This file implements regression tests for SQLite library.  The
# focus of this script is testing the FTS4 module.
#
#

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

# If SQLITE_ENABLE_FTS3 is defined, omit this file.
ifcapable !fts3 {
  finish_test
  return
}

................................................................................
source $testdir/genesis.tcl

do_execsql_test 1.0 { CREATE TABLE t1(docid, words); }
fts_kjv_genesis 

proc tt {val} {
  execsql {

    DELETE FROM x1 
      WHERE docid IN (SELECT docid FROM t1 WHERE (rowid-1)%4==$val+0);
    INSERT INTO x1(docid, content) 
      SELECT docid, words FROM t1 WHERE (rowid%4)==$val+0;

  }
  #puts [db eval {SELECT level, idx, end_block FROM x1_segdir}]
}

do_execsql_test 1.1 {
  CREATE VIRTUAL TABLE x1 USING fts4;
  INSERT INTO x1(x1) VALUES('automerge=2');
}

do_test 1.2 {
  for {set i 0} {$i < 40} {incr i} {
    tt 0 ; tt 1 ; tt 2 ; tt 3
  }
  execsql { 
    SELECT max(level) FROM x1_segdir; 
    SELECT count(*) FROM x1_segdir WHERE level=3;
  }
} {3 1}

do_test 1.3 {
  for {set i 0} {$i < 40} {incr i} {
    tt 0 ; tt 1 ; tt 2 ; tt 3
  }
  execsql { 
    SELECT max(level) FROM x1_segdir; 
    SELECT count(*) FROM x1_segdir WHERE level=2;
  }
} {2 1}

#-------------------------------------------------------------------------
#
do_execsql_test 2.1 {
  DELETE FROM t1 WHERE rowid>16;
  DROP TABLE IF EXISTS x1;
  CREATE VIRTUAL TABLE x1 USING fts4;

Changes to test/fts4merge4.test.

49
50
51
52
53
54
55


56










































57
58
    execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}
  }
} {}
do_execsql_test 2.2 { SELECT count(*) FROM t1_segdir; } 35
do_execsql_test 2.3 { INSERT INTO t1(t1) VALUES('optimize') } {}
do_execsql_test 2.4 { SELECT count(*) FROM t1_segdir; } 1














































sqlite3_enable_shared_cache $::enable_shared_cache
finish_test







>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


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
94
95
96
97
98
99
100
101
102
    execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}
  }
} {}
do_execsql_test 2.2 { SELECT count(*) FROM t1_segdir; } 35
do_execsql_test 2.3 { INSERT INTO t1(t1) VALUES('optimize') } {}
do_execsql_test 2.4 { SELECT count(*) FROM t1_segdir; } 1

#-------------------------------------------------------------------------
# Now test that the automerge=? option appears to work.
#
do_execsql_test 2.1 { CREATE VIRTUAL TABLE t2 USING fts4; }

set doc ""
foreach c1 "a b c d e f g h i j" {
  foreach c2 "a b c d e f g h i j" {
    foreach c3 "a b c d e f g h i j" {
      lappend doc "$c1$c2$c3"
    }
  }
}
set doc [string repeat $doc 10]

foreach {tn am expected} {
  1 {automerge=2} {1 1   2 1   4 1   6 1}
  2 {automerge=4} {1 2   2 1   3 1}
  3 {automerge=8} {0 4   1 3   2 1}
  4 {automerge=1} {0 4   1 3   2 1}
} {
  foreach {tn2 openclose} {1 {} 2 { db close ; sqlite3 db test.db }} {
    do_test 2.2.$tn.$tn2 {
      execsql { DELETE FROM t2 }
      execsql { INSERT INTO t2(t2) VALUES($am) };

      eval $openclose
  
      for {set i 0} {$i < 100} {incr i} {
        execsql { 
          BEGIN;
            INSERT INTO t2 VALUES($doc);
            INSERT INTO t2 VALUES($doc);
            INSERT INTO t2 VALUES($doc);
            INSERT INTO t2 VALUES($doc);
            INSERT INTO t2 VALUES($doc);
          COMMIT;
        }
      }
  
      execsql { SELECT level, count(*) FROM t2_segdir GROUP BY level }
    } [list {*}$expected]
  }
}

sqlite3_enable_shared_cache $::enable_shared_cache
finish_test

Changes to test/permutations.test.

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

#############################################################################
# Start of tests







|







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

#############################################################################
# Start of tests