mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Fix for ticket #76: Fix a database corruption that might occur when
dropping tables or indices. (CVS 635) FossilOrigin-Name: 7936b0325024c81ed8d4bab192d7350d045ec999
This commit is contained in:
12
manifest
12
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)
|
C Fix\sfor\sticket\s#76:\sFix\sa\sdatabase\scorruption\sthat\smight\soccur\swhen\ndropping\stables\sor\sindices.\s(CVS\s635)
|
||||||
D 2002-06-21T11:55:49
|
D 2002-06-21T13:09:17
|
||||||
F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c
|
F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c
|
||||||
F Makefile.template 4e11752e0b5c7a043ca50af4296ec562857ba495
|
F Makefile.template 4e11752e0b5c7a043ca50af4296ec562857ba495
|
||||||
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
|
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
|
||||||
@@ -18,7 +18,7 @@ F publish.sh d115bd49631e3bb0d799e7dc1da51f9866d67647
|
|||||||
F spec.template 238f7db425a78dc1bb7682e56e3834c7270a3f5e
|
F spec.template 238f7db425a78dc1bb7682e56e3834c7270a3f5e
|
||||||
F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
|
F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
|
||||||
F src/TODO af7f3cab0228e34149cf98e073aa83d45878e7e6
|
F src/TODO af7f3cab0228e34149cf98e073aa83d45878e7e6
|
||||||
F src/btree.c 8b86be8f234c1c5dab3186f69cee2544ec9d7257
|
F src/btree.c 6aaa67d7eab70c2531dc13e5d9eb87e626c0b4d7
|
||||||
F src/btree.h 8abeabfe6e0b1a990b64fa457592a6482f6674f3
|
F src/btree.h 8abeabfe6e0b1a990b64fa457592a6482f6674f3
|
||||||
F src/build.c 95eac6ce4ae2871388d49066c78dd0657ce40a1f
|
F src/build.c 95eac6ce4ae2871388d49066c78dd0657ce40a1f
|
||||||
F src/delete.c 44c45460b1e03033756e35adc6d569ffbf30b725
|
F src/delete.c 44c45460b1e03033756e35adc6d569ffbf30b725
|
||||||
@@ -137,7 +137,7 @@ F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f
|
|||||||
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
|
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
|
||||||
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
|
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
|
||||||
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
||||||
P d28a2ecc91c0a6d64725887dcf2758f69553eb59
|
P 2532792a5875f9cc0f7d8eaf90dd49d1f6025ca3
|
||||||
R 7c501d6833981a37701d9630a4f2a397
|
R 3fe0ffaffb77713981828251190bdd81
|
||||||
U drh
|
U drh
|
||||||
Z 04318c7b992ec9784c65132ba98bdc91
|
Z 08d058b9c9d8b8b2fa6e6514672f1243
|
||||||
|
@@ -1 +1 @@
|
|||||||
2532792a5875f9cc0f7d8eaf90dd49d1f6025ca3
|
7936b0325024c81ed8d4bab192d7350d045ec999
|
14
src/btree.c
14
src/btree.c
@@ -9,7 +9,7 @@
|
|||||||
** May you share freely, never taking more than you give.
|
** 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.
|
** This file implements a external (disk-based) database using BTrees.
|
||||||
** For a detailed discussion of BTrees, refer to
|
** For a detailed discussion of BTrees, refer to
|
||||||
@@ -367,6 +367,7 @@ static void defragmentPage(MemPage *pPage){
|
|||||||
char newPage[SQLITE_PAGE_SIZE];
|
char newPage[SQLITE_PAGE_SIZE];
|
||||||
|
|
||||||
assert( sqlitepager_iswriteable(pPage) );
|
assert( sqlitepager_iswriteable(pPage) );
|
||||||
|
assert( pPage->isInit );
|
||||||
pc = sizeof(PageHdr);
|
pc = sizeof(PageHdr);
|
||||||
pPage->u.hdr.firstCell = pc;
|
pPage->u.hdr.firstCell = pc;
|
||||||
memcpy(newPage, pPage->u.aDisk, pc);
|
memcpy(newPage, pPage->u.aDisk, pc);
|
||||||
@@ -417,6 +418,7 @@ static int allocateSpace(MemPage *pPage, int nByte){
|
|||||||
|
|
||||||
assert( sqlitepager_iswriteable(pPage) );
|
assert( sqlitepager_iswriteable(pPage) );
|
||||||
assert( nByte==ROUNDUP(nByte) );
|
assert( nByte==ROUNDUP(nByte) );
|
||||||
|
assert( pPage->isInit );
|
||||||
if( pPage->nFree<nByte || pPage->isOverfull ) return 0;
|
if( pPage->nFree<nByte || pPage->isOverfull ) return 0;
|
||||||
pIdx = &pPage->u.hdr.firstFree;
|
pIdx = &pPage->u.hdr.firstFree;
|
||||||
p = (FreeBlk*)&pPage->u.aDisk[*pIdx];
|
p = (FreeBlk*)&pPage->u.aDisk[*pIdx];
|
||||||
@@ -464,6 +466,7 @@ static void freeSpace(MemPage *pPage, int start, int size){
|
|||||||
assert( sqlitepager_iswriteable(pPage) );
|
assert( sqlitepager_iswriteable(pPage) );
|
||||||
assert( size == ROUNDUP(size) );
|
assert( size == ROUNDUP(size) );
|
||||||
assert( start == ROUNDUP(start) );
|
assert( start == ROUNDUP(start) );
|
||||||
|
assert( pPage->isInit );
|
||||||
pIdx = &pPage->u.hdr.firstFree;
|
pIdx = &pPage->u.hdr.firstFree;
|
||||||
idx = *pIdx;
|
idx = *pIdx;
|
||||||
while( idx!=0 && idx<start ){
|
while( idx!=0 && idx<start ){
|
||||||
@@ -1367,6 +1370,7 @@ int sqliteBtreeLast(BtCursor *pCur, int *pRes){
|
|||||||
if( pCur->pPage==0 ) return SQLITE_ABORT;
|
if( pCur->pPage==0 ) return SQLITE_ABORT;
|
||||||
rc = moveToRoot(pCur);
|
rc = moveToRoot(pCur);
|
||||||
if( rc ) return rc;
|
if( rc ) return rc;
|
||||||
|
assert( pCur->pPage->isInit );
|
||||||
if( pCur->pPage->nCell==0 ){
|
if( pCur->pPage->nCell==0 ){
|
||||||
*pRes = 1;
|
*pRes = 1;
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
@@ -1432,6 +1436,7 @@ int sqliteBtreeMoveto(BtCursor *pCur, const void *pKey, int nKey, int *pRes){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert( lwr==upr+1 );
|
assert( lwr==upr+1 );
|
||||||
|
assert( pPage->isInit );
|
||||||
if( lwr>=pPage->nCell ){
|
if( lwr>=pPage->nCell ){
|
||||||
chldPg = pPage->u.hdr.rightChild;
|
chldPg = pPage->u.hdr.rightChild;
|
||||||
}else{
|
}else{
|
||||||
@@ -1460,6 +1465,7 @@ int sqliteBtreeNext(BtCursor *pCur, int *pRes){
|
|||||||
if( pRes ) *pRes = 1;
|
if( pRes ) *pRes = 1;
|
||||||
return SQLITE_ABORT;
|
return SQLITE_ABORT;
|
||||||
}
|
}
|
||||||
|
assert( pCur->pPage->isInit );
|
||||||
if( pCur->bSkipNext && pCur->idx<pCur->pPage->nCell ){
|
if( pCur->bSkipNext && pCur->idx<pCur->pPage->nCell ){
|
||||||
pCur->bSkipNext = 0;
|
pCur->bSkipNext = 0;
|
||||||
if( pRes ) *pRes = 0;
|
if( pRes ) *pRes = 0;
|
||||||
@@ -1936,6 +1942,7 @@ static int balance(Btree *pBt, MemPage *pPage, BtCursor *pCur){
|
|||||||
if( pParent==0 ){
|
if( pParent==0 ){
|
||||||
Pgno pgnoChild;
|
Pgno pgnoChild;
|
||||||
MemPage *pChild;
|
MemPage *pChild;
|
||||||
|
assert( pPage->isInit );
|
||||||
if( pPage->nCell==0 ){
|
if( pPage->nCell==0 ){
|
||||||
if( pPage->u.hdr.rightChild ){
|
if( pPage->u.hdr.rightChild ){
|
||||||
/*
|
/*
|
||||||
@@ -1999,6 +2006,7 @@ static int balance(Btree *pBt, MemPage *pPage, BtCursor *pCur){
|
|||||||
}
|
}
|
||||||
rc = sqlitepager_write(pParent);
|
rc = sqlitepager_write(pParent);
|
||||||
if( rc ) return rc;
|
if( rc ) return rc;
|
||||||
|
assert( pParent->isInit );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Find the Cell in the parent page whose h.leftChild points back
|
** Find the Cell in the parent page whose h.leftChild points back
|
||||||
@@ -2310,6 +2318,7 @@ int sqliteBtreeInsert(
|
|||||||
rc = sqliteBtreeMoveto(pCur, pKey, nKey, &loc);
|
rc = sqliteBtreeMoveto(pCur, pKey, nKey, &loc);
|
||||||
if( rc ) return rc;
|
if( rc ) return rc;
|
||||||
pPage = pCur->pPage;
|
pPage = pCur->pPage;
|
||||||
|
assert( pPage->isInit );
|
||||||
rc = sqlitepager_write(pPage);
|
rc = sqlitepager_write(pPage);
|
||||||
if( rc ) return rc;
|
if( rc ) return rc;
|
||||||
rc = fillInCell(pBt, &newCell, pKey, nKey, pData, nData);
|
rc = fillInCell(pBt, &newCell, pKey, nKey, pData, nData);
|
||||||
@@ -2349,6 +2358,7 @@ int sqliteBtreeDelete(BtCursor *pCur){
|
|||||||
int rc;
|
int rc;
|
||||||
Pgno pgnoChild;
|
Pgno pgnoChild;
|
||||||
|
|
||||||
|
assert( pPage->isInit );
|
||||||
if( pCur->pPage==0 ){
|
if( pCur->pPage==0 ){
|
||||||
return SQLITE_ABORT; /* A rollback destroyed this cursor */
|
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;
|
if( rc ) return rc;
|
||||||
rc = sqlitepager_write(pPage);
|
rc = sqlitepager_write(pPage);
|
||||||
if( rc ) return rc;
|
if( rc ) return rc;
|
||||||
|
rc = initPage(pPage, pgno, 0);
|
||||||
|
if( rc ) return rc;
|
||||||
idx = pPage->u.hdr.firstCell;
|
idx = pPage->u.hdr.firstCell;
|
||||||
while( idx>0 ){
|
while( idx>0 ){
|
||||||
pCell = (Cell*)&pPage->u.aDisk[idx];
|
pCell = (Cell*)&pPage->u.aDisk[idx];
|
||||||
|
Reference in New Issue
Block a user