From: drh Date: Mon, 29 Jun 2015 19:08:18 +0000 (+0000) Subject: Combine subjRequiresPage() and subjournalPage() into a single X-Git-Tag: version-3.8.11~95 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=60e32edba5b50692af25ad56f849d6b41c2b2c72;p=thirdparty%2Fsqlite.git Combine subjRequiresPage() and subjournalPage() into a single subjournalPageIfRequired() routine. FossilOrigin-Name: 3b65eb56c422855ca47f709247205f0c77d98a5c --- diff --git a/manifest b/manifest index 38f44bf307..97944da70e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -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 +C Combine\ssubjRequiresPage()\sand\ssubjournalPage()\sinto\sa\ssingle\nsubjournalPageIfRequired()\sroutine. +D 2015-06-29T19:08:18.213 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 285a0a234ed7610d431d91671c136098c2bd86a9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -314,7 +314,7 @@ 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 349cc089392bd0111e575bb0abacae0038a193c9 +F src/pager.c 4cf1b151727f5f12898927c6688b167fd4999d14 F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 F src/parse.y 6d60dda8f8d418b6dc034f1fbccd816c459983a8 F src/pcache.c 379fd77feb732b39750eb733260d9c227d8a4314 @@ -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 14de3d39267a4005a0fa900bab4adc4c104e4084 -R 87e4d0501eab929e3fc91ca03b341d4f +P 7c4ef7b7c8744af19075bb96d1e0b63e35978ed1 +R f62d201ad6eea9a89949366a04424df3 U drh -Z 78f063c06b61cea5c0d3875d2ce428dd +Z d7a21ab6fd66c107b4716f65f30e363a diff --git a/manifest.uuid b/manifest.uuid index 4c09287aba..76f6ffe525 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c4ef7b7c8744af19075bb96d1e0b63e35978ed1 \ No newline at end of file +3b65eb56c422855ca47f709247205f0c77d98a5c \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 7fe8c92def..bf6f8f4d69 100644 --- a/src/pager.c +++ b/src/pager.c @@ -4320,8 +4320,6 @@ static int openSubJournal(Pager *pPager){ /* ** Append a record of the current state of page pPg to the sub-journal. -** It is the callers responsibility to use subjRequiresPage() to check -** that it is really required before calling this function. ** ** If successful, set the bit corresponding to pPg->pgno in the bitvecs ** for all open savepoints before returning. @@ -4368,6 +4366,13 @@ static int subjournalPage(PgHdr *pPg){ } return rc; } +static int subjournalPageIfRequired(PgHdr *pPg){ + if( subjRequiresPage(pPg) ){ + return subjournalPage(pPg); + }else{ + return SQLITE_OK; + } +} /* ** This function is called by the pcache layer when it has reached some @@ -4425,9 +4430,7 @@ static int pagerStress(void *p, PgHdr *pPg){ pPg->pDirty = 0; if( pagerUseWal(pPager) ){ /* Write a single frame for this page to the log. */ - if( subjRequiresPage(pPg) ){ - rc = subjournalPage(pPg); - } + rc = subjournalPageIfRequired(pPg); if( rc==SQLITE_OK ){ rc = pagerWalFrames(pPager, pPg, 0, 0); } @@ -4440,39 +4443,6 @@ static int pagerStress(void *p, PgHdr *pPg){ rc = syncJournal(pPager, 1); } - /* If the page number of this page is larger than the current size of - ** the database image, it may need to be written to the sub-journal. - ** This is because the call to pager_write_pagelist() below will not - ** actually write data to the file in this case. - ** - ** Consider the following sequence of events: - ** - ** BEGIN; - ** - ** - ** SAVEPOINT sp; - ** - ** pagerStress(page X) - ** ROLLBACK TO sp; - ** - ** If (X>Y), then when pagerStress is called page X will not be written - ** out to the database file, but will be dropped from the cache. Then, - ** following the "ROLLBACK TO sp" statement, reading page X will read - ** data from the database file. This will be the copy of page X as it - ** was when the transaction started, not as it was when "SAVEPOINT sp" - ** was executed. - ** - ** The solution is to write the current data for page X into the - ** sub-journal file now (if it is not already there), so that it will - ** be restored to its current value when the "ROLLBACK TO sp" is - ** executed. - */ - if( NEVER( - rc==SQLITE_OK && pPg->pgno>pPager->dbSize && subjRequiresPage(pPg) - ) ){ - rc = subjournalPage(pPg); - } - /* Write the contents of the page out to the database file. */ if( rc==SQLITE_OK ){ assert( (pPg->flags&PGHDR_NEED_SYNC)==0 ); @@ -5781,8 +5751,8 @@ static int pager_write(PgHdr *pPg){ /* If the statement journal is open and the page is not in it, ** then write the page into the statement journal. */ - if( pPager->nSavepoint>0 && subjRequiresPage(pPg) ){ - rc = subjournalPage(pPg); + if( pPager->nSavepoint>0 ){ + rc = subjournalPageIfRequired(pPg); } /* Update the database size and return. */ @@ -6772,9 +6742,8 @@ int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){ ** one or more savepoint bitvecs. This is the reason this function ** may return SQLITE_NOMEM. */ - if( pPg->flags&PGHDR_DIRTY - && subjRequiresPage(pPg) - && SQLITE_OK!=(rc = subjournalPage(pPg)) + if( (pPg->flags & PGHDR_DIRTY)!=0 + && SQLITE_OK!=(rc = subjournalPageIfRequired(pPg)) ){ return rc; }