mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Make sure the sqlite3BtreePrevious() routine terminates properly if the
table is deleted out from under it. Ticket #2286. This bug was discovered while trying to increase test coverage from 98.5% to 99% - once again showing the value of full coverage testing. (CVS 3818) FossilOrigin-Name: bebf8d2f886ed9fe1b96e4cb11ab3de2f2f7d2c8
This commit is contained in:
27
src/btree.c
27
src/btree.c
@@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.350 2007/04/02 05:07:47 danielk1977 Exp $
|
||||
** $Id: btree.c,v 1.351 2007/04/06 01:03:33 drh Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** For a detailed discussion of BTrees, refer to
|
||||
@@ -3520,6 +3520,14 @@ int sqlite3BtreeNext(BtCursor *pCur, int *pRes){
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
assert( pRes!=0 );
|
||||
pPage = pCur->pPage;
|
||||
if( CURSOR_INVALID==pCur->eState ){
|
||||
*pRes = 1;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_SHARED_CACHE
|
||||
if( pCur->skip>0 ){
|
||||
pCur->skip = 0;
|
||||
*pRes = 0;
|
||||
@@ -3528,12 +3536,6 @@ int sqlite3BtreeNext(BtCursor *pCur, int *pRes){
|
||||
pCur->skip = 0;
|
||||
#endif
|
||||
|
||||
assert( pRes!=0 );
|
||||
pPage = pCur->pPage;
|
||||
if( CURSOR_INVALID==pCur->eState ){
|
||||
*pRes = 1;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
assert( pPage->isInit );
|
||||
assert( pCur->idx<pPage->nCell );
|
||||
|
||||
@@ -3588,6 +3590,12 @@ int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
if( CURSOR_INVALID==pCur->eState ){
|
||||
*pRes = 1;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_SHARED_CACHE
|
||||
if( pCur->skip<0 ){
|
||||
pCur->skip = 0;
|
||||
*pRes = 0;
|
||||
@@ -3596,11 +3604,6 @@ int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){
|
||||
pCur->skip = 0;
|
||||
#endif
|
||||
|
||||
if( CURSOR_INVALID==pCur->eState ){
|
||||
*pRes = 1;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
pPage = pCur->pPage;
|
||||
assert( pPage->isInit );
|
||||
assert( pCur->idx>=0 );
|
||||
|
Reference in New Issue
Block a user