From: drh Date: Mon, 29 Jun 2015 18:29:10 +0000 (+0000) Subject: Add the PGHDR_WRITEABLE bit for PgHdr.flags which is used to X-Git-Tag: version-3.8.11~96 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1aacbdb3745e04b3b59ef36fb81034c054b8f154;p=thirdparty%2Fsqlite.git Add the PGHDR_WRITEABLE bit for PgHdr.flags which is used to distinguish between pages that are on the dirty list and pages that are safe to modify. FossilOrigin-Name: 7c4ef7b7c8744af19075bb96d1e0b63e35978ed1 --- diff --git a/manifest b/manifest index 52d2f83173..38f44bf307 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sover-length\ssource\scode\slines\sin\spager.c. -D 2015-06-29T18:14:02.529 +C Add\sthe\sPGHDR_WRITEABLE\sbit\sfor\sPgHdr.flags\swhich\sis\sused\sto\s\ndistinguish\sbetween\spages\sthat\sare\son\sthe\sdirty\slist\sand\spages\sthat\sare\nsafe\sto\smodify. +D 2015-06-29T18:29:10.051 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 285a0a234ed7610d431d91671c136098c2bd86a9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -314,11 +314,11 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 23eb5f56fac54d8fe0cb204291f3b3b2d94f23fc F src/os_win.c 27cc135e2d0b8b1e2e4944db1e2669a6a18fa0f8 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c 81099edb051a46330cb4f526aaa782ac31d5f576 +F src/pager.c 349cc089392bd0111e575bb0abacae0038a193c9 F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 F src/parse.y 6d60dda8f8d418b6dc034f1fbccd816c459983a8 -F src/pcache.c 994f15b465337a079feb04aac34c199dbc610247 -F src/pcache.h 445374bcf296515fb970c8bbf47c36222196d197 +F src/pcache.c 379fd77feb732b39750eb733260d9c227d8a4314 +F src/pcache.h 9968603796240cdf83da7e7bef76edf90619cea9 F src/pcache1.c 9ec20f98f50ed7415019303ae9bd3745d4b7bd9b F src/pragma.c c1f4d012ea9f6b1ce52d341b2cd0ad72d560afd7 F src/pragma.h b8632d7cdda7b25323fa580e3e558a4f0d4502cc @@ -1364,7 +1364,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6aaaec6e63cdf713b0d67e24a892088ff251c82a -R 00b6fa5674088c81a24f73d93b973d9c +P 14de3d39267a4005a0fa900bab4adc4c104e4084 +R 87e4d0501eab929e3fc91ca03b341d4f U drh -Z 08a04bd3dea2dc293fe05f9e7c08921e +Z 78f063c06b61cea5c0d3875d2ce428dd diff --git a/manifest.uuid b/manifest.uuid index 106562fbad..4c09287aba 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -14de3d39267a4005a0fa900bab4adc4c104e4084 \ No newline at end of file +7c4ef7b7c8744af19075bb96d1e0b63e35978ed1 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 687a87ce88..7fe8c92def 100644 --- a/src/pager.c +++ b/src/pager.c @@ -5770,6 +5770,13 @@ static int pager_write(PgHdr *pPg){ ((pPg->flags&PGHDR_NEED_SYNC)?1:0))); } } + + /* The PGHDR_DIRTY bit is set above when the page was added to the dirty-list + ** and before writing the page into the rollback journal. Wait until now, + ** after the page has been successfully journalled, before setting the + ** PGHDR_WRITEABLE bit that indicates that the page can be safely modified. + */ + pPg->flags |= PGHDR_WRITEABLE; /* If the statement journal is open and the page is not in it, ** then write the page into the statement journal. @@ -5909,7 +5916,7 @@ int sqlite3PagerWrite(PgHdr *pPg){ */ #ifndef NDEBUG int sqlite3PagerIswriteable(DbPage *pPg){ - return pPg->flags&PGHDR_DIRTY; + return pPg->flags & PGHDR_WRITEABLE; } #endif diff --git a/src/pcache.c b/src/pcache.c index 220f0bf523..9b23bd8433 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -422,7 +422,7 @@ void sqlite3PcacheMakeClean(PgHdr *p){ if( (p->flags & PGHDR_DIRTY) ){ assert( (p->flags & PGHDR_CLEAN)==0 ); pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE); - p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC); + p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC|PGHDR_WRITEABLE); p->flags |= PGHDR_CLEAN; if( p->nRef==0 ){ pcacheUnpin(p); diff --git a/src/pcache.h b/src/pcache.h index 14053c06f3..a0724df22f 100644 --- a/src/pcache.h +++ b/src/pcache.h @@ -46,15 +46,14 @@ struct PgHdr { }; /* Bit values for PgHdr.flags */ -#define PGHDR_CLEAN 0x001 /* Page is unchanged */ -#define PGHDR_DIRTY 0x002 /* Page has changed */ -#define PGHDR_NEED_SYNC 0x004 /* Fsync the rollback journal before - ** writing this page to the database */ -#define PGHDR_NEED_READ 0x008 /* Content is unread */ -#define PGHDR_REUSE_UNLIKELY 0x010 /* A hint that reuse is unlikely */ -#define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */ - -#define PGHDR_MMAP 0x040 /* This is an mmap page object */ +#define PGHDR_CLEAN 0x001 /* Page not on the PCache.pDirty list */ +#define PGHDR_DIRTY 0x002 /* Page is on the PCache.pDirty list */ +#define PGHDR_WRITEABLE 0x004 /* Journaled and ready to modify */ +#define PGHDR_NEED_SYNC 0x008 /* Fsync the rollback journal before + ** writing this page to the database */ +#define PGHDR_NEED_READ 0x010 /* Content is unread */ +#define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */ +#define PGHDR_MMAP 0x040 /* This is an mmap page object */ /* Initialize and shutdown the page cache subsystem */ int sqlite3PcacheInitialize(void);