-C Make\ssure\sthat\swhen\sa\sCREATE\sINDEX\sfails,\sit\sdoes\snot\sleave\sa\sresidue\sbehind\nthat\scan\scorrupt\sthe\sdatabase.\s\sTicket\s#1115.\s(CVS\s2330)
-D 2005-02-14T20:48:19
+C Check\sthat\sread-only\spages\sare\snot\sbeing\smodified\s(disabled\sby\sdefault).\s(CVS\s2331)
+D 2005-02-15T02:54:15
F Makefile.in d928187101fa3d78426cf48ca30e39d0fb714e57
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
F src/os_unix.h f3097815e041e82e24d92505e1ff61ba24172d13
F src/os_win.c bddeae1c3299be0fbe47077dd4e98b786a067f71
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c d0c1f41b41d2b56a6fd0e1308a66518872f68ed5
+F src/pager.c 69efe972d6034d8d5603f5b2a768e43e25dad0c0
F src/pager.h 70d496f372163abb6340f474288c4bb9ea962cf7
F src/parse.y 450fc9c4d5a737be6fdba6e4b2e3de5800d4d750
F src/pragma.c 7e65c5545d83909238adf231e2a6eee6eb43e0d5
F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl 3e522a06ad41992023c80ca29a048ae2331ca5bd
-P 41d2214b83dd52acdda64a50d0c1ef16009d06d0
-R 9e0bcb38fd98e646a6dce64083f59531
-U drh
-Z b1359ca9d31266c1dc27ad6e9e05dbe4
+P cbed92f397ec13b57771ab8b5be74c0cacf35dfd
+R f5e0bf334bc8ca4771ae6f5140466932
+U danielk1977
+Z 79138fc5bf3ab18977a8db63dd8b495b
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.188 2005/02/06 02:45:42 drh Exp $
+** @(#) $Id: pager.c,v 1.189 2005/02/15 02:54:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
u8 alwaysRollback; /* Disable dont_rollback() for this page */
short int nRef; /* Number of users of this page */
PgHdr *pDirty; /* Dirty pages sorted by PgHdr.pgno */
+#ifdef SQLITE_CHECK_PAGES
+ u32 pageHash;
+#endif
/* pPager->psAligned bytes of page data follow this header */
/* Pager.nExtra bytes of local data follow the page data */
};
return rc;
}
+#ifdef SQLITE_CHECK_PAGES
+/*
+** Return a 32-bit hash of the page data for pPage.
+*/
+static u32 pager_pagehash(PgHdr *pPage){
+ u32 hash = 0;
+ int i;
+ unsigned char *pData = (unsigned char *)PGHDR_TO_DATA(pPage);
+ for(i=0; i<pPage->pPager->pageSize; i++){
+ hash = (hash+i)^pData[i];
+ }
+ return hash;
+}
+
+/*
+** The CHECK_PAGE macro takes a PgHdr* as an argument. If SQLITE_CHECK_PAGES
+** is defined, and NDEBUG is not defined, an assert() statement checks
+** that the page is either dirty or still matches the calculated page-hash.
+*/
+#define CHECK_PAGE(x) checkPage(x)
+static void checkPage(PgHdr *pPg){
+ Pager *pPager = pPg->pPager;
+ assert( !pPg->pageHash || pPager->errMask || MEMDB || pPg->dirty ||
+ pPg->pageHash==pager_pagehash(pPg) );
+}
+
+#else
+#define CHECK_PAGE(x)
+#endif
+
/*
** When this is called the journal file for pager pPager must be open.
** The master journal file name is read from the end of the file and
pPg->inJournal = 0;
pPg->dirty = 0;
pPg->needSync = 0;
+#ifdef SQLITE_CHECK_PAGES
+ pPg->pageHash = pager_pagehash(pPg);
+#endif
}
pPager->dirtyCache = 0;
pPager->nRec = 0;
if( pPager->state>=PAGER_EXCLUSIVE ){
pPg->dirty = 0;
pPg->needSync = 0;
+#ifdef SQLITE_CHECK_PAGES
+ pPg->pageHash = pager_pagehash(pPg);
+#endif
}
CODEC(pPager, pData, pPg->pgno, 3);
}
}
pPg->needSync = 0;
pPg->dirty = 0;
+#ifdef SQLITE_CHECK_PAGES
+ pPg->pageHash = pager_pagehash(pPg);
+#endif
}
return rc;
}
#endif
if( rc ) return rc;
pList->dirty = 0;
+#ifdef SQLITE_CHECK_PAGES
+ pList->pageHash = pager_pagehash(pList);
+#endif
pList = pList->pDirty;
}
return SQLITE_OK;
pPager->nRead++;
}
}
+#ifdef SQLITE_CHECK_PAGES
+ pPg->pageHash = pager_pagehash(pPg);
+#endif
}else{
/* The requested page is in the page cache. */
pPager->nHit++;
pPg->nRef--;
REFINFO(pPg);
+ CHECK_PAGE(pPg);
+
/* When the number of references to a page reach 0, call the
** destructor and add the page to the freelist.
*/
assert( !pPager->setMaster );
+ CHECK_PAGE(pPg);
+
/* Mark the page as dirty. If the page has already been written
** to the journal then we can return right away.
*/
}else{
TRACE3("DONT_WRITE page %d of %d\n", pgno, PAGERID(pPager));
pPg->dirty = 0;
+#ifdef SQLITE_CHECK_PAGES
+ pPg->pageHash = pager_pagehash(pPg);
+#endif
}
}
}