/ Check-in [e746832f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid calling OsDelete() on journal files when they are opened for temporary databases. Fix for #2255. (CVS 3748)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:e746832f5f3e1c58e6f6456866156824d23dd846
User & Date: danielk1977 2007-03-29 17:28:15
Context
2007-03-29
17:57
Make sure the strftime() date conversions put in leading zeros correctly. Ticket #2276. (CVS 3749) check-in: e853067e user: drh tags: trunk
17:28
Avoid calling OsDelete() on journal files when they are opened for temporary databases. Fix for #2255. (CVS 3748) check-in: e746832f user: danielk1977 tags: trunk
17:07
Add a couple of test cases to improve coverage testing. (CVS 3747) check-in: 0b22ce36 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

    14     14   ** The pager is used to access a database disk file.  It implements
    15     15   ** atomic commit and rollback through the use of a journal file that
    16     16   ** is separate from the database file.  The pager also implements file
    17     17   ** locking to prevent two processes from writing the same database
    18     18   ** file simultaneously, or one process from reading the database while
    19     19   ** another is writing.
    20     20   **
    21         -** @(#) $Id: pager.c,v 1.304 2007/03/28 01:59:34 drh Exp $
           21  +** @(#) $Id: pager.c,v 1.305 2007/03/29 17:28:15 danielk1977 Exp $
    22     22   */
    23     23   #ifndef SQLITE_OMIT_DISKIO
    24     24   #include "sqliteInt.h"
    25     25   #include "os.h"
    26     26   #include "pager.h"
    27     27   #include <assert.h>
    28     28   #include <string.h>
................................................................................
   937    937         rc = sqlite3OsTruncate(pPager->jfd, 0);
   938    938         sqlite3OsSeek(pPager->jfd, 0);
   939    939         pPager->journalOff = 0;
   940    940         pPager->journalStarted = 0;
   941    941       }else{
   942    942         sqlite3OsClose(&pPager->jfd);
   943    943         pPager->journalOpen = 0;
   944         -      rc = sqlite3OsDelete(pPager->zJournal);
          944  +      /* If this is a temporary pager file, then the journal file should
          945  +      ** have been configured as delete-on-close. Otherwise, it should still
          946  +      ** be in the file system. This pager still holds a RESERVED or greater
          947  +      ** lock on the database file, so there is no chance another process
          948  +      ** could create or remove a journal file.
          949  +      */
          950  +      assert( sqlite3OsFileExists(pPager->zJournal) || pPager->tempFile );
          951  +      assert( !sqlite3OsFileExists(pPager->zJournal) || !pPager->tempFile );
          952  +      if( !pPager->tempFile ){
          953  +        rc = sqlite3OsDelete(pPager->zJournal);
          954  +      }
   945    955       }
   946    956       sqliteFree( pPager->aInJournal );
   947    957       pPager->aInJournal = 0;
   948    958       for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){
   949    959         pPg->inJournal = 0;
   950    960         pPg->dirty = 0;
   951    961         pPg->needSync = 0;
................................................................................
  2710   2720           ** possibly used for a transaction later on. On some systems, the
  2711   2721           ** OsTruncate() call used in exclusive-access mode also requires
  2712   2722           ** a read/write file handle.
  2713   2723           */
  2714   2724           rc = SQLITE_BUSY;
  2715   2725           if( sqlite3OsFileExists(pPager->zJournal) ){
  2716   2726             int ro;
         2727  +          assert( !pPager->tempFile );
  2717   2728             rc = sqlite3OsOpenReadWrite(pPager->zJournal, &pPager->jfd, &ro);
  2718   2729             if( ro ){
  2719   2730               rc = SQLITE_BUSY;
  2720   2731             }
  2721   2732           }
  2722   2733           if( rc!=SQLITE_OK ){
  2723   2734             pager_unlock(pPager);

Changes to src/test9.c.

    10     10   **
    11     11   *************************************************************************
    12     12   **
    13     13   ** This file contains obscure tests of the C-interface required
    14     14   ** for completeness. Test code is written in C for these cases
    15     15   ** as there is not much point in binding to Tcl.
    16     16   **
    17         -** $Id: test9.c,v 1.1 2007/03/29 12:24:17 danielk1977 Exp $
           17  +** $Id: test9.c,v 1.2 2007/03/29 17:28:15 danielk1977 Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "tcl.h"
    21     21   #include "os.h"
    22     22   #include <stdlib.h>
    23     23   #include <string.h>
    24     24   
................................................................................
    27     27   */
    28     28   static int c_collation_test(
    29     29     ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
    30     30     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
    31     31     int objc,              /* Number of arguments */
    32     32     Tcl_Obj *CONST objv[]  /* Command arguments */
    33     33   ){
    34         -  void *p;
    35     34     const char *zErrFunction = "N/A";
    36     35     sqlite3 *db;
    37     36   
    38     37     int rc;
    39     38     if( objc!=1 ){
    40     39       Tcl_WrongNumArgs(interp, 1, objv, "");
    41     40       return TCL_ERROR;
................................................................................
    72     71     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
    73     72     int objc,              /* Number of arguments */
    74     73     Tcl_Obj *CONST objv[]  /* Command arguments */
    75     74   ){
    76     75     void *p;
    77     76     const char *zErrFunction = "N/A";
    78     77   
    79         -  sqlite3 *db;
    80         -  int rc;
    81     78     if( objc!=1 ){
    82     79       Tcl_WrongNumArgs(interp, 1, objv, "");
    83     80       return TCL_ERROR;
    84     81     }
    85     82   
    86     83     p = sqlite3_malloc(5);
    87     84     if( !p ){