SQLite4
Check-in [dba97f861c]
Not logged in

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

Overview
Comment:Remove the unused LSM_WORK_FLUSH flags.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: dba97f861cdf1c88943eeb846fb2e271e4895bc7
User & Date: dan 2012-11-05 16:41:16
Context
2012-11-06
11:23
Change the format of uncompressed databases so that the prev/next pointers at the end of blocks are the same as for compressed databases. check-in: c93bae9496 user: dan tags: trunk
2012-11-05
16:41
Remove the unused LSM_WORK_FLUSH flags. check-in: dba97f861c user: dan tags: trunk
14:56
Merge range-delete-fixes branch with trunk. check-in: 7605250294 user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/kvlsm.c.

380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
      int eParam = *peSafety + 1;
      lsm_config(p->pDb, LSM_CONFIG_SAFETY, &eParam);
      *peSafety = eParam-1;
      break;
    }

    case SQLITE4_KVCTRL_LSM_FLUSH: {
      lsm_work(p->pDb, LSM_WORK_FLUSH, 0, 0);
      break;
    }

    case SQLITE4_KVCTRL_LSM_MERGE: {
      int nPage = *(int*)pArg;
      int nWrite = 0;
      lsm_work(p->pDb, LSM_WORK_OPTIMIZE, nPage, &nWrite);







|







380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
      int eParam = *peSafety + 1;
      lsm_config(p->pDb, LSM_CONFIG_SAFETY, &eParam);
      *peSafety = eParam-1;
      break;
    }

    case SQLITE4_KVCTRL_LSM_FLUSH: {
      lsm_flush(p->pDb);
      break;
    }

    case SQLITE4_KVCTRL_LSM_MERGE: {
      int nPage = *(int*)pArg;
      int nWrite = 0;
      lsm_work(p->pDb, LSM_WORK_OPTIMIZE, nPage, &nWrite);

Changes to src/lsm.h.

467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
int lsm_ckpt_size(lsm_db *, int *pnByte);

/*
** This function is called by a thread to work on the database structure.
** The actual operations performed by this function depend on the value 
** passed as the "flags" parameter:
**
** LSM_WORK_FLUSH:
**   Attempt to flush the contents of the in-memory tree to disk.
**
** LSM_WORK_OPTIMIZE:
**   If nMerge suitable arrays cannot be found, where nMerge is as 
**   configured by LSM_CONFIG_NMERGE, merge together any arrays that
**   can be found. This is usually used to optimize the database by 
**   merging the whole thing into one big array.
*/
int lsm_work(lsm_db *pDb, int flags, int nPage, int *pnWrite);

#define LSM_WORK_FLUSH           0x00000001
#define LSM_WORK_OPTIMIZE        0x00000002

int lsm_flush(lsm_db *pDb);

/*
** Attempt to checkpoint the current database snapshot. Return an LSM
** error code if an error occurs or LSM_OK otherwise.







<
<
<








<







467
468
469
470
471
472
473



474
475
476
477
478
479
480
481

482
483
484
485
486
487
488
int lsm_ckpt_size(lsm_db *, int *pnByte);

/*
** This function is called by a thread to work on the database structure.
** The actual operations performed by this function depend on the value 
** passed as the "flags" parameter:
**



** LSM_WORK_OPTIMIZE:
**   If nMerge suitable arrays cannot be found, where nMerge is as 
**   configured by LSM_CONFIG_NMERGE, merge together any arrays that
**   can be found. This is usually used to optimize the database by 
**   merging the whole thing into one big array.
*/
int lsm_work(lsm_db *pDb, int flags, int nPage, int *pnWrite);


#define LSM_WORK_OPTIMIZE        0x00000002

int lsm_flush(lsm_db *pDb);

/*
** Attempt to checkpoint the current database snapshot. Return an LSM
** error code if an error occurs or LSM_OK otherwise.

Changes to src/lsm_sorted.c.

4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
    int nRemaining;               /* Units of work to do before returning */

    nRemaining = nUnit * nDepth;
#ifdef LSM_LOG_WORK
    lsmLogMessage(pDb, rc, "lsmSortedAutoWork(): %d*%d = %d pages", 
        nUnit, nDepth, nRemaining);
#endif
    rc = doLsmWork(pDb, LSM_WORK_FLUSH, nRemaining, 0);
    if( rc==LSM_BUSY ) rc = LSM_OK;

    if( bRestore && pDb->pCsr ){
      lsmFreeSnapshot(pDb->pEnv, pDb->pClient);
      pDb->pClient = 0;
      rc = lsmCheckpointLoad(pDb, 0);
      if( rc==LSM_OK ){







|







4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
    int nRemaining;               /* Units of work to do before returning */

    nRemaining = nUnit * nDepth;
#ifdef LSM_LOG_WORK
    lsmLogMessage(pDb, rc, "lsmSortedAutoWork(): %d*%d = %d pages", 
        nUnit, nDepth, nRemaining);
#endif
    rc = doLsmWork(pDb, 0, nRemaining, 0);
    if( rc==LSM_BUSY ) rc = LSM_OK;

    if( bRestore && pDb->pCsr ){
      lsmFreeSnapshot(pDb->pEnv, pDb->pClient);
      pDb->pClient = 0;
      rc = lsmCheckpointLoad(pDb, 0);
      if( rc==LSM_OK ){

Changes to test/csr1.test.

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
..
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
populate_db

do_execsql_test 1.1 { SELECT * FROM t1 } {
  0 0 1 1 2 4 3 9 4 16 5 25 6 36 7 49 8 64 9 81
}
db eval { SELECT a, b FROM t1 } {
  do_test 1.2.1 { 
    list [catch { sqlite4_lsm_work db main -flush 0 } msg] $msg
  } {1 SQLITE4_MISUSE}
  do_test 1.2.2 { 
    list [catch { sqlite4_lsm_work db main 1 } msg] $msg
  } {1 SQLITE4_MISUSE}
  break
}

................................................................................
}
do_test 2.2 { 
  sqlite4 db2 ./test.db
  list [catch { db2 eval { BEGIN ; INSERT INTO t1 VALUES(1, 2) } } msg] $msg
} {1 {database is locked}}

do_execsql_test 2.3 { COMMIT }
do_test 2.4 { sqlite4_lsm_work db2 main -flush 0 } {0}
db2 close


#-------------------------------------------------------------------------
# Check that if a transaction is committed and this causes the in-memory
# tree to be flushed to disk, 
#







|







 







|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
..
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
populate_db

do_execsql_test 1.1 { SELECT * FROM t1 } {
  0 0 1 1 2 4 3 9 4 16 5 25 6 36 7 49 8 64 9 81
}
db eval { SELECT a, b FROM t1 } {
  do_test 1.2.1 { 
    list [catch { sqlite4_lsm_work db main 0 } msg] $msg
  } {1 SQLITE4_MISUSE}
  do_test 1.2.2 { 
    list [catch { sqlite4_lsm_work db main 1 } msg] $msg
  } {1 SQLITE4_MISUSE}
  break
}

................................................................................
}
do_test 2.2 { 
  sqlite4 db2 ./test.db
  list [catch { db2 eval { BEGIN ; INSERT INTO t1 VALUES(1, 2) } } msg] $msg
} {1 {database is locked}}

do_execsql_test 2.3 { COMMIT }
do_test 2.4 { sqlite4_lsm_work db2 main 0 } {0}
db2 close


#-------------------------------------------------------------------------
# Check that if a transaction is committed and this causes the in-memory
# tree to be flushed to disk, 
#

Changes to test/test_lsm.c.

151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
...
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
  int objc,
  Tcl_Obj *CONST objv[]
){
  struct Switch {
    const char *zSwitch;
    int flags;
  } aSwitch[] = {
    { "-flush",      LSM_WORK_FLUSH }, 
    { "-optimize",   LSM_WORK_OPTIMIZE }, 
    { 0, 0 }
  };

  int flags = 0;
  int nPage = 0;
  const char *zDb;
................................................................................
        int iOpt;
        const char *azOpt[] = { "-optimize", "-flush", 0 };

        rc = Tcl_GetIndexFromObj(interp, objv[i], azOpt, "option", 0, &iOpt);
        if( rc!=TCL_OK ) return rc;

        if( iOpt==0 ) flags |= LSM_WORK_OPTIMIZE;
        if( iOpt==1 ) flags |= LSM_WORK_FLUSH;
      }

      rc = lsm_work(p->db, flags, nWork, &nWrite);
      if( rc!=LSM_OK ) return test_lsm_error(interp, "lsm_work", rc);
      Tcl_SetObjResult(interp, Tcl_NewIntObj(nWrite));
      return TCL_OK;
    }







<







 







<







151
152
153
154
155
156
157

158
159
160
161
162
163
164
...
634
635
636
637
638
639
640

641
642
643
644
645
646
647
  int objc,
  Tcl_Obj *CONST objv[]
){
  struct Switch {
    const char *zSwitch;
    int flags;
  } aSwitch[] = {

    { "-optimize",   LSM_WORK_OPTIMIZE }, 
    { 0, 0 }
  };

  int flags = 0;
  int nPage = 0;
  const char *zDb;
................................................................................
        int iOpt;
        const char *azOpt[] = { "-optimize", "-flush", 0 };

        rc = Tcl_GetIndexFromObj(interp, objv[i], azOpt, "option", 0, &iOpt);
        if( rc!=TCL_OK ) return rc;

        if( iOpt==0 ) flags |= LSM_WORK_OPTIMIZE;

      }

      rc = lsm_work(p->db, flags, nWork, &nWrite);
      if( rc!=LSM_OK ) return test_lsm_error(interp, "lsm_work", rc);
      Tcl_SetObjResult(interp, Tcl_NewIntObj(nWrite));
      return TCL_OK;
    }

Changes to test/tester.tcl.

1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
# a single b-tree structure. Because this annihilates all delete keys,
# the next rowid allocated for each table with an IPK will be as expected
# by SQLite 3 tests.
#
proc optimize_db {} { 
  #catch { 
    sqlite4_lsm_flush db main 
    sqlite4_lsm_work db main -opt -flush 100000 
    sqlite4_lsm_checkpoint db main
  #}
  return ""
}


# If the library is compiled with the SQLITE4_DEFAULT_AUTOVACUUM macro set
# to non-zero, then set the global variable $AUTOVACUUM to 1.
set AUTOVACUUM $sqlite_options(default_autovacuum)

source $testdir/malloc_common.tcl







|











1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
# a single b-tree structure. Because this annihilates all delete keys,
# the next rowid allocated for each table with an IPK will be as expected
# by SQLite 3 tests.
#
proc optimize_db {} { 
  #catch { 
    sqlite4_lsm_flush db main 
    sqlite4_lsm_work db main -opt 100000 
    sqlite4_lsm_checkpoint db main
  #}
  return ""
}


# If the library is compiled with the SQLITE4_DEFAULT_AUTOVACUUM macro set
# to non-zero, then set the global variable $AUTOVACUUM to 1.
set AUTOVACUUM $sqlite_options(default_autovacuum)

source $testdir/malloc_common.tcl