/ Check-in [383a08e2]
Login

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

Overview
Comment:Catch an IO error case introduced by (3808). (CVS 3809)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 383a08e26083964e79bfe22156f5f554522fa1fb
User & Date: danielk1977 2007-04-05 08:40:32
Context
2007-04-05
11:25
Improvements to coverage testing. (CVS 3810) check-in: 38af156d user: drh tags: trunk
08:40
Catch an IO error case introduced by (3808). (CVS 3809) check-in: 383a08e2 user: danielk1977 tags: trunk
05:46
Zero cached pages located beyond the end of the file before returning them. Ticket #2285. (CVS 3808) check-in: 5180810e 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.317 2007/04/05 05:46:14 danielk1977 Exp $
           21  +** @(#) $Id: pager.c,v 1.318 2007/04/05 08:40:32 danielk1977 Exp $
    22     22   */
    23     23   #ifndef SQLITE_OMIT_DISKIO
    24     24   #include "sqliteInt.h"
    25     25   #include "os.h"
    26     26   #include "pager.h"
    27     27   #include <assert.h>
    28     28   #include <string.h>
................................................................................
  3030   3030       assert(pPager->nRef>0 || pgno==1);
  3031   3031       if( pgno>sqlite3PagerPagecount(pPager) ){
  3032   3032         /* This can happen after a truncation in exclusive mode. The pager
  3033   3033         ** cache contains pages that are located after the end of the 
  3034   3034         ** database file. Zero such pages before returning. Not doing this 
  3035   3035         ** was causing the problem reported in ticket #2285.
  3036   3036         */
         3037  +      if( pPager->errCode ){
         3038  +        /* This case catches an IO error in sqlite3PagerPagecount(). If
         3039  +        ** the error occured, PagerPagecount() returned 0.
         3040  +        */
         3041  +        return pPager->errCode;
         3042  +      }
  3037   3043         memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize);
  3038   3044       }
  3039   3045       TEST_INCR(pPager->nHit);
  3040   3046       page_ref(pPg);
  3041   3047     }
  3042   3048     *ppPage = pPg;
  3043   3049     return SQLITE_OK;