mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
When doing coverage analysis of a btree page for pragma integrity_check,
make the first entry (that covers the header, cell index, and gap) implied, for a performance boost and size reduction. FossilOrigin-Name: e53d497c2d2fbc5014b39f5624b52ce207800698
This commit is contained in:
20
src/btree.c
20
src/btree.c
@@ -8955,7 +8955,7 @@ static int checkTreePage(
|
||||
u32 usableSize; /* Usable size of the page */
|
||||
u32 contentOffset; /* Offset to the start of the cell content area */
|
||||
u32 *heap = 0; /* Min-heap used for checking cell coverage */
|
||||
u32 x, prev = 0;
|
||||
u32 x, prev = 0; /* Next and previous entry on the min-heap */
|
||||
const char *saved_zPfx = pCheck->zPfx;
|
||||
int saved_v1 = pCheck->v1;
|
||||
int saved_v2 = pCheck->v2;
|
||||
@@ -9018,7 +9018,6 @@ static int checkTreePage(
|
||||
** as the other cell checks, so initialize the heap. */
|
||||
heap = pCheck->heap;
|
||||
heap[0] = 0;
|
||||
btreeHeapInsert(heap, contentOffset-1);
|
||||
}
|
||||
|
||||
/* EVIDENCE-OF: R-02776-14802 The cell pointer array consists of K 2-byte
|
||||
@@ -9099,7 +9098,6 @@ static int checkTreePage(
|
||||
if( !pPage->leaf ){
|
||||
heap = pCheck->heap;
|
||||
heap[0] = 0;
|
||||
btreeHeapInsert(heap, contentOffset-1);
|
||||
for(i=nCell-1; i>=0; i--){
|
||||
u32 size;
|
||||
pc = get2byteAligned(&data[cellStart+i*2]);
|
||||
@@ -9133,13 +9131,21 @@ static int checkTreePage(
|
||||
}
|
||||
/* Analyze the min-heap looking for overlap between cells and/or
|
||||
** freeblocks, and counting the number of untracked bytes in nFrag.
|
||||
**
|
||||
** Each min-heap entry is of the form: (start_address<<16)|end_address.
|
||||
** There is an implied first entry the covers the page header, the cell
|
||||
** pointer index, and the gap between the cell pointer index and the start
|
||||
** of cell content.
|
||||
**
|
||||
** The loop below pulls entries from the min-heap in order and compares
|
||||
** the start_address against the previous end_address. If there is an
|
||||
** overlap, that means bytes are used multiple times. If there is a gap,
|
||||
** that gap is added to the fragmentation count.
|
||||
*/
|
||||
nFrag = 0;
|
||||
assert( heap[0]>0 );
|
||||
assert( (heap[1]>>16)==0 );
|
||||
btreeHeapPull(heap,&prev);
|
||||
prev = contentOffset - 1; /* Implied first min-heap entry */
|
||||
while( btreeHeapPull(heap,&x) ){
|
||||
if( (prev&0xffff)+1>(x>>16) ){
|
||||
if( (prev&0xffff)>=(x>>16) ){
|
||||
checkAppendMsg(pCheck,
|
||||
"Multiple uses for byte %u of page %d", x>>16, iPage);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user