/ Check-in [30c26c3b]
Login

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

Overview
Comment:The previous check-in with changes to the max_page_count pragma was not quite correct. This check-in fixes the problem.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 30c26c3b13b29ce57683e91ac11641d4eb4d678f
User & Date: drh 2010-11-23 20:25:09
Context
2010-11-23
20:55
Cherry-pick the lemon.c updates out of the lemon-update-2010 branch into the trunk. check-in: 1541ae3f user: drh tags: trunk
20:25
The previous check-in with changes to the max_page_count pragma was not quite correct. This check-in fixes the problem. check-in: 30c26c3b user: drh tags: trunk
18:59
Fix the max_page_count pragma so that it will not set to a value smaller than the current database size, as the documentation requires. Also, remove all occurances of atoi() from the core. check-in: 2031974b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

  3479   3479   **
  3480   3480   ** Regardless of mxPage, return the current maximum page count.
  3481   3481   */
  3482   3482   int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){
  3483   3483     if( mxPage>0 ){
  3484   3484       pPager->mxPgno = mxPage;
  3485   3485     }
  3486         -  if( pPager->eState!=PAGER_OPEN && pPager->mxPgno<pPager->dbSize ){
  3487         -    pPager->mxPgno = pPager->dbSize;
  3488         -  }
         3486  +  assert( pPager->eState!=PAGER_OPEN );      /* Called only by OP_MaxPgcnt */
         3487  +  assert( pPager->mxPgno>=pPager->dbSize );  /* OP_MaxPgcnt enforces this */
  3489   3488     return pPager->mxPgno;
  3490   3489   }
  3491   3490   
  3492   3491   /*
  3493   3492   ** The following set of routines are used to disable the simulated
  3494   3493   ** I/O error mechanism.  These routines are used to avoid simulated
  3495   3494   ** errors in places where we do not care about errors.

Changes to src/vdbe.c.

  5789   5789   #endif
  5790   5790   
  5791   5791   
  5792   5792   #ifndef  SQLITE_OMIT_PAGER_PRAGMAS
  5793   5793   /* Opcode: MaxPgcnt P1 P2 P3 * *
  5794   5794   **
  5795   5795   ** Try to set the maximum page count for database P1 to the value in P3.
  5796         -** Do not let the maximum page count fall below the current page count.
         5796  +** Do not let the maximum page count fall below the current page count and
         5797  +** do not change the maximum page count value if P3==0.
         5798  +**
  5797   5799   ** Store the maximum page count after the change in register P2.
  5798   5800   */
  5799   5801   case OP_MaxPgcnt: {            /* out2-prerelease */
  5800         -  unsigned int pgcnt;
         5802  +  unsigned int newMax;
  5801   5803     Btree *pBt;
  5802   5804   
  5803   5805     pBt = db->aDb[pOp->p1].pBt;
  5804         -  pgcnt = sqlite3BtreeLastPage(pBt);
  5805         -  pOut->u.i = sqlite3BtreeMaxPageCount(pBt, pOp->p3<pgcnt ? pgcnt : pOp->p3);
         5806  +  newMax = 0;
         5807  +  if( pOp->p3 ){
         5808  +    newMax = sqlite3BtreeLastPage(pBt);
         5809  +    if( pOp->p3>newMax ) newMax = pOp->p3;
         5810  +  }
         5811  +  pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax);
  5806   5812     break;
  5807   5813   }
  5808   5814   #endif
  5809   5815   
  5810   5816   
  5811   5817   #ifndef SQLITE_OMIT_TRACE
  5812   5818   /* Opcode: Trace * * * P4 *