/ Check-in [27dc5977]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Remove old code to interpret an argument (no longer used) to "PRAGMA checkpoint".
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wal
Files: files | file ages | folders
SHA1: 27dc5977c19e717afd65d3805557e38dec7bedcb
User & Date: dan 2010-04-13 11:56:04
Context
2010-04-13
15:30
Fix an uninitialized variable in readDbPage of pager.c. check-in: f4e1150f user: drh tags: wal
11:56
Remove old code to interpret an argument (no longer used) to "PRAGMA checkpoint". check-in: 27dc5977 user: dan tags: wal
11:45
Fix other problems in the WAL test scripts. check-in: dcb31181 user: dan tags: wal
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/pager.c.

5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){
  return &pPager->pBackup;
}

/*
** This function is called when the user invokes "PRAGMA checkpoint".
*/
int sqlite3PagerCheckpoint(Pager *pPager, int nMin, int nMax, int doSync){
  int rc = SQLITE_OK;
  if( pPager->pLog ){
    rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
    if( rc==SQLITE_OK ){
      u8 *zBuf = (u8 *)pPager->pTmpSpace;
      rc = sqlite3LogCheckpoint(pPager->pLog, pPager->fd, zBuf);
    }
  }
  return rc;
}

#endif /* SQLITE_OMIT_DISKIO */







|












5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){
  return &pPager->pBackup;
}

/*
** This function is called when the user invokes "PRAGMA checkpoint".
*/
int sqlite3PagerCheckpoint(Pager *pPager){
  int rc = SQLITE_OK;
  if( pPager->pLog ){
    rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
    if( rc==SQLITE_OK ){
      u8 *zBuf = (u8 *)pPager->pTmpSpace;
      rc = sqlite3LogCheckpoint(pPager->pLog, pPager->fd, zBuf);
    }
  }
  return rc;
}

#endif /* SQLITE_OMIT_DISKIO */

Changes to src/pager.h.

129
130
131
132
133
134
135

136
137
138
139
140
141
142
int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int);
int sqlite3PagerSync(Pager *pPager);
int sqlite3PagerCommitPhaseTwo(Pager*);
int sqlite3PagerRollback(Pager*);
int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
int sqlite3PagerSharedLock(Pager *pPager);


/* Functions used to query pager state and configuration. */
u8 sqlite3PagerIsreadonly(Pager*);
int sqlite3PagerRefcount(Pager*);
int sqlite3PagerMemUsed(Pager*);
const char *sqlite3PagerFilename(Pager*);
const sqlite3_vfs *sqlite3PagerVfs(Pager*);







>







129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int);
int sqlite3PagerSync(Pager *pPager);
int sqlite3PagerCommitPhaseTwo(Pager*);
int sqlite3PagerRollback(Pager*);
int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
int sqlite3PagerSharedLock(Pager *pPager);
int sqlite3PagerCheckpoint(Pager *pPager);

/* Functions used to query pager state and configuration. */
u8 sqlite3PagerIsreadonly(Pager*);
int sqlite3PagerRefcount(Pager*);
int sqlite3PagerMemUsed(Pager*);
const char *sqlite3PagerFilename(Pager*);
const sqlite3_vfs *sqlite3PagerVfs(Pager*);

Changes to src/pragma.c.

1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
      sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zOpt, 0);
      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
    }
  }else
#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */

  if( sqlite3StrICmp(zLeft, "checkpoint")==0 ){
    int nMin = 0;
    int nMax = 0;
    int nosync = 0;

    if( zRight ){
      char *z = zRight;
      sqlite3GetInt32(z, &nMin);
      while( sqlite3Isdigit(*z) ) z++;
      while( *z && !sqlite3Isdigit(*z) ) z++;
      sqlite3GetInt32(z, &nMax);
      while( sqlite3Isdigit(*z) ) z++;
      while( *z && !sqlite3Isdigit(*z) ) z++;
      sqlite3GetInt32(z, &nosync);
    }
    sqlite3VdbeUsesBtree(v, iDb);
    sqlite3VdbeAddOp2(v, OP_Transaction, iDb, 1);
    sqlite3VdbeAddOp3(v, OP_Checkpoint, iDb, nMin, nMax);
  }else

#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
  /*
  ** Report the current state of file logs for all databases
  */
  if( sqlite3StrICmp(zLeft, "lock_status")==0 ){







<
<
<
<
<
<
<
<
<
<
<
<
<
<


|







1381
1382
1383
1384
1385
1386
1387














1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
      sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zOpt, 0);
      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
    }
  }else
#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */

  if( sqlite3StrICmp(zLeft, "checkpoint")==0 ){














    sqlite3VdbeUsesBtree(v, iDb);
    sqlite3VdbeAddOp2(v, OP_Transaction, iDb, 1);
    sqlite3VdbeAddOp3(v, OP_Checkpoint, iDb, 0, 0);
  }else

#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
  /*
  ** Report the current state of file logs for all databases
  */
  if( sqlite3StrICmp(zLeft, "lock_status")==0 ){

Changes to src/vdbe.c.

5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
  UPDATE_MAX_BLOBSIZE(pMem);
  if( sqlite3VdbeMemTooBig(pMem) ){
    goto too_big;
  }
  break;
}

/* Opcode: Checkpoint P1 P2 P3 * P5
*/
case OP_Checkpoint: {
  Btree *pBt;                     /* Btree to checkpoint */
  int nMin = pOp->p2;             /* Minimum number of pages to copy */
  int nMax = pOp->p3;             /* Maximum number of pages to copy */
  int doNotSync = pOp->p5;        /* True to sync database */

  assert( pOp->p1>=0 && pOp->p1<db->nDb );
  assert( (p->btreeMask & (1<<pOp->p1))!=0 );
  pBt = db->aDb[pOp->p1].pBt;

  rc = sqlite3PagerCheckpoint(sqlite3BtreePager(pBt), nMin, nMax, !doNotSync);
  break;
};  

#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)
/* Opcode: Vacuum * * * * *
**
** Vacuum the entire database.  This opcode will cause other virtual







|



<
<
<




<
|







5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192



5193
5194
5195
5196

5197
5198
5199
5200
5201
5202
5203
5204
  UPDATE_MAX_BLOBSIZE(pMem);
  if( sqlite3VdbeMemTooBig(pMem) ){
    goto too_big;
  }
  break;
}

/* Opcode: Checkpoint P1 * * * *
*/
case OP_Checkpoint: {
  Btree *pBt;                     /* Btree to checkpoint */




  assert( pOp->p1>=0 && pOp->p1<db->nDb );
  assert( (p->btreeMask & (1<<pOp->p1))!=0 );
  pBt = db->aDb[pOp->p1].pBt;

  rc = sqlite3PagerCheckpoint(sqlite3BtreePager(pBt));
  break;
};  

#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)
/* Opcode: Vacuum * * * * *
**
** Vacuum the entire database.  This opcode will cause other virtual

Changes to test/wal.test.

510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
    PRAGMA checkpoint;
  }
  file size test.db
} [expr 68*1024]
do_test wal-12.3 {
  execsql { 
    DELETE FROM t1 WHERE rowid<54;
    PRAGMA checkpoint('1 100000');
  }
  file size test.db
} [expr 14*1024]

# Run some "warm-body" tests to ensure that log-summary files with more
# than 256 entries (log summaries that contain index blocks) work Ok.
#







|







510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
    PRAGMA checkpoint;
  }
  file size test.db
} [expr 68*1024]
do_test wal-12.3 {
  execsql { 
    DELETE FROM t1 WHERE rowid<54;
    PRAGMA checkpoint;
  }
  file size test.db
} [expr 14*1024]

# Run some "warm-body" tests to ensure that log-summary files with more
# than 256 entries (log summaries that contain index blocks) work Ok.
#

Changes to test/walcrash.test.

187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 12 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 16 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 20 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 24 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 28 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 32 */

      PRAGMA checkpoint('70 70');
      INSERT INTO t1 VALUES(randomblob(900));
      INSERT INTO t1 VALUES(randomblob(900));
      INSERT INTO t1 VALUES(randomblob(900));
    }
  } {1 {child process exited abnormally}}

  do_test walcrash-5.$i.2 {
................................................................................
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 12 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 16 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 20 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 24 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 28 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 32 */

      PRAGMA checkpoint('70 70');
      INSERT INTO t1 VALUES(randomblob(900));
      INSERT INTO t1 VALUES(randomblob(900));
      INSERT INTO t1 VALUES(randomblob(900));
    }
  } {1 {child process exited abnormally}}

  do_test walcrash-6.$i.2 {







|







 







|







187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 12 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 16 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 20 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 24 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 28 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 32 */

      PRAGMA checkpoint;
      INSERT INTO t1 VALUES(randomblob(900));
      INSERT INTO t1 VALUES(randomblob(900));
      INSERT INTO t1 VALUES(randomblob(900));
    }
  } {1 {child process exited abnormally}}

  do_test walcrash-5.$i.2 {
................................................................................
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 12 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 16 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 20 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 24 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 28 */
      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 32 */

      PRAGMA checkpoint;
      INSERT INTO t1 VALUES(randomblob(900));
      INSERT INTO t1 VALUES(randomblob(900));
      INSERT INTO t1 VALUES(randomblob(900));
    }
  } {1 {child process exited abnormally}}

  do_test walcrash-6.$i.2 {

Changes to test/walslow.test.

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  } {}

  for {set iTest 1} {$iTest < 100} {incr iTest} {

    do_test walslow-1.seed=$seed.$iTest.1 {
      set w [expr int(rand()*2000)]
      set x [expr int(rand()*2000)]
      set y [expr int(rand()*9)+1]
      set z [expr int(rand()*2)]
      execsql { INSERT INTO t1 VALUES(randomblob($w), randomblob($x)) }
      execsql { PRAGMA integrity_check }
    } {ok}

    do_test walslow-1.seed=$seed.$iTest.2 {
      execsql "PRAGMA checkpoint('$y $y $z')"
      execsql { PRAGMA integrity_check }
    } {ok}

    do_test walslow-1.seed=$seed.$iTest.3 {
      file delete -force testX.db testX.db-wal
      file copy test.db testX.db
      file copy test.db-wal testX.db-wal







<
<





|







37
38
39
40
41
42
43


44
45
46
47
48
49
50
51
52
53
54
55
56
  } {}

  for {set iTest 1} {$iTest < 100} {incr iTest} {

    do_test walslow-1.seed=$seed.$iTest.1 {
      set w [expr int(rand()*2000)]
      set x [expr int(rand()*2000)]


      execsql { INSERT INTO t1 VALUES(randomblob($w), randomblob($x)) }
      execsql { PRAGMA integrity_check }
    } {ok}

    do_test walslow-1.seed=$seed.$iTest.2 {
      execsql "PRAGMA checkpoint;"
      execsql { PRAGMA integrity_check }
    } {ok}

    do_test walslow-1.seed=$seed.$iTest.3 {
      file delete -force testX.db testX.db-wal
      file copy test.db testX.db
      file copy test.db-wal testX.db-wal

Changes to test/walthread.test.

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
    dosql $DB "INSERT INTO t1 VALUES(randomblob(100))"
    dosql $DB "INSERT INTO t1 SELECT md5sum(x) FROM t1"
    dosql $DB COMMIT
  }

  proc checkpointer {DB} {
    while { !$::finished } {
      dosql $DB "PRAGMA checkpoint(32)"
      rest 1000
    }
  }

  proc worker {DB N} {
    set j 0
    while { !$::finished } {







|







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
    dosql $DB "INSERT INTO t1 VALUES(randomblob(100))"
    dosql $DB "INSERT INTO t1 SELECT md5sum(x) FROM t1"
    dosql $DB COMMIT
  }

  proc checkpointer {DB} {
    while { !$::finished } {
      dosql $DB "PRAGMA checkpoint"
      rest 1000
    }
  }

  proc worker {DB N} {
    set j 0
    while { !$::finished } {