/ Changes On Branch pager-get-noinit
Login

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

Changes In Branch pager-get-noinit Excluding Merge-Ins

This is equivalent to a diff from d5fc2f7f90 to 0c97b80240

2016-04-05
13:19
Do not allow pointer arithmetic to move a pointer across a memory allocation boundary. (check-in: 85b979319b user: drh tags: trunk)
00:44
Avoid unnecessary memset() operations in sqlite3PagerGet(). (Leaf check-in: 0c97b80240 user: drh tags: pager-get-noinit)
2016-04-04
18:04
Fix documentation typos. Comment changes only. No changes to code. (check-in: d5fc2f7f90 user: drh tags: trunk)
17:59
Improve error messages from the 'shell1-5.0' test. (check-in: cefd36ff7b user: mistachkin tags: trunk)

Changes to src/backup.c.

   289    289     ** page. For each iteration, variable iOff is set to the byte offset
   290    290     ** of the destination page.
   291    291     */
   292    292     for(iOff=iEnd-(i64)nSrcPgsz; rc==SQLITE_OK && iOff<iEnd; iOff+=nDestPgsz){
   293    293       DbPage *pDestPg = 0;
   294    294       Pgno iDest = (Pgno)(iOff/nDestPgsz)+1;
   295    295       if( iDest==PENDING_BYTE_PAGE(p->pDest->pBt) ) continue;
   296         -    if( SQLITE_OK==(rc = sqlite3PagerGet(pDestPager, iDest, &pDestPg, 0))
          296  +    if( SQLITE_OK==(rc = sqlite3PagerGet(pDestPager, iDest, &pDestPg, 
          297  +                                         PAGER_GET_NOINIT))
   297    298        && SQLITE_OK==(rc = sqlite3PagerWrite(pDestPg))
   298    299       ){
   299    300         const u8 *zIn = &zSrcData[iOff%nSrcPgsz];
   300    301         u8 *zDestData = sqlite3PagerGetData(pDestPg);
   301    302         u8 *zOut = &zDestData[iOff%nDestPgsz];
   302    303   
   303    304         /* Copy the data from the source page into the destination page.

Changes to src/pager.c.

  5296   5296     Pgno pgno,          /* Page number to fetch */
  5297   5297     DbPage **ppPage,    /* Write a pointer to the page here */
  5298   5298     int flags           /* PAGER_GET_XXX flags */
  5299   5299   ){
  5300   5300     int rc = SQLITE_OK;
  5301   5301     PgHdr *pPg = 0;
  5302   5302     u32 iFrame = 0;                 /* Frame to read from WAL file */
  5303         -  const int noContent = (flags & PAGER_GET_NOCONTENT);
         5303  +#define noContent  ((flags & PAGER_GET_NOCONTENT)!=0)
  5304   5304   
  5305   5305     /* It is acceptable to use a read-only (mmap) page for any page except
  5306   5306     ** page 1 if there is no write-transaction open or the ACQUIRE_READONLY
  5307   5307     ** flag was specified by the caller. And so long as the db is not a 
  5308   5308     ** temporary or in-memory database.  */
  5309   5309     const int bMmapOk = (pgno>1 && USEFETCH(pPager)
  5310   5310      && (pPager->eState==PAGER_READER || (flags & PAGER_GET_READONLY))
................................................................................
  5428   5428             TESTONLY( rc = ) sqlite3BitvecSet(pPager->pInJournal, pgno);
  5429   5429             testcase( rc==SQLITE_NOMEM );
  5430   5430           }
  5431   5431           TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno);
  5432   5432           testcase( rc==SQLITE_NOMEM );
  5433   5433           sqlite3EndBenignMalloc();
  5434   5434         }
  5435         -      memset(pPg->pData, 0, pPager->pageSize);
  5436         -      IOTRACE(("ZERO %p %d\n", pPager, pgno));
         5435  +      if( (flags & PAGER_GET_NOINIT)==0 ){
         5436  +        memset(pPg->pData, 0, pPager->pageSize);
         5437  +        IOTRACE(("ZERO %p %d\n", pPager, pgno));
         5438  +      }
  5437   5439       }else{
  5438   5440         if( pagerUseWal(pPager) && bMmapOk==0 ){
  5439   5441           rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iFrame);
  5440   5442           if( rc!=SQLITE_OK ) goto pager_acquire_err;
  5441   5443         }
  5442   5444         assert( pPg->pPager==pPager );
  5443   5445         pPager->aStat[PAGER_STAT_MISS]++;
................................................................................
  5457   5459       sqlite3PcacheDrop(pPg);
  5458   5460     }
  5459   5461     pagerUnlockIfUnused(pPager);
  5460   5462   
  5461   5463     *ppPage = 0;
  5462   5464     return rc;
  5463   5465   }
         5466  +#undef noContent
  5464   5467   
  5465   5468   /*
  5466   5469   ** Acquire a page if it is already in the in-memory cache.  Do
  5467   5470   ** not read the page from disk.  Return a pointer to the page,
  5468   5471   ** or 0 if the page is not in cache. 
  5469   5472   **
  5470   5473   ** See also sqlite3PagerGet().  The difference between this routine

Changes to src/pager.h.

    79     79   #define PAGER_JOURNALMODE_WAL         5   /* Use write-ahead logging */
    80     80   
    81     81   /*
    82     82   ** Flags that make up the mask passed to sqlite3PagerGet().
    83     83   */
    84     84   #define PAGER_GET_NOCONTENT     0x01  /* Do not load data from disk */
    85     85   #define PAGER_GET_READONLY      0x02  /* Read-only page is acceptable */
           86  +#define PAGER_GET_NOINIT        0x04  /* Do not initialize the page */
    86     87   
    87     88   /*
    88     89   ** Flags for sqlite3PagerSetFlags()
    89     90   */
    90     91   #define PAGER_SYNCHRONOUS_OFF       0x01  /* PRAGMA synchronous=OFF */
    91     92   #define PAGER_SYNCHRONOUS_NORMAL    0x02  /* PRAGMA synchronous=NORMAL */
    92     93   #define PAGER_SYNCHRONOUS_FULL      0x03  /* PRAGMA synchronous=FULL */