mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
More changes directed at getting things to work on 64-bit platforms. (CVS 1949)
FossilOrigin-Name: 39755d216608e9d12e1055433549f820f63608a7
This commit is contained in:
16
src/btree.c
16
src/btree.c
@@ -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++){
|
||||
|
||||
12
src/pager.c
12
src/pager.c
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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*, ...);
|
||||
|
||||
39
src/test1.c
39
src/test1.c
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
42
src/test2.c
42
src/test2.c
@@ -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);
|
||||
|
||||
108
src/test3.c
108
src/test3.c
@@ -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);
|
||||
|
||||
36
src/util.c
36
src/util.c
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user