/ Check-in [39755d21]
Login

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

Overview
Comment:More changes directed at getting things to work on 64-bit platforms. (CVS 1949)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:39755d216608e9d12e1055433549f820f63608a7
User & Date: drh 2004-09-08 20:13:04
Original User & Date: drh 2004-09-08 20:13:05
Context
2004-09-08
20:13
More changes directed at getting things to work on 64-bit platforms. (CVS 1950) check-in: 5a3f823c user: drh tags: trunk
20:13
More changes directed at getting things to work on 64-bit platforms. (CVS 1949) check-in: 39755d21 user: drh tags: trunk
15:09
Always cast 0 to (char*)0 when it is an argument in a varargs function. (CVS 1948) check-in: a1f53252 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.188 2004/09/05 00:33:43 drh Exp $
           12  +** $Id: btree.c,v 1.189 2004/09/08 20:13:05 drh Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** For a detailed discussion of BTrees, refer to
    16     16   **
    17     17   **     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
    18     18   **     "Sorting And Searching", pages 473-480. Addison-Wesley
    19     19   **     Publishing Company, Reading, Massachusetts.
................................................................................
  1400   1400   ** Print debugging information about all cursors to standard output.
  1401   1401   */
  1402   1402   void sqlite3BtreeCursorList(Btree *pBt){
  1403   1403     BtCursor *pCur;
  1404   1404     for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
  1405   1405       MemPage *pPage = pCur->pPage;
  1406   1406       char *zMode = pCur->wrFlag ? "rw" : "ro";
  1407         -    printf("CURSOR %08x rooted at %4d(%s) currently at %d.%d%s\n",
  1408         -       (int)pCur, pCur->pgnoRoot, zMode,
         1407  +    sqlite3DebugPrintf("CURSOR %p rooted at %4d(%s) currently at %d.%d%s\n",
         1408  +       pCur, pCur->pgnoRoot, zMode,
  1409   1409          pPage ? pPage->pgno : 0, pCur->idx,
  1410   1410          pCur->isValid ? "" : " eof"
  1411   1411       );
  1412   1412     }
  1413   1413   }
  1414   1414   #endif
  1415   1415   
................................................................................
  3894   3894     c = data[hdr];
  3895   3895     pPage->intKey = (c & (PTF_INTKEY|PTF_LEAFDATA))!=0;
  3896   3896     pPage->zeroData = (c & PTF_ZERODATA)!=0;
  3897   3897     pPage->leafData = (c & PTF_LEAFDATA)!=0;
  3898   3898     pPage->leaf = (c & PTF_LEAF)!=0;
  3899   3899     pPage->hasData = !(pPage->zeroData || (!pPage->leaf && pPage->leafData));
  3900   3900     nCell = get2byte(&data[hdr+3]);
  3901         -  printf("PAGE %d:  flags=0x%02x  frag=%d   parent=%d\n", pgno,
         3901  +  sqlite3DebugPrintf("PAGE %d:  flags=0x%02x  frag=%d   parent=%d\n", pgno,
  3902   3902       data[hdr], data[hdr+7], 
  3903   3903       (pPage->isInit && pPage->pParent) ? pPage->pParent->pgno : 0);
  3904   3904     assert( hdr == (pgno==1 ? 100 : 0) );
  3905   3905     idx = hdr + 12 - pPage->leaf*4;
  3906   3906     for(i=0; i<nCell; i++){
  3907   3907       CellInfo info;
  3908   3908       Pgno child;
................................................................................
  3924   3924       if( !pPage->intKey ) sz += info.nKey;
  3925   3925       if( sz>sizeof(payload)-1 ) sz = sizeof(payload)-1;
  3926   3926       memcpy(payload, &pCell[info.nHeader], sz);
  3927   3927       for(j=0; j<sz; j++){
  3928   3928         if( payload[j]<0x20 || payload[j]>0x7f ) payload[j] = '.';
  3929   3929       }
  3930   3930       payload[sz] = 0;
  3931         -    printf(
         3931  +    sqlite3DebugPrintf(
  3932   3932         "cell %2d: i=%-10s chld=%-4d nk=%-4lld nd=%-4d payload=%s\n",
  3933   3933         i, range, child, info.nKey, info.nData, payload
  3934   3934       );
  3935   3935     }
  3936   3936     if( !pPage->leaf ){
  3937         -    printf("right_child: %d\n", get4byte(&data[hdr+8]));
         3937  +    sqlite3DebugPrintf("right_child: %d\n", get4byte(&data[hdr+8]));
  3938   3938     }
  3939   3939     nFree = 0;
  3940   3940     i = 0;
  3941   3941     idx = get2byte(&data[hdr+1]);
  3942   3942     while( idx>0 && idx<pPage->pBt->usableSize ){
  3943   3943       int sz = get2byte(&data[idx+2]);
  3944   3944       sprintf(range,"%d..%d", idx, idx+sz-1);
  3945   3945       nFree += sz;
  3946         -    printf("freeblock %2d: i=%-10s size=%-4d total=%d\n",
         3946  +    sqlite3DebugPrintf("freeblock %2d: i=%-10s size=%-4d total=%d\n",
  3947   3947          i, range, sz, nFree);
  3948   3948       idx = get2byte(&data[idx]);
  3949   3949       i++;
  3950   3950     }
  3951   3951     if( idx!=0 ){
  3952         -    printf("ERROR: next freeblock index out of range: %d\n", idx);
         3952  +    sqlite3DebugPrintf("ERROR: next freeblock index out of range: %d\n", idx);
  3953   3953     }
  3954   3954     if( recursive && !pPage->leaf ){
  3955   3955       for(i=0; i<nCell; i++){
  3956   3956         unsigned char *pCell = findCell(pPage, i);
  3957   3957         sqlite3BtreePageDump(pBt, get4byte(pCell), 1);
  3958   3958         idx = get2byte(pCell);
  3959   3959       }

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.162 2004/09/02 14:57:08 drh Exp $
           21  +** @(#) $Id: pager.c,v 1.163 2004/09/08 20:13:05 drh Exp $
    22     22   */
    23     23   #include "os.h"         /* Must be first to enable large file support */
    24     24   #include "sqliteInt.h"
    25     25   #include "pager.h"
    26     26   #include <assert.h>
    27     27   #include <string.h>
    28     28   
................................................................................
   300    300   ** Enable reference count tracking (for debugging) here:
   301    301   */
   302    302   #ifdef SQLITE_TEST
   303    303     int pager3_refinfo_enable = 0;
   304    304     static void pager_refinfo(PgHdr *p){
   305    305       static int cnt = 0;
   306    306       if( !pager3_refinfo_enable ) return;
   307         -    printf(
   308         -       "REFCNT: %4d addr=0x%08x nRef=%d\n",
   309         -       p->pgno, (int)PGHDR_TO_DATA(p), p->nRef
          307  +    sqlite3DebugPrintf(
          308  +       "REFCNT: %4d addr=%p nRef=%d\n",
          309  +       p->pgno, PGHDR_TO_DATA(p), p->nRef
   310    310       );
   311    311       cnt++;   /* Something to set a breakpoint on */
   312    312     }
   313    313   # define REFINFO(X)  pager_refinfo(X)
   314    314   #else
   315    315   # define REFINFO(X)
   316    316   #endif
................................................................................
  3165   3165   /*
  3166   3166   ** Print a listing of all referenced pages and their ref count.
  3167   3167   */
  3168   3168   void sqlite3pager_refdump(Pager *pPager){
  3169   3169     PgHdr *pPg;
  3170   3170     for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){
  3171   3171       if( pPg->nRef<=0 ) continue;
  3172         -    printf("PAGE %3d addr=0x%08x nRef=%d\n", 
  3173         -       pPg->pgno, (int)PGHDR_TO_DATA(pPg), pPg->nRef);
         3172  +    sqlite3DebugPrintf("PAGE %3d addr=%p nRef=%d\n", 
         3173  +       pPg->pgno, PGHDR_TO_DATA(pPg), pPg->nRef);
  3174   3174     }
  3175   3175   }
  3176   3176   #endif

Changes to src/printf.c.

    69     69   /* The rest are extensions, not normally found in printf() */
    70     70   #define etCHARLIT    11 /* Literal characters.  %' */
    71     71   #define etSQLESCAPE  12 /* Strings with '\'' doubled.  %q */
    72     72   #define etSQLESCAPE2 13 /* Strings with '\'' doubled and enclosed in '',
    73     73                             NULL pointers replaced by SQL NULL.  %Q */
    74     74   #define etTOKEN      14 /* a pointer to a Token structure */
    75     75   #define etSRCLIST    15 /* a pointer to a SrcList */
           76  +#define etPOINTER    16 /* The %p conversion */
    76     77   
    77     78   
    78     79   /*
    79     80   ** An "etByte" is an 8-bit unsigned value.
    80     81   */
    81     82   typedef unsigned char etByte;
    82     83   
................................................................................
   119    120     {  'e',  0, 1, etEXP,        "e",                0    },
   120    121     {  'E',  0, 1, etEXP,        "E",                0    },
   121    122     {  'g',  0, 1, etGENERIC,    "e",                0    },
   122    123     {  'G',  0, 1, etGENERIC,    "E",                0    },
   123    124     {  'i', 10, 1, etRADIX,      "0123456789",       0    },
   124    125     {  'n',  0, 0, etSIZE,       0,                  0    },
   125    126     {  '%',  0, 0, etPERCENT,    0,                  0    },
   126         -  {  'p', 10, 0, etRADIX,      "0123456789",       0    },
          127  +  {  'p', 16, 0, etPOINTER,    "0123456789abcdef", "x0" },
   127    128     {  'T',  0, 2, etTOKEN,      0,                  0    },
   128    129     {  'S',  0, 2, etSRCLIST,    0,                  0    },
   129    130   };
   130    131   #define etNINFO  (sizeof(fmtinfo)/sizeof(fmtinfo[0]))
   131    132   
   132    133   /*
   133    134   ** If NOFLOATINGPOINT is defined, then none of the floating point
................................................................................
   341    342       **                               always non-negative.  Zero is the default.
   342    343       **   precision                   The specified precision.  The default
   343    344       **                               is -1.
   344    345       **   xtype                       The class of the conversion.
   345    346       **   infop                       Pointer to the appropriate info struct.
   346    347       */
   347    348       switch( xtype ){
          349  +      case etPOINTER:
          350  +        flag_longlong = sizeof(char*)==sizeof(i64);
          351  +        flag_long = sizeof(char*)==sizeof(long int);
          352  +        /* Fall through into the next case */
   348    353         case etRADIX:
   349    354           if( infop->flags & FLAG_SIGNED ){
   350    355             i64 v;
   351    356             if( flag_longlong )   v = va_arg(ap,i64);
   352    357             else if( flag_long )  v = va_arg(ap,long int);
   353    358             else                  v = va_arg(ap,int);
   354    359             if( v<0 ){

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.320 2004/09/07 16:19:54 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.321 2004/09/08 20:13:05 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   #include "config.h"
    20     20   #include "sqlite3.h"
    21     21   #include "hash.h"
................................................................................
  1202   1202     char *sqlite3StrNDup(const char*, int);
  1203   1203   # define sqlite3CheckMemory(a,b)
  1204   1204   #endif
  1205   1205   void sqlite3FreeX(void*);
  1206   1206   char *sqlite3MPrintf(const char*, ...);
  1207   1207   char *sqlite3VMPrintf(const char*, va_list);
  1208   1208   void sqlite3DebugPrintf(const char*, ...);
         1209  +void *sqlite3TextToPtr(const char*);
  1209   1210   void sqlite3SetString(char **, const char *, ...);
  1210   1211   void sqlite3SetNString(char **, ...);
  1211   1212   void sqlite3ErrorMsg(Parse*, const char*, ...);
  1212   1213   void sqlite3Dequote(char*);
  1213   1214   int sqlite3KeywordCode(const char*, int);
  1214   1215   int sqlite3RunParser(Parse*, const char*, char **);
  1215   1216   void sqlite3FinishCoding(Parse*);

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 the printf() interface to SQLite.  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.102 2004/09/07 16:19:54 drh Exp $
           16  +** $Id: test1.c,v 1.103 2004/09/08 20:13:05 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   
    24         -#if OS_WIN
    25         -# define PTR_FMT "%x"
    26         -#else
    27         -# define PTR_FMT "%p"
    28         -#endif
    29         -
    30     24   static const char * errorName(int rc){
    31     25     const char *zName = 0;
    32     26     switch( rc ){
    33     27       case SQLITE_OK:         zName = "SQLITE_OK";          break;
    34     28       case SQLITE_ERROR:      zName = "SQLITE_ERROR";       break;
    35     29       case SQLITE_INTERNAL:   zName = "SQLITE_INTERNAL";    break;
    36     30       case SQLITE_PERM:       zName = "SQLITE_PERM";        break;
................................................................................
    64     58     return zName;
    65     59   }
    66     60   
    67     61   /*
    68     62   ** Decode a pointer to an sqlite3 object.
    69     63   */
    70     64   static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb){
    71         -  if( sscanf(zA, PTR_FMT, (void**)ppDb)!=1 && 
    72         -      (zA[0]!='0' || zA[1]!='x' || sscanf(&zA[2], PTR_FMT, (void**)ppDb)!=1)
    73         -  ){
    74         -    Tcl_AppendResult(interp, "\"", zA, "\" is not a valid pointer value", 0);
    75         -    return TCL_ERROR;
    76         -  }
           65  +  *ppDb = (sqlite3*)sqlite3TextToPtr(zA);
    77     66     return TCL_OK;
    78     67   }
    79     68   
    80     69   /*
    81     70   ** Decode a pointer to an sqlite3_stmt object.
    82     71   */
    83     72   static int getStmtPointer(
    84     73     Tcl_Interp *interp, 
    85     74     const char *zArg,  
    86     75     sqlite3_stmt **ppStmt
    87     76   ){
    88         -  if( sscanf(zArg, PTR_FMT, (void**)ppStmt)!=1 ){
    89         -    Tcl_AppendResult(interp, "\"", zArg, "\" is not a valid pointer value", 0);
    90         -    return TCL_ERROR;
    91         -  }
           77  +  *ppStmt = (sqlite3_stmt*)sqlite3TextToPtr(zArg);
    92     78     return TCL_OK;
    93     79   }
    94     80   
    95     81   /*
    96     82   ** Decode a pointer to an sqlite3_stmt object.
    97     83   */
    98     84   static int getFilePointer(
    99     85     Tcl_Interp *interp, 
   100     86     const char *zArg,  
   101     87     OsFile **ppFile
   102     88   ){
   103         -  if( sscanf(zArg, PTR_FMT, (void**)ppFile)!=1 ){
   104         -    Tcl_AppendResult(interp, "\"", zArg, "\" is not a valid pointer value", 0);
   105         -    return TCL_ERROR;
   106         -  }
           89  +  *ppFile = (OsFile*)sqlite3TextToPtr(zArg);
   107     90     return TCL_OK;
   108     91   }
   109     92   
   110     93   /*
   111     94   ** Generate a text representation of a pointer that can be understood
   112     95   ** by the getDbPointer and getVmPointer routines above.
   113     96   **
................................................................................
   117    100   ** work.  Or at least that is what is reported to me (drh).  But this
   118    101   ** behavior varies from machine to machine.  The solution used her is
   119    102   ** to test the string right after it is generated to see if it can be
   120    103   ** understood by scanf, and if not, try prepending an "0x" to see if
   121    104   ** that helps.  If nothing works, a fatal error is generated.
   122    105   */
   123    106   static int makePointerStr(Tcl_Interp *interp, char *zPtr, void *p){
   124         -  void *p2;
   125         -  sprintf(zPtr, PTR_FMT, p);
   126         -  if( sscanf(zPtr, PTR_FMT, &p2)!=1 || p2!=p ){
   127         -    sprintf(zPtr, "0x" PTR_FMT, p);
   128         -    if( sscanf(zPtr, PTR_FMT, &p2)!=1 || p2!=p ){
   129         -      Tcl_AppendResult(interp, "unable to convert a pointer to a string "
   130         -         "in the file " __FILE__ " in function makePointerStr().  Please "
   131         -         "report this problem to the SQLite mailing list or as a new but "
   132         -         "report.  Please provide detailed information about how you compiled "
   133         -         "SQLite and what computer you are running on.", 0);
   134         -      return TCL_ERROR;
   135         -    }
   136         -  }
          107  +  sqlite3_snprintf(100, zPtr, "%p", p);
   137    108     return TCL_OK;
   138    109   }
   139    110   
   140    111   /*
   141    112   ** The callback routine for sqlite3_exec_printf().
   142    113   */
   143    114   static int exec_printf_cb(void *pArg, int argc, char **argv, char **name){

Changes to src/test2.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the pager.c module in SQLite.  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: test2.c,v 1.24 2004/07/22 01:19:35 drh Exp $
           16  +** $Id: test2.c,v 1.25 2004/09/08 20:13:06 drh Exp $
    17     17   */
    18     18   #include "os.h"
    19     19   #include "sqliteInt.h"
    20     20   #include "pager.h"
    21     21   #include "tcl.h"
    22     22   #include <stdlib.h>
    23     23   #include <string.h>
................................................................................
    84     84     rc = sqlite3pager_open(&pPager, argv[1], 0, 1);
    85     85     if( rc!=SQLITE_OK ){
    86     86       Tcl_AppendResult(interp, errorName(rc), 0);
    87     87       return TCL_ERROR;
    88     88     }
    89     89     sqlite3pager_set_cachesize(pPager, nPage);
    90     90     sqlite3pager_set_pagesize(pPager, test_pagesize);
    91         -  sprintf(zBuf,"0x%x",(int)pPager);
           91  +  sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPager);
    92     92     Tcl_AppendResult(interp, zBuf, 0);
    93     93     return TCL_OK;
    94     94   }
    95     95   
    96     96   /*
    97     97   ** Usage:   pager_close ID
    98     98   **
................................................................................
   107    107     Pager *pPager;
   108    108     int rc;
   109    109     if( argc!=2 ){
   110    110       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   111    111          " ID\"", 0);
   112    112       return TCL_ERROR;
   113    113     }
   114         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
          114  +  pPager = sqlite3TextToPtr(argv[1]);
   115    115     rc = sqlite3pager_close(pPager);
   116    116     if( rc!=SQLITE_OK ){
   117    117       Tcl_AppendResult(interp, errorName(rc), 0);
   118    118       return TCL_ERROR;
   119    119     }
   120    120     return TCL_OK;
   121    121   }
................................................................................
   134    134     Pager *pPager;
   135    135     int rc;
   136    136     if( argc!=2 ){
   137    137       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   138    138          " ID\"", 0);
   139    139       return TCL_ERROR;
   140    140     }
   141         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
          141  +  pPager = sqlite3TextToPtr(argv[1]);
   142    142     rc = sqlite3pager_rollback(pPager);
   143    143     if( rc!=SQLITE_OK ){
   144    144       Tcl_AppendResult(interp, errorName(rc), 0);
   145    145       return TCL_ERROR;
   146    146     }
   147    147     return TCL_OK;
   148    148   }
................................................................................
   161    161     Pager *pPager;
   162    162     int rc;
   163    163     if( argc!=2 ){
   164    164       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   165    165          " ID\"", 0);
   166    166       return TCL_ERROR;
   167    167     }
   168         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
          168  +  pPager = sqlite3TextToPtr(argv[1]);
   169    169     rc = sqlite3pager_commit(pPager);
   170    170     if( rc!=SQLITE_OK ){
   171    171       Tcl_AppendResult(interp, errorName(rc), 0);
   172    172       return TCL_ERROR;
   173    173     }
   174    174     return TCL_OK;
   175    175   }
................................................................................
   188    188     Pager *pPager;
   189    189     int rc;
   190    190     if( argc!=2 ){
   191    191       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   192    192          " ID\"", 0);
   193    193       return TCL_ERROR;
   194    194     }
   195         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
          195  +  pPager = sqlite3TextToPtr(argv[1]);
   196    196     rc = sqlite3pager_stmt_begin(pPager);
   197    197     if( rc!=SQLITE_OK ){
   198    198       Tcl_AppendResult(interp, errorName(rc), 0);
   199    199       return TCL_ERROR;
   200    200     }
   201    201     return TCL_OK;
   202    202   }
................................................................................
   215    215     Pager *pPager;
   216    216     int rc;
   217    217     if( argc!=2 ){
   218    218       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   219    219          " ID\"", 0);
   220    220       return TCL_ERROR;
   221    221     }
   222         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
          222  +  pPager = sqlite3TextToPtr(argv[1]);
   223    223     rc = sqlite3pager_stmt_rollback(pPager);
   224    224     if( rc!=SQLITE_OK ){
   225    225       Tcl_AppendResult(interp, errorName(rc), 0);
   226    226       return TCL_ERROR;
   227    227     }
   228    228     return TCL_OK;
   229    229   }
................................................................................
   242    242     Pager *pPager;
   243    243     int rc;
   244    244     if( argc!=2 ){
   245    245       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   246    246          " ID\"", 0);
   247    247       return TCL_ERROR;
   248    248     }
   249         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
          249  +  pPager = sqlite3TextToPtr(argv[1]);
   250    250     rc = sqlite3pager_stmt_commit(pPager);
   251    251     if( rc!=SQLITE_OK ){
   252    252       Tcl_AppendResult(interp, errorName(rc), 0);
   253    253       return TCL_ERROR;
   254    254     }
   255    255     return TCL_OK;
   256    256   }
................................................................................
   269    269     Pager *pPager;
   270    270     int i, *a;
   271    271     if( argc!=2 ){
   272    272       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   273    273          " ID\"", 0);
   274    274       return TCL_ERROR;
   275    275     }
   276         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
          276  +  pPager = sqlite3TextToPtr(argv[1]);
   277    277     a = sqlite3pager_stats(pPager);
   278    278     for(i=0; i<9; i++){
   279    279       static char *zName[] = {
   280    280         "ref", "page", "max", "size", "state", "err",
   281    281         "hit", "miss", "ovfl",
   282    282       };
   283    283       char zBuf[100];
   284    284       Tcl_AppendElement(interp, zName[i]);
   285         -    sprintf(zBuf,"%d",a[i]);
          285  +    sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",a[i]);
   286    286       Tcl_AppendElement(interp, zBuf);
   287    287     }
   288    288     return TCL_OK;
   289    289   }
   290    290   
   291    291   /*
   292    292   ** Usage:   pager_pagecount ID
................................................................................
   302    302     Pager *pPager;
   303    303     char zBuf[100];
   304    304     if( argc!=2 ){
   305    305       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   306    306          " ID\"", 0);
   307    307       return TCL_ERROR;
   308    308     }
   309         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
   310         -  sprintf(zBuf,"%d",sqlite3pager_pagecount(pPager));
          309  +  pPager = sqlite3TextToPtr(argv[1]);
          310  +  sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",sqlite3pager_pagecount(pPager));
   311    311     Tcl_AppendResult(interp, zBuf, 0);
   312    312     return TCL_OK;
   313    313   }
   314    314   
   315    315   /*
   316    316   ** Usage:   page_get ID PGNO
   317    317   **
................................................................................
   329    329     int pgno;
   330    330     int rc;
   331    331     if( argc!=3 ){
   332    332       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   333    333          " ID PGNO\"", 0);
   334    334       return TCL_ERROR;
   335    335     }
   336         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
          336  +  pPager = sqlite3TextToPtr(argv[1]);
   337    337     if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR;
   338    338     rc = sqlite3pager_get(pPager, pgno, &pPage);
   339    339     if( rc!=SQLITE_OK ){
   340    340       Tcl_AppendResult(interp, errorName(rc), 0);
   341    341       return TCL_ERROR;
   342    342     }
   343         -  sprintf(zBuf,"0x%x",(int)pPage);
          343  +  sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPage);
   344    344     Tcl_AppendResult(interp, zBuf, 0);
   345    345     return TCL_OK;
   346    346   }
   347    347   
   348    348   /*
   349    349   ** Usage:   page_lookup ID PGNO
   350    350   **
................................................................................
   362    362     void *pPage;
   363    363     int pgno;
   364    364     if( argc!=3 ){
   365    365       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   366    366          " ID PGNO\"", 0);
   367    367       return TCL_ERROR;
   368    368     }
   369         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
          369  +  pPager = sqlite3TextToPtr(argv[1]);
   370    370     if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR;
   371    371     pPage = sqlite3pager_lookup(pPager, pgno);
   372    372     if( pPage ){
   373         -    sprintf(zBuf,"0x%x",(int)pPage);
          373  +    sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPage);
   374    374       Tcl_AppendResult(interp, zBuf, 0);
   375    375     }
   376    376     return TCL_OK;
   377    377   }
   378    378   
   379    379   /*
   380    380   ** Usage:   page_unref PAGE
................................................................................
   390    390     void *pPage;
   391    391     int rc;
   392    392     if( argc!=2 ){
   393    393       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   394    394          " PAGE\"", 0);
   395    395       return TCL_ERROR;
   396    396     }
   397         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPage) ) return TCL_ERROR;
          397  +  pPage = sqlite3TextToPtr(argv[1]);
   398    398     rc = sqlite3pager_unref(pPage);
   399    399     if( rc!=SQLITE_OK ){
   400    400       Tcl_AppendResult(interp, errorName(rc), 0);
   401    401       return TCL_ERROR;
   402    402     }
   403    403     return TCL_OK;
   404    404   }
................................................................................
   417    417     char zBuf[100];
   418    418     void *pPage;
   419    419     if( argc!=2 ){
   420    420       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   421    421          " PAGE\"", 0);
   422    422       return TCL_ERROR;
   423    423     }
   424         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPage) ) return TCL_ERROR;
          424  +  pPage = sqlite3TextToPtr(argv[1]);
   425    425     memcpy(zBuf, pPage, sizeof(zBuf));
   426    426     Tcl_AppendResult(interp, zBuf, 0);
   427    427     return TCL_OK;
   428    428   }
   429    429   
   430    430   /*
   431    431   ** Usage:   page_number PAGE
................................................................................
   441    441     char zBuf[100];
   442    442     void *pPage;
   443    443     if( argc!=2 ){
   444    444       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   445    445          " PAGE\"", 0);
   446    446       return TCL_ERROR;
   447    447     }
   448         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPage) ) return TCL_ERROR;
   449         -  sprintf(zBuf, "%d", sqlite3pager_pagenumber(pPage));
          448  +  pPage = sqlite3TextToPtr(argv[1]);
          449  +  sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", sqlite3pager_pagenumber(pPage));
   450    450     Tcl_AppendResult(interp, zBuf, 0);
   451    451     return TCL_OK;
   452    452   }
   453    453   
   454    454   /*
   455    455   ** Usage:   page_write PAGE DATA
   456    456   **
................................................................................
   465    465     void *pPage;
   466    466     int rc;
   467    467     if( argc!=3 ){
   468    468       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   469    469          " PAGE DATA\"", 0);
   470    470       return TCL_ERROR;
   471    471     }
   472         -  if( Tcl_GetInt(interp, argv[1], (int*)&pPage) ) return TCL_ERROR;
          472  +  pPage = sqlite3TextToPtr(argv[1]);
   473    473     rc = sqlite3pager_write(pPage);
   474    474     if( rc!=SQLITE_OK ){
   475    475       Tcl_AppendResult(interp, errorName(rc), 0);
   476    476       return TCL_ERROR;
   477    477     }
   478    478     strncpy((char*)pPage, argv[2], test_pagesize-1);
   479    479     ((char*)pPage)[test_pagesize-1] = 0;

Changes to src/test3.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the btree.c module in SQLite.  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: test3.c,v 1.50 2004/07/23 00:01:39 drh Exp $
           16  +** $Id: test3.c,v 1.51 2004/09/08 20:13:06 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "pager.h"
    20     20   #include "btree.h"
    21     21   #include "tcl.h"
    22     22   #include <stdlib.h>
    23     23   #include <string.h>
................................................................................
    72     72     if( Tcl_GetInt(interp, argv[3], &flags) ) return TCL_ERROR;
    73     73     rc = sqlite3BtreeOpen(argv[1], &pBt, flags);
    74     74     if( rc!=SQLITE_OK ){
    75     75       Tcl_AppendResult(interp, errorName(rc), 0);
    76     76       return TCL_ERROR;
    77     77     }
    78     78     sqlite3BtreeSetCacheSize(pBt, nCache);
    79         -  sprintf(zBuf,"%p", pBt);
    80         -  if( strncmp(zBuf,"0x",2) ){
    81         -    sprintf(zBuf, "0x%p", pBt);
    82         -  }
           79  +  sqlite3_snprintf(sizeof(zBuf), zBuf,"%p", pBt);
    83     80     Tcl_AppendResult(interp, zBuf, 0);
    84     81     return TCL_OK;
    85     82   }
    86     83   
    87     84   /*
    88     85   ** Usage:   btree_close ID
    89     86   **
................................................................................
    98     95     Btree *pBt;
    99     96     int rc;
   100     97     if( argc!=2 ){
   101     98       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   102     99          " ID\"", 0);
   103    100       return TCL_ERROR;
   104    101     }
   105         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          102  +  pBt = sqlite3TextToPtr(argv[1]);
   106    103     rc = sqlite3BtreeClose(pBt);
   107    104     if( rc!=SQLITE_OK ){
   108    105       Tcl_AppendResult(interp, errorName(rc), 0);
   109    106       return TCL_ERROR;
   110    107     }
   111    108     return TCL_OK;
   112    109   }
................................................................................
   125    122     Btree *pBt;
   126    123     int rc;
   127    124     if( argc!=2 ){
   128    125       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   129    126          " ID\"", 0);
   130    127       return TCL_ERROR;
   131    128     }
   132         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          129  +  pBt = sqlite3TextToPtr(argv[1]);
   133    130     rc = sqlite3BtreeBeginTrans(pBt, 1);
   134    131     if( rc!=SQLITE_OK ){
   135    132       Tcl_AppendResult(interp, errorName(rc), 0);
   136    133       return TCL_ERROR;
   137    134     }
   138    135     return TCL_OK;
   139    136   }
................................................................................
   152    149     Btree *pBt;
   153    150     int rc;
   154    151     if( argc!=2 ){
   155    152       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   156    153          " ID\"", 0);
   157    154       return TCL_ERROR;
   158    155     }
   159         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          156  +  pBt = sqlite3TextToPtr(argv[1]);
   160    157     rc = sqlite3BtreeRollback(pBt);
   161    158     if( rc!=SQLITE_OK ){
   162    159       Tcl_AppendResult(interp, errorName(rc), 0);
   163    160       return TCL_ERROR;
   164    161     }
   165    162     return TCL_OK;
   166    163   }
................................................................................
   179    176     Btree *pBt;
   180    177     int rc;
   181    178     if( argc!=2 ){
   182    179       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   183    180          " ID\"", 0);
   184    181       return TCL_ERROR;
   185    182     }
   186         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          183  +  pBt = sqlite3TextToPtr(argv[1]);
   187    184     rc = sqlite3BtreeCommit(pBt);
   188    185     if( rc!=SQLITE_OK ){
   189    186       Tcl_AppendResult(interp, errorName(rc), 0);
   190    187       return TCL_ERROR;
   191    188     }
   192    189     return TCL_OK;
   193    190   }
................................................................................
   206    203     Btree *pBt;
   207    204     int rc;
   208    205     if( argc!=2 ){
   209    206       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   210    207          " ID\"", 0);
   211    208       return TCL_ERROR;
   212    209     }
   213         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          210  +  pBt = sqlite3TextToPtr(argv[1]);
   214    211     rc = sqlite3BtreeBeginStmt(pBt);
   215    212     if( rc!=SQLITE_OK ){
   216    213       Tcl_AppendResult(interp, errorName(rc), 0);
   217    214       return TCL_ERROR;
   218    215     }
   219    216     return TCL_OK;
   220    217   }
................................................................................
   233    230     Btree *pBt;
   234    231     int rc;
   235    232     if( argc!=2 ){
   236    233       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   237    234          " ID\"", 0);
   238    235       return TCL_ERROR;
   239    236     }
   240         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          237  +  pBt = sqlite3TextToPtr(argv[1]);
   241    238     rc = sqlite3BtreeRollbackStmt(pBt);
   242    239     if( rc!=SQLITE_OK ){
   243    240       Tcl_AppendResult(interp, errorName(rc), 0);
   244    241       return TCL_ERROR;
   245    242     }
   246    243     return TCL_OK;
   247    244   }
................................................................................
   260    257     Btree *pBt;
   261    258     int rc;
   262    259     if( argc!=2 ){
   263    260       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   264    261          " ID\"", 0);
   265    262       return TCL_ERROR;
   266    263     }
   267         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          264  +  pBt = sqlite3TextToPtr(argv[1]);
   268    265     rc = sqlite3BtreeCommitStmt(pBt);
   269    266     if( rc!=SQLITE_OK ){
   270    267       Tcl_AppendResult(interp, errorName(rc), 0);
   271    268       return TCL_ERROR;
   272    269     }
   273    270     return TCL_OK;
   274    271   }
................................................................................
   288    285     int rc, iTable, flags;
   289    286     char zBuf[30];
   290    287     if( argc!=3 ){
   291    288       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   292    289          " ID FLAGS\"", 0);
   293    290       return TCL_ERROR;
   294    291     }
   295         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          292  +  pBt = sqlite3TextToPtr(argv[1]);
   296    293     if( Tcl_GetInt(interp, argv[2], &flags) ) return TCL_ERROR;
   297    294     rc = sqlite3BtreeCreateTable(pBt, &iTable, flags);
   298    295     if( rc!=SQLITE_OK ){
   299    296       Tcl_AppendResult(interp, errorName(rc), 0);
   300    297       return TCL_ERROR;
   301    298     }
   302         -  sprintf(zBuf, "%d", iTable);
          299  +  sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", iTable);
   303    300     Tcl_AppendResult(interp, zBuf, 0);
   304    301     return TCL_OK;
   305    302   }
   306    303   
   307    304   /*
   308    305   ** Usage:   btree_drop_table ID TABLENUM
   309    306   **
................................................................................
   319    316     int iTable;
   320    317     int rc;
   321    318     if( argc!=3 ){
   322    319       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   323    320          " ID TABLENUM\"", 0);
   324    321       return TCL_ERROR;
   325    322     }
   326         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          323  +  pBt = sqlite3TextToPtr(argv[1]);
   327    324     if( Tcl_GetInt(interp, argv[2], &iTable) ) return TCL_ERROR;
   328    325     rc = sqlite3BtreeDropTable(pBt, iTable);
   329    326     if( rc!=SQLITE_OK ){
   330    327       Tcl_AppendResult(interp, errorName(rc), 0);
   331    328       return TCL_ERROR;
   332    329     }
   333    330     return TCL_OK;
................................................................................
   348    345     int iTable;
   349    346     int rc;
   350    347     if( argc!=3 ){
   351    348       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   352    349          " ID TABLENUM\"", 0);
   353    350       return TCL_ERROR;
   354    351     }
   355         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          352  +  pBt = sqlite3TextToPtr(argv[1]);
   356    353     if( Tcl_GetInt(interp, argv[2], &iTable) ) return TCL_ERROR;
   357    354     rc = sqlite3BtreeClearTable(pBt, iTable);
   358    355     if( rc!=SQLITE_OK ){
   359    356       Tcl_AppendResult(interp, errorName(rc), 0);
   360    357       return TCL_ERROR;
   361    358     }
   362    359     return TCL_OK;
................................................................................
   377    374     int rc;
   378    375     int i;
   379    376     if( argc!=2 ){
   380    377       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   381    378          " ID\"", 0);
   382    379       return TCL_ERROR;
   383    380     }
   384         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          381  +  pBt = sqlite3TextToPtr(argv[1]);
   385    382     for(i=0; i<SQLITE_N_BTREE_META; i++){
   386    383       char zBuf[30];
   387    384       unsigned int v;
   388    385       rc = sqlite3BtreeGetMeta(pBt, i, &v);
   389    386       if( rc!=SQLITE_OK ){
   390    387         Tcl_AppendResult(interp, errorName(rc), 0);
   391    388         return TCL_ERROR;
   392    389       }
   393         -    sprintf(zBuf,"%d",v);
          390  +    sqlite3_snprintf(sizeof(zBuf), zBuf,"%d",v);
   394    391       Tcl_AppendElement(interp, zBuf);
   395    392     }
   396    393     return TCL_OK;
   397    394   }
   398    395   
   399    396   /*
   400    397   ** Usage:   btree_update_meta ID METADATA...
................................................................................
   410    407     Btree *pBt;
   411    408     int rc;
   412    409     int i;
   413    410     int aMeta[SQLITE_N_BTREE_META];
   414    411   
   415    412     if( argc!=2+SQLITE_N_BTREE_META ){
   416    413       char zBuf[30];
   417         -    sprintf(zBuf,"%d",SQLITE_N_BTREE_META);
          414  +    sqlite3_snprintf(sizeof(zBuf), zBuf,"%d",SQLITE_N_BTREE_META);
   418    415       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   419    416          " ID METADATA...\" (METADATA is ", zBuf, " integers)", 0);
   420    417       return TCL_ERROR;
   421    418     }
   422         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          419  +  pBt = sqlite3TextToPtr(argv[1]);
   423    420     for(i=1; i<SQLITE_N_BTREE_META; i++){
   424    421       if( Tcl_GetInt(interp, argv[i+2], &aMeta[i]) ) return TCL_ERROR;
   425    422     }
   426    423     for(i=1; i<SQLITE_N_BTREE_META; i++){
   427    424       rc = sqlite3BtreeUpdateMeta(pBt, i, aMeta[i]);
   428    425       if( rc!=SQLITE_OK ){
   429    426         Tcl_AppendResult(interp, errorName(rc), 0);
................................................................................
   449    446     int rc;
   450    447   
   451    448     if( argc!=3 ){
   452    449       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   453    450          " ID\"", 0);
   454    451       return TCL_ERROR;
   455    452     }
   456         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          453  +  pBt = sqlite3TextToPtr(argv[1]);
   457    454     if( Tcl_GetInt(interp, argv[2], &iPage) ) return TCL_ERROR;
   458    455     rc = sqlite3BtreePageDump(pBt, iPage, 0);
   459    456     if( rc!=SQLITE_OK ){
   460    457       Tcl_AppendResult(interp, errorName(rc), 0);
   461    458       return TCL_ERROR;
   462    459     }
   463    460     return TCL_OK;
................................................................................
   479    476     int rc;
   480    477   
   481    478     if( argc!=3 ){
   482    479       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   483    480          " ID\"", 0);
   484    481       return TCL_ERROR;
   485    482     }
   486         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          483  +  pBt = sqlite3TextToPtr(argv[1]);
   487    484     if( Tcl_GetInt(interp, argv[2], &iPage) ) return TCL_ERROR;
   488    485     rc = sqlite3BtreePageDump(pBt, iPage, 1);
   489    486     if( rc!=SQLITE_OK ){
   490    487       Tcl_AppendResult(interp, errorName(rc), 0);
   491    488       return TCL_ERROR;
   492    489     }
   493    490     return TCL_OK;
................................................................................
   509    506     int *a;
   510    507   
   511    508     if( argc!=2 ){
   512    509       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   513    510          " ID\"", 0);
   514    511       return TCL_ERROR;
   515    512     }
   516         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          513  +  pBt = sqlite3TextToPtr(argv[1]);
   517    514     a = sqlite3pager_stats(sqlite3BtreePager(pBt));
   518    515     for(i=0; i<9; i++){
   519    516       static char *zName[] = {
   520    517         "ref", "page", "max", "size", "state", "err",
   521    518         "hit", "miss", "ovfl",
   522    519       };
   523    520       char zBuf[100];
   524    521       Tcl_AppendElement(interp, zName[i]);
   525         -    sprintf(zBuf,"%d",a[i]);
          522  +    sqlite3_snprintf(sizeof(zBuf), zBuf,"%d",a[i]);
   526    523       Tcl_AppendElement(interp, zBuf);
   527    524     }
   528    525     return TCL_OK;
   529    526   }
   530    527   
   531    528   /*
   532    529   ** Usage:   btree_pager_ref_dump ID
................................................................................
   542    539     Btree *pBt;
   543    540   
   544    541     if( argc!=2 ){
   545    542       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   546    543          " ID\"", 0);
   547    544       return TCL_ERROR;
   548    545     }
   549         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          546  +  pBt = sqlite3TextToPtr(argv[1]);
   550    547     sqlite3pager_refdump(sqlite3BtreePager(pBt));
   551    548     return TCL_OK;
   552    549   }
   553    550   
   554    551   /*
   555    552   ** Usage:   btree_integrity_check ID ROOT ...
   556    553   **
................................................................................
   571    568     int i;
   572    569   
   573    570     if( argc<3 ){
   574    571       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   575    572          " ID ROOT ...\"", 0);
   576    573       return TCL_ERROR;
   577    574     }
   578         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          575  +  pBt = sqlite3TextToPtr(argv[1]);
   579    576     nRoot = argc-2;
   580    577     aRoot = malloc( sizeof(int)*(argc-2) );
   581    578     for(i=0; i<argc-2; i++){
   582    579       if( Tcl_GetInt(interp, argv[i+2], &aRoot[i]) ) return TCL_ERROR;
   583    580     }
   584    581     zResult = sqlite3BtreeIntegrityCheck(pBt, aRoot, nRoot);
   585    582     if( zResult ){
................................................................................
   603    600     Btree *pBt;
   604    601   
   605    602     if( argc!=2 ){
   606    603       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   607    604          " ID\"", 0);
   608    605       return TCL_ERROR;
   609    606     }
   610         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          607  +  pBt = sqlite3TextToPtr(argv[1]);
   611    608     sqlite3BtreeCursorList(pBt);
   612    609     return SQLITE_OK;
   613    610   }
   614    611   
   615    612   /*
   616    613   ** Usage:   btree_cursor ID TABLENUM WRITEABLE
   617    614   **
................................................................................
   631    628     char zBuf[30];
   632    629   
   633    630     if( argc!=4 ){
   634    631       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   635    632          " ID TABLENUM WRITEABLE\"", 0);
   636    633       return TCL_ERROR;
   637    634     }
   638         -  if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
          635  +  pBt = sqlite3TextToPtr(argv[1]);
   639    636     if( Tcl_GetInt(interp, argv[2], &iTable) ) return TCL_ERROR;
   640    637     if( Tcl_GetBoolean(interp, argv[3], &wrFlag) ) return TCL_ERROR;
   641    638     rc = sqlite3BtreeCursor(pBt, iTable, wrFlag, 0, 0, &pCur);
   642    639     if( rc ){
   643    640       Tcl_AppendResult(interp, errorName(rc), 0);
   644    641       return TCL_ERROR;
   645    642     }
   646         -  sprintf(zBuf,"0x%x", (int)pCur);
          643  +  sqlite3_snprintf(sizeof(zBuf), zBuf,"%p", pCur);
   647    644     Tcl_AppendResult(interp, zBuf, 0);
   648    645     return SQLITE_OK;
   649    646   }
   650    647   
   651    648   /*
   652    649   ** Usage:   btree_close_cursor ID
   653    650   **
................................................................................
   663    660     int rc;
   664    661   
   665    662     if( argc!=2 ){
   666    663       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   667    664          " ID\"", 0);
   668    665       return TCL_ERROR;
   669    666     }
   670         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
          667  +  pCur = sqlite3TextToPtr(argv[1]);
   671    668     rc = sqlite3BtreeCloseCursor(pCur);
   672    669     if( rc ){
   673    670       Tcl_AppendResult(interp, errorName(rc), 0);
   674    671       return TCL_ERROR;
   675    672     }
   676    673     return SQLITE_OK;
   677    674   }
................................................................................
   693    690     char zBuf[20];
   694    691   
   695    692     if( argc!=3 ){
   696    693       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   697    694          " ID KEY\"", 0);
   698    695       return TCL_ERROR;
   699    696     }
   700         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
          697  +  pCur = sqlite3TextToPtr(argv[1]);
   701    698     if( sqlite3BtreeFlags(pCur) & BTREE_INTKEY ){
   702    699       int iKey;
   703    700       if( Tcl_GetInt(interp, argv[2], &iKey) ) return TCL_ERROR;
   704    701       rc = sqlite3BtreeMoveto(pCur, 0, iKey, &res);
   705    702     }else{
   706    703       rc = sqlite3BtreeMoveto(pCur, argv[2], strlen(argv[2]), &res);  
   707    704     }
   708    705     if( rc ){
   709    706       Tcl_AppendResult(interp, errorName(rc), 0);
   710    707       return TCL_ERROR;
   711    708     }
   712    709     if( res<0 ) res = -1;
   713    710     if( res>0 ) res = 1;
   714         -  sprintf(zBuf,"%d",res);
          711  +  sqlite3_snprintf(sizeof(zBuf), zBuf,"%d",res);
   715    712     Tcl_AppendResult(interp, zBuf, 0);
   716    713     return SQLITE_OK;
   717    714   }
   718    715   
   719    716   /*
   720    717   ** Usage:   btree_delete ID
   721    718   **
................................................................................
   731    728     int rc;
   732    729   
   733    730     if( argc!=2 ){
   734    731       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   735    732          " ID\"", 0);
   736    733       return TCL_ERROR;
   737    734     }
   738         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
          735  +  pCur = sqlite3TextToPtr(argv[1]);
   739    736     rc = sqlite3BtreeDelete(pCur);
   740    737     if( rc ){
   741    738       Tcl_AppendResult(interp, errorName(rc), 0);
   742    739       return TCL_ERROR;
   743    740     }
   744    741     return SQLITE_OK;
   745    742   }
................................................................................
   759    756     BtCursor *pCur;
   760    757     int rc;
   761    758   
   762    759     if( objc!=4 ){
   763    760       Tcl_WrongNumArgs(interp, 1, objv, "ID KEY DATA");
   764    761       return TCL_ERROR;
   765    762     }
   766         -
   767         -  if( Tcl_GetIntFromObj(interp, objv[1], (int*)&pCur) ) return TCL_ERROR;
          763  +  pCur = sqlite3TextToPtr(Tcl_GetString(objv[1]));
   768    764     if( sqlite3BtreeFlags(pCur) & BTREE_INTKEY ){
   769    765       i64 iKey;
   770    766       int len;
   771    767       unsigned char *pBuf;
   772    768       if( Tcl_GetWideIntFromObj(interp, objv[2], &iKey) ) return TCL_ERROR;
   773    769       pBuf = Tcl_GetByteArrayFromObj(objv[3], &len);
   774    770       rc = sqlite3BtreeInsert(pCur, 0, iKey, pBuf, len);
................................................................................
   807    803     char zBuf[100];
   808    804   
   809    805     if( argc!=2 ){
   810    806       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   811    807          " ID\"", 0);
   812    808       return TCL_ERROR;
   813    809     }
   814         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
          810  +  pCur = sqlite3TextToPtr(argv[1]);
   815    811     rc = sqlite3BtreeNext(pCur, &res);
   816    812     if( rc ){
   817    813       Tcl_AppendResult(interp, errorName(rc), 0);
   818    814       return TCL_ERROR;
   819    815     }
   820         -  sprintf(zBuf,"%d",res);
          816  +  sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",res);
   821    817     Tcl_AppendResult(interp, zBuf, 0);
   822    818     return SQLITE_OK;
   823    819   }
   824    820   
   825    821   /*
   826    822   ** Usage:   btree_prev ID
   827    823   **
................................................................................
   841    837     char zBuf[100];
   842    838   
   843    839     if( argc!=2 ){
   844    840       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   845    841          " ID\"", 0);
   846    842       return TCL_ERROR;
   847    843     }
   848         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
          844  +  pCur = sqlite3TextToPtr(argv[1]);
   849    845     rc = sqlite3BtreePrevious(pCur, &res);
   850    846     if( rc ){
   851    847       Tcl_AppendResult(interp, errorName(rc), 0);
   852    848       return TCL_ERROR;
   853    849     }
   854         -  sprintf(zBuf,"%d",res);
          850  +  sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",res);
   855    851     Tcl_AppendResult(interp, zBuf, 0);
   856    852     return SQLITE_OK;
   857    853   }
   858    854   
   859    855   /*
   860    856   ** Usage:   btree_first ID
   861    857   **
................................................................................
   874    870     char zBuf[100];
   875    871   
   876    872     if( argc!=2 ){
   877    873       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   878    874          " ID\"", 0);
   879    875       return TCL_ERROR;
   880    876     }
   881         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
          877  +  pCur = sqlite3TextToPtr(argv[1]);
   882    878     rc = sqlite3BtreeFirst(pCur, &res);
   883    879     if( rc ){
   884    880       Tcl_AppendResult(interp, errorName(rc), 0);
   885    881       return TCL_ERROR;
   886    882     }
   887         -  sprintf(zBuf,"%d",res);
          883  +  sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",res);
   888    884     Tcl_AppendResult(interp, zBuf, 0);
   889    885     return SQLITE_OK;
   890    886   }
   891    887   
   892    888   /*
   893    889   ** Usage:   btree_last ID
   894    890   **
................................................................................
   907    903     char zBuf[100];
   908    904   
   909    905     if( argc!=2 ){
   910    906       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   911    907          " ID\"", 0);
   912    908       return TCL_ERROR;
   913    909     }
   914         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
          910  +  pCur = sqlite3TextToPtr(argv[1]);
   915    911     rc = sqlite3BtreeLast(pCur, &res);
   916    912     if( rc ){
   917    913       Tcl_AppendResult(interp, errorName(rc), 0);
   918    914       return TCL_ERROR;
   919    915     }
   920         -  sprintf(zBuf,"%d",res);
          916  +  sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",res);
   921    917     Tcl_AppendResult(interp, zBuf, 0);
   922    918     return SQLITE_OK;
   923    919   }
   924    920   
   925    921   /*
   926    922   ** Usage:   btree_eof ID
   927    923   **
................................................................................
   938    934     char zBuf[50];
   939    935   
   940    936     if( argc!=2 ){
   941    937       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   942    938          " ID\"", 0);
   943    939       return TCL_ERROR;
   944    940     }
   945         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
   946         -  sprintf(zBuf, "%d", sqlite3BtreeEof(pCur));
          941  +  pCur = sqlite3TextToPtr(argv[1]);
          942  +  sqlite3_snprintf(sizeof(zBuf),zBuf, "%d", sqlite3BtreeEof(pCur));
   947    943     Tcl_AppendResult(interp, zBuf, 0);
   948    944     return SQLITE_OK;
   949    945   }
   950    946   
   951    947   /*
   952    948   ** Usage:   btree_keysize ID
   953    949   **
................................................................................
   965    961     char zBuf[50];
   966    962   
   967    963     if( argc!=2 ){
   968    964       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   969    965          " ID\"", 0);
   970    966       return TCL_ERROR;
   971    967     }
   972         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
          968  +  pCur = sqlite3TextToPtr(argv[1]);
   973    969     sqlite3BtreeKeySize(pCur, &n);
   974         -  sprintf(zBuf, "%llu", n);
          970  +  sqlite3_snprintf(sizeof(zBuf),zBuf, "%llu", n);
   975    971     Tcl_AppendResult(interp, zBuf, 0);
   976    972     return SQLITE_OK;
   977    973   }
   978    974   
   979    975   /*
   980    976   ** Usage:   btree_key ID
   981    977   **
................................................................................
   993    989     char *zBuf;
   994    990   
   995    991     if( argc!=2 ){
   996    992       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   997    993          " ID\"", 0);
   998    994       return TCL_ERROR;
   999    995     }
  1000         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
          996  +  pCur = sqlite3TextToPtr(argv[1]);
  1001    997     sqlite3BtreeKeySize(pCur, &n);
  1002    998     if( sqlite3BtreeFlags(pCur) & BTREE_INTKEY ){
  1003    999       char zBuf2[60];
  1004         -    sprintf(zBuf2, "%llu", n);
         1000  +    sqlite3_snprintf(sizeof(zBuf),zBuf2, "%llu", n);
  1005   1001       Tcl_AppendResult(interp, zBuf2, 0);
  1006   1002     }else{
  1007   1003       zBuf = malloc( n+1 );
  1008   1004       rc = sqlite3BtreeKey(pCur, 0, n, zBuf);
  1009   1005       if( rc ){
  1010   1006         Tcl_AppendResult(interp, errorName(rc), 0);
  1011   1007         return TCL_ERROR;
................................................................................
  1034   1030     char *zBuf;
  1035   1031   
  1036   1032     if( argc!=2 ){
  1037   1033       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
  1038   1034          " ID\"", 0);
  1039   1035       return TCL_ERROR;
  1040   1036     }
  1041         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
         1037  +  pCur = sqlite3TextToPtr(argv[1]);
  1042   1038     sqlite3BtreeDataSize(pCur, &n);
  1043   1039     zBuf = malloc( n+1 );
  1044   1040     rc = sqlite3BtreeData(pCur, 0, n, zBuf);
  1045   1041     if( rc ){
  1046   1042       Tcl_AppendResult(interp, errorName(rc), 0);
  1047   1043       return TCL_ERROR;
  1048   1044     }
................................................................................
  1072   1068     char zStatic[1000];
  1073   1069   
  1074   1070     if( argc!=3 ){
  1075   1071       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
  1076   1072          " ID AMT\"", 0);
  1077   1073       return TCL_ERROR;
  1078   1074     }
  1079         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
         1075  +  pCur = sqlite3TextToPtr(argv[1]);
  1080   1076     if( Tcl_GetInt(interp, argv[2], &n) ) return TCL_ERROR;
  1081   1077     sqlite3BtreeKeySize(pCur, &nKey);
  1082   1078     zBuf = sqlite3BtreeKeyFetch(pCur, &amt);
  1083   1079     if( zBuf && amt>=n ){
  1084   1080       assert( nKey<sizeof(zStatic) );
  1085   1081       if( n>0 ) nKey = n;
  1086   1082       memcpy(zStatic, zBuf, (int)nKey); 
................................................................................
  1110   1106     char zStatic[1000];
  1111   1107   
  1112   1108     if( argc!=3 ){
  1113   1109       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
  1114   1110          " ID AMT\"", 0);
  1115   1111       return TCL_ERROR;
  1116   1112     }
  1117         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
         1113  +  pCur = sqlite3TextToPtr(argv[1]);
  1118   1114     if( Tcl_GetInt(interp, argv[2], &n) ) return TCL_ERROR;
  1119   1115     sqlite3BtreeDataSize(pCur, &nData);
  1120   1116     zBuf = sqlite3BtreeDataFetch(pCur, &amt);
  1121   1117     if( zBuf && amt>=n ){
  1122   1118       assert( nData<sizeof(zStatic) );
  1123   1119       if( n>0 ) nData = n;
  1124   1120       memcpy(zStatic, zBuf, (int)nData); 
................................................................................
  1145   1141     char zBuf[50];
  1146   1142   
  1147   1143     if( argc!=2 ){
  1148   1144       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
  1149   1145          " ID\"", 0);
  1150   1146       return TCL_ERROR;
  1151   1147     }
  1152         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
         1148  +  pCur = sqlite3TextToPtr(argv[1]);
  1153   1149     if( sqlite3BtreeFlags(pCur) & BTREE_INTKEY ){
  1154   1150       n1 = 0;
  1155   1151     }else{
  1156   1152       sqlite3BtreeKeySize(pCur, &n1);
  1157   1153     }
  1158   1154     sqlite3BtreeDataSize(pCur, &n2);
  1159         -  sprintf(zBuf, "%d", (int)(n1+n2));
         1155  +  sqlite3_snprintf(sizeof(zBuf),zBuf, "%d", (int)(n1+n2));
  1160   1156     Tcl_AppendResult(interp, zBuf, 0);
  1161   1157     return SQLITE_OK;
  1162   1158   }
  1163   1159   
  1164   1160   /*
  1165   1161   ** Usage:   btree_cursor_info ID ?UP-CNT?
  1166   1162   **
................................................................................
  1192   1188     char zBuf[400];
  1193   1189   
  1194   1190     if( argc!=2 && argc!=3 ){
  1195   1191       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
  1196   1192          " ID ?UP-CNT?\"", 0);
  1197   1193       return TCL_ERROR;
  1198   1194     }
  1199         -  if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
         1195  +  pCur = sqlite3TextToPtr(argv[1]);
  1200   1196     if( argc==3 ){
  1201   1197       if( Tcl_GetInt(interp, argv[2], &up) ) return TCL_ERROR;
  1202   1198     }else{
  1203   1199       up = 0;
  1204   1200     }
  1205   1201     rc = sqlite3BtreeCursorInfo(pCur, aResult, up);
  1206   1202     if( rc ){
  1207   1203       Tcl_AppendResult(interp, errorName(rc), 0);
  1208   1204       return TCL_ERROR;
  1209   1205     }
  1210   1206     j = 0;
  1211   1207     for(i=0; i<sizeof(aResult)/sizeof(aResult[0]); i++){
  1212         -    sprintf(&zBuf[j]," %d", aResult[i]);
         1208  +    sqlite3_snprintf(40,&zBuf[j]," %d", aResult[i]);
  1213   1209       j += strlen(&zBuf[j]);
  1214   1210     }
  1215   1211     Tcl_AppendResult(interp, &zBuf[1], 0);
  1216   1212     return SQLITE_OK;
  1217   1213   }
  1218   1214   
  1219   1215   /*

Changes to src/util.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Utility functions used throughout sqlite.
    13     13   **
    14     14   ** This file contains functions for allocating memory, comparing
    15     15   ** strings, and stuff like that.
    16     16   **
    17         -** $Id: util.c,v 1.116 2004/09/06 17:24:13 drh Exp $
           17  +** $Id: util.c,v 1.117 2004/09/08 20:13:06 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include <stdarg.h>
    21     21   #include <ctype.h>
    22     22   
    23     23   #if SQLITE_DEBUG>2 && defined(__GLIBC__)
    24     24   #include <execinfo.h>
    25     25   void print_stack_trace(){
    26     26     void *bt[30];
    27     27     int i;
    28     28     int n = backtrace(bt, 30);
    29     29   
    30         -  fprintf(stderr, "STACK: ");
           30  +  sqlite3DebugPrintf("STACK: ");
    31     31     for(i=0; i<n;i++){
    32         -    fprintf(stderr, "%p ", bt[i]);
           32  +    sqlite3DebugPrintf("%p ", bt[i]);
    33     33     }
    34         -  fprintf(stderr, "\n");
           34  +  sqlite3DebugPrintf("\n");
    35     35   }
    36     36   #else
    37     37   #define print_stack_trace()
    38     38   #endif
    39     39   
    40     40   /*
    41     41   ** If malloc() ever fails, this global variable gets set to 1.
................................................................................
   990    990   
   991    991     zBlob = (char *)sqliteMalloc(n/2);
   992    992     for(i=0; i<n; i+=2){
   993    993       zBlob[i/2] = (hexToInt(z[i])<<4) | hexToInt(z[i+1]);
   994    994     }
   995    995     return zBlob;
   996    996   }
          997  +
          998  +#if defined(SQLITE_TEST)
          999  +/*
         1000  +** Convert text generated by the "%p" conversion format back into
         1001  +** a pointer.
         1002  +*/
         1003  +void *sqlite3TextToPtr(const char *z){
         1004  +  void *p;
         1005  +  u64 v;
         1006  +  u32 v2;
         1007  +  if( z[0]=='0' && z[1]=='x' ){
         1008  +    z += 2;
         1009  +  }
         1010  +  v = 0;
         1011  +  while( *z ){
         1012  +    v = (v<<4) + hexToInt(*z);
         1013  +    z++;
         1014  +  }
         1015  +  if( sizeof(p)==sizeof(v) ){
         1016  +    p = *(void**)&v;
         1017  +  }else{
         1018  +    assert( sizeof(p)==sizeof(v2) );
         1019  +    v2 = (u32)v;
         1020  +    p = *(void**)&v2;
         1021  +  }
         1022  +  return p;
         1023  +}
         1024  +#endif

Changes to test/pager.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is page cache subsystem.
    13     13   #
    14         -# $Id: pager.test,v 1.17 2004/06/19 00:16:31 drh Exp $
           14  +# $Id: pager.test,v 1.18 2004/09/08 20:13:06 drh Exp $
    15     15   
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   if {[info commands pager_open]!=""} {
    21     21   db close
................................................................................
    75     75     set ::gx [page_lookup $::p1 1]
    76     76     expr {$::gx!=""}
    77     77   } {1}
    78     78   do_test pager-2.3.5 {
    79     79     pager_stats $::p1
    80     80   } {ref 1 page 1 max 10 size 0 state 1 err 0 hit 0 miss 1 ovfl 0}
    81     81   do_test pager-2.3.6 {
    82         -  expr $::g1==$::gx
           82  +  expr {$::g1==$::gx}
    83     83   } {1}
    84     84   do_test pager-2.3.7 {
    85     85     page_unref $::gx
    86     86     pager_stats $::p1
    87     87   } {ref 1 page 1 max 10 size 0 state 1 err 0 hit 0 miss 1 ovfl 0}
    88     88   do_test pager-2.4 {
    89     89     pager_stats $::p1

Changes to test/pager2.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is page cache subsystem.
    13     13   #
    14         -# $Id: pager2.test,v 1.2 2004/06/09 20:03:10 drh Exp $
           14  +# $Id: pager2.test,v 1.3 2004/09/08 20:13:06 drh Exp $
    15     15   
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   if {[info commands pager_open]!=""} {
    21     21   db close
................................................................................
    73     73     set ::gx [page_lookup $::p1 1]
    74     74     expr {$::gx!=""}
    75     75   } {1}
    76     76   do_test pager2-2.3.5 {
    77     77     pager_stats $::p1
    78     78   } {ref 1 page 1 max 10 size 0 state 1 err 0 hit 0 miss 1 ovfl 0}
    79     79   do_test pager2-2.3.6 {
    80         -  expr $::g1==$::gx
           80  +  expr {$::g1==$::gx}
    81     81   } {1}
    82     82   do_test pager2-2.3.7 {
    83     83     page_unref $::gx
    84     84     pager_stats $::p1
    85     85   } {ref 1 page 1 max 10 size 0 state 1 err 0 hit 0 miss 1 ovfl 0}
    86     86   do_test pager2-2.4 {
    87     87     pager_stats $::p1