From: shaneh Date: Fri, 5 Feb 2010 16:28:00 +0000 (+0000) Subject: Avoid truncating non-in-memory sub-journals when releasing a savepoint for a small... X-Git-Tag: version-3.7.2~618 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6885de360dd15b3e72ce8b98066e8dcd4b5aa4f2;p=thirdparty%2Fsqlite.git Avoid truncating non-in-memory sub-journals when releasing a savepoint for a small performance improvement. FossilOrigin-Name: 27dc5b1c52eaa5f99cf44ee31204f62598fbf011 --- diff --git a/manifest b/manifest index 55655e2664..f80a7cca1b 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Remove\sthe\suse\sof\s64-bit\smath\sin\sthe\soffset\scomputations\sof\s\nthe\sOP_Column\sopcode\sfor\sa\ssmall\sperformance\simprovement. -D 2010-02-05T14:12:54 +C Avoid\struncating\snon-in-memory\ssub-journals\swhen\sreleasing\sa\ssavepoint\sfor\sa\ssmall\sperformance\simprovement. +D 2010-02-05T16:28:00 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -153,7 +150,7 @@ F src/os_common.h 240c88b163b02c21a9f21f87d49678a0aa21ff30 F src/os_os2.c 75a8c7b9a00a2cf1a65f9fa4afbc27d46634bb2f F src/os_unix.c 0b97269557d5a148d43c55edab5a20b62d0e10e3 F src/os_win.c 5ffab20249a61e0625f869efe157fa009747039b -F src/pager.c e5421d38470fe58faee71a5a66a778ada882394c +F src/pager.c 4cf8da7cf454d09086400c3b2943b41e6e46e829 F src/pager.h 1b32faf2e578ac3e7bcf9c9d11217128261c5c54 F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e F src/pcache.c 815bcb3cf0e14b23212efd3f4981f667a5fd633e @@ -789,14 +786,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 26cb1df73504d5d883cf0967e57b46aa062d0b00 -R 1958cacd7f583aec4ab73bfa77d04590 -U drh -Z fc01b4de0eee88e8eb53af6f3beff67e ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFLbCdpoxKgR168RlERAleAAJ9zp4nXhvCTHxqvWnr21SgA/iUicACdEllu -mfGoLjhZumCpTb2x8CplRYs= -=/N/5 ------END PGP SIGNATURE----- +P 61a2c8d4d64c28119e9f06eb42f9c0437ba7a7bd +R 7b780dc261c98bc95bb0a9dcb2e2f834 +U shaneh +Z d9892d5150c22658e41a11ffe03f2d66 diff --git a/manifest.uuid b/manifest.uuid index 52cc347d92..31437588c1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -61a2c8d4d64c28119e9f06eb42f9c0437ba7a7bd \ No newline at end of file +27dc5b1c52eaa5f99cf44ee31204f62598fbf011 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index a0576f36d6..62d9775e10 100644 --- a/src/pager.c +++ b/src/pager.c @@ -4981,30 +4981,34 @@ int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){ ** operation. Store this value in nNew. Then free resources associated ** with any savepoints that are destroyed by this operation. */ - nNew = iSavepoint + (op==SAVEPOINT_ROLLBACK); + nNew = iSavepoint + (( op==SAVEPOINT_RELEASE ) ? 0 : 1); for(ii=nNew; iinSavepoint; ii++){ sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint); } pPager->nSavepoint = nNew; - /* If this is a rollback operation, playback the specified savepoint. + /* If this is a release of the outermost savepoint, truncate + ** the sub-journal to zero bytes in size. */ + if( op==SAVEPOINT_RELEASE ){ + if( nNew==0 && isOpen(pPager->sjfd) ){ + /* Only truncate if it is an in-memory sub-journal. */ + if( sqlite3IsMemJournal(pPager->sjfd) ){ + rc = sqlite3OsTruncate(pPager->sjfd, 0); + } + pPager->nSubRec = 0; + } + } + /* Else this is a rollback operation, playback the specified savepoint. ** If this is a temp-file, it is possible that the journal file has ** not yet been opened. In this case there have been no changes to ** the database file, so the playback operation can be skipped. */ - if( op==SAVEPOINT_ROLLBACK && isOpen(pPager->jfd) ){ + else if( isOpen(pPager->jfd) ){ PagerSavepoint *pSavepoint = (nNew==0)?0:&pPager->aSavepoint[nNew-1]; rc = pagerPlaybackSavepoint(pPager, pSavepoint); assert(rc!=SQLITE_DONE); } - /* If this is a release of the outermost savepoint, truncate - ** the sub-journal to zero bytes in size. */ - if( nNew==0 && op==SAVEPOINT_RELEASE && isOpen(pPager->sjfd) ){ - assert( rc==SQLITE_OK ); - rc = sqlite3OsTruncate(pPager->sjfd, 0); - pPager->nSubRec = 0; - } } return rc; }