/ Check-in [5b7e3a41]
Login

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

Overview
Comment:Speed improvements by avoiding unnecessary calls to fstat() and ftruncate(). (CVS 6522)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5b7e3a411a6f2fe296675de9467783f6625cff3f
User & Date: drh 2009-04-20 11:34:27
Context
2009-04-20
12:07
Do not use deprecated interfaces internally when compiling with SQLITE_OMIT_DEPRECATED. Ticket #3813. (CVS 6523) check-in: 7f17956d user: drh tags: trunk
11:34
Speed improvements by avoiding unnecessary calls to fstat() and ftruncate(). (CVS 6522) check-in: 5b7e3a41 user: drh tags: trunk
2009-04-19
20:51
Update comments and remove unused code in btree.c. No functional changes. (CVS 6521) check-in: bd860184 user: drh 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.580 2009/04/11 16:27:50 drh Exp $
           21  +** @(#) $Id: pager.c,v 1.581 2009/04/20 11:34:27 drh Exp $
    22     22   */
    23     23   #ifndef SQLITE_OMIT_DISKIO
    24     24   #include "sqliteInt.h"
    25     25   
    26     26   /*
    27     27   ** Macros for troubleshooting.  Normally turned off
    28     28   */
................................................................................
  1037   1037   **
  1038   1038   ** TODO: Why can we not reset the pager while in error state?
  1039   1039   */
  1040   1040   static void pager_reset(Pager *pPager){
  1041   1041     if( SQLITE_OK==pPager->errCode ){
  1042   1042       sqlite3BackupRestart(pPager->pBackup);
  1043   1043       sqlite3PcacheClear(pPager->pPCache);
         1044  +    pPager->dbSizeValid = 0;
  1044   1045     }
  1045   1046   }
  1046   1047   
  1047   1048   /*
  1048   1049   ** Free all structures in the Pager.aSavepoint[] array and set both
  1049   1050   ** Pager.aSavepoint and Pager.nSavepoint to zero. Close the sub-journal
  1050   1051   ** if it is open and the pager is not in exclusive mode.
................................................................................
  1286   1287       if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ){
  1287   1288         int isMemoryJournal = sqlite3IsMemJournal(pPager->jfd);
  1288   1289         sqlite3OsClose(pPager->jfd);
  1289   1290         if( !isMemoryJournal ){
  1290   1291           rc = sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);
  1291   1292         }
  1292   1293       }else if( pPager->journalMode==PAGER_JOURNALMODE_TRUNCATE ){
  1293         -      rc = sqlite3OsTruncate(pPager->jfd, 0);
         1294  +      if( pPager->journalOff==0 ){
         1295  +        rc = SQLITE_OK;
         1296  +      }else{
         1297  +        rc = sqlite3OsTruncate(pPager->jfd, 0);
         1298  +      }
  1294   1299         pPager->journalOff = 0;
  1295   1300         pPager->journalStarted = 0;
  1296   1301       }else if( pPager->exclusiveMode 
  1297   1302        || pPager->journalMode==PAGER_JOURNALMODE_PERSIST
  1298   1303       ){
  1299   1304         rc = zeroJournalHdr(pPager, hasMaster);
  1300   1305         pager_error(pPager, rc);
................................................................................
  3660   3665     }
  3661   3666     return rc;
  3662   3667   }
  3663   3668   
  3664   3669   /*
  3665   3670   ** If the reference count has reached zero, rollback any active
  3666   3671   ** transaction and unlock the pager.
         3672  +**
         3673  +** Except, in locking_mode=EXCLUSIVE when there is nothing to in
         3674  +** the rollback journal, the unlock is not performed and there is
         3675  +** nothing to rollback, so this routine is a no-op.
  3667   3676   */ 
  3668   3677   static void pagerUnlockIfUnused(Pager *pPager){
  3669         -  if( sqlite3PcacheRefCount(pPager->pPCache)==0 ){
         3678  +  if( (sqlite3PcacheRefCount(pPager->pPCache)==0)
         3679  +   && (!pPager->exclusiveMode || pPager->journalOff>0) 
         3680  +  ){
  3670   3681       pagerUnlockAndRollback(pPager);
  3671   3682     }
  3672   3683   }
  3673   3684   
  3674   3685   /*
  3675   3686   ** Drop a page from the cache using sqlite3PcacheDrop().
  3676   3687   **