/ Check-in [cb6be84d]
Login

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

Overview
Comment:Modifications to pager.c to avoid the unsigned/signed warnings. (CVS 5909)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cb6be84dfc5d6546d07359b32fe04555561325de
User & Date: danielk1977 2008-11-17 04:56:24
Context
2008-11-17
08:05
Added support for vxworks >= 6.4; RTP mode tested, kernel mode untested. (CVS 5910) check-in: f45a1493 user: chw tags: trunk
04:56
Modifications to pager.c to avoid the unsigned/signed warnings. (CVS 5909) check-in: cb6be84d user: danielk1977 tags: trunk
2008-11-15
11:22
Fix compiler warnings in pcache1.c related to comparison of unsigned and signed values. (CVS 5908) check-in: ce77ea98 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

    14     14   ** The pager is used to access a database disk file.  It implements
    15     15   ** atomic commit and rollback through the use of a journal file that
    16     16   ** is separate from the database file.  The pager also implements file
    17     17   ** locking to prevent two processes from writing the same database
    18     18   ** file simultaneously, or one process from reading the database while
    19     19   ** another is writing.
    20     20   **
    21         -** @(#) $Id: pager.c,v 1.503 2008/11/13 14:28:29 danielk1977 Exp $
           21  +** @(#) $Id: pager.c,v 1.504 2008/11/17 04:56:24 danielk1977 Exp $
    22     22   */
    23     23   #ifndef SQLITE_OMIT_DISKIO
    24     24   #include "sqliteInt.h"
    25     25   
    26     26   /*
    27     27   ** Macros for troubleshooting.  Normally turned off
    28     28   */
................................................................................
   172    172     u8 memDb;                   /* True to inhibit all file I/O */
   173    173     u8 setMaster;               /* True if a m-j name has been written to jrnl */
   174    174     u8 doNotSync;               /* Boolean. While true, do not spill the cache */
   175    175     u8 exclusiveMode;           /* Boolean. True if locking_mode==EXCLUSIVE */
   176    176     u8 journalMode;             /* On of the PAGER_JOURNALMODE_* values */
   177    177     u8 dbModified;              /* True if there are any changes to the Db */
   178    178     u8 changeCountDone;         /* Set after incrementing the change-counter */
          179  +  u8 dbSizeValid;             /* Set when dbSize is correct */
   179    180     u32 vfsFlags;               /* Flags for sqlite3_vfs.xOpen() */
   180    181     int errCode;                /* One of several kinds of errors */
   181         -  int dbSize;                 /* Number of pages in the file */
   182         -  int origDbSize;             /* dbSize before the current change */
   183         -  int stmtSize;               /* Size of database (in pages) at stmt_begin() */
          182  +  Pgno dbSize;                /* Number of pages in the file */
          183  +  Pgno origDbSize;            /* dbSize before the current change */
          184  +  Pgno stmtSize;              /* Size of database (in pages) at stmt_begin() */
   184    185     int nRec;                   /* Number of pages written to the journal */
   185    186     u32 cksumInit;              /* Quasi-random value added to every checksum */
   186    187     int stmtNRec;               /* Number of records in stmt subjournal */
   187    188     int nExtra;                 /* Add this many bytes to each in-memory page */
   188    189     int pageSize;               /* Number of bytes in a page */
   189    190     int nPage;                  /* Total number of in-memory pages */
   190    191     int mxPage;                 /* Maximum number of pages to hold in cache */
................................................................................
   291    292   ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is
   292    293   ** reserved for working around a windows/posix incompatibility). It is
   293    294   ** used in the journal to signify that the remainder of the journal file 
   294    295   ** is devoted to storing a master journal name - there are no more pages to
   295    296   ** roll back. See comments for function writeMasterJournal() for details.
   296    297   */
   297    298   /* #define PAGER_MJ_PGNO(x) (PENDING_BYTE/((x)->pageSize)) */
   298         -#define PAGER_MJ_PGNO(x) ((PENDING_BYTE/((x)->pageSize))+1)
          299  +#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1))
   299    300   
   300    301   /*
   301    302   ** The maximum legal page number is (2^31 - 1).
   302    303   */
   303    304   #define PAGER_MAX_PGNO 2147483647
   304    305   
   305    306   /*
................................................................................
   491    492   ** name in the journal is longer than nMaster bytes (including a
   492    493   ** nul-terminator), then this is handled as if no master journal name
   493    494   ** were present in the journal.
   494    495   **
   495    496   ** If no master journal file name is present zMaster[0] is set to 0 and
   496    497   ** SQLITE_OK returned.
   497    498   */
   498         -static int readMasterJournal(sqlite3_file *pJrnl, char *zMaster, int nMaster){
          499  +static int readMasterJournal(sqlite3_file *pJrnl, char *zMaster, u32 nMaster){
   499    500     int rc;
   500    501     u32 len;
   501    502     i64 szJ;
   502    503     u32 cksum;
   503    504     u32 u;                   /* Unsigned loop counter */
   504    505     unsigned char aMagic[8]; /* A buffer to hold the magic header */
   505    506   
................................................................................
   623    624   ** - 4 bytes: Database page size.
   624    625   ** 
   625    626   ** Followed by (JOURNAL_HDR_SZ - 28) bytes of unused space.
   626    627   */
   627    628   static int writeJournalHdr(Pager *pPager){
   628    629     int rc = SQLITE_OK;
   629    630     char *zHeader = pPager->pTmpSpace;
   630         -  int nHeader = pPager->pageSize;
   631         -  int nWrite;
          631  +  u32 nHeader = pPager->pageSize;
          632  +  u32 nWrite;
   632    633   
   633    634     if( nHeader>JOURNAL_HDR_SZ(pPager) ){
   634    635       nHeader = JOURNAL_HDR_SZ(pPager);
   635    636     }
   636    637   
   637    638     if( pPager->stmtHdrOff==0 ){
   638    639       pPager->stmtHdrOff = pPager->journalOff;
................................................................................
   883    884   ** on the pager file (by this or any other process), it will be
   884    885   ** treated as a hot-journal and rolled back.
   885    886   */
   886    887   static void pager_unlock(Pager *pPager){
   887    888     if( !pPager->exclusiveMode ){
   888    889       int rc = osUnlock(pPager->fd, NO_LOCK);
   889    890       if( rc ) pPager->errCode = rc;
   890         -    pPager->dbSize = -1;
          891  +    pPager->dbSizeValid = 0;
   891    892       IOTRACE(("UNLOCK %p\n", pPager))
   892    893   
   893    894       /* Always close the journal file when dropping the database lock.
   894    895       ** Otherwise, another connection with journal_mode=delete might
   895    896       ** delete the file out from under us.
   896    897       */
   897    898       if( pPager->journalOpen ){
................................................................................
  1018   1019       pPager->state = PAGER_EXCLUSIVE;
  1019   1020     }
  1020   1021     pPager->origDbSize = 0;
  1021   1022     pPager->setMaster = 0;
  1022   1023     pPager->needSync = 0;
  1023   1024     /* lruListSetFirstSynced(pPager); */
  1024   1025     if( !MEMDB ){
  1025         -    pPager->dbSize = -1;
         1026  +    pPager->dbSizeValid = 0;
  1026   1027     }
  1027   1028     pPager->dbModified = 0;
  1028   1029   
  1029   1030     return (rc==SQLITE_OK?rc2:rc);
  1030   1031   }
  1031   1032   
  1032   1033   /*
................................................................................
  1306   1307   ** which has extended the file size and the new pages are still all held
  1307   1308   ** in cache, then an INSERT or UPDATE does a statement rollback.  Some
  1308   1309   ** operating system implementations can get confused if you try to
  1309   1310   ** truncate a file to some size that is larger than it currently is,
  1310   1311   ** so detect this case and write a single zero byte to the end of the new
  1311   1312   ** file instead.
  1312   1313   */
  1313         -static int pager_truncate(Pager *pPager, int nPage){
         1314  +static int pager_truncate(Pager *pPager, Pgno nPage){
  1314   1315     int rc = SQLITE_OK;
  1315   1316     if( pPager->state>=PAGER_EXCLUSIVE && pPager->fd->pMethods ){
  1316   1317       i64 currentSize, newSize;
  1317   1318       rc = sqlite3OsFileSize(pPager->fd, &currentSize);
  1318   1319       newSize = pPager->pageSize*(i64)nPage;
  1319   1320       if( rc==SQLITE_OK && currentSize!=newSize ){
  1320   1321         if( currentSize>newSize ){
................................................................................
  1815   1816       memcpy(pPager->zFilename, zPathname, nPathname+1);
  1816   1817       sqlite3_free(zPathname);
  1817   1818     }
  1818   1819   
  1819   1820     /* Open the pager file.
  1820   1821     */
  1821   1822     if( zFilename && zFilename[0] && !memDb ){
  1822         -    if( nPathname>(pVfs->mxPathname - sizeof("-journal")) ){
         1823  +    if( nPathname>(pVfs->mxPathname - (int)sizeof("-journal")) ){
  1823   1824         rc = SQLITE_CANTOPEN;
  1824   1825       }else{
  1825   1826         int fout = 0;
  1826   1827         rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd,
  1827   1828                            pPager->vfsFlags, &fout);
  1828   1829         readOnly = (fout&SQLITE_OPEN_READONLY);
  1829   1830   
................................................................................
  1906   1907   
  1907   1908     /* pPager->journalOpen = 0; */
  1908   1909     pPager->useJournal = useJournal;
  1909   1910     pPager->noReadlock = noReadlock && readOnly;
  1910   1911     /* pPager->stmtOpen = 0; */
  1911   1912     /* pPager->stmtInUse = 0; */
  1912   1913     /* pPager->nRef = 0; */
  1913         -  pPager->dbSize = memDb-1;
         1914  +  pPager->dbSizeValid = memDb;
  1914   1915     pPager->pageSize = szPageDflt;
  1915   1916     /* pPager->stmtSize = 0; */
  1916   1917     /* pPager->stmtJSize = 0; */
  1917   1918     /* pPager->nPage = 0; */
  1918   1919     pPager->mxPage = 100;
  1919   1920     pPager->mxPgno = SQLITE_MAX_PAGE_COUNT;
  1920   1921     /* pPager->state = PAGER_UNLOCK; */
................................................................................
  2084   2085     i64 n = 0;
  2085   2086     int rc;
  2086   2087     assert( pPager!=0 );
  2087   2088     if( pPager->errCode ){
  2088   2089       rc = pPager->errCode;
  2089   2090       return rc;
  2090   2091     }
  2091         -  if( pPager->dbSize>=0 ){
         2092  +  if( pPager->dbSizeValid ){
  2092   2093       n = pPager->dbSize;
  2093   2094     } else {
  2094   2095       assert(pPager->fd->pMethods||pPager->tempFile);
  2095   2096       if( (pPager->fd->pMethods)
  2096   2097        && (rc = sqlite3OsFileSize(pPager->fd, &n))!=SQLITE_OK ){
  2097   2098         pager_error(pPager, rc);
  2098   2099         return rc;
................................................................................
  2100   2101       if( n>0 && n<pPager->pageSize ){
  2101   2102         n = 1;
  2102   2103       }else{
  2103   2104         n /= pPager->pageSize;
  2104   2105       }
  2105   2106       if( pPager->state!=PAGER_UNLOCK ){
  2106   2107         pPager->dbSize = n;
         2108  +      pPager->dbSizeValid = 1;
  2107   2109       }
  2108   2110     }
  2109   2111     if( n==(PENDING_BYTE/pPager->pageSize) ){
  2110   2112       n++;
  2111   2113     }
  2112   2114     if( n>pPager->mxPgno ){
  2113   2115       pPager->mxPgno = n;
................................................................................
  2152   2154   
  2153   2155     /* The OS lock values must be the same as the Pager lock values */
  2154   2156     assert( PAGER_SHARED==SHARED_LOCK );
  2155   2157     assert( PAGER_RESERVED==RESERVED_LOCK );
  2156   2158     assert( PAGER_EXCLUSIVE==EXCLUSIVE_LOCK );
  2157   2159   
  2158   2160     /* If the file is currently unlocked then the size must be unknown */
  2159         -  assert( pPager->state>=PAGER_SHARED || pPager->dbSize<0 );
         2161  +  assert( pPager->state>=PAGER_SHARED || pPager->dbSizeValid==0 );
  2160   2162   
  2161   2163     if( pPager->state>=locktype ){
  2162   2164       rc = SQLITE_OK;
  2163   2165     }else{
  2164   2166       if( pPager->pBusyHandler ) pPager->pBusyHandler->nBusy = 0;
  2165   2167       do {
  2166   2168         rc = sqlite3OsLock(pPager->fd, locktype);
................................................................................
  2179   2181   int sqlite3PagerTruncate(Pager *pPager, Pgno nPage){
  2180   2182     int rc = SQLITE_OK;
  2181   2183     assert( pPager->state>=PAGER_SHARED );
  2182   2184   
  2183   2185     sqlite3PagerPagecount(pPager, 0);
  2184   2186     if( pPager->errCode ){
  2185   2187       rc = pPager->errCode;
  2186         -  }else if( nPage<(unsigned)pPager->dbSize ){
         2188  +  }else if( nPage<pPager->dbSize ){
  2187   2189       rc = syncJournal(pPager);
  2188   2190       if( rc==SQLITE_OK ){
  2189   2191         /* Get an exclusive lock on the database before truncating. */
  2190   2192         rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
  2191   2193       }
  2192   2194       if( rc==SQLITE_OK ){
  2193   2195         rc = pager_truncate(pPager, nPage);
................................................................................
  2689   2691         sqlite3PagerPagecount(pPager, 0);
  2690   2692   
  2691   2693         if( pPager->errCode ){
  2692   2694           rc = pPager->errCode;
  2693   2695           goto failed;
  2694   2696         }
  2695   2697   
         2698  +      assert( pPager->dbSizeValid );
  2696   2699         if( pPager->dbSize>0 ){
  2697   2700           IOTRACE(("CKVERS %p %d\n", pPager, sizeof(dbFileVers)));
  2698   2701           rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
  2699   2702           if( rc!=SQLITE_OK ){
  2700   2703             goto failed;
  2701   2704           }
  2702   2705         }else{
................................................................................
  3181   3184       pPager->dbModified = 1;
  3182   3185     
  3183   3186       /* The transaction journal now exists and we have a RESERVED or an
  3184   3187       ** EXCLUSIVE lock on the main database file.  Write the current page to
  3185   3188       ** the transaction journal if it is not there already.
  3186   3189       */
  3187   3190       if( !pageInJournal(pPg) && pPager->journalOpen ){
  3188         -      if( (int)pPg->pgno <= pPager->origDbSize ){
         3191  +      if( pPg->pgno<=pPager->origDbSize ){
  3189   3192           u32 cksum;
  3190   3193           char *pData2;
  3191   3194   
  3192   3195           /* We should never write to the journal file the page that
  3193   3196           ** contains the database locks.  The following assert verifies
  3194   3197           ** that we do not. */
  3195   3198           assert( pPg->pgno!=PAGER_MJ_PGNO(pPager) );
................................................................................
  3244   3247       /* If the statement journal is open and the page is not in it,
  3245   3248       ** then write the current page to the statement journal.  Note that
  3246   3249       ** the statement journal format differs from the standard journal format
  3247   3250       ** in that it omits the checksums and the header.
  3248   3251       */
  3249   3252       if( pPager->stmtInUse 
  3250   3253        && !pageInStatement(pPg) 
  3251         -     && (int)pPg->pgno<=pPager->stmtSize 
         3254  +     && pPg->pgno<=pPager->stmtSize 
  3252   3255       ){
  3253   3256         i64 offset = pPager->stmtNRec*(4+pPager->pageSize);
  3254   3257         char *pData2 = CODEC2(pPager, pData, pPg->pgno, 7);
  3255         -      assert( pageInJournal(pPg) || (int)pPg->pgno>pPager->origDbSize );
         3258  +      assert( pageInJournal(pPg) || pPg->pgno>pPager->origDbSize );
  3256   3259         rc = write32bits(pPager->stfd, offset, pPg->pgno);
  3257   3260         if( rc==SQLITE_OK ){
  3258   3261           rc = sqlite3OsWrite(pPager->stfd, pData2, pPager->pageSize, offset+4);
  3259   3262         }
  3260   3263         PAGERTRACE3("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno);
  3261   3264         if( rc!=SQLITE_OK ){
  3262   3265           return rc;
................................................................................
  3266   3269         sqlite3BitvecSet(pPager->pInStmt, pPg->pgno);
  3267   3270       }
  3268   3271     }
  3269   3272   
  3270   3273     /* Update the database size and return.
  3271   3274     */
  3272   3275     assert( pPager->state>=PAGER_SHARED );
  3273         -  if( pPager->dbSize<(int)pPg->pgno ){
         3276  +  if( pPager->dbSize<pPg->pgno ){
  3274   3277       pPager->dbSize = pPg->pgno;
  3275         -    if( pPager->dbSize==PENDING_BYTE/pPager->pageSize ){
         3278  +    if( pPager->dbSize==(PAGER_MJ_PGNO(pPager)-1) ){
  3276   3279         pPager->dbSize++;
  3277   3280       }
  3278   3281     }
  3279   3282     return rc;
  3280   3283   }
  3281   3284   
  3282   3285   /*
................................................................................
  3426   3429         return SQLITE_NOMEM;
  3427   3430       }
  3428   3431     }
  3429   3432     rc = sqlite3BitvecSet(pPager->pAlwaysRollback, pPg->pgno);
  3430   3433   
  3431   3434     if( rc==SQLITE_OK && (pPg->flags&PGHDR_DIRTY) && !pPager->stmtInUse ){
  3432   3435       assert( pPager->state>=PAGER_SHARED );
  3433         -    if( pPager->dbSize==(int)pPg->pgno && pPager->origDbSize<pPager->dbSize ){
         3436  +    if( pPager->dbSize==pPg->pgno && pPager->origDbSize<pPager->dbSize ){
  3434   3437         /* If this pages is the last page in the file and the file has grown
  3435   3438         ** during the current transaction, then do NOT mark the page as clean.
  3436   3439         ** When the database file grows, we must make sure that the last page
  3437   3440         ** gets written at least once so that the disk file will be the correct
  3438   3441         ** size. If you do not write this page and the size of the file
  3439   3442         ** on the disk ends up being too small, that can lead to database
  3440   3443         ** corruption during the next transaction.
................................................................................
  3475   3478      || sqlite3BitvecTest(pPager->pAlwaysRollback, pPg->pgno)
  3476   3479      || pPg->pgno>pPager->origDbSize
  3477   3480     ){
  3478   3481       return;
  3479   3482     }
  3480   3483   
  3481   3484   #ifdef SQLITE_SECURE_DELETE
  3482         -  if( (pPg->flags & PGHDR_IN_JOURNAL)!=0 || (int)pPg->pgno>pPager->origDbSize ){
         3485  +  if( (pPg->flags & PGHDR_IN_JOURNAL)!=0 || pPg->pgno>pPager->origDbSize ){
  3483   3486       return;
  3484   3487     }
  3485   3488   #endif
  3486   3489   
  3487   3490     /* If SECURE_DELETE is disabled, then there is no way that this
  3488   3491     ** routine can be called on a page for which sqlite3PagerDontWrite()
  3489   3492     ** has not been previously called during the same transaction.
................................................................................
  3674   3677   #ifndef SQLITE_OMIT_AUTOVACUUM
  3675   3678           if( nTrunc!=0 ){
  3676   3679             /* If this transaction has made the database smaller, then all pages
  3677   3680             ** being discarded by the truncation must be written to the journal
  3678   3681             ** file.
  3679   3682             */
  3680   3683             Pgno i;
  3681         -          int iSkip = PAGER_MJ_PGNO(pPager);
         3684  +          Pgno iSkip = PAGER_MJ_PGNO(pPager);
  3682   3685             for( i=nTrunc+1; i<=pPager->origDbSize; i++ ){
  3683   3686               if( !sqlite3BitvecTest(pPager->pInJournal, i) && i!=iSkip ){
  3684   3687                 rc = sqlite3PagerGet(pPager, i, &pPg);
  3685   3688                 if( rc!=SQLITE_OK ) goto sync_exit;
  3686   3689                 rc = sqlite3PagerWrite(pPg);
  3687   3690                 sqlite3PagerUnref(pPg);
  3688   3691                 if( rc!=SQLITE_OK ) goto sync_exit;
................................................................................
  3804   3807           rc = rc2;
  3805   3808         }
  3806   3809       }else{
  3807   3810         rc = pager_playback(pPager, 0);
  3808   3811       }
  3809   3812   
  3810   3813       if( !MEMDB ){
  3811         -      pPager->dbSize = -1;
         3814  +      pPager->dbSizeValid = 0;
  3812   3815       }
  3813   3816   
  3814   3817       /* If an error occurs during a ROLLBACK, we can no longer trust the pager
  3815   3818       ** cache. So call pager_error() on the way out to make any error 
  3816   3819       ** persistent.
  3817   3820       */
  3818   3821       rc = pager_error(pPager, rc);
................................................................................
  3847   3850   ** This routine is used for testing and analysis only.
  3848   3851   */
  3849   3852   int *sqlite3PagerStats(Pager *pPager){
  3850   3853     static int a[11];
  3851   3854     a[0] = sqlite3PcacheRefCount(pPager->pPCache);
  3852   3855     a[1] = sqlite3PcachePagecount(pPager->pPCache);
  3853   3856     a[2] = sqlite3PcacheGetCachesize(pPager->pPCache);
  3854         -  a[3] = pPager->dbSize;
         3857  +  a[3] = pPager->dbSizeValid ? (int) pPager->dbSize : -1;
  3855   3858     a[4] = pPager->state;
  3856   3859     a[5] = pPager->errCode;
  3857   3860     a[6] = pPager->nHit;
  3858   3861     a[7] = pPager->nMiss;
  3859   3862     a[8] = 0;  /* Used to be pPager->nOvfl */
  3860   3863     a[9] = pPager->nRead;
  3861   3864     a[10] = pPager->nWrite;
................................................................................
  3873   3876   ** open.  A new statement journal is created that can be used to rollback
  3874   3877   ** changes of a single SQL command within a larger transaction.
  3875   3878   */
  3876   3879   static int pagerStmtBegin(Pager *pPager){
  3877   3880     int rc;
  3878   3881     assert( !pPager->stmtInUse );
  3879   3882     assert( pPager->state>=PAGER_SHARED );
  3880         -  assert( pPager->dbSize>=0 );
         3883  +  assert( pPager->dbSizeValid );
  3881   3884     PAGERTRACE2("STMT-BEGIN %d\n", PAGERID(pPager));
  3882   3885     if( !pPager->journalOpen ){
  3883   3886       pPager->stmtAutoopen = 1;
  3884   3887       return SQLITE_OK;
  3885   3888     }
  3886   3889     assert( pPager->journalOpen );
  3887   3890     assert( pPager->pInStmt==0 );
................................................................................
  4055   4058     **
  4056   4059     ** If the isCommit flag is set, there is no need to remember that
  4057   4060     ** the journal needs to be sync()ed before database page pPg->pgno 
  4058   4061     ** can be written to. The caller has already promised not to write to it.
  4059   4062     */
  4060   4063     if( (pPg->flags&PGHDR_NEED_SYNC) && !isCommit ){
  4061   4064       needSyncPgno = pPg->pgno;
  4062         -    assert( pageInJournal(pPg) || (int)pgno>pPager->origDbSize );
         4065  +    assert( pageInJournal(pPg) || pgno>pPager->origDbSize );
  4063   4066       assert( pPg->flags&PGHDR_DIRTY );
  4064   4067       assert( pPager->needSync );
  4065   4068     }
  4066   4069   
  4067   4070     /* If the cache contains a page with page-number pgno, remove it
  4068   4071     ** from its hash chain. Also, if the PgHdr.needSync was set for 
  4069   4072     ** page pgno before the 'move' operation, it needs to be retained 
................................................................................
  4104   4107       ** sure the Pager.needSync flag is set too.
  4105   4108       */
  4106   4109       int rc;
  4107   4110       PgHdr *pPgHdr;
  4108   4111       assert( pPager->needSync );
  4109   4112       rc = sqlite3PagerGet(pPager, needSyncPgno, &pPgHdr);
  4110   4113       if( rc!=SQLITE_OK ){
  4111         -      if( pPager->pInJournal && (int)needSyncPgno<=pPager->origDbSize ){
         4114  +      if( pPager->pInJournal && needSyncPgno<=pPager->origDbSize ){
  4112   4115           sqlite3BitvecClear(pPager->pInJournal, needSyncPgno);
  4113   4116         }
  4114   4117         return rc;
  4115   4118       }
  4116   4119       pPager->needSync = 1;
  4117   4120       assert( pPager->noSync==0 && !MEMDB );
  4118   4121       pPgHdr->flags |= PGHDR_NEED_SYNC;