- C Fix\sa\scouple\sof\sunreachable\sbranches.
- D 2015-04-16T20:27:09.079
-C Use\sa\sheap\sinstead\sof\sa\sbitmap\sfor\scell\soverlap\sand\scoverage\stesting\sof\nbtree\spages\sin\sPRAGMA\sintegrity_check.
-D 2015-04-16T11:56:03.678
++C Use\sa\sheap\srather\sthan\sa\sbitmap\sfor\scell\scoverage\sand\soverlap\stesting\son\nbtree\spages\sin\sPRAGMA\sintegrity_check.
++D 2015-04-16T21:57:37.861
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/backup.c ff743689c4d6c5cb55ad42ed9d174b2b3e71f1e3
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79
- F src/btree.c c6e32d84442f79d5b96965265d65b3baa231dffc
-F src/btree.c c0e7a97c1125b7b0791ced5fc7ab82adb1b47861
++F src/btree.c 127aceb71ba93f59bc9c6ba810e992a04299e98a
F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1
F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4
F src/build.c 01b969b20a44a3d9620e597d9af8242348123540
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
- P 55d10baf0bffdb1a34bf5627ed8f25e4a4efd942
- R 114fb2d7e0df7ea2622d3974dda61e5a
-P d3c00d61581c8ba6dce5618391432d3af8d324d4
-R 47f1d98f50d53f3c70bce340530e7599
-T *branch * integrity-check-heap
-T *sym-integrity-check-heap *
-T -sym-trunk *
++P 8f391dffcfe068d48f854784648610d8a86f6bc8 5619c959bf7babb19fd8ba8b228be7f090fe0ce3
++R 72a6fa603587f85ee318933146285087
++T +closed 5619c959bf7babb19fd8ba8b228be7f090fe0ce3
U drh
- Z 08da3cff84a49c68f76471919d394d1c
-Z 60d66e717d835dfb89af877c15f0d57c
++Z e48be2bfe822e32604f22d78d2be1c02
}
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */
-** root element. For element aHeap[N] the daughter nodes are aHeap[N*2]
+ /*
+ ** An implementation of a min-heap.
+ **
+ ** aHeap[0] is the number of elements on the heap. aHeap[1] is the
- while( i>1 && aHeap[j=i/2]>aHeap[i] ){
++** root element. The daughter nodes of aHeap[N] are aHeap[N*2]
+ ** and aHeap[N*2+1].
+ **
+ ** The heap property is this: Every node is less than or equal to both
+ ** of its daughter nodes. A consequence of the heap property is that the
+ ** root node aHeap[1] is always the minimum value current in the heap.
+ **
+ ** The btreeHeapInsert() routine inserts an unsigned 32-bit number onto
+ ** the heap, preserving the heap property. The btreeHeapPull() routine
+ ** removes the root element from the heap (the minimum value in the heap)
+ ** and then move other nodes around as necessary to preserve the heap
+ ** property.
+ **
+ ** This heap is used for cell overlap and coverage testing. Each u32
+ ** entry represents the span of a cell or freeblock on a btree page.
+ ** The upper 16 bits are the index of the first byte of a range and the
+ ** lower 16 bits are the index of the last byte of that range.
+ */
+ static void btreeHeapInsert(u32 *aHeap, u32 x){
+ u32 j, i = ++aHeap[0];
+ aHeap[i] = x;
++ while( (j = i/2)>0 && aHeap[j]>aHeap[i] ){
+ x = aHeap[j];
+ aHeap[j] = aHeap[i];
+ aHeap[i] = x;
+ i = j;
+ }
+ }
+ static int btreeHeapPull(u32 *aHeap, u32 *pOut){
+ u32 j, i, x;
+ if( (x = aHeap[0])==0 ) return 0;
+ *pOut = aHeap[1];
+ aHeap[1] = aHeap[x];
+ aHeap[x] = 0xffffffff;
+ aHeap[0]--;
+ i = 1;
+ while( (j = i*2)<=aHeap[0] ){
+ if( aHeap[j]>aHeap[j+1] ) j++;
+ if( aHeap[i]<aHeap[j] ) break;
+ x = aHeap[i];
+ aHeap[i] = aHeap[j];
+ aHeap[j] = x;
+ i = j;
+ }
+ return 1;
+ }
+
#ifndef SQLITE_OMIT_INTEGRITY_CHECK
/*
** Do various sanity checks on a single page of a tree. Return
u8 *data;
BtShared *pBt;
int usableSize;
- char *hit = 0;
+ u32 *heap = 0;
- u32 x, prev;
++ u32 x, prev = 0;
i64 nMinKey = 0;
i64 nMaxKey = 0;
const char *saved_zPfx = pCheck->zPfx;
** EVIDENCE-OF: R-07161-27322 The one-byte integer at offset 7 gives the
** number of fragmented free bytes within the cell content area.
*/
-- if( cnt!=data[hdr+7] ){
++ if( heap[0]==0 && cnt!=data[hdr+7] ){
checkAppendMsg(pCheck,
"Fragmentation of %d bytes reported as %d on page %d",
cnt, data[hdr+7], iPage);