mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Have "PRAGMA quick_check" compare the number of entries in tables and indexes.
FossilOrigin-Name: b736519d3d2e93c76fa36253143f2664b9dd12e26acba555f0bf9c4d44705499
This commit is contained in:
23
src/btree.c
23
src/btree.c
@@ -10800,6 +10800,9 @@ static int checkTreePage(
|
||||
** number of cells on the page. */
|
||||
nCell = get2byte(&data[hdr+3]);
|
||||
assert( pPage->nCell==nCell );
|
||||
if( pPage->leaf || pPage->intKey==0 ){
|
||||
pCheck->nRow += nCell;
|
||||
}
|
||||
|
||||
/* EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page
|
||||
** immediately follows the b-tree page header. */
|
||||
@@ -11010,6 +11013,7 @@ int sqlite3BtreeIntegrityCheck(
|
||||
sqlite3 *db, /* Database connection that is running the check */
|
||||
Btree *p, /* The btree to be checked */
|
||||
Pgno *aRoot, /* An array of root pages numbers for individual trees */
|
||||
Mem *aCnt, /* Memory cells to write counts for each tree to */
|
||||
int nRoot, /* Number of entries in aRoot[] */
|
||||
int mxErr, /* Stop reporting errors after this many */
|
||||
int *pnErr, /* OUT: Write number of errors seen to this variable */
|
||||
@@ -11096,15 +11100,20 @@ int sqlite3BtreeIntegrityCheck(
|
||||
testcase( pBt->db->flags & SQLITE_CellSizeCk );
|
||||
pBt->db->flags &= ~(u64)SQLITE_CellSizeCk;
|
||||
for(i=0; (int)i<nRoot && sCheck.mxErr; i++){
|
||||
i64 notUsed;
|
||||
if( aRoot[i]==0 ) continue;
|
||||
sCheck.nRow = 0;
|
||||
if( aRoot[i] && sCheck.mxErr ){
|
||||
i64 notUsed;
|
||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||
if( pBt->autoVacuum && aRoot[i]>1 && !bPartial ){
|
||||
checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0);
|
||||
}
|
||||
if( pBt->autoVacuum && aRoot[i]>1 && !bPartial ){
|
||||
checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0);
|
||||
}
|
||||
#endif
|
||||
sCheck.v0 = aRoot[i];
|
||||
checkTreePage(&sCheck, aRoot[i], ¬Used, LARGEST_INT64);
|
||||
sCheck.v0 = aRoot[i];
|
||||
checkTreePage(&sCheck, aRoot[i], ¬Used, LARGEST_INT64);
|
||||
}
|
||||
if( aCnt ){
|
||||
sqlite3MemSetArrayInt64(aCnt, i, sCheck.nRow);
|
||||
}
|
||||
}
|
||||
pBt->db->flags = savedDbFlags;
|
||||
|
||||
|
Reference in New Issue
Block a user