From: dan Date: Mon, 29 Feb 2016 20:00:13 +0000 (+0000) Subject: Fix minor problems with new code in memjournal.c. X-Git-Tag: version-3.12.0~108^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5f37ed5121b705f6e2683b071a4bf34f66005cb9;p=thirdparty%2Fsqlite.git Fix minor problems with new code in memjournal.c. FossilOrigin-Name: 9fd3f7b9c93325a83cdbe7dc9ee312b22a9c2898 --- diff --git a/manifest b/manifest index 7546ccd6d9..97a63c3c19 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Extend\sthe\scode\sin\smemjournal.c\sso\sthat\sit\ssubsumes\sthe\srole\sof\sjournal.c.\sAnd\s(untested)\scan\sflush\sjournal\sor\sstatement\sjournal\sfiles\sto\sdisk\safter\sthey\sgrow\sto\sa\sspecified\ssize. -D 2016-02-27T20:14:55.339 +C Fix\sminor\sproblems\swith\snew\scode\sin\smemjournal.c. +D 2016-02-29T20:00:13.233 F Makefile.in 4e90dc1521879022aa9479268a4cd141d1771142 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 4f319afb7c049d40aff7af6e8c4e7cc2ba18e079 @@ -321,7 +321,7 @@ F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944 -F src/memjournal.c 8d045e50120e9988e63bb0af69187e1e5e35122f +F src/memjournal.c 9b71f171dd20827022e9edd874adf8dba2b8d218 F src/msvc.h d9ba56c6851227ab44b3f228a35f3f5772296495 F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85 @@ -336,7 +336,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 3a6f20736dfb8a0949cdd66553fdf59f6604be35 F src/os_win.c f0d7aa603eb6262143d7169a222aea07c4fca91d F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c e2bf43b506447d649e9d9266e988007ae7248699 +F src/pager.c 24dd5e463f527427dd55fccc338c62260ae09b3a F src/pager.h e1d38a2f14849e219df0f91f8323504d134c8a56 F src/parse.y c3ce2c4a7cbf0b699239be6b2a945c5cb51875e2 F src/pcache.c 647bb53a86b7bbcf55ad88089b3ea5a9170b90df @@ -1451,10 +1451,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f681d800340e0e710f73d0f7c09101f899249183 -R f456c30e495865d50fc2c9c2ddb305ed -T *branch * memjournal-exp -T *sym-memjournal-exp * -T -sym-trunk * +P e0b0b4316531fc8afa74b4882d9c74a91030ec69 +R 662914373e55c4521cf0e8e3f2bf03da U dan -Z dad681f00ca4c98b68e43d3727f3c92e +Z 9ebd4b81ff0d949546d50775b32308aa diff --git a/manifest.uuid b/manifest.uuid index b15150144a..9b400a9c26 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e0b0b4316531fc8afa74b4882d9c74a91030ec69 \ No newline at end of file +9fd3f7b9c93325a83cdbe7dc9ee312b22a9c2898 \ No newline at end of file diff --git a/src/memjournal.c b/src/memjournal.c index 6e1bf4edf7..632f9dc023 100644 --- a/src/memjournal.c +++ b/src/memjournal.c @@ -248,6 +248,10 @@ static int memjrnlWrite( /* ** Truncate the file. +** +** If the journal file is already on disk, truncate it there. Or, if it +** is still in main memory but is being truncated to zero bytes in size, +** ignore */ static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){ MemJournal *p = (MemJournal *)pJfd; @@ -350,7 +354,7 @@ int sqlite3JournalOpen( ** it using the sqlite3OsOpen() function of the underlying VFS. In this ** case none of the code in this module is executed as a result of calls ** made on the journal file-handle. */ - memset(p, 0, sizeof(MemJournal)); + memset(p, 0, sizeof(MemJournal) + pVfs ? pVfs->szOsFile : 0); if( nBuf==0 ){ return sqlite3OsOpen(pVfs, zName, pJfd, flags, 0); } @@ -377,30 +381,23 @@ void sqlite3MemJournalOpen(sqlite3_file *pJfd){ sqlite3JournalOpen(0, 0, pJfd, 0, -1); } -/* -** Return true if the file-handle passed as an argument is an in-memory -** journal. -*/ -int sqlite3IsMemJournal(sqlite3_file *pJfd){ - return pJfd->pMethods==&MemJournalMethods && ((MemJournal*)pJfd)->pReal==0; -} - /* ** If the argument p points to a MemJournal structure that is not an -** in-memory-only journal file, and the underlying file has not yet been -** created, create it now. +** in-memory-only journal file (i.e. is one that was opened with a +ve +** nBuf parameter), and the underlying file has not yet been created, +** create it now. */ int sqlite3JournalCreate(sqlite3_file *p){ int rc = SQLITE_OK; - if( p->pMethods==&MemJournalMethods && ((MemJournal*)p)->nBuf>=0 ){ + if( p->pMethods==&MemJournalMethods && ((MemJournal*)p)->nBuf>0 ){ rc = createFile((MemJournal*)p); } return rc; } /* -** The file-handle passed as teh only argument is open on a journal file. -** Return true if this "journal file" is actually stored in heap memory, +** The file-handle passed as the only argument is open on a journal file. +** Return true if this "journal file" is currently stored in heap memory, ** or false otherwise. */ int sqlite3JournalIsInMemory(sqlite3_file *p){ diff --git a/src/pager.c b/src/pager.c index 5998a57831..81c6572c9d 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1343,6 +1343,7 @@ static i64 journalHdrOffset(Pager *pPager){ static int zeroJournalHdr(Pager *pPager, int doTruncate){ int rc = SQLITE_OK; /* Return code */ assert( isOpen(pPager->jfd) ); + assert( !sqlite3JournalIsInMemory(pPager->jfd) ); if( pPager->journalOff ){ const i64 iLimit = pPager->journalSizeLimit; /* Local cache of jsl */ @@ -1989,9 +1990,10 @@ static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){ /* This branch may be executed with Pager.journalMode==MEMORY if ** a hot-journal was just rolled back. In this case the journal ** file should be closed and deleted. If this connection writes to - ** the database file, it will do so using an in-memory journal. + ** the database file, it will do so using an in-memory journal. */ - int bDelete = (!pPager->tempFile&&!sqlite3JournalIsInMemory(pPager->jfd)); + int bDelete = !pPager->tempFile; + assert( sqlite3JournalIsInMemory(pPager->jfd)==0 ); assert( pPager->journalMode==PAGER_JOURNALMODE_DELETE || pPager->journalMode==PAGER_JOURNALMODE_MEMORY || pPager->journalMode==PAGER_JOURNALMODE_WAL @@ -2729,7 +2731,7 @@ static int pager_playback(Pager *pPager, int isHot){ ** TODO: Technically the following is an error because it assumes that ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that ** (pPager->pageSize >= pPager->pVfs->mxPathname+1). Using os_unix.c, - ** mxPathname is 512, which is the same as the minimum allowable value + ** mxPathname is 512, which is the same as the minimum allowable value ** for pageSize. */ zMaster = pPager->pTmpSpace;