Remove most static and global variables from a pure build. There

are still a number of static and global variables used for testing. (CVS 3342)

FossilOrigin-Name: 76e4d4187779097954038e444111f837737e789c
This commit is contained in:
drh
2006-08-08 13:51:43 +00:00
parent ffc13f69b5
commit 0f7eb61108
9 changed files with 61 additions and 37 deletions
+7 -7
View File
@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.325 2006/06/27 16:34:57 danielk1977 Exp $
** $Id: btree.c,v 1.326 2006/08/08 13:51:43 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@@ -426,10 +426,10 @@ struct BtCursor {
#if SQLITE_TEST
# define TRACE(X) if( sqlite3_btree_trace )\
{ sqlite3DebugPrintf X; fflush(stdout); }
int sqlite3_btree_trace=0; /* True to enable tracing */
#else
# define TRACE(X)
#endif
int sqlite3_btree_trace=0; /* True to enable tracing */
/*
** Forward declaration
@@ -2367,7 +2367,7 @@ static int autoVacuumCommit(BtShared *pBt, Pgno *nTrunc){
MemPage *pFreeMemPage = 0; /* "" */
#ifndef NDEBUG
int nRef = *sqlite3pager_stats(pPager);
int nRef = sqlite3pager_refcount(pPager);
#endif
assert( pBt->autoVacuum );
@@ -2475,7 +2475,7 @@ static int autoVacuumCommit(BtShared *pBt, Pgno *nTrunc){
assert( finSize!=PENDING_BYTE_PAGE(pBt) );
autovacuum_out:
assert( nRef==*sqlite3pager_stats(pPager) );
assert( nRef==sqlite3pager_refcount(pPager) );
if( rc!=SQLITE_OK ){
sqlite3pager_rollback(pPager);
}
@@ -6388,7 +6388,7 @@ char *sqlite3BtreeIntegrityCheck(Btree *p, int *aRoot, int nRoot){
IntegrityCk sCheck;
BtShared *pBt = p->pBt;
nRef = *sqlite3pager_stats(pBt->pPager);
nRef = sqlite3pager_refcount(pBt->pPager);
if( lockBtreeWithRetry(p)!=SQLITE_OK ){
return sqliteStrDup("Unable to acquire a read lock on the database");
}
@@ -6454,10 +6454,10 @@ char *sqlite3BtreeIntegrityCheck(Btree *p, int *aRoot, int nRoot){
/* Make sure this analysis did not leave any unref() pages
*/
unlockBtreeIfUnused(pBt);
if( nRef != *sqlite3pager_stats(pBt->pPager) ){
if( nRef != sqlite3pager_refcount(pBt->pPager) ){
checkAppendMsg(&sCheck, 0,
"Outstanding page count goes from %d to %d during this analysis",
nRef, *sqlite3pager_stats(pBt->pPager)
nRef, sqlite3pager_refcount(pBt->pPager)
);
}
+15 -4
View File
@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.270 2006/06/28 18:18:09 drh Exp $
** @(#) $Id: pager.c,v 1.271 2006/08/08 13:51:43 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
@@ -370,7 +370,7 @@ static const unsigned char aJournalMagic[] = {
/*
** Enable reference count tracking (for debugging) here:
*/
#ifdef SQLITE_DEBUG
#ifdef SQLITE_TEST
int pager3_refinfo_enable = 0;
static void pager_refinfo(PgHdr *p){
static int cnt = 0;
@@ -1535,7 +1535,9 @@ void sqlite3pager_set_safety_level(Pager *pPager, int level, int full_fsync){
** attempts to open a temporary file. This information is used for
** testing and analysis only.
*/
#ifdef SQLITE_TEST
int sqlite3_opentemp_count = 0;
#endif
/*
** Open a temporary file. Write the name of the file into zFile
@@ -1549,7 +1551,9 @@ int sqlite3_opentemp_count = 0;
static int sqlite3pager_opentemp(char *zFile, OsFile **pFd){
int cnt = 8;
int rc;
#ifdef SQLITE_TEST
sqlite3_opentemp_count++; /* Used for testing and analysis only */
#endif
do{
cnt--;
sqlite3OsTempFileName(zFile);
@@ -3497,6 +3501,14 @@ int sqlite3pager_isreadonly(Pager *pPager){
return pPager->readOnly;
}
/*
** Return the number of references to the pager.
*/
int sqlite3pager_refcount(Pager *pPager){
return pPager->nRef;
}
#ifdef SQLITE_TEST
/*
** This routine is used for testing and analysis only.
*/
@@ -3508,15 +3520,14 @@ int *sqlite3pager_stats(Pager *pPager){
a[3] = pPager->dbSize;
a[4] = pPager->state;
a[5] = pPager->errCode;
#ifdef SQLITE_TEST
a[6] = pPager->nHit;
a[7] = pPager->nMiss;
a[8] = pPager->nOvfl;
a[9] = pPager->nRead;
a[10] = pPager->nWrite;
#endif
return a;
}
#endif
/*
** Set the statement rollback point.
+2 -1
View File
@@ -13,7 +13,7 @@
** subsystem. The page cache subsystem reads and writes a file a page
** at a time and provides a journal for rollback.
**
** @(#) $Id: pager.h,v 1.50 2006/03/06 18:23:17 drh Exp $
** @(#) $Id: pager.h,v 1.51 2006/08/08 13:51:43 drh Exp $
*/
#ifndef _PAGER_H_
@@ -98,6 +98,7 @@ int sqlite3pager_stmt_commit(Pager*);
int sqlite3pager_stmt_rollback(Pager*);
void sqlite3pager_dont_rollback(void*);
void sqlite3pager_dont_write(Pager*, Pgno);
int sqlite3pager_refcount(Pager*);
int *sqlite3pager_stats(Pager*);
void sqlite3pager_set_safety_level(Pager*,int,int);
const char *sqlite3pager_filename(Pager*);
+6 -7
View File
@@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
** $Id: pragma.c,v 1.120 2006/03/03 21:20:17 drh Exp $
** $Id: pragma.c,v 1.121 2006/08/08 13:51:43 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -780,7 +780,7 @@ void sqlite3Pragma(
** useful if invoked immediately after the main database i
*/
if( sqlite3StrICmp(zLeft, "encoding")==0 ){
static struct EncName {
static const struct EncName {
char *zName;
u8 enc;
} encnames[] = {
@@ -790,12 +790,11 @@ void sqlite3Pragma(
{ "UTF16le", SQLITE_UTF16LE },
{ "UTF-16be", SQLITE_UTF16BE },
{ "UTF16be", SQLITE_UTF16BE },
{ "UTF-16", 0 /* Filled in at run-time */ },
{ "UTF16", 0 /* Filled in at run-time */ },
{ "UTF-16", 0 }, /* SQLITE_UTF16NATIVE */
{ "UTF16", 0 }, /* SQLITE_UTF16NATIVE */
{ 0, 0 }
};
struct EncName *pEnc;
encnames[6].enc = encnames[7].enc = SQLITE_UTF16NATIVE;
const struct EncName *pEnc;
if( !zRight ){ /* "PRAGMA encoding" */
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
sqlite3VdbeSetNumCols(v, 1);
@@ -820,7 +819,7 @@ void sqlite3Pragma(
){
for(pEnc=&encnames[0]; pEnc->zName; pEnc++){
if( 0==sqlite3StrICmp(zRight, pEnc->zName) ){
ENC(pParse->db) = pEnc->enc;
ENC(pParse->db) = pEnc->enc ? pEnc->enc : SQLITE_UTF16NATIVE;
break;
}
}
+13 -1
View File
@@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.572 2006/07/26 13:43:31 drh Exp $
** $Id: vdbe.c,v 1.573 2006/08/08 13:51:43 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -57,7 +57,9 @@
** working correctly. This variable has no function other than to
** help verify the correct operation of the library.
*/
#ifdef SQLITE_TEST
int sqlite3_search_count = 0;
#endif
/*
** When this global variable is positive, it gets decremented once before
@@ -67,7 +69,9 @@ int sqlite3_search_count = 0;
** This facility is used for testing purposes only. It does not function
** in an ordinary build.
*/
#ifdef SQLITE_TEST
int sqlite3_interrupt_count = 0;
#endif
/*
** The next global variable is incremented each type the OP_Sort opcode
@@ -76,7 +80,9 @@ int sqlite3_interrupt_count = 0;
** has no function other than to help verify the correct operation of the
** library.
*/
#ifdef SQLITE_TEST
int sqlite3_sort_count = 0;
#endif
/*
** Release the memory associated with the given stack level. This
@@ -2824,7 +2830,9 @@ case OP_MoveGt: { /* no-push */
pC->deferredMoveto = 0;
pC->cacheStatus = CACHE_STALE;
*pC->pIncrKey = 0;
#ifdef SQLITE_TEST
sqlite3_search_count++;
#endif
if( oc==OP_MoveGe || oc==OP_MoveGt ){
if( res<0 ){
rc = sqlite3BtreeNext(pC->pCursor, &res);
@@ -3582,8 +3590,10 @@ case OP_Last: { /* no-push */
** correctly optimizing out sorts.
*/
case OP_Sort: { /* no-push */
#ifdef SQLITE_TEST
sqlite3_sort_count++;
sqlite3_search_count--;
#endif
/* Fall through into OP_Rewind */
}
/* Opcode: Rewind P1 P2 *
@@ -3656,7 +3666,9 @@ case OP_Next: { /* no-push */
}
if( res==0 ){
pc = pOp->p2 - 1;
#ifdef SQLITE_TEST
sqlite3_search_count++;
#endif
}
}else{
pC->nullRow = 1;
+2 -3
View File
@@ -383,10 +383,9 @@ static Mem *columnMem(sqlite3_stmt *pStmt, int i){
Vdbe *pVm = (Vdbe *)pStmt;
int vals = sqlite3_data_count(pStmt);
if( i>=vals || i<0 ){
static Mem nullMem;
if( nullMem.flags==0 ){ nullMem.flags = MEM_Null; }
static const Mem nullMem = {0, 0.0, "", 0, MEM_Null, MEM_Null };
sqlite3Error(pVm->db, SQLITE_RANGE, 0);
return &nullMem;
return (Mem*)&nullMem;
}
return &pVm->pTos[(1-vals)+i];
}
+3 -1
View File
@@ -782,7 +782,9 @@ void sqlite3VdbeMakeReady(
resizeOpArray(p, p->nOp);
assert( nVar>=0 );
assert( nStack<p->nOp );
nStack = isExplain ? 10 : nStack;
if( isExplain ){
nStack = 10;
}
p->aStack = sqliteMalloc(
nStack*sizeof(p->aStack[0]) /* aStack */
+ nArg*sizeof(Mem*) /* apArg */