]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improvements to comments in btree.c:freeSpace(). Added a testcase() macro
authordrh <drh@noemail.net>
Wed, 8 Jul 2009 16:54:40 +0000 (16:54 +0000)
committerdrh <drh@noemail.net>
Wed, 8 Jul 2009 16:54:40 +0000 (16:54 +0000)
to verify a boundary case is tested in sqlite3BtreeInitPage(). (CVS 6862)

FossilOrigin-Name: 5ac991b3cea214095b8369e85f3e0ad8e5059ad6

manifest
manifest.uuid
src/btree.c

index 64587835de646bb4d38f9c0bde3aba15cfb9c630..eebce2498fe5f3f0f24ad7294b9771cda443323c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Comment\sout\ssqlite3BtreeFlags()\swhen\snot\sin\sdebug\smode.\s\sTweaks\sto\ndatabase\scorruption\sdetection\slogic\sin\sfreeSpace().\s(CVS\s6861)
-D 2009-07-08T15:14:50
+C Improvements\sto\scomments\sin\sbtree.c:freeSpace().\s\sAdded\sa\stestcase()\smacro\nto\sverify\sa\sboundary\scase\sis\stested\sin\ssqlite3BtreeInitPage().\s(CVS\s6862)
+D 2009-07-08T16:54:40
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -106,7 +106,7 @@ F src/auth.c 802a9439dfa0b8c208b10055cba400e82ef18025
 F src/backup.c 6f1c2d9862c8a3feb7739dfcca02c1f5352e37f3
 F src/bitvec.c 0ef0651714728055d43de7a4cdd95e703fac0119
 F src/btmutex.c 9b899c0d8df3bd68f527b0afe03088321b696d3c
-F src/btree.c e95997f1c9a54562b9f99d5cfa0e3acdd88fd514
+F src/btree.c 88efb67b8816b6e773cfc824916a4a1df1178715
 F src/btree.h e761619e76a1125d2d82bd3613b5a7ac7d1ee6f7
 F src/btreeInt.h b31e5ac04181c7e2892c33ab06228c551df6233c
 F src/build.c 867028ee9f63f7bc8eb8d4a720bb98cf9b9a12b4
@@ -740,7 +740,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P 86eba4f16fd9e97344ab6dfb9cb9a85cf14751dd
-R 77bdafcdba4dd2c5e2b38b3389f64b9d
+P 196cbf82290a308e78b13044d0fae993f2d5cb90
+R a273a9df3f7120ba57b67913a5610fd6
 U drh
-Z 8aa5344ef6ac6101e28f4ec787507ab1
+Z b118b571b45c65757687df0def85d091
index 15d0ecd77952e65ac51ef3ede6f8df9f6017a546..1bc0478ed5c58fc3eeb5f34add7b536e27b02b87 100644 (file)
@@ -1 +1 @@
-196cbf82290a308e78b13044d0fae993f2d5cb90
\ No newline at end of file
+5ac991b3cea214095b8369e85f3e0ad8e5059ad6
\ No newline at end of file
index 51136b95cb95b849f70a0769667ce40f11ae979b..e466a5a5acdb4240904ea93272970c31c75f0e3a 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.661 2009/07/08 15:14:50 drh Exp $
+** $Id: btree.c,v 1.662 2009/07/08 16:54:40 drh Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** See the header comment on "btreeInt.h" for additional information.
@@ -1206,10 +1206,12 @@ static int freeSpace(MemPage *pPage, int start, int size){
 
   /* Add the space back into the linked list of freeblocks.  Note that
   ** even though the freeblock list was checked by sqlite3BtreeInitPage(),
-  ** sqlite3BtreeInitPage() did not detect overlapping freeblocks or
-  ** freeblocks that overlapped cells.  If there was overlap then
-  ** subsequent insert operations might have corrupted the freelist.
-  ** So we do need to check for corruption while scanning the freelist.
+  ** sqlite3BtreeInitPage() did not detect overlapping cells or
+  ** freeblocks that overlapped cells.   Nor does it detect when the
+  ** cell content area exceeds the value in the page header.  If these
+  ** situations arise, then subsequent insert operations might corrupt
+  ** the freelist.  So we do need to check for corruption while scanning
+  ** the freelist.
   */
   hdr = pPage->hdrOffset;
   addr = hdr + 1;
@@ -1347,6 +1349,7 @@ int sqlite3BtreeInitPage(MemPage *pPage){
       /* To many cells for a single page.  The page must be corrupt */
       return SQLITE_CORRUPT_BKPT;
     }
+    testcase( pPage->nCell==MX_CELL(pBt) );
 
     /* A malformed database page might cause use to read past the end
     ** of page when parsing a cell.