1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

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
This commit is contained in:
drh
2015-06-29 18:29:10 +00:00
parent e399ac2e1e
commit 1aacbdb374
5 changed files with 26 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
C Fix\sover-length\ssource\scode\slines\sin\spager.c. 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:14:02.529 D 2015-06-29T18:29:10.051
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 285a0a234ed7610d431d91671c136098c2bd86a9 F Makefile.in 285a0a234ed7610d431d91671c136098c2bd86a9
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -314,11 +314,11 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
F src/os_unix.c 23eb5f56fac54d8fe0cb204291f3b3b2d94f23fc F src/os_unix.c 23eb5f56fac54d8fe0cb204291f3b3b2d94f23fc
F src/os_win.c 27cc135e2d0b8b1e2e4944db1e2669a6a18fa0f8 F src/os_win.c 27cc135e2d0b8b1e2e4944db1e2669a6a18fa0f8
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
F src/pager.c 81099edb051a46330cb4f526aaa782ac31d5f576 F src/pager.c 349cc089392bd0111e575bb0abacae0038a193c9
F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77
F src/parse.y 6d60dda8f8d418b6dc034f1fbccd816c459983a8 F src/parse.y 6d60dda8f8d418b6dc034f1fbccd816c459983a8
F src/pcache.c 994f15b465337a079feb04aac34c199dbc610247 F src/pcache.c 379fd77feb732b39750eb733260d9c227d8a4314
F src/pcache.h 445374bcf296515fb970c8bbf47c36222196d197 F src/pcache.h 9968603796240cdf83da7e7bef76edf90619cea9
F src/pcache1.c 9ec20f98f50ed7415019303ae9bd3745d4b7bd9b F src/pcache1.c 9ec20f98f50ed7415019303ae9bd3745d4b7bd9b
F src/pragma.c c1f4d012ea9f6b1ce52d341b2cd0ad72d560afd7 F src/pragma.c c1f4d012ea9f6b1ce52d341b2cd0ad72d560afd7
F src/pragma.h b8632d7cdda7b25323fa580e3e558a4f0d4502cc F src/pragma.h b8632d7cdda7b25323fa580e3e558a4f0d4502cc
@@ -1364,7 +1364,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 6aaaec6e63cdf713b0d67e24a892088ff251c82a P 14de3d39267a4005a0fa900bab4adc4c104e4084
R 00b6fa5674088c81a24f73d93b973d9c R 87e4d0501eab929e3fc91ca03b341d4f
U drh U drh
Z 08a04bd3dea2dc293fe05f9e7c08921e Z 78f063c06b61cea5c0d3875d2ce428dd

View File

@@ -1 +1 @@
14de3d39267a4005a0fa900bab4adc4c104e4084 7c4ef7b7c8744af19075bb96d1e0b63e35978ed1

View File

@@ -5771,6 +5771,13 @@ static int pager_write(PgHdr *pPg){
} }
} }
/* 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, /* If the statement journal is open and the page is not in it,
** then write the page into the statement journal. ** then write the page into the statement journal.
*/ */
@@ -5909,7 +5916,7 @@ int sqlite3PagerWrite(PgHdr *pPg){
*/ */
#ifndef NDEBUG #ifndef NDEBUG
int sqlite3PagerIswriteable(DbPage *pPg){ int sqlite3PagerIswriteable(DbPage *pPg){
return pPg->flags&PGHDR_DIRTY; return pPg->flags & PGHDR_WRITEABLE;
} }
#endif #endif

View File

@@ -422,7 +422,7 @@ void sqlite3PcacheMakeClean(PgHdr *p){
if( (p->flags & PGHDR_DIRTY) ){ if( (p->flags & PGHDR_DIRTY) ){
assert( (p->flags & PGHDR_CLEAN)==0 ); assert( (p->flags & PGHDR_CLEAN)==0 );
pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE); 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; p->flags |= PGHDR_CLEAN;
if( p->nRef==0 ){ if( p->nRef==0 ){
pcacheUnpin(p); pcacheUnpin(p);

View File

@@ -46,15 +46,14 @@ struct PgHdr {
}; };
/* Bit values for PgHdr.flags */ /* Bit values for PgHdr.flags */
#define PGHDR_CLEAN 0x001 /* Page is unchanged */ #define PGHDR_CLEAN 0x001 /* Page not on the PCache.pDirty list */
#define PGHDR_DIRTY 0x002 /* Page has changed */ #define PGHDR_DIRTY 0x002 /* Page is on the PCache.pDirty list */
#define PGHDR_NEED_SYNC 0x004 /* Fsync the rollback journal before #define PGHDR_WRITEABLE 0x004 /* Journaled and ready to modify */
** writing this page to the database */ #define PGHDR_NEED_SYNC 0x008 /* Fsync the rollback journal before
#define PGHDR_NEED_READ 0x008 /* Content is unread */ ** writing this page to the database */
#define PGHDR_REUSE_UNLIKELY 0x010 /* A hint that reuse is unlikely */ #define PGHDR_NEED_READ 0x010 /* Content is unread */
#define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */ #define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */
#define PGHDR_MMAP 0x040 /* This is an mmap page object */
#define PGHDR_MMAP 0x040 /* This is an mmap page object */
/* Initialize and shutdown the page cache subsystem */ /* Initialize and shutdown the page cache subsystem */
int sqlite3PcacheInitialize(void); int sqlite3PcacheInitialize(void);