/ Check-in [1f07abe4]
Login

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

Overview
Comment:Working on the pager (CVS 212)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1f07abe46e2de8c5d9659bd5a78efe4ce23144ae
User & Date: drh 2001-04-15 02:27:25
Context
2001-04-15
02:30
Version 1.0.31 (CVS 472) check-in: a7bfcbb4 user: drh tags: trunk
02:27
Working on the pager (CVS 212) check-in: 1f07abe4 user: drh tags: trunk
00:37
Pager is working, mostly. (CVS 211) check-in: f82fa707 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

    23     23   *************************************************************************
    24     24   ** This is the implementation of the page cache subsystem.
    25     25   ** 
    26     26   ** The page cache is used to access a database file.  The pager journals
    27     27   ** all writes in order to support rollback.  Locking is used to limit
    28     28   ** access to one or more reader or on writer.
    29     29   **
    30         -** @(#) $Id: pager.c,v 1.3 2001/04/15 00:37:09 drh Exp $
           30  +** @(#) $Id: pager.c,v 1.4 2001/04/15 02:27:25 drh Exp $
    31     31   */
    32     32   #include "sqliteInt.h"
    33     33   #include "pager.h"
    34     34   #include <fcntl.h>
    35     35   #include <sys/stat.h>
    36     36   #include <unistd.h>
    37     37   #include <assert.h>
................................................................................
   452    452     strcpy(pPager->zJournal, zFilename);
   453    453     strcpy(&pPager->zJournal[nameLen], "-journal");
   454    454     pPager->fd = fd;
   455    455     pPager->jfd = -1;
   456    456     pPager->nRef = 0;
   457    457     pPager->dbSize = -1;
   458    458     pPager->nPage = 0;
   459         -  pPager->mxPage = mxPage>10 ? mxPage : 10;
          459  +  pPager->mxPage = mxPage>5 ? mxPage : 10;
   460    460     pPager->state = SQLITE_UNLOCK;
   461    461     pPager->errMask = 0;
   462    462     pPager->pFirst = 0;
   463    463     pPager->pLast = 0;
   464    464     memset(pPager->aHash, 0, sizeof(pPager->aHash));
   465    465     *ppPager = pPager;
   466    466     return SQLITE_OK;
................................................................................
   616    616         }
   617    617         pPg->pPager = pPager;
   618    618         pPg->pNextAll = pPager->pAll;
   619    619         if( pPager->pAll ){
   620    620           pPager->pAll->pPrevAll = pPg;
   621    621         }
   622    622         pPg->pPrevAll = 0;
          623  +      pPager->pAll = pPg;
   623    624         pPager->nPage++;
   624    625       }else{
   625    626         /* Recycle an older page.  First locate the page to be recycled.
   626    627         ** Try to find one that is not dirty and is near the head of
   627    628         ** of the free list */
   628    629         int cnt = 4;
   629    630         pPg = pPager->pFirst;
................................................................................
   772    773   ** All subsequent write attempts also return SQLITE_FULL until there
   773    774   ** is a call to sqlitepager_commit() or sqlitepager_rollback() to
   774    775   ** reset.
   775    776   */
   776    777   int sqlitepager_write(void *pData){
   777    778     PgHdr *pPg = DATA_TO_PGHDR(pData);
   778    779     Pager *pPager = pPg->pPager;
   779         -  int rc;
          780  +  int rc = SQLITE_OK;
   780    781   
   781    782     if( pPager->errMask ){ 
   782    783       return pager_errcode(pPager);
   783    784     }
   784    785     pPg->dirty = 1;
   785    786     if( pPg->inJournal ){ return SQLITE_OK; }
   786    787     assert( pPager->state!=SQLITE_UNLOCK );

Changes to test/pager.test.

    19     19   #   drh@hwaci.com
    20     20   #   http://www.hwaci.com/drh/
    21     21   #
    22     22   #***********************************************************************
    23     23   # This file implements regression tests for SQLite library.  The
    24     24   # focus of this script is page cache subsystem.
    25     25   #
    26         -# $Id: pager.test,v 1.1 2001/04/15 00:37:21 drh Exp $
           26  +# $Id: pager.test,v 1.2 2001/04/15 02:27:25 drh Exp $
    27     27   
    28     28   
    29     29   set testdir [file dirname $argv0]
    30     30   source $testdir/tester.tcl
    31     31   
    32     32   if {$dbprefix!="mem:" && [info commands pager_open]!=""} {
    33     33   
................................................................................
   161    161       pager_rollback $::p1
   162    162     } msg]
   163    163     lappend v $msg
   164    164   } {0 {}}
   165    165   do_test pager-2.29 {
   166    166     page_read $::g1
   167    167   } {Page-One}
   168         -
   169    168   do_test pager-2.99 {
   170    169     pager_close $::p1
   171    170   } {}
          171  +
          172  +do_test pager-3.1 {
          173  +  set v [catch {
          174  +    set ::p1 [pager_open ptf1.db 5]
          175  +  } msg]
          176  +  if {$v} {lappend v $msg}
          177  +  set v
          178  +} {0}
          179  +do_test pager-3.2 {
          180  +  pager_pagecount $::p1
          181  +} {1}
          182  +do_test pager-3.3 {
          183  +  set v [catch {
          184  +    set ::g(1) [page_get $::p1 1]
          185  +  } msg]
          186  +  if {$v} {lappend v $msg}
          187  +  set v
          188  +} {0}
          189  +do_test pager-3.4 {
          190  +  page_read $::g(1)
          191  +} {Page-One}
          192  +do_test pager-3.5 {
          193  +  for {set i 2} {$i<=20} {incr i} {
          194  +    set gx [page_get $::p1 $i]
          195  +    page_write $gx "Page-$i"
          196  +    page_unref $gx
          197  +  }
          198  +  pager_commit $::p1
          199  +} {}
          200  +for {set i 2} {$i<=20} {incr i} {
          201  +  do_test pager-3.6.[expr {$i-1}] [subst {
          202  +    set gx \[page_get $::p1 $i\]
          203  +    set v \[page_read \$gx\]
          204  +    page_unref \$gx
          205  +    set v
          206  +  }] "Page-$i"
          207  +}
          208  +do_test pager-3.99 {
          209  +  pager_close $::p1
          210  +} {}
   172    211   
   173    212   
   174    213   } ;# end if( not mem: and has pager_open command );
   175    214   
   176    215   finish_test