SQLite

Check-in [96ed47493b]
Login

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

Overview
Comment:Remove an incorrect assert() statement. Fix a const-related warning.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | fts4-incr-merge
Files: files | file ages | folders
SHA1: 96ed47493b3d46344fd2105642f31690aee06674
User & Date: dan 2012-03-23 14:38:49.144
Context
2012-03-23
15:38
Add a test to verify that sqlite3_total_changes() works with incr-merge operations. (check-in: 1c72cecc6b user: dan tags: fts4-incr-merge)
14:38
Remove an incorrect assert() statement. Fix a const-related warning. (check-in: 96ed47493b user: dan tags: fts4-incr-merge)
13:40
Fix another test case issue in trace2.test. (check-in: 02a8e4236c user: dan tags: fts4-incr-merge)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/fts3/fts3_write.c.
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
  Fts3MultiSegReader *pCsr        /* Cursor object to populate */
){
  int rc;                         /* Return Code */
  sqlite3_stmt *pStmt = 0;        /* Statement used to read %_segdir entry */  
  int nByte;                      /* Bytes allocated at pCsr->apSegment[] */

  /* Allocate space for the Fts3MultiSegReader.aCsr[] array */
  assert( nSeg>=2 );
  memset(pCsr, 0, sizeof(*pCsr));
  nByte = sizeof(Fts3SegReader *) * nSeg;
  pCsr->apSegment = (Fts3SegReader **)sqlite3_malloc(nByte);

  if( pCsr->apSegment==0 ){
    rc = SQLITE_NOMEM;
  }else{







<







3281
3282
3283
3284
3285
3286
3287

3288
3289
3290
3291
3292
3293
3294
  Fts3MultiSegReader *pCsr        /* Cursor object to populate */
){
  int rc;                         /* Return Code */
  sqlite3_stmt *pStmt = 0;        /* Statement used to read %_segdir entry */  
  int nByte;                      /* Bytes allocated at pCsr->apSegment[] */

  /* Allocate space for the Fts3MultiSegReader.aCsr[] array */

  memset(pCsr, 0, sizeof(*pCsr));
  nByte = sizeof(Fts3SegReader *) * nSeg;
  pCsr->apSegment = (Fts3SegReader **)sqlite3_malloc(nByte);

  if( pCsr->apSegment==0 ){
    rc = SQLITE_NOMEM;
  }else{
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
  *pnMerge = 0;
  *piAbsLevel = 0;

  rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pSelect, 0);
  if( rc==SQLITE_OK ){
    sqlite3_bind_int(pSelect, 1, FTS_STAT_INCRMERGEHINT);
    if( SQLITE_ROW==sqlite3_step(pSelect) ){
      char *aHint = sqlite3_column_blob(pSelect, 0);
      int nHint = sqlite3_column_bytes(pSelect, 0);
      if( aHint ){
        int i;
        char aBlob[FTS3_VARINT_MAX * 2];
        memcpy(aBlob, aHint, MAX(sizeof(aBlob), nHint));
        i = sqlite3Fts3GetVarint(aBlob, piAbsLevel);
        sqlite3Fts3GetVarint32(&aBlob[i], pnMerge);







|







4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
  *pnMerge = 0;
  *piAbsLevel = 0;

  rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pSelect, 0);
  if( rc==SQLITE_OK ){
    sqlite3_bind_int(pSelect, 1, FTS_STAT_INCRMERGEHINT);
    if( SQLITE_ROW==sqlite3_step(pSelect) ){
      const char *aHint = sqlite3_column_blob(pSelect, 0);
      int nHint = sqlite3_column_bytes(pSelect, 0);
      if( aHint ){
        int i;
        char aBlob[FTS3_VARINT_MAX * 2];
        memcpy(aBlob, aHint, MAX(sizeof(aBlob), nHint));
        i = sqlite3Fts3GetVarint(aBlob, piAbsLevel);
        sqlite3Fts3GetVarint32(&aBlob[i], pnMerge);
Changes to test/fts4merge.test.
157
158
159
160
161
162
163

164
165
166
167
168
169
170
} {X'0006'}

do_execsql_test 4.4.2 {
  DELETE FROM t4_stat WHERE rowid=1;
  INSERT INTO t4(t4) VALUES('merge=1,12');
  SELECT level, group_concat(idx, ' ') FROM t4_segdir GROUP BY level;
} "0 {0 1 2 3 4 5}                     1 0"


#-------------------------------------------------------------------------
# Test cases 5.*
#
# Test that if a crisis-merge occurs that disrupts an ongoing incremental
# merge, the next call to "merge=A,B" identifies this and starts a new
# incremental merge. There are two scenarios:







>







157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
} {X'0006'}

do_execsql_test 4.4.2 {
  DELETE FROM t4_stat WHERE rowid=1;
  INSERT INTO t4(t4) VALUES('merge=1,12');
  SELECT level, group_concat(idx, ' ') FROM t4_segdir GROUP BY level;
} "0 {0 1 2 3 4 5}                     1 0"


#-------------------------------------------------------------------------
# Test cases 5.*
#
# Test that if a crisis-merge occurs that disrupts an ongoing incremental
# merge, the next call to "merge=A,B" identifies this and starts a new
# incremental merge. There are two scenarios:
251
252
253
254
255
256
257


258




























259
  SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;
  SELECT quote(value) from t1_stat WHERE rowid=1;
} {
  0 0   1 0   2 0   3 {0 1}
  X'0000'
}
































finish_test







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

252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
  SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;
  SELECT quote(value) from t1_stat WHERE rowid=1;
} {
  0 0   1 0   2 0   3 {0 1}
  X'0000'
}

#-------------------------------------------------------------------------
# Test cases 6.*
#
# At one point the following test caused an assert() to fail (because the
# second 'merge=1,2' operation below actually "merges" a single input
# segment, which was unexpected).
#
do_test 6.1 {
  reset_db
  set a [string repeat a 900]
  set b [string repeat b 900]
  set c [string repeat c 900]
  set d [string repeat d 900]
  execsql {
    CREATE VIRTUAL TABLE t1 USING fts4;
    BEGIN;
      INSERT INTO t1 VALUES($a);
      INSERT INTO t1 VALUES($b);
    COMMIT;
    BEGIN;
      INSERT INTO t1 VALUES($c);
      INSERT INTO t1 VALUES($d);
    COMMIT;
  }

  execsql {
    INSERT INTO t1(t1) VALUES('merge=1,2');
    INSERT INTO t1(t1) VALUES('merge=1,2');
  }
} {}

finish_test