/ Check-in [36fc0add]
Login

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

Overview
Comment:Bug fix: When the database file grows in size during a transaction, make sure the last page of the file gets written to disk even if that page is on the free list and contains no data. Otherwise the disk file will be too small which can lead to database corruption in subsequent transactions. (CVS 643)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:36fc0add660f9f3676783765d37280aa874caecb
User & Date: drh 2002-06-25 14:43:58
Context
2002-06-25
14:46
Fix a spelling error in the change log. (CVS 644) check-in: 37cc4044 user: drh tags: trunk
14:43
Bug fix: When the database file grows in size during a transaction, make sure the last page of the file gets written to disk even if that page is on the free list and contains no data. Otherwise the disk file will be too small which can lead to database corruption in subsequent transactions. (CVS 643) check-in: 36fc0add user: drh tags: trunk
13:16
Enhance the INTEGRITY_CHECK pragma to test the auxiliary database file in addition to the main database file. (CVS 642) check-in: 52eba4de user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to VERSION.

     1         -2.5.2
            1  +2.5.3

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.46 2002/05/30 12:27:03 drh Exp $
           21  +** @(#) $Id: pager.c,v 1.47 2002/06/25 14:43:58 drh Exp $
    22     22   */
    23     23   #include "sqliteInt.h"
    24     24   #include "pager.h"
    25     25   #include "os.h"
    26     26   #include <assert.h>
    27     27   #include <string.h>
    28     28   
................................................................................
  1191   1191   ** sqlitepager_dont_rollback() below, more than double the speed
  1192   1192   ** of large INSERT operations and quadruple the speed of large DELETEs.
  1193   1193   */
  1194   1194   void sqlitepager_dont_write(Pager *pPager, Pgno pgno){
  1195   1195     PgHdr *pPg;
  1196   1196     pPg = pager_lookup(pPager, pgno);
  1197   1197     if( pPg && pPg->dirty ){
  1198         -    pPg->dirty = 0;
         1198  +    if( pPager->dbSize==(int)pPg->pgno && pPager->origDbSize<pPager->dbSize ){
         1199  +      /* If this pages is the last page in the file and the file has grown
         1200  +      ** during the current transaction, then do NOT mark the page as clean.
         1201  +      ** When the database file grows, we must make sure that the last page
         1202  +      ** gets written at least once so that the disk file will be the correct
         1203  +      ** size. If you do not write this page and the size of the file
         1204  +      ** on the disk ends up being too small, that can lead to database
         1205  +      ** corruption during the next transaction.
         1206  +      */
         1207  +    }else{
         1208  +      pPg->dirty = 0;
         1209  +    }
  1199   1210     }
  1200   1211   }
  1201   1212   
  1202   1213   /*
  1203   1214   ** A call to this routine tells the pager that if a rollback occurs,
  1204   1215   ** it is not necessary to restore the data on the given page.  This
  1205   1216   ** means that the pager does not have to record the given page in the

Changes to www/changes.tcl.

    20     20   }
    21     21   
    22     22   
    23     23   proc chng {date desc} {
    24     24     puts "<DT><B>$date</B></DT>"
    25     25     puts "<DD><P><UL>$desc</UL></P></DD>"
    26     26   }
           27  +
           28  +chng {2002 Jun 24 (2.5.3)} {
           29  +<li>Bug fix:  Database corruption can occur due to the optimization
           30  +    that was introduced in version 2.4.0 (checking [410]).  The problem
           31  +    should now be fixed.  The use of versions 2.4.0 through 2.5.2 is
           32  +    not recommended.</li>
           33  +}
    27     34   
    28     35   chng {2002 Jun 24 (2.5.2)} {
    29     36   <li>Added the new <b>SQLITE_TEMP_MASTER</b> table which records the schema
    30     37       for temporary tables in the same way that <b>SQLITE_MASTER</b> does for
    31     38       persistent tables.</li>
    32     39   <li>Added an optimization to UNION ALL</li>
    33     40   <li>Fixed a bug in the processing of LEFT OUTER JOIN</li>