/ Check-in [bd50fbb5]
Login

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

Overview
Comment:Auto-vacuum bugfix: Do not attempt to move a pointer-map page during auto-vacuum. (CVS 2044)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: bd50fbb5fecd1829c87e8ca72c458c71f590274b
User & Date: danielk1977 2004-11-03 03:52:37
Context
2004-11-03
03:59
The makefile now runs mkkeywordhash.c. Keywords that are unused are omitted from the keyword hash table. (CVS 2045) check-in: 007aec11 user: drh tags: trunk
03:52
Auto-vacuum bugfix: Do not attempt to move a pointer-map page during auto-vacuum. (CVS 2044) check-in: bd50fbb5 user: danielk1977 tags: trunk
03:01
Fix an auto-vacuum bug that occurs when a btree cell is promoted to the parent page during a delete. (CVS 2043) check-in: b7d953e1 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.200 2004/11/03 03:01:17 danielk1977 Exp $
           12  +** $Id: btree.c,v 1.201 2004/11/03 03:52:37 danielk1977 Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** For a detailed discussion of BTrees, refer to
    16     16   **
    17     17   **     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
    18     18   **     "Sorting And Searching", pages 473-480. Addison-Wesley
    19     19   **     Publishing Company, Reading, Massachusetts.
................................................................................
  1636   1636   
  1637   1637     /* Figure out how many free-pages are in the database. If there are no
  1638   1638     ** free pages, then auto-vacuum is a no-op.
  1639   1639     */
  1640   1640     nFreeList = get4byte(&pBt->pPage1->aData[36]);
  1641   1641     if( nFreeList==0 ) return SQLITE_OK;
  1642   1642   
         1643  +  /* TODO: This does not calculate finDbSize correctly for the case where
         1644  +  ** pointer-map pages must be deallocated.
         1645  +  */
  1643   1646     origDbSize = sqlite3pager_pagecount(pPager);
  1644   1647     finDbSize = origDbSize - nFreeList;
  1645   1648     TRACE(("AUTOVACUUM: Begin (db size %d->%d)\n", origDbSize, finDbSize));
  1646   1649   
  1647   1650     /* Note: This is temporary code for use during development of auto-vacuum. 
  1648   1651     **
  1649   1652     ** Inspect the pointer map to make sure there are no root pages with a
................................................................................
  1667   1670     ** to a free page earlier in the file (somewhere before finDbSize).
  1668   1671     */
  1669   1672     for( iDbPage=finDbSize+1; iDbPage<=origDbSize; iDbPage++ ){
  1670   1673       rc = ptrmapGet(pBt, iDbPage, &eType, &iPtrPage);
  1671   1674       if( rc!=SQLITE_OK ) goto autovacuum_out;
  1672   1675       assert( eType!=PTRMAP_ROOTPAGE );
  1673   1676   
  1674         -    /* If iDbPage is already on the free-list, do not swap it. */
  1675         -    if( eType==PTRMAP_FREEPAGE ){
         1677  +    /* If iDbPage is a free or pointer map page, do not swap it. */
         1678  +    if( eType==PTRMAP_FREEPAGE ||
         1679  +        iDbPage==PTRMAP_PAGENO(pBt->pageSize, iDbPage) ){
  1676   1680         continue;
  1677   1681       }
  1678   1682       rc = getPage(pBt, iDbPage, &pDbMemPage);
  1679   1683       if( rc!=SQLITE_OK ) goto autovacuum_out;
  1680   1684       pDbPage = pDbMemPage->aData;
  1681   1685   
  1682   1686       /* Find the next page in the free-list that is not already at the end