SQLite

Check-in [54c1718e6d]
Login

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

Overview
Comment:Remove unreachable code associated with WAL from the pager.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 54c1718e6d15a20414cae15895eb5e83217722e2
User & Date: drh 2010-05-25 02:24:01.000
Context
2010-05-25
10:50
If a writer exits unexpectedly in the middle of a transaction, have the following writer remove any wal-index hash-table entries left by the interrupted transaction. (check-in: ed77556adc user: dan tags: trunk)
02:24
Remove unreachable code associated with WAL from the pager. (check-in: 54c1718e6d user: drh tags: trunk)
2010-05-24
20:27
OOM errors during an auto-checkpoint are benign. (check-in: 3d252ce5d0 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pager.c.
2388
2389
2390
2391
2392
2393
2394

2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
** Check if the *-wal file that corresponds to the database opened by pPager
** exists. Assuming no error occurs, set *pExists to 1 if the file exists,
** or 0 otherwise and return SQLITE_OK. If an IO or OOM error occurs, return
** an SQLite error code.
*/
static int pagerHasWAL(Pager *pPager, int *pExists){
  int rc;                         /* Return code */


  if( !pPager->tempFile ){
    char *zWal = sqlite3_mprintf("%s-wal", pPager->zFilename);
    if( !zWal ){
      rc = SQLITE_NOMEM;
    }else{
      rc = sqlite3OsAccess(pPager->pVfs, zWal, SQLITE_ACCESS_EXISTS, pExists);
      sqlite3_free(zWal);
    }
  }else{
    rc = SQLITE_OK;
    *pExists = 0;
  }
  return rc;
}

/*
** Check if the *-wal file that corresponds to the database opened by pPager
** exists. If it does, open the pager in WAL mode. Otherwise, if no error







>

|
|
|
|
|
|
|
<
<
<
<







2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403




2404
2405
2406
2407
2408
2409
2410
** Check if the *-wal file that corresponds to the database opened by pPager
** exists. Assuming no error occurs, set *pExists to 1 if the file exists,
** or 0 otherwise and return SQLITE_OK. If an IO or OOM error occurs, return
** an SQLite error code.
*/
static int pagerHasWAL(Pager *pPager, int *pExists){
  int rc;                         /* Return code */
  char *zWal;                     /* Name of the WAL file */

  assert( !pPager->tempFile );
  zWal = sqlite3_mprintf("%s-wal", pPager->zFilename);
  if( !zWal ){
    rc = SQLITE_NOMEM;
  }else{
    rc = sqlite3OsAccess(pPager->pVfs, zWal, SQLITE_ACCESS_EXISTS, pExists);
    sqlite3_free(zWal);




  }
  return rc;
}

/*
** Check if the *-wal file that corresponds to the database opened by pPager
** exists. If it does, open the pager in WAL mode. Otherwise, if no error
2843
2844
2845
2846
2847
2848
2849






2850
2851
2852
2853
2854
2855
2856

2857
2858
2859
2860
2861
2862
2863
** output buffer undefined.
*/
int sqlite3PagerReadFileheader(Pager *pPager, int N, unsigned char *pDest){
  int rc = SQLITE_OK;
  memset(pDest, 0, N);
  assert( isOpen(pPager->fd) || pPager->tempFile );







  if( pagerUseWal(pPager) ){
    int isInWal = 0;
    rc = sqlite3WalRead(pPager->pWal, 1, &isInWal, N, pDest);
    if( rc!=SQLITE_OK || isInWal ){
      return rc;
    }
  }


  if( isOpen(pPager->fd) ){
    IOTRACE(("DBHDR %p 0 %d\n", pPager, N))
    rc = sqlite3OsRead(pPager->fd, pDest, N, 0);
    if( rc==SQLITE_IOERR_SHORT_READ ){
      rc = SQLITE_OK;
    }







>
>
>
>
>
>







>







2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
** output buffer undefined.
*/
int sqlite3PagerReadFileheader(Pager *pPager, int N, unsigned char *pDest){
  int rc = SQLITE_OK;
  memset(pDest, 0, N);
  assert( isOpen(pPager->fd) || pPager->tempFile );

  /* This routine is only called by btree immediately after creating
  ** the Pager object.  There has not been an opportunity to transition
  ** to WAL mode yet.
  */
  assert( !pagerUseWal(pPager) );
#if 0
  if( pagerUseWal(pPager) ){
    int isInWal = 0;
    rc = sqlite3WalRead(pPager->pWal, 1, &isInWal, N, pDest);
    if( rc!=SQLITE_OK || isInWal ){
      return rc;
    }
  }
#endif

  if( isOpen(pPager->fd) ){
    IOTRACE(("DBHDR %p 0 %d\n", pPager, N))
    rc = sqlite3OsRead(pPager->fd, pDest, N, 0);
    if( rc==SQLITE_IOERR_SHORT_READ ){
      rc = SQLITE_OK;
    }