Index: src/btree.c ================================================================== --- src/btree.c +++ src/btree.c @@ -3904,12 +3904,12 @@ ** pages (iFirst..MIN(nPage,nHPage)) to (MAX(nPage,nHPage)+1). */ Pgno iLast = MIN(nPage, nHPage); /* Last page to move */ Pgno iPg; Pgno nCurrent; /* Current size of db */ - nCurrent = MAX(nPage, nHPage); + for(iPg=pMap->iFirst; iPg<=iLast && rc==SQLITE_OK; iPg++){ MemPage *pPg = 0; Pgno iNew; /* New page number for pPg */ PtrmapEntry *pEntry; /* Pointer map entry for page iPg */ Index: src/main.c ================================================================== --- src/main.c +++ src/main.c @@ -2742,11 +2742,10 @@ assert( sizeof(db->aLimit)==sizeof(aHardLimit) ); memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit)); db->aLimit[SQLITE_LIMIT_WORKER_THREADS] = SQLITE_DEFAULT_WORKER_THREADS; db->autoCommit = 1; - db->bUnlocked = 0; db->nextAutovac = -1; db->szMmap = sqlite3GlobalConfig.szMmap; db->nextPagesize = 0; db->nMaxSorterMmap = 0x7FFFFFFF; db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger | SQLITE_CacheSpill Index: src/pager.c ================================================================== --- src/pager.c +++ src/pager.c @@ -5629,12 +5629,10 @@ rc = sqlite3WalBeginWriteTransaction(pPager->pWal); }else{ pPager->pAllRead = sqlite3BitvecCreate(pPager->dbSize); if( pPager->pAllRead==0 ){ rc = SQLITE_NOMEM; - }else{ - rc = sqlite3BitvecSet(pPager->pAllRead, 1); } } }else{ /* Obtain a RESERVED lock on the database file. If the exFlag parameter ** is true, then immediately upgrade this to an EXCLUSIVE lock. The @@ -6153,12 +6151,11 @@ sqlite3WalEndWriteTransaction(pPager->pWal); } } /* -** Return true if this is a WAL database and snapshot upgrade is required -** before the current transaction can be committed. +** Return true if this pager is currently within an UNLOCKED transaction. */ int sqlite3PagerIsUnlocked(Pager *pPager){ return pPager->pAllRead!=0; } Index: src/pager.h ================================================================== --- src/pager.h +++ src/pager.h @@ -143,11 +143,10 @@ void sqlite3PagerDontWrite(DbPage*); int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); int sqlite3PagerPageRefcount(DbPage*); void *sqlite3PagerGetData(DbPage *); void *sqlite3PagerGetExtra(DbPage *); -int sqlite3PagerIsDirty(DbPage*); /* Functions used to manage pager transactions and savepoints. */ void sqlite3PagerPagecount(Pager*, int*); int sqlite3PagerBegin(Pager*, int exFlag, int); int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int); @@ -157,12 +156,10 @@ int sqlite3PagerRollback(Pager*); int sqlite3PagerOpenSavepoint(Pager *pPager, int n); int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); int sqlite3PagerSharedLock(Pager *pPager); -void sqlite3PagerDropExclusiveLock(Pager*); -int sqlite3PagerIsUnlocked(Pager*); #ifndef SQLITE_OMIT_WAL int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*); int sqlite3PagerWalSupported(Pager *pPager); int sqlite3PagerWalCallback(Pager *pPager); @@ -195,10 +192,12 @@ /* Functions used to truncate the database file. */ void sqlite3PagerTruncateImage(Pager*,Pgno); void sqlite3PagerRekey(DbPage*, Pgno, u16); +void sqlite3PagerDropExclusiveLock(Pager*); +int sqlite3PagerIsUnlocked(Pager*); int sqlite3PagerIswriteable(DbPage*); int sqlite3PagerUpgradeSnapshot(Pager *pPager, DbPage*); void sqlite3PagerSetDbsize(Pager *pPager, Pgno); #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) Index: src/vacuum.c ================================================================== --- src/vacuum.c +++ src/vacuum.c @@ -354,11 +354,11 @@ ** by manually setting the autoCommit flag to true and detaching the ** vacuum database. The vacuum_db journal file is deleted when the pager ** is closed by the DETACH. */ db->autoCommit = 1; - db->bUnlocked = 0; + assert( db->bUnlocked==0 ); if( pDb ){ sqlite3BtreeClose(pDb->pBt); pDb->pBt = 0; pDb->pSchema = 0; Index: src/vdbeaux.c ================================================================== --- src/vdbeaux.c +++ src/vdbeaux.c @@ -2569,11 +2569,11 @@ if( db->autoCommit ){ sqlite3ConnectionUnlocked(db); } assert( db->nVdbeActive>0 || db->autoCommit==0 || db->nStatement==0 ); - return ((p->rc & 0xFF)==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK); + return (p->rc==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK); } /* ** Each VDBE holds the result of the most recent sqlite3_step() call Index: src/wal.c ================================================================== --- src/wal.c +++ src/wal.c @@ -2669,29 +2669,10 @@ void sqlite3WalUpgradeSnapshot(Wal *pWal){ assert( pWal->writeLock ); memcpy(&pWal->hdr, (void*)walIndexHdr(pWal), sizeof(WalIndexHdr)); } -/* -** This function is only ever called while committing an UNLOCKED -** transaction, after the caller has already obtained the WRITER lock -** (by calling the sqlite3WalLockForCommit() routine). This function -** returns true if the transaction was prepared against a database -** snapshot older than the current head of the wal file. -** -** Note that this will only work as described if the database is -** currently executing an UNLOCKED transaction, as it assumes that -** pWal->hdr has not been modified since the beginning of the -** transaction. This may not be true for a non-UNLOCKED transaction, -** as pWal->hdr is updated if any pages are spilled to the wal file -** while the transaction is executing. -*/ -int sqlite3WalCommitRequiresUpgrade(Wal *pWal){ - assert( pWal->writeLock ); - return memcmp(&pWal->hdr, (void*)walIndexHdr(pWal), sizeof(WalIndexHdr))!=0; -} - /* ** End a write transaction. The commit has already been done. This ** routine merely releases the lock. */ int sqlite3WalEndWriteTransaction(Wal *pWal){ Index: src/wal.h ================================================================== --- src/wal.h +++ src/wal.h @@ -124,13 +124,11 @@ ** heap-memory for the wal-index. Otherwise, if the argument is NULL or the ** WAL module is using shared-memory, return false. */ int sqlite3WalHeapMemory(Wal *pWal); -/* Return true if the WRITER lock is held. False otherwise. */ int sqlite3WalLockForCommit(Wal *pWal, PgHdr *pPg, Bitvec *pRead); -int sqlite3WalCommitRequiresUpgrade(Wal *pWal); void sqlite3WalUpgradeSnapshot(Wal *pWal); #ifdef SQLITE_ENABLE_ZIPVFS /* If the WAL file is not empty, return the number of bytes of content ** stored in each frame (i.e. the db page-size when the WAL was created).