From: drh Date: Mon, 17 Mar 2008 13:50:58 +0000 (+0000) Subject: Put the statement journal in the temp-file directory since that X-Git-Tag: version-3.6.10~1309 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=99b90c3fa9f68079f18f82f2b1e5c48559ed497d;p=thirdparty%2Fsqlite.git Put the statement journal in the temp-file directory since that directory is often on optimized storage such as RAM disk and because unlike the main journal, the statement journal does not need to be colocated with the database file. (CVS 4868) FossilOrigin-Name: 72c40726932695a2cf5c593707d098c8fb6e8875 --- diff --git a/manifest b/manifest index d4a2525879..a4619269ac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Return\san\serror\swhen\san\sxBestIndex()\smethod\sindicates\sthat\sit\sintends\sto\suse\sthe\svalue\sof\san\sunusable\sconstraint.\sRelated\sto\s#2998.\s(CVS\s4867) -D 2008-03-17T09:36:45 +C Put\sthe\sstatement\sjournal\sin\sthe\stemp-file\sdirectory\ssince\sthat\ndirectory\sis\soften\son\soptimized\sstorage\ssuch\sas\sRAM\sdisk\sand\sbecause\nunlike\sthe\smain\sjournal,\sthe\sstatement\sjournal\sdoes\snot\sneed\sto\nbe\scolocated\swith\sthe\sdatabase\sfile.\s(CVS\s4868) +D 2008-03-17T13:50:58 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in 5be94fea84f1599672e5041de03b97990baca593 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -129,7 +129,7 @@ F src/os_unix.c 4cdd17e768888b865047805ca49beeacf0929683 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e F src/os_win.c aa3f4bbee3b8c182d25a33fbc319f486857c12c1 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b -F src/pager.c c2cabad85f50c895430cd317c46b43fe87ccb95b +F src/pager.c 2ebd895730163721d0b470aca47afbe28039c5e7 F src/pager.h 8174615ffd14ccc2cad2b081b919a398fa95e3f9 F src/parse.y 00f2698c8ae84f315be5e3f10b63c94f531fdd6d F src/pragma.c e3f39f8576234887ecd0c1de43dc51af5855930c @@ -623,7 +623,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P 5589b9d395fb8267a124d56dd5d7987e57505e3d -R 5404f9fa9fd8ab644119c7147401ab02 -U danielk1977 -Z c0d9e9f0eaef6302049326fc96233904 +P ffd470279540b1b8e3fdce6eb14001bae489b16d +R b0594243937ab6c61e858122dd1f0c8e +U drh +Z 1448a749c8158f88c0270cbac8188569 diff --git a/manifest.uuid b/manifest.uuid index f94a853512..61ec7a000d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ffd470279540b1b8e3fdce6eb14001bae489b16d \ No newline at end of file +72c40726932695a2cf5c593707d098c8fb6e8875 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 4367c6c8cd..7b0dbebd6b 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.416 2008/03/14 19:33:06 drh Exp $ +** @(#) $Id: pager.c,v 1.417 2008/03/17 13:50:58 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -2083,13 +2083,15 @@ int sqlite3PagerOpen( int nDefaultPage = SQLITE_DEFAULT_PAGE_SIZE; char *zPathname; int nPathname; + char *zStmtJrnl; + int nStmtJrnl; /* The default return is a NULL pointer */ *ppPager = 0; /* Compute the full pathname */ nPathname = pVfs->mxPathname+1; - zPathname = sqlite3_malloc(nPathname); + zPathname = sqlite3_malloc(nPathname*2); if( zPathname==0 ){ return SQLITE_NOMEM; } @@ -2112,12 +2114,26 @@ int sqlite3PagerOpen( } nPathname = strlen(zPathname); + /* Put the statement journal in temporary disk space since this is + ** sometimes RAM disk or other optimized storage. Unlikely the main + ** main journal file, the statement journal does not need to be + ** colocated with the database nor does it need to be persistent. + */ + zStmtJrnl = &zPathname[nPathname+1]; + rc = sqlite3OsGetTempname(pVfs, pVfs->mxPathname+1, zStmtJrnl); + if( rc!=SQLITE_OK ){ + sqlite3_free(zPathname); + return rc; + } + nStmtJrnl = strlen(zStmtJrnl); + /* Allocate memory for the pager structure */ pPager = sqlite3MallocZero( sizeof(*pPager) + /* Pager structure */ journalFileSize + /* The journal file structure */ pVfs->szOsFile * 3 + /* The main db and two journal files */ - 4*nPathname + 40 /* zFilename, zDirectory, zJournal, zStmtJrnl */ + 3*nPathname + 40 + /* zFilename, zDirectory, zJournal */ + nStmtJrnl /* zStmtJrnl */ ); if( !pPager ){ sqlite3_free(zPathname); @@ -2134,6 +2150,7 @@ int sqlite3PagerOpen( pPager->zStmtJrnl = &pPager->zJournal[nPathname+10]; pPager->pVfs = pVfs; memcpy(pPager->zFilename, zPathname, nPathname+1); + memcpy(pPager->zStmtJrnl, zStmtJrnl, nStmtJrnl+1); sqlite3_free(zPathname); /* Open the pager file. @@ -2209,11 +2226,9 @@ int sqlite3PagerOpen( for(i=strlen(pPager->zDirectory); i>0 && pPager->zDirectory[i-1]!='/'; i--){} if( i>0 ) pPager->zDirectory[i-1] = 0; - /* Fill in Pager.zJournal[] and Pager.zStmtJrnl[] */ + /* Fill in Pager.zJournal[] */ memcpy(pPager->zJournal, pPager->zFilename, nPathname); memcpy(&pPager->zJournal[nPathname], "-journal", 9); - memcpy(pPager->zStmtJrnl, pPager->zFilename, nPathname); - memcpy(&pPager->zStmtJrnl[nPathname], "-stmtjrnl", 10); /* pPager->journalOpen = 0; */ pPager->useJournal = useJournal && !memDb;