/ Check-in [19345416]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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 Unified Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

3466
3467
3468
3469
3470
3471
3472








3473
3474
3475
3476
3477
3478
3479
....
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
    ** that effectively updates the change counter.  This might happen
    ** when restoring a database using the backup API from a zero-length
    ** source.
    */
    if( pFile->inNormalWrite && nByte==0 ){
      pFile->transCntrChng = 1;
    }








#endif

    return SQLITE_OK;
  }
}

/*
................................................................................
  unixFile *p = (unixFile *)fd;   /* The underlying database file */
  int rc = SQLITE_OK;             /* Return code */
  void *pNew = 0;                 /* New mapping */
  i64 nNewRnd;                    /* nNew rounded up */
  i64 nOldRnd;                    /* nOld rounded up */

  assert( iOff==0 );
  assert( p->mmapSize==nOld );
  assert( p->pMapRegion==0 || p->pMapRegion==(*ppMap) );

  /* If the SQLITE_MREMAP_EXTEND flag is set, then the size of the requested 
  ** mapping (nNew bytes) may be greater than the size of the database file.
  ** If this is the case, extend the file on disk using ftruncate().  */
  assert( nNew>0 || (flags & SQLITE_MREMAP_EXTEND)==0 );
  if( flags & SQLITE_MREMAP_EXTEND ){







>
>
>
>
>
>
>
>







 







|







3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
....
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
    ** that effectively updates the change counter.  This might happen
    ** when restoring a database using the backup API from a zero-length
    ** source.
    */
    if( pFile->inNormalWrite && nByte==0 ){
      pFile->transCntrChng = 1;
    }

    /* If the file was just truncated to a size smaller than the currently
    ** mapped region, reduce the effective mapping size as well. SQLite will
    ** use read() and write() to access data beyond this point from now on.  
    */
    if( nByte<pFile->mmapSize ){
      pFile->mmapSize = nByte;
    }
#endif

    return SQLITE_OK;
  }
}

/*
................................................................................
  unixFile *p = (unixFile *)fd;   /* The underlying database file */
  int rc = SQLITE_OK;             /* Return code */
  void *pNew = 0;                 /* New mapping */
  i64 nNewRnd;                    /* nNew rounded up */
  i64 nOldRnd;                    /* nOld rounded up */

  assert( iOff==0 );
  /* assert( p->mmapSize==nOld ); */
  assert( p->pMapRegion==0 || p->pMapRegion==(*ppMap) );

  /* If the SQLITE_MREMAP_EXTEND flag is set, then the size of the requested 
  ** mapping (nNew bytes) may be greater than the size of the database file.
  ** If this is the case, extend the file on disk using ftruncate().  */
  assert( nNew>0 || (flags & SQLITE_MREMAP_EXTEND)==0 );
  if( flags & SQLITE_MREMAP_EXTEND ){