SQLite4
Check-in [9afc42d70d]
Not logged in

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

Overview
Comment:Avoid extending the database file when truncating it to the minimum number of blocks required during system shutdown.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9afc42d70d50444a43e5e1c87a9ad307e6f7617d
User & Date: dan 2013-02-08 15:22:56
Context
2013-02-09
16:55
Have worker clients and writers that discard an old in-memory tree update a read-lock slot before concluding their work or write transaction. This is required for read-only clients - which cannot set the value of their own read-lock slot. check-in: 798d9e23be user: dan tags: trunk
05:27
Make LARGEST_UINT64 unsigned. This was causing adjustExponent to fail when compiled with msvc. check-in: 9ff6991d9f user: peterreid tags: num_work
2013-02-08
15:22
Avoid extending the database file when truncating it to the minimum number of blocks required during system shutdown. check-in: 9afc42d70d user: dan tags: trunk
14:39
Changes to lsm_unix.c to build on android: (a) do not use fdatasync() on android and (b) account for the fact that usleep() returns void on android. check-in: 302b222395 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/lsm_file.c.

   549    549   
   550    550   /*
   551    551   ** Configure the file-system object according to the current values of
   552    552   ** the LSM_CONFIG_MMAP and LSM_CONFIG_SET_COMPRESSION options.
   553    553   */
   554    554   int lsmFsConfigure(lsm_db *db){
   555    555     FileSystem *pFS = db->pFS;
          556  +  if( pFS ){
   556    557     lsm_env *pEnv = pFS->pEnv;
   557    558     Page *pPg;
   558    559   
   559    560     assert( pFS->nOut==0 );
   560    561     assert( pFS->pWaiting==0 );
   561    562   
   562    563     /* Reset any compression/decompression buffers already allocated */
................................................................................
   589    590     if( db->compress.xCompress ){
   590    591       pFS->pCompress = &db->compress;
   591    592       pFS->bUseMmap = 0;
   592    593     }else{
   593    594       pFS->pCompress = 0;
   594    595       pFS->bUseMmap = db->bMmap;
   595    596     }
          597  +  }
   596    598   
   597    599     return LSM_OK;
   598    600   }
   599    601   
   600    602   /*
   601    603   ** Close and destroy a FileSystem object.
   602    604   */

Changes to src/lsm_main.c.

   293    293         }
   294    294         *piVal = pDb->eSafety;
   295    295         break;
   296    296       }
   297    297   
   298    298       case LSM_CONFIG_MMAP: {
   299    299         int *piVal = va_arg(ap, int *);
   300         -      if( pDb->pDatabase==0 ){
   301         -        pDb->bMmap = (LSM_IS_64_BIT && *piVal);
          300  +      if( pDb->iReader<0 && *piVal>=0 && *piVal<=1 ){
          301  +        pDb->bMmap = *piVal;
          302  +        rc = lsmFsConfigure(pDb);
   302    303         }
   303    304         *piVal = pDb->bMmap;
   304    305         break;
   305    306       }
   306    307   
   307    308       case LSM_CONFIG_USE_LOG: {
   308    309         int *piVal = va_arg(ap, int *);

Changes to src/lsm_unix.c.

   119    119     return rc;
   120    120   }
   121    121   
   122    122   static int lsmPosixOsTruncate(
   123    123     lsm_file *pFile,                /* File to write to */
   124    124     lsm_i64 nSize                   /* Size to truncate file to */
   125    125   ){
   126         -  int rc = LSM_OK;
          126  +  PosixFile *p = (PosixFile *)pFile;
          127  +  int rc = LSM_OK;                /* Return code */
   127    128     int prc;                        /* Posix Return Code */
   128         -  PosixFile *p = (PosixFile *)pFile;
          129  +  struct stat sStat;              /* Result of fstat() invocation */
   129    130   
          131  +  prc = fstat(p->fd, &sStat);
          132  +  if( prc==0 && sStat.st_size>nSize ){
   130    133     prc = ftruncate(p->fd, (off_t)nSize);
          134  +  }
   131    135     if( prc<0 ) rc = lsm_ioerr();
   132    136   
   133    137     return rc;
   134    138   }
   135    139   
   136    140   static int lsmPosixOsRead(
   137    141     lsm_file *pFile,                /* File to read from */

Changes to test/lsm4.test.

     4      4   # a legal notice, here is a blessing:
     5      5   #
     6      6   #    May you do good and not evil.
     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
           11  +#
           12  +# The focus of this file is testing the LSM library. More specifically,
           13  +# it focuses on testing the compression, compression-id and
           14  +# compression-factory functionality.
    11     15   #
    12     16   
    13     17   set testdir [file dirname $argv0]
    14     18   source $testdir/tester.tcl
    15     19   set testprefix lsm4
    16     20   db close
    17     21   

Added test/lsm5.test.

            1  +# 2013 February 08
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# The focus of this file is testing the LSM library. 
           13  +#
           14  +
           15  +set testdir [file dirname $argv0]
           16  +source $testdir/tester.tcl
           17  +set testprefix lsm5
           18  +db close
           19  +
           20  +#-------------------------------------------------------------------------
           21  +# When the database system is shut down (i.e. when the last connection
           22  +# disconnects), an attempt is made to truncate the database file to the
           23  +# minimum number of blocks required.
           24  +# 
           25  +# This test case checks that this process does not actually cause the
           26  +# database to grow.
           27  +# 
           28  +do_test 1.1 {
           29  +  lsm_open db test.db
           30  +  db config {mmap 0}
           31  +} {0}
           32  +do_test 1.2 {
           33  +  db write 1 one
           34  +  db write 2 two
           35  +  db close
           36  +} {}
           37  +do_test 1.3 {
           38  +  expr [file size test.db] < (64*1024)
           39  +} 1
           40  +
           41  +finish_test
           42  +

Changes to www/lsmusr.wiki.

  1013   1013       always set to 0.
  1014   1014       <p> If it is set to true, the entire database file is memory mapped. Or, if
  1015   1015       it is false, data is accessed using ordinary OS file read and write
  1016   1016       primitives. Memory mapping the database file can significantly improve the
  1017   1017       performance of read operations, as database pages do not have to be copied
  1018   1018       from operating system buffers into user space buffers before they can be
  1019   1019       examined. 
  1020         -    <p>This option can only be set before lsm_open() is called on the database
  1021         -    connection.
         1020  +    <p>This option may not be set if there is a read or write transaction
         1021  +    open on the database.
  1022   1022       <p>The default value is 1 (true) on a 64-bit platform, and 0 otherwise.
  1023   1023   
  1024   1024     <dt> <a href=lsmapi.wiki#LSM_CONFIG_MULTIPLE_PROCESSES>LSM_CONFIG_MULTIPLE_PROCESSES</a>
  1025   1025     <dd> <p style=margin-top:0>
  1026   1026       This option may also be set to either 1 (true) or 0 (false).  The default
  1027   1027       value is 1 (true). If it is set to false, then the library assumes that all
  1028   1028       database clients are located within the same process (have access to the