1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Got a lot of BTree tests working. Still lots more needed. (CVS 230)

FossilOrigin-Name: 9cfeeb5896d2a17c8c7904136d346a6245c9e497
This commit is contained in:
drh
2001-06-28 01:54:48 +00:00
parent 2aa679f604
commit dd79342e87
9 changed files with 405 additions and 46 deletions

View File

@@ -27,7 +27,7 @@
** all writes in order to support rollback. Locking is used to limit
** access to one or more reader or one writer.
**
** @(#) $Id: pager.c,v 1.11 2001/06/24 20:39:41 drh Exp $
** @(#) $Id: pager.c,v 1.12 2001/06/28 01:54:49 drh Exp $
*/
#include "sqliteInt.h"
#include "pager.h"
@@ -158,6 +158,25 @@ static const unsigned char aJournalMagic[] = {
*/
#define pager_hash(PN) ((PN)%N_PG_HASH)
/*
** Enable reference count tracking here:
*/
#if SQLITE_TEST
int pager_refinfo_enable = 0;
static void pager_refinfo(PgHdr *p){
static int cnt = 0;
if( !pager_refinfo_enable ) return;
printf(
"REFCNT: %4d addr=0x%08x nRef=%d\n",
p->pgno, (int)PGHDR_TO_DATA(p), p->nRef
);
cnt++; /* Something to set a breakpoint on */
}
# define REFINFO(X) pager_refinfo(X)
#else
# define REFINFO(X)
#endif
/*
** Attempt to acquire a read lock (if wrlock==0) or a write lock (if wrlock==1)
** on the database file. Return 0 on success and non-zero if the lock
@@ -579,6 +598,7 @@ static void page_ref(PgHdr *pPg){
pPg->pPager->nRef++;
}
pPg->nRef++;
REFINFO(pPg);
}
/*
@@ -754,6 +774,7 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){
pPg->inJournal = 0;
pPg->dirty = 0;
pPg->nRef = 1;
REFINFO(pPg);
pPager->nRef++;
h = pager_hash(pgno);
pPg->pNextHash = pPager->aHash[h];
@@ -830,6 +851,7 @@ int sqlitepager_unref(void *pData){
assert( pPg->nRef>0 );
pPager = pPg->pPager;
pPg->nRef--;
REFINFO(pPg);
/* When the number of references to a page reach 0, call the
** destructor and add the page to the freelist.
@@ -1034,3 +1056,17 @@ int *sqlitepager_stats(Pager *pPager){
a[8] = pPager->nOvfl;
return a;
}
#if SQLITE_TEST
/*
** Print a listing of all referenced pages and their ref count.
*/
void sqlitepager_refdump(Pager *pPager){
PgHdr *pPg;
for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){
if( pPg->nRef<=0 ) continue;
printf("PAGE %3d addr=0x%08x nRef=%d\n",
pPg->pgno, (int)PGHDR_TO_DATA(pPg), pPg->nRef);
}
}
#endif