]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix for ticket #76: Fix a database corruption that might occur when
authordrh <drh@noemail.net>
Fri, 21 Jun 2002 13:09:16 +0000 (13:09 +0000)
committerdrh <drh@noemail.net>
Fri, 21 Jun 2002 13:09:16 +0000 (13:09 +0000)
dropping tables or indices. (CVS 635)

FossilOrigin-Name: 7936b0325024c81ed8d4bab192d7350d045ec999

manifest
manifest.uuid
src/btree.c

index 0335f782a03d3d8777e26d266c76de3e688382ed..e1f7bd2dfd01c81bcbd92c52109c5324704c69d8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sfor\sticket\s#78:\sAvoid\san\sassertion\sfailure\swhen\ssqlite_close()\sto\sbe\ncalled\sin\sthe\smiddle\sof\sa\stransaction.\s(CVS\s634)
-D 2002-06-21T11:55:49
+C Fix\sfor\sticket\s#76:\sFix\sa\sdatabase\scorruption\sthat\smight\soccur\swhen\ndropping\stables\sor\sindices.\s(CVS\s635)
+D 2002-06-21T13:09:17
 F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c
 F Makefile.template 4e11752e0b5c7a043ca50af4296ec562857ba495
 F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
@@ -18,7 +18,7 @@ F publish.sh d115bd49631e3bb0d799e7dc1da51f9866d67647
 F spec.template 238f7db425a78dc1bb7682e56e3834c7270a3f5e
 F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
 F src/TODO af7f3cab0228e34149cf98e073aa83d45878e7e6
-F src/btree.c 8b86be8f234c1c5dab3186f69cee2544ec9d7257
+F src/btree.c 6aaa67d7eab70c2531dc13e5d9eb87e626c0b4d7
 F src/btree.h 8abeabfe6e0b1a990b64fa457592a6482f6674f3
 F src/build.c 95eac6ce4ae2871388d49066c78dd0657ce40a1f
 F src/delete.c 44c45460b1e03033756e35adc6d569ffbf30b725
@@ -137,7 +137,7 @@ F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f
 F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P d28a2ecc91c0a6d64725887dcf2758f69553eb59
-R 7c501d6833981a37701d9630a4f2a397
+P 2532792a5875f9cc0f7d8eaf90dd49d1f6025ca3
+R 3fe0ffaffb77713981828251190bdd81
 U drh
-Z 04318c7b992ec9784c65132ba98bdc91
+Z 08d058b9c9d8b8b2fa6e6514672f1243
index 33f7bf281d278031c566737e8ba50f2290b6d48e..80ff91e26178efd7b68155ebadf3f5f7aed830d8 100644 (file)
@@ -1 +1 @@
-2532792a5875f9cc0f7d8eaf90dd49d1f6025ca3
\ No newline at end of file
+7936b0325024c81ed8d4bab192d7350d045ec999
\ No newline at end of file
index 6eb5b96cc27633066d420468119aa3b63fe34ecd..f558a455da5353fcbb6dd7ae2478b3942ee4b68d 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.62 2002/06/06 23:16:05 drh Exp $
+** $Id: btree.c,v 1.63 2002/06/21 13:09:17 drh Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** For a detailed discussion of BTrees, refer to
@@ -367,6 +367,7 @@ static void defragmentPage(MemPage *pPage){
   char newPage[SQLITE_PAGE_SIZE];
 
   assert( sqlitepager_iswriteable(pPage) );
+  assert( pPage->isInit );
   pc = sizeof(PageHdr);
   pPage->u.hdr.firstCell = pc;
   memcpy(newPage, pPage->u.aDisk, pc);
@@ -417,6 +418,7 @@ static int allocateSpace(MemPage *pPage, int nByte){
 
   assert( sqlitepager_iswriteable(pPage) );
   assert( nByte==ROUNDUP(nByte) );
+  assert( pPage->isInit );
   if( pPage->nFree<nByte || pPage->isOverfull ) return 0;
   pIdx = &pPage->u.hdr.firstFree;
   p = (FreeBlk*)&pPage->u.aDisk[*pIdx];
@@ -464,6 +466,7 @@ static void freeSpace(MemPage *pPage, int start, int size){
   assert( sqlitepager_iswriteable(pPage) );
   assert( size == ROUNDUP(size) );
   assert( start == ROUNDUP(start) );
+  assert( pPage->isInit );
   pIdx = &pPage->u.hdr.firstFree;
   idx = *pIdx;
   while( idx!=0 && idx<start ){
@@ -1367,6 +1370,7 @@ int sqliteBtreeLast(BtCursor *pCur, int *pRes){
   if( pCur->pPage==0 ) return SQLITE_ABORT;
   rc = moveToRoot(pCur);
   if( rc ) return rc;
+  assert( pCur->pPage->isInit );
   if( pCur->pPage->nCell==0 ){
     *pRes = 1;
     return SQLITE_OK;
@@ -1432,6 +1436,7 @@ int sqliteBtreeMoveto(BtCursor *pCur, const void *pKey, int nKey, int *pRes){
       }
     }
     assert( lwr==upr+1 );
+    assert( pPage->isInit );
     if( lwr>=pPage->nCell ){
       chldPg = pPage->u.hdr.rightChild;
     }else{
@@ -1460,6 +1465,7 @@ int sqliteBtreeNext(BtCursor *pCur, int *pRes){
     if( pRes ) *pRes = 1;
     return SQLITE_ABORT;
   }
+  assert( pCur->pPage->isInit );
   if( pCur->bSkipNext && pCur->idx<pCur->pPage->nCell ){
     pCur->bSkipNext = 0;
     if( pRes ) *pRes = 0;
@@ -1936,6 +1942,7 @@ static int balance(Btree *pBt, MemPage *pPage, BtCursor *pCur){
   if( pParent==0 ){
     Pgno pgnoChild;
     MemPage *pChild;
+    assert( pPage->isInit );
     if( pPage->nCell==0 ){
       if( pPage->u.hdr.rightChild ){
         /*
@@ -1999,6 +2006,7 @@ static int balance(Btree *pBt, MemPage *pPage, BtCursor *pCur){
   }
   rc = sqlitepager_write(pParent);
   if( rc ) return rc;
+  assert( pParent->isInit );
   
   /*
   ** Find the Cell in the parent page whose h.leftChild points back
@@ -2310,6 +2318,7 @@ int sqliteBtreeInsert(
   rc = sqliteBtreeMoveto(pCur, pKey, nKey, &loc);
   if( rc ) return rc;
   pPage = pCur->pPage;
+  assert( pPage->isInit );
   rc = sqlitepager_write(pPage);
   if( rc ) return rc;
   rc = fillInCell(pBt, &newCell, pKey, nKey, pData, nData);
@@ -2349,6 +2358,7 @@ int sqliteBtreeDelete(BtCursor *pCur){
   int rc;
   Pgno pgnoChild;
 
+  assert( pPage->isInit );
   if( pCur->pPage==0 ){
     return SQLITE_ABORT;  /* A rollback destroyed this cursor */
   }
@@ -2468,6 +2478,8 @@ static int clearDatabasePage(Btree *pBt, Pgno pgno, int freePageFlag){
   if( rc ) return rc;
   rc = sqlitepager_write(pPage);
   if( rc ) return rc;
+  rc = initPage(pPage, pgno, 0);
+  if( rc ) return rc;
   idx = pPage->u.hdr.firstCell;
   while( idx>0 ){
     pCell = (Cell*)&pPage->u.aDisk[idx];