mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Remove unused code. Test coverage enhancements. Modify the algorithm used
to select column names for VIEWs of joins so that the constructed column names omits the underlying table names. (CVS 5386) FossilOrigin-Name: 636cd723296a8b1709011fdd99b236ffddf3f1b0
This commit is contained in:
111
src/test_btree.c
111
src/test_btree.c
@@ -13,120 +13,11 @@
|
||||
** is not included in the SQLite library. It is used for automated
|
||||
** testing of the SQLite library.
|
||||
**
|
||||
** $Id: test_btree.c,v 1.3 2007/08/17 01:14:39 drh Exp $
|
||||
** $Id: test_btree.c,v 1.4 2008/07/10 00:32:42 drh Exp $
|
||||
*/
|
||||
#include "btreeInt.h"
|
||||
#include <tcl.h>
|
||||
|
||||
/*
|
||||
** Print a disassembly of the given page on standard output. This routine
|
||||
** is used for debugging and testing only.
|
||||
*/
|
||||
static int btreePageDump(
|
||||
BtShared *pBt, /* The Btree to be dumped */
|
||||
int pgno, /* The page to be dumped */
|
||||
int recursive, /* True to decend into child pages */
|
||||
MemPage *pParent /* Parent page */
|
||||
){
|
||||
int rc;
|
||||
MemPage *pPage;
|
||||
int i, j, c;
|
||||
int nFree;
|
||||
u16 idx;
|
||||
int hdr;
|
||||
int nCell;
|
||||
int isInit;
|
||||
unsigned char *data;
|
||||
char range[20];
|
||||
unsigned char payload[20];
|
||||
|
||||
rc = sqlite3BtreeGetPage(pBt, (Pgno)pgno, &pPage, 0);
|
||||
isInit = pPage->isInit;
|
||||
if( pPage->isInit==0 ){
|
||||
sqlite3BtreeInitPage(pPage, pParent);
|
||||
}
|
||||
if( rc ){
|
||||
return rc;
|
||||
}
|
||||
hdr = pPage->hdrOffset;
|
||||
data = pPage->aData;
|
||||
c = data[hdr];
|
||||
pPage->intKey = (c & (PTF_INTKEY|PTF_LEAFDATA))!=0;
|
||||
pPage->zeroData = (c & PTF_ZERODATA)!=0;
|
||||
pPage->leafData = (c & PTF_LEAFDATA)!=0;
|
||||
pPage->leaf = (c & PTF_LEAF)!=0;
|
||||
pPage->hasData = !(pPage->zeroData || (!pPage->leaf && pPage->leafData));
|
||||
nCell = get2byte(&data[hdr+3]);
|
||||
sqlite3DebugPrintf("PAGE %d: flags=0x%02x frag=%d parent=%d\n", pgno,
|
||||
data[hdr], data[hdr+7],
|
||||
(pPage->isInit && pPage->pParent) ? pPage->pParent->pgno : 0);
|
||||
assert( hdr == (pgno==1 ? 100 : 0) );
|
||||
idx = hdr + 12 - pPage->leaf*4;
|
||||
for(i=0; i<nCell; i++){
|
||||
CellInfo info;
|
||||
Pgno child;
|
||||
unsigned char *pCell;
|
||||
int sz;
|
||||
int addr;
|
||||
|
||||
addr = get2byte(&data[idx + 2*i]);
|
||||
pCell = &data[addr];
|
||||
sqlite3BtreeParseCellPtr(pPage, pCell, &info);
|
||||
sz = info.nSize;
|
||||
sqlite3_snprintf(sizeof(range),range,"%d..%d", addr, addr+sz-1);
|
||||
if( pPage->leaf ){
|
||||
child = 0;
|
||||
}else{
|
||||
child = get4byte(pCell);
|
||||
}
|
||||
sz = info.nData;
|
||||
if( !pPage->intKey ) sz += info.nKey;
|
||||
if( sz>sizeof(payload)-1 ) sz = sizeof(payload)-1;
|
||||
memcpy(payload, &pCell[info.nHeader], sz);
|
||||
for(j=0; j<sz; j++){
|
||||
if( payload[j]<0x20 || payload[j]>0x7f ) payload[j] = '.';
|
||||
}
|
||||
payload[sz] = 0;
|
||||
sqlite3DebugPrintf(
|
||||
"cell %2d: i=%-10s chld=%-4d nk=%-4lld nd=%-4d payload=%s\n",
|
||||
i, range, child, info.nKey, info.nData, payload
|
||||
);
|
||||
}
|
||||
if( !pPage->leaf ){
|
||||
sqlite3DebugPrintf("right_child: %d\n", get4byte(&data[hdr+8]));
|
||||
}
|
||||
nFree = 0;
|
||||
i = 0;
|
||||
idx = get2byte(&data[hdr+1]);
|
||||
while( idx>0 && idx<pPage->pBt->usableSize ){
|
||||
int sz = get2byte(&data[idx+2]);
|
||||
sqlite3_snprintf(sizeof(range),range,"%d..%d", idx, idx+sz-1);
|
||||
nFree += sz;
|
||||
sqlite3DebugPrintf("freeblock %2d: i=%-10s size=%-4d total=%d\n",
|
||||
i, range, sz, nFree);
|
||||
idx = get2byte(&data[idx]);
|
||||
i++;
|
||||
}
|
||||
if( idx!=0 ){
|
||||
sqlite3DebugPrintf("ERROR: next freeblock index out of range: %d\n", idx);
|
||||
}
|
||||
if( recursive && !pPage->leaf ){
|
||||
for(i=0; i<nCell; i++){
|
||||
unsigned char *pCell = sqlite3BtreeFindCell(pPage, i);
|
||||
btreePageDump(pBt, get4byte(pCell), 1, pPage);
|
||||
idx = get2byte(pCell);
|
||||
}
|
||||
btreePageDump(pBt, get4byte(&data[hdr+8]), 1, pPage);
|
||||
}
|
||||
pPage->isInit = isInit;
|
||||
sqlite3PagerUnref(pPage->pDbPage);
|
||||
fflush(stdout);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
int sqlite3BtreePageDump(Btree *p, int pgno, int recursive){
|
||||
return btreePageDump(p->pBt, pgno, recursive, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: sqlite3_shared_cache_report
|
||||
**
|
||||
|
Reference in New Issue
Block a user