SQLite

Check-in [4016b42228]
Login

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

Overview
Comment:When sqlite3PagerPagecount() is called without any locks, always return the physical file size, not the logical file size.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4016b422286587beda7323052d27821adb1fed73
User & Date: drh 2010-05-04 18:50:40.000
Context
2010-05-05
00:05
When the in single-threaded mode, the sqlite3_mutex_alloc() interface still returns a non-NULL value. The mutex doesn't do anything, but it tests non-NULL. This way, extensions (or VFSes) that use sqlite3_mutex_alloc() can tell the difference between an OOM error and mutexes being disabled. (check-in: 451fd17575 user: drh tags: trunk)
2010-05-04
18:50
When sqlite3PagerPagecount() is called without any locks, always return the physical file size, not the logical file size. (check-in: 4016b42228 user: drh tags: trunk)
17:38
Be sure to release all wal-index locks before closing the wal-index. (check-in: b15b67fa14 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pager.c.
2781
2782
2783
2784
2785
2786
2787

2788
2789

2790
2791
2792
2793
2794
2795
2796
** Regardless of mxPage, return the current maximum page count.
*/
int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){
  int nPage;
  if( mxPage>0 ){
    pPager->mxPgno = mxPage;
  }

  sqlite3PagerPagecount(pPager, &nPage);
  assert( pPager->mxPgno>=nPage );

  return pPager->mxPgno;
}

/*
** The following set of routines are used to disable the simulated
** I/O error mechanism.  These routines are used to avoid simulated
** errors in places where we do not care about errors.







>
|
|
>







2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
** Regardless of mxPage, return the current maximum page count.
*/
int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){
  int nPage;
  if( mxPage>0 ){
    pPager->mxPgno = mxPage;
  }
  if( pPager->state!=PAGER_UNLOCK ){
    sqlite3PagerPagecount(pPager, &nPage);
    assert( pPager->mxPgno>=nPage );
  }
  return pPager->mxPgno;
}

/*
** The following set of routines are used to disable the simulated
** I/O error mechanism.  These routines are used to avoid simulated
** errors in places where we do not care about errors.
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
  /* Determine the number of pages in the file. Store this in nPage. */
  if( pPager->dbSizeValid ){
    nPage = pPager->dbSize;
  }else{
    int rc;                 /* Error returned by OsFileSize() */
    i64 n = 0;              /* File size in bytes returned by OsFileSize() */

    if( pagerUseWal(pPager) ){
      sqlite3WalDbsize(pPager->pWal, &nPage);
    }

    if( nPage==0 ){
      assert( isOpen(pPager->fd) || pPager->tempFile );
      if( isOpen(pPager->fd) ){
        if( SQLITE_OK!=(rc = sqlite3OsFileSize(pPager->fd, &n)) ){







|







2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
  /* Determine the number of pages in the file. Store this in nPage. */
  if( pPager->dbSizeValid ){
    nPage = pPager->dbSize;
  }else{
    int rc;                 /* Error returned by OsFileSize() */
    i64 n = 0;              /* File size in bytes returned by OsFileSize() */

    if( pagerUseWal(pPager) && pPager->state!=PAGER_UNLOCK ){
      sqlite3WalDbsize(pPager->pWal, &nPage);
    }

    if( nPage==0 ){
      assert( isOpen(pPager->fd) || pPager->tempFile );
      if( isOpen(pPager->fd) ){
        if( SQLITE_OK!=(rc = sqlite3OsFileSize(pPager->fd, &n)) ){