/ Check-in [19345416]
Login

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

Overview
Comment:Add a fix for the assert() statements added by the previous commit.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | experimental-mmap
Files: files | file ages | folders
SHA1: 19345416ed5e1ab5b0b35993b0b9069c2fb1683b
User & Date: dan 2013-03-22 17:46:11
Context
2013-03-22
18:20
Allow the database file to be memory mapped in wal mode. check-in: d190ddab user: dan tags: experimental-mmap
17:46
Add a fix for the assert() statements added by the previous commit. check-in: 19345416 user: dan tags: experimental-mmap
08:58
Add assert statements to os_unix.c to ensure that any mapped region of the database file is not being read or written using the xRead() or xWrite() methods. check-in: 765615f9 user: dan tags: experimental-mmap
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

  3466   3466       ** that effectively updates the change counter.  This might happen
  3467   3467       ** when restoring a database using the backup API from a zero-length
  3468   3468       ** source.
  3469   3469       */
  3470   3470       if( pFile->inNormalWrite && nByte==0 ){
  3471   3471         pFile->transCntrChng = 1;
  3472   3472       }
         3473  +
         3474  +    /* If the file was just truncated to a size smaller than the currently
         3475  +    ** mapped region, reduce the effective mapping size as well. SQLite will
         3476  +    ** use read() and write() to access data beyond this point from now on.  
         3477  +    */
         3478  +    if( nByte<pFile->mmapSize ){
         3479  +      pFile->mmapSize = nByte;
         3480  +    }
  3473   3481   #endif
  3474   3482   
  3475   3483       return SQLITE_OK;
  3476   3484     }
  3477   3485   }
  3478   3486   
  3479   3487   /*
................................................................................
  4457   4465     unixFile *p = (unixFile *)fd;   /* The underlying database file */
  4458   4466     int rc = SQLITE_OK;             /* Return code */
  4459   4467     void *pNew = 0;                 /* New mapping */
  4460   4468     i64 nNewRnd;                    /* nNew rounded up */
  4461   4469     i64 nOldRnd;                    /* nOld rounded up */
  4462   4470   
  4463   4471     assert( iOff==0 );
  4464         -  assert( p->mmapSize==nOld );
         4472  +  /* assert( p->mmapSize==nOld ); */
  4465   4473     assert( p->pMapRegion==0 || p->pMapRegion==(*ppMap) );
  4466   4474   
  4467   4475     /* If the SQLITE_MREMAP_EXTEND flag is set, then the size of the requested 
  4468   4476     ** mapping (nNew bytes) may be greater than the size of the database file.
  4469   4477     ** If this is the case, extend the file on disk using ftruncate().  */
  4470   4478     assert( nNew>0 || (flags & SQLITE_MREMAP_EXTEND)==0 );
  4471   4479     if( flags & SQLITE_MREMAP_EXTEND ){