/ Check-in [71d699de]
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:Make the Pager.pAll linked-list doubly linked when ENABLE_MEMORY_MANAGEMENT is defined. This is used to speed up sqlite3_release_memory(). (CVS 5346)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 71d699de366fc9c97d4a5122e2bf754310b9b34a
User & Date: danielk1977 2008-07-07 11:18:28
Context
2008-07-07
12:44
Fix a comment in alter.c. No changes to code. (CVS 5347) check-in: 3e558acd user: drh tags: trunk
11:18
Make the Pager.pAll linked-list doubly linked when ENABLE_MEMORY_MANAGEMENT is defined. This is used to speed up sqlite3_release_memory(). (CVS 5346) check-in: 71d699de user: danielk1977 tags: trunk
2008-07-06
00:21
Fail to build if the -ffast-math option is specified in GCC. Ticket #3202. (CVS 5345) check-in: aa5be9ee user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/pager.c.

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
...
265
266
267
268
269
270
271

272
273
274
275
276
277
278
....
3332
3333
3334
3335
3336
3337
3338


3339



3340
3341



3342



3343
3344
3345
3346
3347
3348
3349
....
3661
3662
3663
3664
3665
3666
3667





3668
3669
3670
3671
3672
3673
3674
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.460 2008/06/20 14:59:51 danielk1977 Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
#include <assert.h>
#include <string.h>

/*
................................................................................
  u8 dirty;                      /* TRUE if we need to write back changes */
  u8 needSync;                   /* Sync journal before writing this page */
  u8 alwaysRollback;             /* Disable DontRollback() for this page */
  u8 needRead;                   /* Read content if PagerWrite() is called */
  short int nRef;                /* Number of users of this page */
  PgHdr *pDirty, *pPrevDirty;    /* Dirty pages */
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT

  PagerLruLink gfree;            /* Global list of nRef==0 pages */
#endif
#ifdef SQLITE_CHECK_PAGES
  u32 pageHash;
#endif
  void *pData;                   /* Page data */
  /* Pager.nExtra bytes of local data appended to this header */
................................................................................
      **
      ** Todo: Check the Pager.pStmt list to make sure this is Ok. It 
      ** probably is though.
      */
      PgHdr *pTmp;
      assert( pPg );
      if( pPg==pPager->pAll ){


         pPager->pAll = pPg->pNextAll;



      }else{
        for( pTmp=pPager->pAll; pTmp->pNextAll!=pPg; pTmp=pTmp->pNextAll ){}



        pTmp->pNextAll = pPg->pNextAll;



      }
      nReleased += (
          sizeof(*pPg) + pPager->pageSize
          + sizeof(u32) + pPager->nExtra
          + MEMDB*sizeof(PgHistory) 
      );
      IOTRACE(("PGFREE %p %d *\n", pPager, pPg->pgno));
................................................................................
      rc = SQLITE_NOMEM;
      goto pager_allocate_out;
    }
    memset(pPg, 0, nByteHdr);
    pPg->pData = pData;
    pPg->pPager = pPager;
    pPg->pNextAll = pPager->pAll;





    pPager->pAll = pPg;
    pPager->nPage++;
  }else{
    /* Recycle an existing page with a zero ref-count. */
    rc = pager_recycle(pPager, &pPg);
    if( rc==SQLITE_BUSY ){
      rc = SQLITE_IOERR_BLOCKED;







|







 







>







 







>
>

>
>
>

<
>
>
>
|
>
>
>







 







>
>
>
>
>







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
...
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
....
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346

3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
....
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.461 2008/07/07 11:18:28 danielk1977 Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
#include <assert.h>
#include <string.h>

/*
................................................................................
  u8 dirty;                      /* TRUE if we need to write back changes */
  u8 needSync;                   /* Sync journal before writing this page */
  u8 alwaysRollback;             /* Disable DontRollback() for this page */
  u8 needRead;                   /* Read content if PagerWrite() is called */
  short int nRef;                /* Number of users of this page */
  PgHdr *pDirty, *pPrevDirty;    /* Dirty pages */
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
  PgHdr *pPrevAll;               /* A list of all pages */
  PagerLruLink gfree;            /* Global list of nRef==0 pages */
#endif
#ifdef SQLITE_CHECK_PAGES
  u32 pageHash;
#endif
  void *pData;                   /* Page data */
  /* Pager.nExtra bytes of local data appended to this header */
................................................................................
      **
      ** Todo: Check the Pager.pStmt list to make sure this is Ok. It 
      ** probably is though.
      */
      PgHdr *pTmp;
      assert( pPg );
      if( pPg==pPager->pAll ){
         assert(pPg->pPrevAll==0);
         assert(pPg->pNextAll==0 || pPg->pNextAll->pPrevAll==pPg);
         pPager->pAll = pPg->pNextAll;
         if( pPager->pAll ){
           pPager->pAll->pPrevAll = 0;
         }
      }else{

         assert(pPg->pPrevAll);
         assert(pPg->pPrevAll->pNextAll==pPg);
         pTmp = pPg->pPrevAll;
         pTmp->pNextAll = pPg->pNextAll;
         if( pTmp->pNextAll ){
           pTmp->pNextAll->pPrevAll = pTmp;
         }
      }
      nReleased += (
          sizeof(*pPg) + pPager->pageSize
          + sizeof(u32) + pPager->nExtra
          + MEMDB*sizeof(PgHistory) 
      );
      IOTRACE(("PGFREE %p %d *\n", pPager, pPg->pgno));
................................................................................
      rc = SQLITE_NOMEM;
      goto pager_allocate_out;
    }
    memset(pPg, 0, nByteHdr);
    pPg->pData = pData;
    pPg->pPager = pPager;
    pPg->pNextAll = pPager->pAll;
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
    if( pPg->pNextAll ){
      pPg->pNextAll->pPrevAll = pPg;
    }
#endif
    pPager->pAll = pPg;
    pPager->nPage++;
  }else{
    /* Recycle an existing page with a zero ref-count. */
    rc = pager_recycle(pPager, &pPg);
    if( rc==SQLITE_BUSY ){
      rc = SQLITE_IOERR_BLOCKED;