/ Check-in [7338e68e]
Login

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

Overview
Comment:New testfixture command: sqlite3_pager_refcounts. Returns a list of integers which is the pager refcount for each pager in the database. (CVS 3815)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7338e68e0fd9263236f12f8911cb8293747dd1a4
User & Date: drh 2007-04-05 17:36:19
Context
2007-04-05
18:34
Add a target to the autoconf-generated makefile for amalgamation. (CVS 3816) check-in: 204e7d38 user: drh tags: trunk
17:36
New testfixture command: sqlite3_pager_refcounts. Returns a list of integers which is the pager refcount for each pager in the database. (CVS 3815) check-in: 7338e68e user: drh tags: trunk
17:15
Always truncate the pager cache when truncating the database file. Also reorganize the code to check the change-counter after first obtaining a shared lock. (CVS 3814) check-in: 9dc4100e user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing all sorts of SQLite interfaces.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test1.c,v 1.233 2007/04/02 12:29:01 danielk1977 Exp $
           16  +** $Id: test1.c,v 1.234 2007/04/05 17:36:19 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include "os.h"
    21     21   #include <stdlib.h>
    22     22   #include <string.h>
    23     23   
................................................................................
  3745   3745     int objc,
  3746   3746     Tcl_Obj *CONST objv[]
  3747   3747   ){
  3748   3748     sqlite3_thread_cleanup();
  3749   3749     return TCL_OK;
  3750   3750   }
  3751   3751   
         3752  +
         3753  +/*
         3754  +** Usage:   sqlite3_pager_refcounts  DB
         3755  +**
         3756  +** Return a list of numbers when are the PagerRefcount for each
         3757  +** pager on each database.
         3758  +*/
         3759  +static int test_pager_refcounts(
         3760  +  void * clientData,
         3761  +  Tcl_Interp *interp,
         3762  +  int objc,
         3763  +  Tcl_Obj *CONST objv[]
         3764  +){
         3765  +  sqlite3 *db;
         3766  +  int i;
         3767  +  int v, *a;
         3768  +  Tcl_Obj *pResult;
         3769  +
         3770  +  if( objc!=2 ){
         3771  +    Tcl_AppendResult(interp, "wrong # args: should be \"",
         3772  +        Tcl_GetStringFromObj(objv[0], 0), " <STMT>", 0);
         3773  +    return TCL_ERROR;
         3774  +  }
         3775  +  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
         3776  +  pResult = Tcl_NewObj();
         3777  +  for(i=0; i<db->nDb; i++){
         3778  +    if( db->aDb[i].pBt==0 ){
         3779  +      v = -1;
         3780  +    }else{
         3781  +      a = sqlite3PagerStats(sqlite3BtreePager(db->aDb[i].pBt));
         3782  +      v = a[0];
         3783  +    }
         3784  +    Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(v));
         3785  +  }
         3786  +  Tcl_SetObjResult(interp, pResult);
         3787  +  return TCL_OK;
         3788  +}
         3789  +
  3752   3790   
  3753   3791   /*
  3754   3792   ** This routine sets entries in the global ::sqlite_options() array variable
  3755   3793   ** according to the compile-time configuration of the database.  Test
  3756   3794   ** procedures use this to determine when tests should be omitted.
  3757   3795   */
  3758   3796   static void set_options(Tcl_Interp *interp){
................................................................................
  4198   4236        { "sqlite3_step",                  test_step          ,0 },
  4199   4237   
  4200   4238        { "sqlite3_release_memory",        test_release_memory,     0},
  4201   4239        { "sqlite3_soft_heap_limit",       test_soft_heap_limit,    0},
  4202   4240        { "sqlite3_clear_tsd_memdebug",    test_clear_tsd_memdebug, 0},
  4203   4241        { "sqlite3_tsd_release",           test_tsd_release,        0},
  4204   4242        { "sqlite3_thread_cleanup",        test_thread_cleanup,     0},
         4243  +     { "sqlite3_pager_refcounts",       test_pager_refcounts,    0},
  4205   4244   
  4206   4245        { "sqlite3_load_extension",        test_load_extension,     0},
  4207   4246        { "sqlite3_enable_load_extension", test_enable_load,        0},
  4208   4247        { "sqlite3_extended_result_codes", test_extended_result_codes, 0},
  4209   4248   
  4210   4249        /* sqlite3_column_*() API */
  4211   4250        { "sqlite3_column_count",          test_column_count  ,0 },