/ Check-in [2ddc8d72]
Login

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

Overview
Comment:Add experimental pragma "quick_check", a reduced version of integrity_check that runs without most of the overhead of the full integrity_check. (CVS 4645)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2ddc8d72723e5a294e850491fcd9c1fb7474a9c3
User & Date: danielk1977 2007-12-29 13:39:20
Context
2007-12-30
23:29
move variable declaration to be able to compile sqlite3_mutex_alloc() with older compilers (like EMX/gcc 2.8.1) (CVS 4646) check-in: a568a9cf user: pweilbacher tags: trunk
2007-12-29
13:39
Add experimental pragma "quick_check", a reduced version of integrity_check that runs without most of the overhead of the full integrity_check. (CVS 4645) check-in: 2ddc8d72 user: danielk1977 tags: trunk
13:18
Mem3.c enhanced so that an allocation of N bytes only requires (N+11)&~7 bytes instead of (N+15)&~7 bytes of heap storage. Minimum heap usage per allocation is still 16 bytes. 8-byte alignment is preserved. (CVS 4644) check-in: d027f91c user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pragma.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the PRAGMA command.
    13     13   **
    14         -** $Id: pragma.c,v 1.152 2007/12/13 21:54:11 drh Exp $
           14  +** $Id: pragma.c,v 1.153 2007/12/29 13:39:20 danielk1977 Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include <ctype.h>
    18     18   
    19     19   /* Ignore this whole file if pragmas are disabled
    20     20   */
    21     21   #if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER)
................................................................................
   811    811     }else
   812    812   
   813    813   #ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX
   814    814   # define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100
   815    815   #endif
   816    816   
   817    817   #ifndef SQLITE_OMIT_INTEGRITY_CHECK
   818         -  if( sqlite3StrICmp(zLeft, "integrity_check")==0 ){
          818  +  /* Pragma "quick_check" is an experimental reduced version of 
          819  +  ** integrity_check designed to detect most database corruption
          820  +  ** without most of the overhead of a full integrity-check.
          821  +  */
          822  +  if( sqlite3StrICmp(zLeft, "integrity_check")==0
          823  +   || sqlite3StrICmp(zLeft, "quick_check")==0 
          824  +  ){
   819    825       int i, j, addr, mxErr;
   820    826   
   821    827       /* Code that appears at the end of the integrity check.  If no error
   822    828       ** messages have been generated, output OK.  Otherwise output the
   823    829       ** error message
   824    830       */
   825    831       static const VdbeOpList endCode[] = {
   826    832         { OP_MemLoad,     0, 0,        0},
   827    833         { OP_Integer,     0, 0,        0},
   828    834         { OP_Ne,          0, 0,        0},    /* 2 */
   829    835         { OP_String8,     0, 0,        "ok"},
   830    836         { OP_Callback,    1, 0,        0},
   831    837       };
          838  +
          839  +    int isQuick = (zLeft[0]=='q');
   832    840   
   833    841       /* Initialize the VDBE program */
   834    842       if( sqlite3ReadSchema(pParse) ) goto pragma_out;
   835    843       sqlite3VdbeSetNumCols(v, 1);
   836    844       sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "integrity_check", P3_STATIC);
   837    845   
   838    846       /* Set the maximum error count */
................................................................................
   880    888         sqlite3VdbeAddOp(v, OP_Pull, 1, 0);
   881    889         sqlite3VdbeAddOp(v, OP_Concat, 0, 0);
   882    890         sqlite3VdbeAddOp(v, OP_Callback, 1, 0);
   883    891         sqlite3VdbeJumpHere(v, addr);
   884    892   
   885    893         /* Make sure all the indices are constructed correctly.
   886    894         */
   887         -      for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
          895  +      for(x=sqliteHashFirst(pTbls); x && !isQuick; x=sqliteHashNext(x)){
   888    896           Table *pTab = sqliteHashData(x);
   889    897           Index *pIdx;
   890    898           int loopTop;
   891    899   
   892    900           if( pTab->pIndex==0 ) continue;
   893    901           addr = sqlite3VdbeAddOp(v, OP_IfMemPos, 0, 0);
   894    902           sqlite3VdbeAddOp(v, OP_Halt, 0, 0);

Changes to test/pragma.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for the PRAGMA command.
    14     14   #
    15         -# $Id: pragma.test,v 1.55 2007/10/09 08:29:33 danielk1977 Exp $
           15  +# $Id: pragma.test,v 1.56 2007/12/29 13:39:21 danielk1977 Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Test organization:
    21     21   #
    22     22   # pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
................................................................................
   311    311         seek $in 0
   312    312         puts -nonewline $out [read $in]
   313    313         close $in
   314    314         close $out
   315    315         execsql {REINDEX t2}
   316    316         execsql {PRAGMA integrity_check}
   317    317       } {ok}
          318  +    do_test pragma-3.8.1 {
          319  +      execsql {PRAGMA quick_check}
          320  +    } {ok}
   318    321       do_test pragma-3.9 {
   319    322         execsql {
   320    323           ATTACH 'testerr.db' AS t2;
   321    324           PRAGMA integrity_check
   322    325         }
   323    326       } {{*** in database t2 ***
   324    327   Page 4 is never used