New btree.c module compiles and links. (CVS 1320)

FossilOrigin-Name: dcd6b55f932a7ade4ad058534651e198b56370ad
This commit is contained in:
drh 2004-05-07 13:30:42 +00:00
parent 4fc0fb4358
commit a34b676483
8 changed files with 298 additions and 263 deletions

View File

@ -54,7 +54,7 @@ TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src
# Object files for the SQLite library.
#
LIBOBJ = hash.o os.o pager.o random.o \
LIBOBJ = btree.o hash.o os.o pager.o random.o \
util.o tclsqlite.o utf.o
LIBOBJ_ORIG = attach.o auth.o btree.o btree_rb.o build.o copy.o date.o delete.o \
@ -66,6 +66,8 @@ LIBOBJ_ORIG = attach.o auth.o btree.o btree_rb.o build.o copy.o date.o delete.o
# All of the source code files.
#
SRC = \
$(TOP)/src/btree.c \
$(TOP)/src/btree.h \
$(TOP)/src/hash.c \
$(TOP)/src/hash.h \
$(TOP)/src/os.c \
@ -121,6 +123,7 @@ TESTSRC = \
$(TOP)/src/os.c \
$(TOP)/src/pager.c \
$(TOP)/src/test2.c \
$(TOP)/src/test3.c \
$(TOP)/src/test5.c \
$(TOP)/src/md5.c

View File

@ -1,5 +1,5 @@
C Trying\sto\ssynchronize\sthe\stest3.c\smodule\swith\sthe\snew\sbtree.c\scode.\s(CVS\s1319)
D 2004-05-07T02:26:28
C New\sbtree.c\smodule\scompiles\sand\slinks.\s(CVS\s1320)
D 2004-05-07T13:30:42
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@ -15,7 +15,7 @@ F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538
F doc/report1.txt a031aaf37b185e4fa540223cb516d3bccec7eeac
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
F ltmain.sh f6b283068efa69f06eb8aa1fe4bddfdbdeb35826
F main.mk b0b22dffdd728c3a96c2b2e87e01fe86a017fa34
F main.mk 8981b769a3538a8fbd5031786353e8f41bc6a07f
F publish.sh 1cd5c982388560fa91eedf6a338e210f713b35c8
F spec.template a38492f1c1dd349fc24cb0565e08afc53045304b
F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
@ -23,8 +23,8 @@ F sqlite.def fc4f5734786fe4743cfe2aa98eb2da4b089edb5f
F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
F src/attach.c b01db0d3211f673d8e670abf7eaad04591d40d14
F src/auth.c 4fa3b05bd19445d1c474d6751c4a508d6ea0abe1
F src/btree.c 54f5f2d0004ca0a2c36d863632f6b5a84fd04095
F src/btree.h 858659c6605ae07a2a0fb3d176b25573d30f27c5
F src/btree.c 4c4ccf85d2852aa85c5d6ec7b34b047e363c0366
F src/btree.h 49b255b2880c50a3572a536ea935edb2dd33aae3
F src/btree_rb.c 99feb3ff835106d018a483a1ce403e5cf9c718bc
F src/build.c 76fbca30081decd6615dee34b48c927ed5063752
F src/copy.c 750e13828c3e4a293123e36aaa7cf0f22466248a
@ -44,17 +44,17 @@ F src/pager.c 2e3af839e7aab5bfaff7a0ef4694bae487b0ffeb
F src/pager.h 138ca7f73c47bebf469591939dcefa934cdf8d26
F src/parse.y 023720cb8c3bef74e51738bca78335d0dc6d2cfd
F src/pragma.c f9c157b0591419d2d3407dac90222020d2a6d822
F src/printf.c 8c58b7b6d4069eec6ebe2d46bdbc3a89a367bf95
F src/printf.c 8dba7092430549e70c57de2bde6be92a28819eb0
F src/random.c 775913e0b7fbd6295d21f12a7bd35b46387c44b2
F src/select.c 3833e2b64cc6d249385ee44e13bf49c9ae5b903d
F src/shell.c 920af040d3a33ea8919c82cee45b424ad841cee0
F src/sqlite.h.in 35bec264dfb4965bbfeb7e75221f8658f210c30d
F src/sqliteInt.h dca24187ffe06e9207f9f400a2a0632ea483e55b
F src/sqliteInt.h 44a17815ec6ffb93151723aa5cde7263162f52f3
F src/table.c d845cb101b5afc1f7fea083c99e3d2fa7998d895
F src/tclsqlite.c 3a5f8192ed5279a68610102a92a3a9f0cdd09e68
F src/test1.c 9aa62b89d420e6763b5e7ae89a47f6cf87370477
F src/test2.c 9d611c45e1b07039a2bd95f5ea73178362b23229
F src/test3.c 3965c323b3a84b1a93e43b412e2c38cd3e3a8e6e
F src/test3.c 0b62d371f43bdb8fb1e3d5c4863743d6729f4e80
F src/test4.c 6e3e31acfaf21d66420fc35fda5b17dc0000cc8d
F src/test5.c 3ff0565057b8d23e20092d5c6c0b7cb0d932c51e
F src/tokenize.c 6676b946fd8825b67ab52140af4fdc57a70bda48
@ -190,7 +190,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P 49c3c86c17bcd8132216791d7a1a17e2c6256206
R 121265b7ada7abd612209a97396c18a3
P 7fd1a660b0607b7c36de1278724521cbea72af0c
R e634acb38b6d10c4d5783a02c4f65e26
U drh
Z cd14b2dc0ebca94dac5f612d17c68cb1
Z a193f9bb2598a024f21bcc3c2eb519e6

View File

@ -1 +1 @@
7fd1a660b0607b7c36de1278724521cbea72af0c
dcd6b55f932a7ade4ad058534651e198b56370ad

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
** subsystem. See comments in the source code for a detailed description
** of what each interface routine does.
**
** @(#) $Id: btree.h,v 1.37 2004/04/26 14:10:21 drh Exp $
** @(#) $Id: btree.h,v 1.38 2004/05/07 13:30:42 drh Exp $
*/
#ifndef _BTREE_H_
#define _BTREE_H_
@ -64,7 +64,7 @@ int sqlite3BtreeCursor(
BtCursor **ppCursor /* Returned cursor */
);
int sqlite3BtreeCursorClose(BtCursor*);
int sqlite3BtreeCloseCursor(BtCursor*);
int sqlite3BtreeMoveto(BtCursor*, const void *pKey, u64 nKey, int *pRes);
int sqlite3BtreeDelete(BtCursor*);
int sqlite3BtreeInsert(BtCursor*, const void *pKey, u64 nKey,
@ -79,5 +79,14 @@ void *sqlite3BtreeKeyFetch(BtCursor*);
int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot);
struct Pager *sqlite3BtreePager(Btree*);
#ifdef SQLITE_TEST
int sqlite3BtreeCursorDump(BtCursor*, int*);
int sqlite3BtreeFlags(BtCursor*);
int sqlite3BtreePageDump(Btree*, int, int recursive);
#endif
#endif /* _BTREE_H_ */

View File

@ -208,7 +208,8 @@ static int vxprintf(
etByte flag_alternateform; /* True if "#" flag is present */
etByte flag_zeropad; /* True if field width constant starts with zero */
etByte flag_long; /* True if "l" flag is present */
unsigned long longvalue; /* Value for integer types */
etByte flag_longlong; /* True if the "ll" flag is present */
UINT64_TYPE longvalue; /* Value for integer types */
LONGDOUBLE_TYPE realvalue; /* Value for real types */
et_info *infop; /* Pointer to the appropriate info structure */
char buf[etBUFSIZE]; /* Conversion buffer */
@ -299,8 +300,14 @@ static int vxprintf(
if( c=='l' ){
flag_long = 1;
c = *++fmt;
if( c=='l' ){
flag_longlong = 1;
c = *++fmt;
}else{
flag_longlong = 0;
}
}else{
flag_long = 0;
flag_long = flag_longlong = 0;
}
/* Fetch the info entry for the field */
infop = 0;
@ -326,6 +333,8 @@ static int vxprintf(
** flag_zeropad TRUE if the width began with 0.
** flag_long TRUE if the letter 'l' (ell) prefixed
** the conversion character.
** flag_longlong TRUE if the letter 'll' (ell ell) prefixed
** the conversion character.
** flag_blanksign TRUE if a ' ' is present.
** width The specified field width. This is
** always non-negative. Zero is the default.
@ -336,8 +345,9 @@ static int vxprintf(
*/
switch( xtype ){
case etRADIX:
if( flag_long ) longvalue = va_arg(ap,long);
else longvalue = va_arg(ap,int);
if( flag_longlong ) longvalue = va_arg(ap,INT64_TYPE);
else if( flag_long ) longvalue = va_arg(ap,long ing);
else longvalue = va_arg(ap,int);
#if 1
/* For the format %#x, the value zero is printed "0" not "0x0".
** I think this is stupid. */

View File

@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.222 2004/05/06 23:37:53 danielk1977 Exp $
** @(#) $Id: sqliteInt.h,v 1.223 2004/05/07 13:30:42 drh Exp $
*/
#include "config.h"
#include "sqlite.h"
@ -95,6 +95,9 @@
**
** cc '-DUINTPTR_TYPE=long long int' ...
*/
#ifndef INT64_TYPE
# define INT64_TYPE long long int
#endif
#ifndef UINT64_TYPE
# define UINT64_TYPE unsigned long long int
#endif
@ -1274,4 +1277,3 @@ void *sqlite3utf8to16be(const unsigned char *pIn, int N);
void *sqlite3utf8to16le(const unsigned char *pIn, int N);
void sqlite3utf16to16le(void *pData, int N);
void sqlite3utf16to16be(void *pData, int N);

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.25 2004/05/07 02:26:28 drh Exp $
** $Id: test3.c,v 1.26 2004/05/07 13:30:42 drh Exp $
*/
#include "sqliteInt.h"
#include "pager.h"
@ -433,7 +433,7 @@ static int btree_pager_stats(
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
a = sqlitepager_stats(sqlite3BtreePager(pBt));
a = sqlite3pager_stats(sqlite3BtreePager(pBt));
for(i=0; i<9; i++){
static char *zName[] = {
"ref", "page", "max", "size", "state", "err",
@ -466,7 +466,7 @@ static int btree_pager_ref_dump(
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
sqlitepager_refdump(sqlite3BtreePager(pBt));
sqlite3pager_refdump(sqlite3BtreePager(pBt));
return TCL_OK;
}
@ -534,7 +534,7 @@ static int btree_cursor(
if( Tcl_GetInt(interp, argv[1], (int*)&pBt) ) return TCL_ERROR;
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, &pCur);
rc = sqlite3BtreeCursor(pBt, iTable, wrFlag, 0, 0, &pCur);
if( rc ){
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
@ -810,9 +810,7 @@ static int btree_keysize(
const char **argv /* Text of each argument */
){
BtCursor *pCur;
int rc;
u64 n64;
u32 n;
u64 n;
char zBuf[50];
if( argc!=2 ){
@ -821,9 +819,8 @@ static int btree_keysize(
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
sqlite3BtreeKeySize(pCur, &n64);
n = (u32)n64
sprintf(zBuf, "%u", n);
sqlite3BtreeKeySize(pCur, &n);
sprintf(zBuf, "%llu", n);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
@ -851,18 +848,24 @@ static int btree_key(
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
sqlite3BtreeKeySize(pCur, &n);
zBuf = malloc( n+1 );
rc = sqliteBtreeKey(pCur, 0, n, zBuf);
if( rc!=n ){
char zMsg[100];
if( sqlite3BtreeFlags(pCur) & BTREE_INTKEY ){
char zBuf2[60];
sprintf(zBuf2, "%llu", n);
Tcl_AppendResult(interp, zBuf2, 0);
}else{
zBuf = malloc( n+1 );
rc = sqlite3BtreeKey(pCur, 0, n, zBuf);
if( rc!=n ){
char zMsg[100];
free(zBuf);
sprintf(zMsg, "truncated key: got %d of %llu bytes", rc, n);
Tcl_AppendResult(interp, zMsg, 0);
return TCL_ERROR;
}
zBuf[n] = 0;
Tcl_AppendResult(interp, zBuf, 0);
free(zBuf);
sprintf(zMsg, "truncated key: got %d of %d bytes", rc, n);
Tcl_AppendResult(interp, zMsg, 0);
return TCL_ERROR;
}
zBuf[n] = 0;
Tcl_AppendResult(interp, zBuf, 0);
free(zBuf);
return SQLITE_OK;
}
@ -879,7 +882,7 @@ static int btree_data(
){
BtCursor *pCur;
int rc;
int n;
u32 n;
char *zBuf;
if( argc!=2 ){
@ -888,13 +891,13 @@ static int btree_data(
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
sqliteBtreeDataSize(pCur, &n);
sqlite3BtreeDataSize(pCur, &n);
zBuf = malloc( n+1 );
rc = sqlite3BtreeData(pCur, 0, n, zBuf);
if( rc!=n ){
char zMsg[100];
free(zBuf);
sprintf(zMsg, "truncated data: got %d of %d bytes", rc, n);
sprintf(zMsg, "truncated data: got %d of %u bytes", rc, n);
Tcl_AppendResult(interp, zMsg, 0);
return TCL_ERROR;
}
@ -917,7 +920,7 @@ static int btree_payload_size(
){
BtCursor *pCur;
int n2;
u32 n1;
u64 n1;
char zBuf[50];
if( argc!=2 ){
@ -926,9 +929,13 @@ static int btree_payload_size(
return TCL_ERROR;
}
if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR;
sqlite3BtreeKeySize(pCur, &n1);
if( sqlite3BtreeFlags(pCur) & BTREE_INTKEY ){
n1 = 0;
}else{
sqlite3BtreeKeySize(pCur, &n1);
}
sqlite3BtreeDataSize(pCur, &n2);
sprintf(zBuf, "%d", n1+n2);
sprintf(zBuf, "%d", (int)(n1+n2));
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
}
@ -1009,6 +1016,7 @@ int Sqlitetest3_Init(Tcl_Interp *interp){
{ "btree_insert", (Tcl_CmdProc*)btree_insert },
{ "btree_next", (Tcl_CmdProc*)btree_next },
{ "btree_prev", (Tcl_CmdProc*)btree_prev },
{ "btree_keysize", (Tcl_CmdProc*)btree_keysize },
{ "btree_key", (Tcl_CmdProc*)btree_key },
{ "btree_data", (Tcl_CmdProc*)btree_data },
{ "btree_payload_size", (Tcl_CmdProc*)btree_payload_size },
@ -1022,7 +1030,7 @@ int Sqlitetest3_Init(Tcl_Interp *interp){
for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){
Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);
}
Tcl_LinkVar(interp, "pager_refinfo_enable", (char*)&pager_refinfo_enable,
Tcl_LinkVar(interp, "pager_refinfo_enable", (char*)&pager3_refinfo_enable,
TCL_LINK_INT);
return TCL_OK;
}