]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the PGHDR_WRITEABLE bit for PgHdr.flags which is used to
authordrh <drh@noemail.net>
Mon, 29 Jun 2015 18:29:10 +0000 (18:29 +0000)
committerdrh <drh@noemail.net>
Mon, 29 Jun 2015 18:29:10 +0000 (18:29 +0000)
distinguish between pages that are on the dirty list and pages that are
safe to modify.

FossilOrigin-Name: 7c4ef7b7c8744af19075bb96d1e0b63e35978ed1

manifest
manifest.uuid
src/pager.c
src/pcache.c
src/pcache.h

index 52d2f83173f32457bd58f4284dddd6ad77c06b72..38f44bf307231cc764034a897efe01cc8cfd32e0 100644 (file)
--- 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
index 106562fbadc9a2fafc3ed4830c1714d721beb1ed..4c09287aba3ec864087523e9af17ecca4207654c 100644 (file)
@@ -1 +1 @@
-14de3d39267a4005a0fa900bab4adc4c104e4084
\ No newline at end of file
+7c4ef7b7c8744af19075bb96d1e0b63e35978ed1
\ No newline at end of file
index 687a87ce88cf16f9e9ebfc56705b711114f415e3..7fe8c92defaefc3f6eb366abe7a78a643f9c3b1e 100644 (file)
@@ -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
 
index 220f0bf5236548090bb7924a794df6ecf7d5c626..9b23bd84337eac4c71ff163d2f25aa0276b4c8f8 100644 (file)
@@ -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);
index 14053c06f35940238b58af7f28cc64056f843010..a0724df22fdd451936cb92cf93f1c555dacdb06c 100644 (file)
@@ -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);