Index: src/pragma.c ================================================================== --- src/pragma.c +++ src/pragma.c @@ -9,11 +9,11 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** -** $Id: pragma.c,v 1.152 2007/12/13 21:54:11 drh Exp $ +** $Id: pragma.c,v 1.153 2007/12/29 13:39:20 danielk1977 Exp $ */ #include "sqliteInt.h" #include /* Ignore this whole file if pragmas are disabled @@ -813,11 +813,17 @@ #ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX # define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100 #endif #ifndef SQLITE_OMIT_INTEGRITY_CHECK - if( sqlite3StrICmp(zLeft, "integrity_check")==0 ){ + /* Pragma "quick_check" is an experimental reduced version of + ** integrity_check designed to detect most database corruption + ** without most of the overhead of a full integrity-check. + */ + if( sqlite3StrICmp(zLeft, "integrity_check")==0 + || sqlite3StrICmp(zLeft, "quick_check")==0 + ){ int i, j, addr, mxErr; /* Code that appears at the end of the integrity check. If no error ** messages have been generated, output OK. Otherwise output the ** error message @@ -827,10 +833,12 @@ { OP_Integer, 0, 0, 0}, { OP_Ne, 0, 0, 0}, /* 2 */ { OP_String8, 0, 0, "ok"}, { OP_Callback, 1, 0, 0}, }; + + int isQuick = (zLeft[0]=='q'); /* Initialize the VDBE program */ if( sqlite3ReadSchema(pParse) ) goto pragma_out; sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "integrity_check", P3_STATIC); @@ -882,11 +890,11 @@ sqlite3VdbeAddOp(v, OP_Callback, 1, 0); sqlite3VdbeJumpHere(v, addr); /* Make sure all the indices are constructed correctly. */ - for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ + for(x=sqliteHashFirst(pTbls); x && !isQuick; x=sqliteHashNext(x)){ Table *pTab = sqliteHashData(x); Index *pIdx; int loopTop; if( pTab->pIndex==0 ) continue; Index: test/pragma.test ================================================================== --- test/pragma.test +++ test/pragma.test @@ -10,11 +10,11 @@ #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the PRAGMA command. # -# $Id: pragma.test,v 1.55 2007/10/09 08:29:33 danielk1977 Exp $ +# $Id: pragma.test,v 1.56 2007/12/29 13:39:21 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Test organization: @@ -313,10 +313,13 @@ close $in close $out execsql {REINDEX t2} execsql {PRAGMA integrity_check} } {ok} + do_test pragma-3.8.1 { + execsql {PRAGMA quick_check} + } {ok} do_test pragma-3.9 { execsql { ATTACH 'testerr.db' AS t2; PRAGMA integrity_check }