Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix some minor formatting and code organization issues. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | defrag-opt |
Files: | files | file ages | folders |
SHA1: | eab8706dc47aa0a44caf73619de85839 |
User & Date: | dan 2014-10-24 16:40:49 |
Context
2014-10-24
| ||
18:43 | Fix some issues in the new code on this branch related to the handling of corrupt databases. check-in: 19736dd9 user: dan tags: defrag-opt | |
16:40 | Fix some minor formatting and code organization issues. check-in: eab8706d user: dan tags: defrag-opt | |
2014-10-22
| ||
18:42 | Merge latest trunk with this branch. check-in: 854a54c6 user: dan tags: defrag-opt | |
Changes
Changes to src/btree.c.
1229 1229 ** size. If one can be found, return a pointer to the space and remove it 1230 1230 ** from the free-list. 1231 1231 ** 1232 1232 ** If no suitable space can be found on the free-list, return NULL. 1233 1233 ** 1234 1234 ** This function may detect corruption within pPg. If it does and argument 1235 1235 ** pRc is non-NULL, then *pRc is set to SQLITE_CORRUPT and NULL is returned. 1236 -** Or, if corruption is detected by pRc is NULL, NULL is returned and the 1236 +** Or, if corruption is detected and pRc is NULL, NULL is returned and the 1237 1237 ** corruption goes unreported. 1238 1238 */ 1239 1239 static u8 *pageFindSlot(MemPage *pPg, int nByte, int *pRc){ 1240 1240 const int hdr = pPg->hdrOffset; 1241 1241 u8 * const aData = pPg->aData; 1242 1242 int iAddr; 1243 1243 int pc; ................................................................................ 6341 6341 releasePage(pNew); 6342 6342 } 6343 6343 6344 6344 return rc; 6345 6345 } 6346 6346 #endif /* SQLITE_OMIT_QUICKBALANCE */ 6347 6347 6348 -#if 1 6348 +#if 0 6349 6349 /* 6350 6350 ** This function does not contribute anything to the operation of SQLite. 6351 6351 ** it is sometimes activated temporarily while debugging code responsible 6352 6352 ** for setting pointer-map entries. 6353 6353 */ 6354 6354 static int ptrmapCheckPages(MemPage **apPage, int nPage){ 6355 6355 int i, j; ................................................................................ 6518 6518 int cntNew[NB+2]; /* Index in aCell[] of cell after i-th page */ 6519 6519 int cntOld[NB+2]; /* Old index in aCell[] after i-th page */ 6520 6520 int szNew[NB+2]; /* Combined size of cells place on i-th page */ 6521 6521 u8 **apCell = 0; /* All cells begin balanced */ 6522 6522 u16 *szCell; /* Local size of all cells in apCell[] */ 6523 6523 u8 *aSpace1; /* Space for copies of dividers cells */ 6524 6524 Pgno pgno; /* Temp var to store a page number in */ 6525 - 6526 - u8 abDone[NB+2]; 6527 - Pgno aPgno[NB+2]; 6528 - u16 aPgFlags[NB+2]; 6525 + u8 abDone[NB+2]; /* True after i'th new page is populated */ 6526 + Pgno aPgno[NB+2]; /* Page numbers of new pages before shuffling */ 6527 + u16 aPgFlags[NB+2]; /* flags field of new pages before shuffling */ 6529 6528 6530 6529 memset(abDone, 0, sizeof(abDone)); 6531 6530 pBt = pParent->pBt; 6532 6531 assert( sqlite3_mutex_held(pBt->mutex) ); 6533 6532 assert( sqlite3PagerIswriteable(pParent->pDbPage) ); 6534 6533 6535 6534 #if 0 ................................................................................ 6864 6863 Pgno iPgno = aPgno[j]; 6865 6864 if( iPgno>iGt && (iMin==0 || iPgno<iMin) ){ 6866 6865 iMin = iPgno; 6867 6866 flags = aPgFlags[j]; 6868 6867 } 6869 6868 } 6870 6869 if( apNew[i]->pgno!=iMin ){ 6871 - apNew[i]->pDbPage->flags = flags; 6872 - sqlite3PagerRekey(apNew[i]->pDbPage, iMin); 6870 + sqlite3PagerRekey(apNew[i]->pDbPage, iMin, flags); 6873 6871 apNew[i]->pgno = iMin; 6874 6872 } 6875 6873 } 6876 6874 6877 6875 TRACE(("BALANCE: new: %d(%d nc=%d) %d(%d nc=%d) %d(%d nc=%d) " 6878 6876 "%d(%d nc=%d) %d(%d nc=%d)\n", 6879 6877 apNew[0]->pgno, szNew[0], cntNew[0], ................................................................................ 7086 7084 7087 7085 /* Free any old pages that were not reused as new pages. 7088 7086 */ 7089 7087 for(i=nNew; i<nOld; i++){ 7090 7088 freePage(apOld[i], &rc); 7091 7089 } 7092 7090 7093 -#if 1 7091 +#if 0 7094 7092 if( ISAUTOVACUUM && rc==SQLITE_OK && apNew[0]->isInit ){ 7095 7093 /* The ptrmapCheckPages() contains assert() statements that verify that 7096 7094 ** all pointer map pages are set correctly. This is helpful while 7097 7095 ** debugging. This is usually disabled because a corrupt database may 7098 7096 ** cause an assert() statement to fail. */ 7099 7097 ptrmapCheckPages(apNew, nNew); 7100 7098 ptrmapCheckPages(&pParent, 1);
Changes to src/pager.c.
6841 6841 pPgHdr->flags |= PGHDR_NEED_SYNC; 6842 6842 sqlite3PcacheMakeDirty(pPgHdr); 6843 6843 sqlite3PagerUnrefNotNull(pPgHdr); 6844 6844 } 6845 6845 6846 6846 return SQLITE_OK; 6847 6847 } 6848 +#endif 6848 6849 6849 -void sqlite3PagerRekey(DbPage *pPage, Pgno iNew){ 6850 +/* 6851 +** The page handle passed as the first argument refers to a dirty page 6852 +** with a page number other than iNew. This function changes the page's 6853 +** page number to iNew and sets the value of the PgHdr.flags field to 6854 +** the value passed as the third parameter. 6855 +*/ 6856 +void sqlite3PagerRekey(DbPage *pPage, Pgno iNew, u16 flags){ 6850 6857 PgHdr *pPg = (PgHdr*)pPage; 6851 - assert( pPg->flags & PGHDR_DIRTY ); 6858 + assert( (flags & PGHDR_DIRTY) && (pPg->flags & PGHDR_DIRTY) ); 6852 6859 assert( !subjRequiresPage(pPg) ); 6860 + assert( pPg->pgno!=iNew ); 6861 + pPg->flags = flags; 6853 6862 sqlite3PcacheMove(pPg, iNew); 6854 6863 } 6855 6864 6856 -#endif 6857 - 6858 6865 /* 6859 6866 ** Return a pointer to the data for the specified page. 6860 6867 */ 6861 6868 void *sqlite3PagerGetData(DbPage *pPg){ 6862 6869 assert( pPg->nRef>0 || pPg->pPager->memDb ); 6863 6870 return pPg->pData; 6864 6871 }
Changes to src/pager.h.
184 184 void sqlite3PagerCacheStat(Pager *, int, int, int *); 185 185 void sqlite3PagerClearCache(Pager *); 186 186 int sqlite3SectorSize(sqlite3_file *); 187 187 188 188 /* Functions used to truncate the database file. */ 189 189 void sqlite3PagerTruncateImage(Pager*,Pgno); 190 190 191 -void sqlite3PagerRekey(DbPage*, Pgno); 191 +void sqlite3PagerRekey(DbPage*, Pgno, u16); 192 192 193 193 #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) 194 194 void *sqlite3PagerCodec(DbPage *); 195 195 #endif 196 196 197 197 /* Functions to support testing and debugging. */ 198 198 #if !defined(NDEBUG) || defined(SQLITE_TEST)