]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Base the name of the statement journal on the original database filename.
authordrh <drh@noemail.net>
Thu, 6 Sep 2007 23:28:23 +0000 (23:28 +0000)
committerdrh <drh@noemail.net>
Thu, 6 Sep 2007 23:28:23 +0000 (23:28 +0000)
Remember the statement journal name for the lifetime of the Pager so
that the name pointer passed to xOpen persists as long as the file
exists. (CVS 4410)

FossilOrigin-Name: 44d8d1e92d93a5bb28bd10281b4d87e89586ef58

manifest
manifest.uuid
src/pager.c
test/lock4.test

index bc950fd0137cf8064f3b6691a4220ca490964eaf..8db50619a5af7fe82e3e303c99e01ce66f348ded 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Allocate\spage\scache\sheaders\sand\spage\scache\sdata\sbuffers\sseparately.\nThe\sdata\sbuffer\swill\sbe\sa\spower\sof\stwo\sin\ssize\sand\sthis\sgives\ssome\nmalloc\simplementation\sadditional\soptimization\sopportunitites.\s(CVS\s4409)
-D 2007-09-06T22:19:15
+C Base\sthe\sname\sof\sthe\sstatement\sjournal\son\sthe\soriginal\sdatabase\sfilename.\nRemember\sthe\sstatement\sjournal\sname\sfor\sthe\slifetime\sof\sthe\sPager\sso\nthat\sthe\sname\spointer\spassed\sto\sxOpen\spersists\sas\slong\sas\sthe\sfile\nexists.\s(CVS\s4410)
+D 2007-09-06T23:28:24
 F Makefile.in cbfb898945536a8f9ea8b897e1586dd1fdbcc5db
 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -120,7 +120,7 @@ F src/os_unix.c 522486e24d1a743efc366cb93a727fa9314797b4
 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
 F src/os_win.c b663c171abbbfa8ca20e5b9b93f7a0f09df616e9
 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c 10a95d9373105af62255a05aac1ffe0400b93a3d
+F src/pager.c 70b4b9b6e1715adba48cd6a263885ae848f3f263
 F src/pager.h d783e7f184afdc33adff37ba58d4e029bd8793b3
 F src/parse.y 2d2ce439dc6184621fb0b86f4fc5aca7f391a590
 F src/pragma.c 363e548dafb52327face8d99757ab56a7b1c1b26
@@ -344,7 +344,7 @@ F test/loadext2.test 95ca7e2cb03fd3e068de97c3a2fe58dbdfd769e1
 F test/lock.test 6825aea0b5885578b1b63a3b178803842c4ee9f1
 F test/lock2.test 5f9557b775662c2a5ee435378f39e10d64f65cb3
 F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
-F test/lock4.test c8e035ba9cf08985e4fc0f4600ffae241a435ab3
+F test/lock4.test f358fa835dff485d462072eee991111f09e87441
 F test/main.test 05f585bb70c05caac3e047903b517cbb319ed204
 F test/malloc.test 5b4ac16e0e11cca99a25574298eb5ac8e93236db
 F test/malloc2.test c1a74f46a3581b56df29ff46a4e1c99b41c44ad9
@@ -570,7 +570,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 3298441086330d1d24c30b7c061dfec98e9ea3ac
-R fab7f476269f83c2a9fb525589500817
+P 2b755defe51a565a2b6ace58381d6e91f6f17db8
+R 7302a8ee1069963289d7beafba5ccbcf
 U drh
-Z 091fe80161eedb1e09f57479031bbfb6
+Z 2eeafbb47f910b6b2e141f033520b30a
index f5421050f9bf53020e0238c78fa5c5a303fa4518..d3658ec245109f03203042c2310252d06701ac1f 100644 (file)
@@ -1 +1 @@
-2b755defe51a565a2b6ace58381d6e91f6f17db8
\ No newline at end of file
+44d8d1e92d93a5bb28bd10281b4d87e89586ef58
\ No newline at end of file
index c276736a3e0294cf200ad156a04992bc49789a74..efc00a085a0bdc7ee4ef3d7e2c1f889f8191ae61 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.386 2007/09/06 22:19:15 drh Exp $
+** @(#) $Id: pager.c,v 1.387 2007/09/06 23:28:24 drh Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -370,6 +370,7 @@ struct Pager {
   char *zFilename;            /* Name of the database file */
   char *zJournal;             /* Name of the journal file */
   char *zDirectory;           /* Directory hold database and journal files */
+  char *zStmtJrnl;            /* Name of the statement journal file */
   sqlite3_file *fd, *jfd;     /* File descriptors for database and journal */
   sqlite3_file *stfd;         /* File descriptor for the statement subjournal*/
   BusyHandler *pBusyHandler;  /* Pointer to sqlite.busyHandler */
@@ -1977,11 +1978,6 @@ int sqlite3_opentemp_count = 0;
 ** Write the file descriptor into *fd.  Return SQLITE_OK on success or some
 ** other error code if we fail. The OS will automatically delete the temporary
 ** file when it is closed.
-**
-** If zFilename is 0, then an appropriate temporary filename is
-** generated automatically.
-**
-** The vfsFlags value should be SQLITE_OPEN_SUBJOURNAL or SQLITE_OPEN
 */
 static int sqlite3PagerOpentemp(
   sqlite3_vfs *pVfs,    /* The virtual file system layer */
@@ -1990,20 +1986,7 @@ static int sqlite3PagerOpentemp(
   int vfsFlags          /* Flags passed through to the VFS */
 ){
   int rc;
-
-  char *zFree = 0;
-  if( zFilename==0 ){
-    zFree = (char *)sqlite3_malloc(pVfs->mxPathname);
-    if( !zFree ){
-      return SQLITE_NOMEM;
-    }
-    zFilename = zFree;
-    rc = sqlite3OsGetTempName(pVfs, zFilename);
-    if( rc!=SQLITE_OK ){
-      sqlite3_free(zFree);
-      return rc;
-    }
-  }
+  assert( zFilename!=0 );
 
 #ifdef SQLITE_TEST
   sqlite3_opentemp_count++;  /* Used for testing and analysis only */
@@ -2013,7 +1996,6 @@ static int sqlite3PagerOpentemp(
             SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE;
   rc = sqlite3OsOpen(pVfs, zFilename, pFile, vfsFlags, 0);
   assert( rc!=SQLITE_OK || pFile->pMethods );
-  sqlite3_free(zFree);
   return rc;
 }
 
@@ -2085,7 +2067,7 @@ int sqlite3PagerOpen(
     sizeof(*pPager) +           /* Pager structure */
     journalFileSize +           /* The journal file structure */ 
     pVfs->szOsFile * 2 +        /* The db and stmt journal files */ 
-    nPathname * 3 + 30          /* zFilename, zDirectory, zJournal */
+    4*nPathname + 40            /* zFilename, zDirectory, zJournal, zStmtJrnl */
   );
   if( !pPager ){
     sqlite3_free(zPathname);
@@ -2099,6 +2081,7 @@ int sqlite3PagerOpen(
   pPager->zFilename = (char*)&pPtr[pVfs->szOsFile*2+journalFileSize];
   pPager->zDirectory = &pPager->zFilename[nPathname+1];
   pPager->zJournal = &pPager->zDirectory[nPathname+1];
+  pPager->zStmtJrnl = &pPager->zJournal[nPathname+10];
   pPager->pVfs = pVfs;
   memcpy(pPager->zFilename, zPathname, nPathname+1);
   sqlite3_free(zPathname);
@@ -2176,9 +2159,11 @@ 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[] */
+  /* Fill in Pager.zJournal[] and Pager.zStmtJrnl[] */
   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;
@@ -4726,9 +4711,11 @@ static int pagerStmtBegin(Pager *pPager){
   pPager->stmtHdrOff = 0;
   pPager->stmtCksum = pPager->cksumInit;
   if( !pPager->stmtOpen ){
-    rc = sqlite3PagerOpentemp(pPager->pVfs, pPager->stfd, 0,
+    rc = sqlite3PagerOpentemp(pPager->pVfs, pPager->stfd, pPager->zStmtJrnl,
                               SQLITE_OPEN_SUBJOURNAL);
-    if( rc ) goto stmt_begin_failed;
+    if( rc ){
+      goto stmt_begin_failed;
+    }
     pPager->stmtOpen = 1;
     pPager->stmtNRec = 0;
   }
index 4138d2107848fa2f14b51bb4523f345350c66103..3820476a67979e18c898faf22b75d6c0396fc253 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script is database locks.
 #
-# $Id: lock4.test,v 1.5 2007/09/05 13:56:32 danielk1977 Exp $
+# $Id: lock4.test,v 1.6 2007/09/06 23:28:25 drh Exp $
 
 
 set testdir [file dirname $argv0]
@@ -83,7 +83,6 @@ do_test lock4-1.3 {
   db eval {
      COMMIT;
   }
-breakpoint
   while {[file exists test2.db-journal]} {
     after 10
   }