/ Check-in [942daf94]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Add an assert() to verify that the dirty-page list in the pager is valid before using it. (CVS 4810)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 942daf94ef1f8ac678988e175ef968a2d3f801e9
User & Date: drh 2008-02-26 14:46:05
Context
2008-02-26
16:16
Add commentary to clarify what is happening when an I/O error occurs while writing dirty pages to the database file. (CVS 4811) check-in: afe49d81 user: drh tags: trunk
14:46
Add an assert() to verify that the dirty-page list in the pager is valid before using it. (CVS 4810) check-in: 942daf94 user: drh tags: trunk
06:05
Have sqlite3PagerPagecount() return -1 when the pager is in error state. Fix for #2961. (CVS 4809) check-in: 427e7f8b user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

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.409 2008/02/26 06:05:31 danielk1977 Exp $
           21  +** @(#) $Id: pager.c,v 1.410 2008/02/26 14:46:05 drh Exp $
    22     22   */
    23     23   #ifndef SQLITE_OMIT_DISKIO
    24     24   #include "sqliteInt.h"
    25     25   #include <assert.h>
    26     26   #include <string.h>
    27     27   
    28     28   /*
................................................................................
  3000   3000   
  3001   3001   /*
  3002   3002   ** Collect every dirty page into a dirty list and
  3003   3003   ** return a pointer to the head of that list.  All pages are
  3004   3004   ** collected even if they are still in use.
  3005   3005   */
  3006   3006   static PgHdr *pager_get_all_dirty_pages(Pager *pPager){
         3007  +
         3008  +#ifndef NDEBUG
         3009  +  /* Verify the sanity of the dirty list when we are running
         3010  +  ** in debugging mode.  This is expensive, so do not
         3011  +  ** do this on a normal build. */
         3012  +  int n1 = 0;
         3013  +  int n2 = 0;
         3014  +  PgHdr *p;
         3015  +  for(p=pPager->pAll; p; p=p->pNextAll){ if( p->dirty ) n1++; }
         3016  +  for(p=pPager->pDirty; p; p=p->pDirty){ n2++; }
         3017  +  assert( n1==n2 );
         3018  +#endif
         3019  +
  3007   3020     return pPager->pDirty;
  3008   3021   }
  3009   3022   
  3010   3023   /*
  3011   3024   ** Return TRUE if there is a hot journal on the given pager.
  3012   3025   ** A hot journal is one that needs to be played back.
  3013   3026   **