/ Check-in [a420ebd0]
Login

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

Overview
Comment:When computing the amount of scratch memory needed during a rebalance operation, assume the worst case for the number of cells per page, rather than relying on the BtPage.nCell value, which might be incorrect for a corrupt database.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:a420ebd08f5a96b9e61a37cb42e1b3f346c23505630d9c33fe30ce7882959b36
User & Date: drh 2019-03-19 15:36:46
Context
2019-03-19
20:13
Fix a compiler warning in FTS5. check-in: d5acf3af user: drh tags: trunk
15:36
When computing the amount of scratch memory needed during a rebalance operation, assume the worst case for the number of cells per page, rather than relying on the BtPage.nCell value, which might be incorrect for a corrupt database. check-in: a420ebd0 user: drh tags: trunk
11:35
Tweak the tool/cg_anno.tcl script so that it can run on systems without /usr/bin/tclsh. check-in: a026189a user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  7555   7555       if( apOld[i]->nFree<0 ){
  7556   7556         rc = btreeComputeFreeSpace(apOld[i]);
  7557   7557         if( rc ){
  7558   7558           memset(apOld, 0, (i)*sizeof(MemPage*));
  7559   7559           goto balance_cleanup;
  7560   7560         }
  7561   7561       }
  7562         -    nMaxCells += 1+apOld[i]->nCell+apOld[i]->nOverflow;
  7563   7562       if( (i--)==0 ) break;
  7564   7563   
  7565   7564       if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){
  7566   7565         apDiv[i] = pParent->apOvfl[0];
  7567   7566         pgno = get4byte(apDiv[i]);
  7568   7567         szNew[i] = pParent->xCellSize(pParent, apDiv[i]);
  7569   7568         pParent->nOverflow = 0;
................................................................................
  7599   7598         }
  7600   7599         dropCell(pParent, i+nxDiv-pParent->nOverflow, szNew[i], &rc);
  7601   7600       }
  7602   7601     }
  7603   7602   
  7604   7603     /* Make nMaxCells a multiple of 4 in order to preserve 8-byte
  7605   7604     ** alignment */
         7605  +  nMaxCells = nOld*(MX_CELL(pBt) + ArraySize(pParent->apOvfl));
  7606   7606     nMaxCells = (nMaxCells + 3)&~3;
  7607   7607   
  7608   7608     /*
  7609   7609     ** Allocate space for memory structures
  7610   7610     */
  7611   7611     szScratch =
  7612   7612          nMaxCells*sizeof(u8*)                       /* b.apCell */
  7613   7613        + nMaxCells*sizeof(u16)                       /* b.szCell */
  7614   7614        + pBt->pageSize;                              /* aSpace1 */
  7615   7615   
  7616         -  assert( szScratch<=6*(int)pBt->pageSize );
         7616  +  assert( szScratch<=7*(int)pBt->pageSize );
  7617   7617     b.apCell = sqlite3StackAllocRaw(0, szScratch );
  7618   7618     if( b.apCell==0 ){
  7619   7619       rc = SQLITE_NOMEM_BKPT;
  7620   7620       goto balance_cleanup;
  7621   7621     }
  7622   7622     b.szCell = (u16*)&b.apCell[nMaxCells];
  7623   7623     aSpace1 = (u8*)&b.szCell[nMaxCells];