1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Add an sqlite3FaultSim() to make an OOM case more accessible and remove

the ALWAYS() on the conditional that is false when the OOM actually occurs.

FossilOrigin-Name: 2a251af84ff1f5ca281aa69c5410d6ae7aa5a85ef47149909a297525e1651e9d
This commit is contained in:
drh
2020-07-28 17:17:36 +00:00
parent f31230af12
commit e7f3edcd49
3 changed files with 11 additions and 9 deletions

View File

@@ -590,7 +590,9 @@ static SQLITE_NOINLINE int walIndexPageRealloc(
);
assert( pWal->apWiData[iPage]!=0 || rc!=SQLITE_OK || pWal->writeLock==0 );
testcase( pWal->apWiData[iPage]==0 && rc==SQLITE_OK );
if( (rc&0xff)==SQLITE_READONLY ){
if( rc==SQLITE_OK ){
if( iPage>0 && sqlite3FaultSim(600) ) rc = SQLITE_NOMEM;
}else if( (rc&0xff)==SQLITE_READONLY ){
pWal->readOnly |= WAL_SHM_RDONLY;
if( rc==SQLITE_READONLY ){
rc = SQLITE_OK;
@@ -1062,7 +1064,7 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
/* Assuming the wal-index file was successfully mapped, populate the
** page number array and hash table entry.
*/
if( ALWAYS(rc==SQLITE_OK) ){
if( rc==SQLITE_OK ){
int iKey; /* Hash table key */
int idx; /* Value to write to hash-table slot */
int nCollide; /* Number of hash collisions */