More changes directed at getting things to work on 64-bit platforms. (CVS 1949)

FossilOrigin-Name: 39755d216608e9d12e1055433549f820f63608a7
This commit is contained in:
drh 2004-09-08 20:13:04 +00:00
parent 03c8988076
commit fe63d1c98b
12 changed files with 152 additions and 151 deletions

View File

@ -1,5 +1,5 @@
C Always\scast\s0\sto\s(char*)0\swhen\sit\sis\san\sargument\sin\sa\svarargs\sfunction.\s(CVS\s1948)
D 2004-09-08T15:09:41
C More\schanges\sdirected\sat\sgetting\sthings\sto\swork\son\s64-bit\splatforms.\s(CVS\s1949)
D 2004-09-08T20:13:05
F Makefile.in 65a7c43fcaf9a710d62f120b11b6e435eeb4a450
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@ -28,7 +28,7 @@ F sqlite3.def dbaeb20c153e1d366e8f421b55a573f5dfc00863
F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689
F src/auth.c 038d7c7c2224fa92f0125c0c30c90f7b2ca8c39a
F src/btree.c fe763fde639793ef2010d5388d0d135ecc02b4eb
F src/btree.c 470e00b08688f065c2e62a6dcd3fb18880e8e309
F src/btree.h 94dfec0a1722d33359b23e7e310f2b64ffedf029
F src/build.c 662f4e56a64aacadc97c481492b08c842b9ec0f4
F src/date.c eb8d5fa1a6d5cfc09031c8852d10ff742a94b15b
@ -52,28 +52,28 @@ F src/os_unix.c a5625eed7ab071d1715df783f4684945ae538a22
F src/os_unix.h f3097815e041e82e24d92505e1ff61ba24172d13
F src/os_win.c 9e2887825b1a32f0ceb1b73b93ffe29a112cd86f
F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44
F src/pager.c ae06c85de0db43f61a7a3e5eacad3fd5615daf59
F src/pager.c db8f6cb80798091fcff95c1f86873381fbfefee6
F src/pager.h 67739fe649f33be55dba522ca8a9cc4e42d14f71
F src/parse.y 9389af67bd49b8e5c9d2968b3315a30565b4a200
F src/pragma.c 1f7781c4bb37a558100e3b044beded171b75cf98
F src/printf.c 17b28a1eedfe8129b05de981719306c18c3f1327
F src/printf.c a8b92a3bcb4e9cae8066aea39a7b57b566255509
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
F src/select.c 5f60fc164a6a72ec26eb8221df4ba45aa8ab6f56
F src/shell.c 4f1a2760ced81c829defb47b0a3b61ffec61b604
F src/sqlite.h.in e29a526593b806f148017ed8bada760ada84cf2f
F src/sqliteInt.h abbb66373b410e242b617af0364def4f7af084fc
F src/sqliteInt.h c63aad21da12f12193cfa46a820c51cc837f5048
F src/table.c 8168c6e824009f8485bff79fc60ea8fea6829b10
F src/tclsqlite.c 9225350a3144b3c0dd07a3cc88d2c219d57e2f0d
F src/test1.c e7df5556002c50e917420f6f0edcc63047567659
F src/test2.c f4c2f3928f1998fd8cb75a81e33a60e025ea85d4
F src/test3.c 94d0a2a90bccd85802488cb42c69ec8afd2e4646
F src/test1.c 1305825c29575ee55a1c8b98a191669fd78b6287
F src/test2.c 0f3e0ad7b675a6f3323211ab4ea95490855654c3
F src/test3.c 1df9ea27467e50666e574ebe22d434288beb3050
F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df
F src/test5.c b001fa7f1b9e2dc5c2331de62fc641b5ab2bd7a1
F src/tokenize.c 418ef7ba1149603a30dcf0057e04a3ea0e99edbe
F src/trigger.c 98dd620bebd9f3dadaacf0db3958b916cf1e7b7f
F src/update.c 0e00300763d2ce0dbd6a0598882a5039580b225e
F src/utf.c 328890099db492dda5620ee5f924e244c6e57ff7
F src/util.c dc00e84eabc09d89fec31e908306fffa3eab449b
F src/util.c f9b661a3b80a1469777771776a59a5f0e2f193fc
F src/vacuum.c 819a3f411cb8d2d714e55f0805e8c23a642dd7ba
F src/vdbe.c b19de04c57b4136a8e0203d5e3b76dd82bded1b5
F src/vdbe.h 067ca8d6750ba4f69a50284765e5883dee860181
@ -148,8 +148,8 @@ F test/misc4.test 9f8ab4896dd627f5f9ba893a7b57c9f0a95dfd64
F test/misuse.test 2a64ce711419f2fd12806ed95af930fd4e7bb8f3
F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0
F test/null.test 642428b6a5408cc5b954b49e1b6e5025e4458b2b
F test/pager.test 059cc5c58d3b5a851343dff8c56cf7286425d03a
F test/pager2.test 55469c7c1c1a54d6b32d7b3cc99001e90101a1ce
F test/pager.test 394455707a079804e8a4e431d12edce831a065f0
F test/pager2.test 2b505eca6bf214dfff412cf615678a835c83ca74
F test/pager3.test 16f546293bb751b8151dc17df613fca938bbec8b
F test/pagesize.test f8b46ec46b9fe9f708a8d757dda232588dfb7217
F test/pragma.test 66a66b7f3b273b93325c9a5794acb418f52fdcbf
@ -248,7 +248,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P ff256fb5281e8f01c0acc3963c59399e949cc991
R ae046d327d52dd7ec8356d3392b51d85
P a1f532520c16a1f4b4285cd522774669292fb234
R 6047026f7d4b4901b427c44c73fb5a78
U drh
Z 97e780e7fb268a508d578730fd3b2624
Z 1ab41b9e5e58dc7d541f086c557c8e24

View File

@ -1 +1 @@
a1f532520c16a1f4b4285cd522774669292fb234
39755d216608e9d12e1055433549f820f63608a7

View File

@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.188 2004/09/05 00:33:43 drh Exp $
** $Id: btree.c,v 1.189 2004/09/08 20:13:05 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@ -1404,8 +1404,8 @@ void sqlite3BtreeCursorList(Btree *pBt){
for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
MemPage *pPage = pCur->pPage;
char *zMode = pCur->wrFlag ? "rw" : "ro";
printf("CURSOR %08x rooted at %4d(%s) currently at %d.%d%s\n",
(int)pCur, pCur->pgnoRoot, zMode,
sqlite3DebugPrintf("CURSOR %p rooted at %4d(%s) currently at %d.%d%s\n",
pCur, pCur->pgnoRoot, zMode,
pPage ? pPage->pgno : 0, pCur->idx,
pCur->isValid ? "" : " eof"
);
@ -3898,7 +3898,7 @@ int sqlite3BtreePageDump(Btree *pBt, int pgno, int recursive){
pPage->leaf = (c & PTF_LEAF)!=0;
pPage->hasData = !(pPage->zeroData || (!pPage->leaf && pPage->leafData));
nCell = get2byte(&data[hdr+3]);
printf("PAGE %d: flags=0x%02x frag=%d parent=%d\n", pgno,
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) );
@ -3928,13 +3928,13 @@ int sqlite3BtreePageDump(Btree *pBt, int pgno, int recursive){
if( payload[j]<0x20 || payload[j]>0x7f ) payload[j] = '.';
}
payload[sz] = 0;
printf(
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 ){
printf("right_child: %d\n", get4byte(&data[hdr+8]));
sqlite3DebugPrintf("right_child: %d\n", get4byte(&data[hdr+8]));
}
nFree = 0;
i = 0;
@ -3943,13 +3943,13 @@ int sqlite3BtreePageDump(Btree *pBt, int pgno, int recursive){
int sz = get2byte(&data[idx+2]);
sprintf(range,"%d..%d", idx, idx+sz-1);
nFree += sz;
printf("freeblock %2d: i=%-10s size=%-4d total=%d\n",
sqlite3DebugPrintf("freeblock %2d: i=%-10s size=%-4d total=%d\n",
i, range, sz, nFree);
idx = get2byte(&data[idx]);
i++;
}
if( idx!=0 ){
printf("ERROR: next freeblock index out of range: %d\n", idx);
sqlite3DebugPrintf("ERROR: next freeblock index out of range: %d\n", idx);
}
if( recursive && !pPage->leaf ){
for(i=0; i<nCell; i++){

View File

@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.162 2004/09/02 14:57:08 drh Exp $
** @(#) $Id: pager.c,v 1.163 2004/09/08 20:13:05 drh Exp $
*/
#include "os.h" /* Must be first to enable large file support */
#include "sqliteInt.h"
@ -304,9 +304,9 @@ static const unsigned char aJournalMagic[] = {
static void pager_refinfo(PgHdr *p){
static int cnt = 0;
if( !pager3_refinfo_enable ) return;
printf(
"REFCNT: %4d addr=0x%08x nRef=%d\n",
p->pgno, (int)PGHDR_TO_DATA(p), p->nRef
sqlite3DebugPrintf(
"REFCNT: %4d addr=%p nRef=%d\n",
p->pgno, PGHDR_TO_DATA(p), p->nRef
);
cnt++; /* Something to set a breakpoint on */
}
@ -3169,8 +3169,8 @@ void sqlite3pager_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);
sqlite3DebugPrintf("PAGE %3d addr=%p nRef=%d\n",
pPg->pgno, PGHDR_TO_DATA(pPg), pPg->nRef);
}
}
#endif

View File

@ -73,6 +73,7 @@
NULL pointers replaced by SQL NULL. %Q */
#define etTOKEN 14 /* a pointer to a Token structure */
#define etSRCLIST 15 /* a pointer to a SrcList */
#define etPOINTER 16 /* The %p conversion */
/*
@ -123,7 +124,7 @@ static et_info fmtinfo[] = {
{ 'i', 10, 1, etRADIX, "0123456789", 0 },
{ 'n', 0, 0, etSIZE, 0, 0 },
{ '%', 0, 0, etPERCENT, 0, 0 },
{ 'p', 10, 0, etRADIX, "0123456789", 0 },
{ 'p', 16, 0, etPOINTER, "0123456789abcdef", "x0" },
{ 'T', 0, 2, etTOKEN, 0, 0 },
{ 'S', 0, 2, etSRCLIST, 0, 0 },
};
@ -345,6 +346,10 @@ static int vxprintf(
** infop Pointer to the appropriate info struct.
*/
switch( xtype ){
case etPOINTER:
flag_longlong = sizeof(char*)==sizeof(i64);
flag_long = sizeof(char*)==sizeof(long int);
/* Fall through into the next case */
case etRADIX:
if( infop->flags & FLAG_SIGNED ){
i64 v;

View File

@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.320 2004/09/07 16:19:54 drh Exp $
** @(#) $Id: sqliteInt.h,v 1.321 2004/09/08 20:13:05 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@ -1206,6 +1206,7 @@ void sqlite3FreeX(void*);
char *sqlite3MPrintf(const char*, ...);
char *sqlite3VMPrintf(const char*, va_list);
void sqlite3DebugPrintf(const char*, ...);
void *sqlite3TextToPtr(const char*);
void sqlite3SetString(char **, const char *, ...);
void sqlite3SetNString(char **, ...);
void sqlite3ErrorMsg(Parse*, const char*, ...);

View File

@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.102 2004/09/07 16:19:54 drh Exp $
** $Id: test1.c,v 1.103 2004/09/08 20:13:05 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@ -21,12 +21,6 @@
#include <stdlib.h>
#include <string.h>
#if OS_WIN
# define PTR_FMT "%x"
#else
# define PTR_FMT "%p"
#endif
static const char * errorName(int rc){
const char *zName = 0;
switch( rc ){
@ -68,12 +62,7 @@ static const char * errorName(int rc){
** Decode a pointer to an sqlite3 object.
*/
static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb){
if( sscanf(zA, PTR_FMT, (void**)ppDb)!=1 &&
(zA[0]!='0' || zA[1]!='x' || sscanf(&zA[2], PTR_FMT, (void**)ppDb)!=1)
){
Tcl_AppendResult(interp, "\"", zA, "\" is not a valid pointer value", 0);
return TCL_ERROR;
}
*ppDb = (sqlite3*)sqlite3TextToPtr(zA);
return TCL_OK;
}
@ -85,10 +74,7 @@ static int getStmtPointer(
const char *zArg,
sqlite3_stmt **ppStmt
){
if( sscanf(zArg, PTR_FMT, (void**)ppStmt)!=1 ){
Tcl_AppendResult(interp, "\"", zArg, "\" is not a valid pointer value", 0);
return TCL_ERROR;
}
*ppStmt = (sqlite3_stmt*)sqlite3TextToPtr(zArg);
return TCL_OK;
}
@ -100,10 +86,7 @@ static int getFilePointer(
const char *zArg,
OsFile **ppFile
){
if( sscanf(zArg, PTR_FMT, (void**)ppFile)!=1 ){
Tcl_AppendResult(interp, "\"", zArg, "\" is not a valid pointer value", 0);
return TCL_ERROR;
}
*ppFile = (OsFile*)sqlite3TextToPtr(zArg);
return TCL_OK;
}
@ -121,19 +104,7 @@ static int getFilePointer(
** that helps. If nothing works, a fatal error is generated.
*/
static int makePointerStr(Tcl_Interp *interp, char *zPtr, void *p){
void *p2;
sprintf(zPtr, PTR_FMT, p);
if( sscanf(zPtr, PTR_FMT, &p2)!=1 || p2!=p ){
sprintf(zPtr, "0x" PTR_FMT, p);
if( sscanf(zPtr, PTR_FMT, &p2)!=1 || p2!=p ){
Tcl_AppendResult(interp, "unable to convert a pointer to a string "
"in the file " __FILE__ " in function makePointerStr(). Please "
"report this problem to the SQLite mailing list or as a new but "
"report. Please provide detailed information about how you compiled "
"SQLite and what computer you are running on.", 0);
return TCL_ERROR;
}
}
sqlite3_snprintf(100, zPtr, "%p", p);
return TCL_OK;
}

View File

@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test2.c,v 1.24 2004/07/22 01:19:35 drh Exp $
** $Id: test2.c,v 1.25 2004/09/08 20:13:06 drh Exp $
*/
#include "os.h"
#include "sqliteInt.h"
@ -88,7 +88,7 @@ static int pager_open(
}
sqlite3pager_set_cachesize(pPager, nPage);
sqlite3pager_set_pagesize(pPager, test_pagesize);
sprintf(zBuf,"0x%x",(int)pPager);
sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPager);
Tcl_AppendResult(interp, zBuf, 0);
return TCL_OK;
}
@ -111,7 +111,7 @@ static int pager_close(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
pPager = sqlite3TextToPtr(argv[1]);
rc = sqlite3pager_close(pPager);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -138,7 +138,7 @@ static int pager_rollback(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
pPager = sqlite3TextToPtr(argv[1]);
rc = sqlite3pager_rollback(pPager);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -165,7 +165,7 @@ static int pager_commit(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
pPager = sqlite3TextToPtr(argv[1]);
rc = sqlite3pager_commit(pPager);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -192,7 +192,7 @@ static int pager_stmt_begin(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
pPager = sqlite3TextToPtr(argv[1]);
rc = sqlite3pager_stmt_begin(pPager);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -219,7 +219,7 @@ static int pager_stmt_rollback(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
pPager = sqlite3TextToPtr(argv[1]);
rc = sqlite3pager_stmt_rollback(pPager);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -246,7 +246,7 @@ static int pager_stmt_commit(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
pPager = sqlite3TextToPtr(argv[1]);
rc = sqlite3pager_stmt_commit(pPager);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -273,7 +273,7 @@ static int pager_stats(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
pPager = sqlite3TextToPtr(argv[1]);
a = sqlite3pager_stats(pPager);
for(i=0; i<9; i++){
static char *zName[] = {
@ -282,7 +282,7 @@ static int pager_stats(
};
char zBuf[100];
Tcl_AppendElement(interp, zName[i]);
sprintf(zBuf,"%d",a[i]);
sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",a[i]);
Tcl_AppendElement(interp, zBuf);
}
return TCL_OK;
@ -306,8 +306,8 @@ static int pager_pagecount(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
sprintf(zBuf,"%d",sqlite3pager_pagecount(pPager));
pPager = sqlite3TextToPtr(argv[1]);
sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",sqlite3pager_pagecount(pPager));
Tcl_AppendResult(interp, zBuf, 0);
return TCL_OK;
}
@ -333,14 +333,14 @@ static int page_get(
" ID PGNO\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
pPager = sqlite3TextToPtr(argv[1]);
if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR;
rc = sqlite3pager_get(pPager, pgno, &pPage);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
sprintf(zBuf,"0x%x",(int)pPage);
sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPage);
Tcl_AppendResult(interp, zBuf, 0);
return TCL_OK;
}
@ -366,11 +366,11 @@ static int page_lookup(
" ID PGNO\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
pPager = sqlite3TextToPtr(argv[1]);
if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR;
pPage = sqlite3pager_lookup(pPager, pgno);
if( pPage ){
sprintf(zBuf,"0x%x",(int)pPage);
sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPage);
Tcl_AppendResult(interp, zBuf, 0);
}
return TCL_OK;
@ -394,7 +394,7 @@ static int page_unref(
" PAGE\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPage) ) return TCL_ERROR;
pPage = sqlite3TextToPtr(argv[1]);
rc = sqlite3pager_unref(pPage);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -421,7 +421,7 @@ static int page_read(
" PAGE\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPage) ) return TCL_ERROR;
pPage = sqlite3TextToPtr(argv[1]);
memcpy(zBuf, pPage, sizeof(zBuf));
Tcl_AppendResult(interp, zBuf, 0);
return TCL_OK;
@ -445,8 +445,8 @@ static int page_number(
" PAGE\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPage) ) return TCL_ERROR;
sprintf(zBuf, "%d", sqlite3pager_pagenumber(pPage));
pPage = sqlite3TextToPtr(argv[1]);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", sqlite3pager_pagenumber(pPage));
Tcl_AppendResult(interp, zBuf, 0);
return TCL_OK;
}
@ -469,7 +469,7 @@ static int page_write(
" PAGE DATA\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pPage) ) return TCL_ERROR;
pPage = sqlite3TextToPtr(argv[1]);
rc = sqlite3pager_write(pPage);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);

View File

@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test3.c,v 1.50 2004/07/23 00:01:39 drh Exp $
** $Id: test3.c,v 1.51 2004/09/08 20:13:06 drh Exp $
*/
#include "sqliteInt.h"
#include "pager.h"
@ -76,10 +76,7 @@ static int btree_open(
return TCL_ERROR;
}
sqlite3BtreeSetCacheSize(pBt, nCache);
sprintf(zBuf,"%p", pBt);
if( strncmp(zBuf,"0x",2) ){
sprintf(zBuf, "0x%p", pBt);
}
sqlite3_snprintf(sizeof(zBuf), zBuf,"%p", pBt);
Tcl_AppendResult(interp, zBuf, 0);
return TCL_OK;
}
@ -102,7 +99,7 @@ static int btree_close(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
rc = sqlite3BtreeClose(pBt);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -129,7 +126,7 @@ static int btree_begin_transaction(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
rc = sqlite3BtreeBeginTrans(pBt, 1);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -156,7 +153,7 @@ static int btree_rollback(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
rc = sqlite3BtreeRollback(pBt);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -183,7 +180,7 @@ static int btree_commit(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
rc = sqlite3BtreeCommit(pBt);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -210,7 +207,7 @@ static int btree_begin_statement(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
rc = sqlite3BtreeBeginStmt(pBt);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -237,7 +234,7 @@ static int btree_rollback_statement(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
rc = sqlite3BtreeRollbackStmt(pBt);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -264,7 +261,7 @@ static int btree_commit_statement(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
rc = sqlite3BtreeCommitStmt(pBt);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -292,14 +289,14 @@ static int btree_create_table(
" ID FLAGS\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
if( Tcl_GetInt(interp, argv[2], &flags) ) return TCL_ERROR;
rc = sqlite3BtreeCreateTable(pBt, &iTable, flags);
if( rc!=SQLITE_OK ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
sprintf(zBuf, "%d", iTable);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", iTable);
Tcl_AppendResult(interp, zBuf, 0);
return TCL_OK;
}
@ -323,7 +320,7 @@ static int btree_drop_table(
" ID TABLENUM\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
if( Tcl_GetInt(interp, argv[2], &iTable) ) return TCL_ERROR;
rc = sqlite3BtreeDropTable(pBt, iTable);
if( rc!=SQLITE_OK ){
@ -352,7 +349,7 @@ static int btree_clear_table(
" ID TABLENUM\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
if( Tcl_GetInt(interp, argv[2], &iTable) ) return TCL_ERROR;
rc = sqlite3BtreeClearTable(pBt, iTable);
if( rc!=SQLITE_OK ){
@ -381,7 +378,7 @@ static int btree_get_meta(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
for(i=0; i<SQLITE_N_BTREE_META; i++){
char zBuf[30];
unsigned int v;
@ -390,7 +387,7 @@ static int btree_get_meta(
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
sprintf(zBuf,"%d",v);
sqlite3_snprintf(sizeof(zBuf), zBuf,"%d",v);
Tcl_AppendElement(interp, zBuf);
}
return TCL_OK;
@ -414,12 +411,12 @@ static int btree_update_meta(
if( argc!=2+SQLITE_N_BTREE_META ){
char zBuf[30];
sprintf(zBuf,"%d",SQLITE_N_BTREE_META);
sqlite3_snprintf(sizeof(zBuf), zBuf,"%d",SQLITE_N_BTREE_META);
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ID METADATA...\" (METADATA is ", zBuf, " integers)", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
for(i=1; i<SQLITE_N_BTREE_META; i++){
if( Tcl_GetInt(interp, argv[i+2], &aMeta[i]) ) return TCL_ERROR;
}
@ -453,7 +450,7 @@ static int btree_page_dump(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
if( Tcl_GetInt(interp, argv[2], &iPage) ) return TCL_ERROR;
rc = sqlite3BtreePageDump(pBt, iPage, 0);
if( rc!=SQLITE_OK ){
@ -483,7 +480,7 @@ static int btree_tree_dump(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
if( Tcl_GetInt(interp, argv[2], &iPage) ) return TCL_ERROR;
rc = sqlite3BtreePageDump(pBt, iPage, 1);
if( rc!=SQLITE_OK ){
@ -513,7 +510,7 @@ static int btree_pager_stats(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
a = sqlite3pager_stats(sqlite3BtreePager(pBt));
for(i=0; i<9; i++){
static char *zName[] = {
@ -522,7 +519,7 @@ static int btree_pager_stats(
};
char zBuf[100];
Tcl_AppendElement(interp, zName[i]);
sprintf(zBuf,"%d",a[i]);
sqlite3_snprintf(sizeof(zBuf), zBuf,"%d",a[i]);
Tcl_AppendElement(interp, zBuf);
}
return TCL_OK;
@ -546,7 +543,7 @@ static int btree_pager_ref_dump(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
sqlite3pager_refdump(sqlite3BtreePager(pBt));
return TCL_OK;
}
@ -575,7 +572,7 @@ static int btree_integrity_check(
" ID ROOT ...\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
nRoot = argc-2;
aRoot = malloc( sizeof(int)*(argc-2) );
for(i=0; i<argc-2; i++){
@ -607,7 +604,7 @@ static int btree_cursor_list(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
sqlite3BtreeCursorList(pBt);
return SQLITE_OK;
}
@ -635,7 +632,7 @@ static int btree_cursor(
" ID TABLENUM WRITEABLE\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
pBt = sqlite3TextToPtr(argv[1]);
if( Tcl_GetInt(interp, argv[2], &iTable) ) return TCL_ERROR;
if( Tcl_GetBoolean(interp, argv[3], &wrFlag) ) return TCL_ERROR;
rc = sqlite3BtreeCursor(pBt, iTable, wrFlag, 0, 0, &pCur);
@ -643,7 +640,7 @@ static int btree_cursor(
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
sprintf(zBuf,"0x%x", (int)pCur);
sqlite3_snprintf(sizeof(zBuf), zBuf,"%p", pCur);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
@ -667,7 +664,7 @@ static int btree_close_cursor(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
rc = sqlite3BtreeCloseCursor(pCur);
if( rc ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -697,7 +694,7 @@ static int btree_move_to(
" ID KEY\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
if( sqlite3BtreeFlags(pCur) & BTREE_INTKEY ){
int iKey;
if( Tcl_GetInt(interp, argv[2], &iKey) ) return TCL_ERROR;
@ -711,7 +708,7 @@ static int btree_move_to(
}
if( res<0 ) res = -1;
if( res>0 ) res = 1;
sprintf(zBuf,"%d",res);
sqlite3_snprintf(sizeof(zBuf), zBuf,"%d",res);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
@ -735,7 +732,7 @@ static int btree_delete(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
rc = sqlite3BtreeDelete(pCur);
if( rc ){
Tcl_AppendResult(interp, errorName(rc), 0);
@ -763,8 +760,7 @@ static int btree_insert(
Tcl_WrongNumArgs(interp, 1, objv, "ID KEY DATA");
return TCL_ERROR;
}
if( Tcl_GetIntFromObj(interp, objv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(Tcl_GetString(objv[1]));
if( sqlite3BtreeFlags(pCur) & BTREE_INTKEY ){
i64 iKey;
int len;
@ -811,13 +807,13 @@ static int btree_next(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
rc = sqlite3BtreeNext(pCur, &res);
if( rc ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
sprintf(zBuf,"%d",res);
sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",res);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
@ -845,13 +841,13 @@ static int btree_prev(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
rc = sqlite3BtreePrevious(pCur, &res);
if( rc ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
sprintf(zBuf,"%d",res);
sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",res);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
@ -878,13 +874,13 @@ static int btree_first(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
rc = sqlite3BtreeFirst(pCur, &res);
if( rc ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
sprintf(zBuf,"%d",res);
sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",res);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
@ -911,13 +907,13 @@ static int btree_last(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
rc = sqlite3BtreeLast(pCur, &res);
if( rc ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
sprintf(zBuf,"%d",res);
sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",res);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
@ -942,8 +938,8 @@ static int btree_eof(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
sprintf(zBuf, "%d", sqlite3BtreeEof(pCur));
pCur = sqlite3TextToPtr(argv[1]);
sqlite3_snprintf(sizeof(zBuf),zBuf, "%d", sqlite3BtreeEof(pCur));
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
@ -969,9 +965,9 @@ static int btree_keysize(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
sqlite3BtreeKeySize(pCur, &n);
sprintf(zBuf, "%llu", n);
sqlite3_snprintf(sizeof(zBuf),zBuf, "%llu", n);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
@ -997,11 +993,11 @@ static int btree_key(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
sqlite3BtreeKeySize(pCur, &n);
if( sqlite3BtreeFlags(pCur) & BTREE_INTKEY ){
char zBuf2[60];
sprintf(zBuf2, "%llu", n);
sqlite3_snprintf(sizeof(zBuf),zBuf2, "%llu", n);
Tcl_AppendResult(interp, zBuf2, 0);
}else{
zBuf = malloc( n+1 );
@ -1038,7 +1034,7 @@ static int btree_data(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
sqlite3BtreeDataSize(pCur, &n);
zBuf = malloc( n+1 );
rc = sqlite3BtreeData(pCur, 0, n, zBuf);
@ -1076,7 +1072,7 @@ static int btree_fetch_key(
" ID AMT\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
if( Tcl_GetInt(interp, argv[2], &n) ) return TCL_ERROR;
sqlite3BtreeKeySize(pCur, &nKey);
zBuf = sqlite3BtreeKeyFetch(pCur, &amt);
@ -1114,7 +1110,7 @@ static int btree_fetch_data(
" ID AMT\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
if( Tcl_GetInt(interp, argv[2], &n) ) return TCL_ERROR;
sqlite3BtreeDataSize(pCur, &nData);
zBuf = sqlite3BtreeDataFetch(pCur, &amt);
@ -1149,14 +1145,14 @@ static int btree_payload_size(
" ID\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
if( sqlite3BtreeFlags(pCur) & BTREE_INTKEY ){
n1 = 0;
}else{
sqlite3BtreeKeySize(pCur, &n1);
}
sqlite3BtreeDataSize(pCur, &n2);
sprintf(zBuf, "%d", (int)(n1+n2));
sqlite3_snprintf(sizeof(zBuf),zBuf, "%d", (int)(n1+n2));
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
@ -1196,7 +1192,7 @@ static int btree_cursor_info(
" ID ?UP-CNT?\"", 0);
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
pCur = sqlite3TextToPtr(argv[1]);
if( argc==3 ){
if( Tcl_GetInt(interp, argv[2], &up) ) return TCL_ERROR;
}else{
@ -1209,7 +1205,7 @@ static int btree_cursor_info(
}
j = 0;
for(i=0; i<sizeof(aResult)/sizeof(aResult[0]); i++){
sprintf(&zBuf[j]," %d", aResult[i]);
sqlite3_snprintf(40,&zBuf[j]," %d", aResult[i]);
j += strlen(&zBuf[j]);
}
Tcl_AppendResult(interp, &zBuf[1], 0);

View File

@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.116 2004/09/06 17:24:13 drh Exp $
** $Id: util.c,v 1.117 2004/09/08 20:13:06 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@ -27,11 +27,11 @@ void print_stack_trace(){
int i;
int n = backtrace(bt, 30);
fprintf(stderr, "STACK: ");
sqlite3DebugPrintf("STACK: ");
for(i=0; i<n;i++){
fprintf(stderr, "%p ", bt[i]);
sqlite3DebugPrintf("%p ", bt[i]);
}
fprintf(stderr, "\n");
sqlite3DebugPrintf("\n");
}
#else
#define print_stack_trace()
@ -994,3 +994,31 @@ void *sqlite3HexToBlob(const char *z){
}
return zBlob;
}
#if defined(SQLITE_TEST)
/*
** Convert text generated by the "%p" conversion format back into
** a pointer.
*/
void *sqlite3TextToPtr(const char *z){
void *p;
u64 v;
u32 v2;
if( z[0]=='0' && z[1]=='x' ){
z += 2;
}
v = 0;
while( *z ){
v = (v<<4) + hexToInt(*z);
z++;
}
if( sizeof(p)==sizeof(v) ){
p = *(void**)&v;
}else{
assert( sizeof(p)==sizeof(v2) );
v2 = (u32)v;
p = *(void**)&v2;
}
return p;
}
#endif

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is page cache subsystem.
#
# $Id: pager.test,v 1.17 2004/06/19 00:16:31 drh Exp $
# $Id: pager.test,v 1.18 2004/09/08 20:13:06 drh Exp $
set testdir [file dirname $argv0]
@ -79,7 +79,7 @@ do_test pager-2.3.5 {
pager_stats $::p1
} {ref 1 page 1 max 10 size 0 state 1 err 0 hit 0 miss 1 ovfl 0}
do_test pager-2.3.6 {
expr $::g1==$::gx
expr {$::g1==$::gx}
} {1}
do_test pager-2.3.7 {
page_unref $::gx

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is page cache subsystem.
#
# $Id: pager2.test,v 1.2 2004/06/09 20:03:10 drh Exp $
# $Id: pager2.test,v 1.3 2004/09/08 20:13:06 drh Exp $
set testdir [file dirname $argv0]
@ -77,7 +77,7 @@ do_test pager2-2.3.5 {
pager_stats $::p1
} {ref 1 page 1 max 10 size 0 state 1 err 0 hit 0 miss 1 ovfl 0}
do_test pager2-2.3.6 {
expr $::g1==$::gx
expr {$::g1==$::gx}
} {1}
do_test pager2-2.3.7 {
page_unref $::gx