mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Pager tests working. (CVS 1308)
FossilOrigin-Name: 910067a200c4b25b5d813a84146673d3d1c80952
This commit is contained in:
20
main.mk
20
main.mk
@ -54,7 +54,10 @@ TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src
|
||||
|
||||
# Object files for the SQLite library.
|
||||
#
|
||||
LIBOBJ = attach.o auth.o btree.o btree_rb.o build.o copy.o date.o delete.o \
|
||||
LIBOBJ = hash.o os.o pager.o random.o \
|
||||
util.o tclsqlite.o
|
||||
|
||||
LIBOBJ_ORIG = attach.o auth.o btree.o btree_rb.o build.o copy.o date.o delete.o \
|
||||
expr.o func.o hash.o insert.o \
|
||||
main.o opcodes.o os.o pager.o parse.o pragma.o printf.o random.o \
|
||||
select.o table.o tokenize.o trigger.o update.o util.o \
|
||||
@ -63,6 +66,15 @@ LIBOBJ = 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/hash.c \
|
||||
$(TOP)/src/hash.h \
|
||||
$(TOP)/src/os.c \
|
||||
$(TOP)/src/pager.c \
|
||||
$(TOP)/src/pager.h \
|
||||
$(TOP)/src/random.c \
|
||||
$(TOP)/src/util.c
|
||||
|
||||
SRC_ORIG = \
|
||||
$(TOP)/src/attach.c \
|
||||
$(TOP)/src/auth.c \
|
||||
$(TOP)/src/btree.c \
|
||||
@ -106,6 +118,12 @@ SRC = \
|
||||
# Source code to the test files.
|
||||
#
|
||||
TESTSRC = \
|
||||
$(TOP)/src/os.c \
|
||||
$(TOP)/src/pager.c \
|
||||
$(TOP)/src/test2.c \
|
||||
$(TOP)/src/md5.c
|
||||
|
||||
TESTSRC_ORIG = \
|
||||
$(TOP)/src/btree.c \
|
||||
$(TOP)/src/func.c \
|
||||
$(TOP)/src/os.c \
|
||||
|
34
manifest
34
manifest
@ -1,5 +1,5 @@
|
||||
C Begin\smodifying\sthe\sBTree\scode\sfor\sthe\snew\sversion-3\sfile\sformat.\nThis\sis\sa\swork-in-progress.\nAs\sof\sthis\scheck-in,\sSQLite\swill\snot\sbuild.\s(CVS\s1306)
|
||||
D 2004-04-23T23:43:10
|
||||
C Pager\stests\sworking.\s(CVS\s1308)
|
||||
D 2004-04-26T14:10:21
|
||||
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 1b27efb94be53a96c4333584a00a59fcc87ddc37
|
||||
F main.mk 1318f38db512abb0abdbdf4d3c9dd213e2960977
|
||||
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 cb9836c17b6d8ee447627caaf614ca97b5dc1188
|
||||
F src/btree.h 41cb3ff6ebc3f6da2d0a074e39ff8c7a2287469f
|
||||
F src/btree.c 4e2b50ae03bd4d9e678bda14b08307d80dd4471c
|
||||
F src/btree.h 858659c6605ae07a2a0fb3d176b25573d30f27c5
|
||||
F src/btree_rb.c 99feb3ff835106d018a483a1ce403e5cf9c718bc
|
||||
F src/build.c 76fbca30081decd6615dee34b48c927ed5063752
|
||||
F src/copy.c 750e13828c3e4a293123e36aaa7cf0f22466248a
|
||||
@ -37,11 +37,11 @@ F src/hash.c 9b56ef3b291e25168f630d5643a4264ec011c70e
|
||||
F src/hash.h 3247573ab95b9dd90bcca0307a75d9a16da1ccc7
|
||||
F src/insert.c c0485ee2d1b99322894e2d1e0b576fd05ed75616
|
||||
F src/main.c 94dd355768e2a389e184a069b6880f4bac100307
|
||||
F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
|
||||
F src/md5.c c53e7b50418afbde22d07128baf3cc615530e846
|
||||
F src/os.c 5f11382733805d4529ec2a30800e117f30995ea8
|
||||
F src/os.h 250a3789be609adfee5c5aa20137ce8683276f24
|
||||
F src/pager.c b246986e5ba31b15aa3cf91d3b9ec2e608aceb8e
|
||||
F src/pager.h 82332878799280145639a48d88cdb4058925e3f6
|
||||
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
|
||||
@ -49,17 +49,17 @@ 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 235ce244b62bb26cc9ab394fb7a0724dd4e65c83
|
||||
F src/sqliteInt.h 36c649d7f2ab0affdc44e51c681dd1d5723ee1e9
|
||||
F src/table.c d845cb101b5afc1f7fea083c99e3d2fa7998d895
|
||||
F src/tclsqlite.c 819d92d305756c4ea57de023c387d2fa8a256aff
|
||||
F src/tclsqlite.c e816201db3ea6ba857a0351547be1d4b7286e95d
|
||||
F src/test1.c 9aa62b89d420e6763b5e7ae89a47f6cf87370477
|
||||
F src/test2.c 75819b0f2c63c6a0fd6995445881f2eb94036996
|
||||
F src/test2.c 9d611c45e1b07039a2bd95f5ea73178362b23229
|
||||
F src/test3.c 30985ebdfaf3ee1462a9b0652d3efbdc8d9798f5
|
||||
F src/test4.c 6e3e31acfaf21d66420fc35fda5b17dc0000cc8d
|
||||
F src/tokenize.c 6676b946fd8825b67ab52140af4fdc57a70bda48
|
||||
F src/trigger.c a9927b57c865b6f3df3fb5e40c9824d722660ded
|
||||
F src/update.c 4c50328ebc127852bde8e2950eb8933234802c21
|
||||
F src/util.c 122bc174f6c8c2eb6a9127d9f13c4c74f83b85e4
|
||||
F src/util.c b2287b07ddf55ef7aaa8888a9473123995a69f40
|
||||
F src/vacuum.c a4e8464c9f6d60659c5343e9d62c742463227820
|
||||
F src/vdbe.c 7c33f761fdc799633468766fb53eda4301daa6b3
|
||||
F src/vdbe.h ac987945e4dd6f987bca534c6005899f089fc270
|
||||
@ -114,7 +114,7 @@ F test/misc3.test 3b5e369514a3ba3f919fb7eafa7d027440b5079e
|
||||
F test/misuse.test 1095f26d1aed406c65e1d2eba651c4bb7c38cbff
|
||||
F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0
|
||||
F test/null.test c14d0f4739f21e929b8115b72bf0c765b6bb1721
|
||||
F test/pager.test 331519008889d45f6df6697395e5bce6ee602fd9
|
||||
F test/pager.test 548968643d91c1c43a3a3eb1a232e9ca87b4069e
|
||||
F test/pragma.test 24a3f7a697b45cb90d664ebce5566bec7ac41571
|
||||
F test/printf.test 46b3d07d59d871d0831b4a657f6dfcafe0574850
|
||||
F test/progress.test 701b6115c2613128ececdfe1398a1bd0e1a4cfb3 x
|
||||
@ -133,7 +133,7 @@ F test/table.test 371a1fc1c470982b2f68f9732f903a5d96f949c4
|
||||
F test/tableapi.test e0c4cce61e58343caa84dab33fa6823cb35fe1e1
|
||||
F test/tclsqlite.test a684fc191b81e6cded8a81263663d5a130fbb013
|
||||
F test/temptable.test a770ba6308d7f7332fce985086b8e06bed6430c2
|
||||
F test/tester.tcl 2f1d43df1311c9dc06acaa7a82e87bfea85dea5f
|
||||
F test/tester.tcl 5b47e21f442fe8afae963bc45beb54795cf5d162
|
||||
F test/thread1.test 53f050d5be6932d9430df7756edd379366508ff6
|
||||
F test/threadtest1.c f7f896e62ed46feae1dc411114a48c15a0f82ee2
|
||||
F test/threadtest2.c d94ca4114fd1504f7e0ae724bcd83d4b40931d86
|
||||
@ -188,7 +188,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
|
||||
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
|
||||
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
|
||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||
P 818bdba5dc25cda56716fdda1781a3d4ecb3a111
|
||||
R f443d88ceb0074719c3a2c8d82169104
|
||||
P ce0bbd3a7159e12c86c5cde6571d6668b234827b
|
||||
R e6250126bdd2ced9348d9f2d5069495a
|
||||
U drh
|
||||
Z 85059b1060ba6075105dfb1d0e91a8dd
|
||||
Z 07ad078caa4fedefbf47bb778c51fa1e
|
||||
|
@ -1 +1 @@
|
||||
ce0bbd3a7159e12c86c5cde6571d6668b234827b
|
||||
910067a200c4b25b5d813a84146673d3d1c80952
|
1149
src/btree.c
1149
src/btree.c
File diff suppressed because it is too large
Load Diff
169
src/btree.h
169
src/btree.h
@ -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.36 2004/02/10 02:57:59 drh Exp $
|
||||
** @(#) $Id: btree.h,v 1.37 2004/04/26 14:10:21 drh Exp $
|
||||
*/
|
||||
#ifndef _BTREE_H_
|
||||
#define _BTREE_H_
|
||||
@ -23,134 +23,61 @@
|
||||
*/
|
||||
typedef struct Btree Btree;
|
||||
typedef struct BtCursor BtCursor;
|
||||
typedef struct BtOps BtOps;
|
||||
typedef struct BtCursorOps BtCursorOps;
|
||||
|
||||
|
||||
/*
|
||||
** An instance of the following structure contains pointers to all
|
||||
** methods against an open BTree. Alternative BTree implementations
|
||||
** (examples: file based versus in-memory) can be created by substituting
|
||||
** different methods. Users of the BTree cannot tell the difference.
|
||||
**
|
||||
** In C++ we could do this by defining a virtual base class and then
|
||||
** creating subclasses for each different implementation. But this is
|
||||
** C not C++ so we have to be a little more explicit.
|
||||
int sqlite3BtreeOpen(const char *zFilename, Btree **, int nCache, int flags);
|
||||
|
||||
/* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the
|
||||
** following values.
|
||||
*/
|
||||
struct BtOps {
|
||||
int (*Close)(Btree*);
|
||||
int (*SetCacheSize)(Btree*, int);
|
||||
int (*SetSafetyLevel)(Btree*, int);
|
||||
int (*BeginTrans)(Btree*);
|
||||
int (*Commit)(Btree*);
|
||||
int (*Rollback)(Btree*);
|
||||
int (*BeginCkpt)(Btree*);
|
||||
int (*CommitCkpt)(Btree*);
|
||||
int (*RollbackCkpt)(Btree*);
|
||||
int (*CreateTable)(Btree*, int*);
|
||||
int (*CreateIndex)(Btree*, int*);
|
||||
int (*DropTable)(Btree*, int);
|
||||
int (*ClearTable)(Btree*, int);
|
||||
int (*Cursor)(Btree*, int iTable, int wrFlag, BtCursor **ppCur);
|
||||
int (*GetMeta)(Btree*, int*);
|
||||
int (*UpdateMeta)(Btree*, int*);
|
||||
char *(*IntegrityCheck)(Btree*, int*, int);
|
||||
const char *(*GetFilename)(Btree*);
|
||||
int (*Copyfile)(Btree*,Btree*);
|
||||
struct Pager *(*Pager)(Btree*);
|
||||
#ifdef SQLITE_TEST
|
||||
int (*PageDump)(Btree*, int, int);
|
||||
#endif
|
||||
};
|
||||
#define BTREE_OMIT_JOURNAL 1 /* Do not use journal. No argument */
|
||||
#define BTREE_MEMORY 2 /* In-memory DB. No argument */
|
||||
|
||||
/*
|
||||
** An instance of this structure defines all of the methods that can
|
||||
** be executed against a cursor.
|
||||
int sqlite3BtreeClose(Btree*);
|
||||
int sqlite3BtreeSetCacheSize(Btree*,int);
|
||||
int sqlite3BtreeSetSafetyLevel(Btree*,int);
|
||||
int sqlite3BtreeBeginTrans(Btree*);
|
||||
int sqlite3BtreeCommit(Btree*);
|
||||
int sqlite3BtreeRollback(Btree*);
|
||||
int sqlite3BtreeBeginStmt(Btree*);
|
||||
int sqlite3BtreeCommitStmt(Btree*);
|
||||
int sqlite3BtreeRollbackStmt(Btree*);
|
||||
int sqlite3BtreeCreateTable(Btree*, int*, int flags);
|
||||
|
||||
/* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
|
||||
** of the following flags:
|
||||
*/
|
||||
struct BtCursorOps {
|
||||
int (*Moveto)(BtCursor*, const void *pKey, int nKey, int *pRes);
|
||||
int (*Delete)(BtCursor*);
|
||||
int (*Insert)(BtCursor*, const void *pKey, int nKey,
|
||||
const void *pData, int nData);
|
||||
int (*First)(BtCursor*, int *pRes);
|
||||
int (*Last)(BtCursor*, int *pRes);
|
||||
int (*Next)(BtCursor*, int *pRes);
|
||||
int (*Previous)(BtCursor*, int *pRes);
|
||||
int (*KeySize)(BtCursor*, int *pSize);
|
||||
int (*Key)(BtCursor*, int offset, int amt, char *zBuf);
|
||||
int (*KeyCompare)(BtCursor*, const void *pKey, int nKey,
|
||||
int nIgnore, int *pRes);
|
||||
int (*DataSize)(BtCursor*, int *pSize);
|
||||
int (*Data)(BtCursor*, int offset, int amt, char *zBuf);
|
||||
int (*CloseCursor)(BtCursor*);
|
||||
#ifdef SQLITE_TEST
|
||||
int (*CursorDump)(BtCursor*, int*);
|
||||
#endif
|
||||
};
|
||||
#define BTREE_INTKEY 1 /* Table has only 64-bit integer keys */
|
||||
#define BTREE_ZERODATA 2 /* Table has keys only - no data */
|
||||
|
||||
/*
|
||||
** The number of 4-byte "meta" values contained on the first page of each
|
||||
** database file.
|
||||
*/
|
||||
#define SQLITE_N_BTREE_META 10
|
||||
int sqlite3BtreeDropTable(Btree*, int);
|
||||
int sqlite3BtreeClearTable(Btree*, int);
|
||||
int sqlite3BtreeGetMeta(Btree*, int idx, u32 *pValue);
|
||||
int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
|
||||
|
||||
int sqliteBtreeOpen(const char *zFilename, int mode, int nPg, Btree **ppBtree);
|
||||
int sqliteRbtreeOpen(const char *zFilename, int mode, int nPg, Btree **ppBtree);
|
||||
int sqlite3BtreeCursor(
|
||||
Btree*, /* BTree containing table to open */
|
||||
int iTable, /* Index of root page */
|
||||
int wrFlag, /* 1 for writing. 0 for read-only */
|
||||
int(*)(void*,int,const void*,int,const void*), /* Key comparison function */
|
||||
void*, /* First argument to compare function */
|
||||
BtCursor **ppCursor /* Returned cursor */
|
||||
);
|
||||
|
||||
#define btOps(pBt) (*((BtOps **)(pBt)))
|
||||
#define btCOps(pCur) (*((BtCursorOps **)(pCur)))
|
||||
|
||||
#define sqliteBtreeClose(pBt) (btOps(pBt)->Close(pBt))
|
||||
#define sqliteBtreeSetCacheSize(pBt, sz) (btOps(pBt)->SetCacheSize(pBt, sz))
|
||||
#define sqliteBtreeSetSafetyLevel(pBt, sl) (btOps(pBt)->SetSafetyLevel(pBt, sl))
|
||||
#define sqliteBtreeBeginTrans(pBt) (btOps(pBt)->BeginTrans(pBt))
|
||||
#define sqliteBtreeCommit(pBt) (btOps(pBt)->Commit(pBt))
|
||||
#define sqliteBtreeRollback(pBt) (btOps(pBt)->Rollback(pBt))
|
||||
#define sqliteBtreeBeginCkpt(pBt) (btOps(pBt)->BeginCkpt(pBt))
|
||||
#define sqliteBtreeCommitCkpt(pBt) (btOps(pBt)->CommitCkpt(pBt))
|
||||
#define sqliteBtreeRollbackCkpt(pBt) (btOps(pBt)->RollbackCkpt(pBt))
|
||||
#define sqliteBtreeCreateTable(pBt,piTable)\
|
||||
(btOps(pBt)->CreateTable(pBt,piTable))
|
||||
#define sqliteBtreeCreateIndex(pBt, piIndex)\
|
||||
(btOps(pBt)->CreateIndex(pBt, piIndex))
|
||||
#define sqliteBtreeDropTable(pBt, iTable) (btOps(pBt)->DropTable(pBt, iTable))
|
||||
#define sqliteBtreeClearTable(pBt, iTable)\
|
||||
(btOps(pBt)->ClearTable(pBt, iTable))
|
||||
#define sqliteBtreeCursor(pBt, iTable, wrFlag, ppCur)\
|
||||
(btOps(pBt)->Cursor(pBt, iTable, wrFlag, ppCur))
|
||||
#define sqliteBtreeMoveto(pCur, pKey, nKey, pRes)\
|
||||
(btCOps(pCur)->Moveto(pCur, pKey, nKey, pRes))
|
||||
#define sqliteBtreeDelete(pCur) (btCOps(pCur)->Delete(pCur))
|
||||
#define sqliteBtreeInsert(pCur, pKey, nKey, pData, nData) \
|
||||
(btCOps(pCur)->Insert(pCur, pKey, nKey, pData, nData))
|
||||
#define sqliteBtreeFirst(pCur, pRes) (btCOps(pCur)->First(pCur, pRes))
|
||||
#define sqliteBtreeLast(pCur, pRes) (btCOps(pCur)->Last(pCur, pRes))
|
||||
#define sqliteBtreeNext(pCur, pRes) (btCOps(pCur)->Next(pCur, pRes))
|
||||
#define sqliteBtreePrevious(pCur, pRes) (btCOps(pCur)->Previous(pCur, pRes))
|
||||
#define sqliteBtreeKeySize(pCur, pSize) (btCOps(pCur)->KeySize(pCur, pSize) )
|
||||
#define sqliteBtreeKey(pCur, offset, amt, zBuf)\
|
||||
(btCOps(pCur)->Key(pCur, offset, amt, zBuf))
|
||||
#define sqliteBtreeKeyCompare(pCur, pKey, nKey, nIgnore, pRes)\
|
||||
(btCOps(pCur)->KeyCompare(pCur, pKey, nKey, nIgnore, pRes))
|
||||
#define sqliteBtreeDataSize(pCur, pSize) (btCOps(pCur)->DataSize(pCur, pSize))
|
||||
#define sqliteBtreeData(pCur, offset, amt, zBuf)\
|
||||
(btCOps(pCur)->Data(pCur, offset, amt, zBuf))
|
||||
#define sqliteBtreeCloseCursor(pCur) (btCOps(pCur)->CloseCursor(pCur))
|
||||
#define sqliteBtreeGetMeta(pBt, aMeta) (btOps(pBt)->GetMeta(pBt, aMeta))
|
||||
#define sqliteBtreeUpdateMeta(pBt, aMeta) (btOps(pBt)->UpdateMeta(pBt, aMeta))
|
||||
#define sqliteBtreeIntegrityCheck(pBt, aRoot, nRoot)\
|
||||
(btOps(pBt)->IntegrityCheck(pBt, aRoot, nRoot))
|
||||
#define sqliteBtreeGetFilename(pBt) (btOps(pBt)->GetFilename(pBt))
|
||||
#define sqliteBtreeCopyFile(pBt1, pBt2) (btOps(pBt1)->Copyfile(pBt1, pBt2))
|
||||
#define sqliteBtreePager(pBt) (btOps(pBt)->Pager(pBt))
|
||||
|
||||
#ifdef SQLITE_TEST
|
||||
#define sqliteBtreePageDump(pBt, pgno, recursive)\
|
||||
(btOps(pBt)->PageDump(pBt, pgno, recursive))
|
||||
#define sqliteBtreeCursorDump(pCur, aResult)\
|
||||
(btCOps(pCur)->CursorDump(pCur, aResult))
|
||||
int btree_native_byte_order;
|
||||
#endif /* SQLITE_TEST */
|
||||
int sqlite3BtreeCursorClose(BtCursor*);
|
||||
int sqlite3BtreeMoveto(BtCursor*, const void *pKey, u64 nKey, int *pRes);
|
||||
int sqlite3BtreeDelete(BtCursor*);
|
||||
int sqlite3BtreeInsert(BtCursor*, const void *pKey, u64 nKey,
|
||||
const void *pData, int nData);
|
||||
int sqlite3BtreeFirst(BtCursor*, int *pRes);
|
||||
int sqlite3BtreeLast(BtCursor*, int *pRes);
|
||||
int sqlite3BtreeNext(BtCursor*, int *pRes);
|
||||
int sqlite3BtreePrevious(BtCursor*, int *pRes);
|
||||
int sqlite3BtreeKeySize(BtCursor*, u64 *pSize);
|
||||
int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
|
||||
void *sqlite3BtreeKeyFetch(BtCursor*);
|
||||
int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
|
||||
int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
|
||||
|
||||
|
||||
#endif /* _BTREE_H_ */
|
||||
|
@ -352,6 +352,7 @@ int Md5_Init(Tcl_Interp *interp){
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
** During testing, the special md5sum() aggregate function is available.
|
||||
** inside SQLite. The following routines implement that function.
|
||||
@ -383,3 +384,4 @@ static void md5finalize(sqlite_func *context){
|
||||
void Md5_Register(sqlite *db){
|
||||
sqlite_create_aggregate(db, "md5sum", -1, md5step, md5finalize, 0);
|
||||
}
|
||||
#endif
|
||||
|
176
src/pager.c
176
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.101 2004/02/25 02:20:41 drh Exp $
|
||||
** @(#) $Id: pager.c,v 1.102 2004/04/26 14:10:21 drh Exp $
|
||||
*/
|
||||
#include "os.h" /* Must be first to enable large file support */
|
||||
#include "sqliteInt.h"
|
||||
@ -85,8 +85,8 @@ static Pager *mainPager = 0;
|
||||
** This header is only visible to this pager module. The client
|
||||
** code that calls pager sees only the data that follows the header.
|
||||
**
|
||||
** Client code should call sqlitepager_write() on a page prior to making
|
||||
** any modifications to that page. The first time sqlitepager_write()
|
||||
** Client code should call sqlite3pager_write() on a page prior to making
|
||||
** any modifications to that page. The first time sqlite3pager_write()
|
||||
** is called, the original page contents are written into the rollback
|
||||
** journal and PgHdr.inJournal and PgHdr.needSync are set. Later, once
|
||||
** the journal page has made it onto the disk surface, PgHdr.needSync
|
||||
@ -94,7 +94,7 @@ static Pager *mainPager = 0;
|
||||
** database file until the journal pages has been synced to disk and the
|
||||
** PgHdr.needSync has been cleared.
|
||||
**
|
||||
** The PgHdr.dirty flag is set when sqlitepager_write() is called and
|
||||
** The PgHdr.dirty flag is set when sqlite3pager_write() is called and
|
||||
** is cleared again when the page content is written back to the original
|
||||
** database file.
|
||||
*/
|
||||
@ -288,10 +288,10 @@ int journal_format = 3;
|
||||
** Enable reference count tracking here:
|
||||
*/
|
||||
#ifdef SQLITE_TEST
|
||||
int pager_refinfo_enable = 0;
|
||||
int pager3_refinfo_enable = 0;
|
||||
static void pager_refinfo(PgHdr *p){
|
||||
static int cnt = 0;
|
||||
if( !pager_refinfo_enable ) return;
|
||||
if( !pager3_refinfo_enable ) return;
|
||||
printf(
|
||||
"REFCNT: %4d addr=0x%08x nRef=%d\n",
|
||||
p->pgno, (int)PGHDR_TO_DATA(p), p->nRef
|
||||
@ -386,11 +386,11 @@ static int pager_errcode(Pager *pPager){
|
||||
** checkpoint journal.
|
||||
**
|
||||
** The Pager keeps a separate list of pages that are currently in
|
||||
** the checkpoint journal. This helps the sqlitepager_ckpt_commit()
|
||||
** the checkpoint journal. This helps the sqlite3pager_stmt_commit()
|
||||
** routine run MUCH faster for the common case where there are many
|
||||
** pages in memory but only a few are in the checkpoint journal.
|
||||
*/
|
||||
static void page_add_to_ckpt_list(PgHdr *pPg){
|
||||
static void page_add_to_stmt_list(PgHdr *pPg){
|
||||
Pager *pPager = pPg->pPager;
|
||||
if( pPg->inCkpt ) return;
|
||||
assert( pPg->pPrevCkpt==0 && pPg->pNextCkpt==0 );
|
||||
@ -402,7 +402,7 @@ static void page_add_to_ckpt_list(PgHdr *pPg){
|
||||
pPager->pCkpt = pPg;
|
||||
pPg->inCkpt = 1;
|
||||
}
|
||||
static void page_remove_from_ckpt_list(PgHdr *pPg){
|
||||
static void page_remove_from_stmt_list(PgHdr *pPg){
|
||||
if( !pPg->inCkpt ) return;
|
||||
if( pPg->pPrevCkpt ){
|
||||
assert( pPg->pPrevCkpt->pNextCkpt==pPg );
|
||||
@ -451,7 +451,7 @@ static void pager_reset(Pager *pPager){
|
||||
memset(pPager->aHash, 0, sizeof(pPager->aHash));
|
||||
pPager->nPage = 0;
|
||||
if( pPager->state>=SQLITE_WRITELOCK ){
|
||||
sqlitepager_rollback(pPager);
|
||||
sqlite3pager_rollback(pPager);
|
||||
}
|
||||
sqliteOsUnlock(&pPager->fd);
|
||||
pPager->state = SQLITE_UNLOCK;
|
||||
@ -474,7 +474,7 @@ static int pager_unwritelock(Pager *pPager){
|
||||
int rc;
|
||||
PgHdr *pPg;
|
||||
if( pPager->state<SQLITE_WRITELOCK ) return SQLITE_OK;
|
||||
sqlitepager_ckpt_commit(pPager);
|
||||
sqlite3pager_stmt_commit(pPager);
|
||||
if( pPager->ckptOpen ){
|
||||
sqliteOsClose(&pPager->cpfd);
|
||||
pPager->ckptOpen = 0;
|
||||
@ -772,7 +772,7 @@ end_playback:
|
||||
** playback all pages of the transaction journal beginning
|
||||
** at offset pPager->ckptJSize.
|
||||
*/
|
||||
static int pager_ckpt_playback(Pager *pPager){
|
||||
static int pager_stmt_playback(Pager *pPager){
|
||||
off_t szJ; /* Size of the full journal */
|
||||
int nRec; /* Number of Records */
|
||||
int i; /* Loop counter */
|
||||
@ -797,7 +797,7 @@ static int pager_ckpt_playback(Pager *pPager){
|
||||
for(i=nRec-1; i>=0; i--){
|
||||
rc = pager_playback_one_page(pPager, &pPager->cpfd, 2);
|
||||
assert( rc!=SQLITE_DONE );
|
||||
if( rc!=SQLITE_OK ) goto end_ckpt_playback;
|
||||
if( rc!=SQLITE_OK ) goto end_stmt_playback;
|
||||
}
|
||||
|
||||
/* Figure out how many pages need to be copied out of the transaction
|
||||
@ -805,22 +805,22 @@ static int pager_ckpt_playback(Pager *pPager){
|
||||
*/
|
||||
rc = sqliteOsSeek(&pPager->jfd, pPager->ckptJSize);
|
||||
if( rc!=SQLITE_OK ){
|
||||
goto end_ckpt_playback;
|
||||
goto end_stmt_playback;
|
||||
}
|
||||
rc = sqliteOsFileSize(&pPager->jfd, &szJ);
|
||||
if( rc!=SQLITE_OK ){
|
||||
goto end_ckpt_playback;
|
||||
goto end_stmt_playback;
|
||||
}
|
||||
nRec = (szJ - pPager->ckptJSize)/JOURNAL_PG_SZ(journal_format);
|
||||
for(i=nRec-1; i>=0; i--){
|
||||
rc = pager_playback_one_page(pPager, &pPager->jfd, journal_format);
|
||||
if( rc!=SQLITE_OK ){
|
||||
assert( rc!=SQLITE_DONE );
|
||||
goto end_ckpt_playback;
|
||||
goto end_stmt_playback;
|
||||
}
|
||||
}
|
||||
|
||||
end_ckpt_playback:
|
||||
end_stmt_playback:
|
||||
if( rc!=SQLITE_OK ){
|
||||
pPager->errMask |= PAGER_ERR_CORRUPT;
|
||||
rc = SQLITE_CORRUPT;
|
||||
@ -838,7 +838,7 @@ end_ckpt_playback:
|
||||
** failure, the database file might be left in an inconsistent and
|
||||
** unrepairable state.
|
||||
*/
|
||||
void sqlitepager_set_cachesize(Pager *pPager, int mxPage){
|
||||
void sqlite3pager_set_cachesize(Pager *pPager, int mxPage){
|
||||
if( mxPage>=0 ){
|
||||
pPager->noSync = pPager->tempFile;
|
||||
if( pPager->noSync==0 ) pPager->needSync = 0;
|
||||
@ -877,7 +877,7 @@ void sqlitepager_set_cachesize(Pager *pPager, int mxPage){
|
||||
** Numeric values associated with these states are OFF==1, NORMAL=2,
|
||||
** and FULL=3.
|
||||
*/
|
||||
void sqlitepager_set_safety_level(Pager *pPager, int level){
|
||||
void sqlite3pager_set_safety_level(Pager *pPager, int level){
|
||||
pPager->noSync = level==1 || pPager->tempFile;
|
||||
pPager->fullSync = level==3 && !pPager->tempFile;
|
||||
if( pPager->noSync==0 ) pPager->needSync = 0;
|
||||
@ -892,7 +892,7 @@ void sqlitepager_set_safety_level(Pager *pPager, int level){
|
||||
** The OS will automatically delete the temporary file when it is
|
||||
** closed.
|
||||
*/
|
||||
static int sqlitepager_opentemp(char *zFile, OsFile *fd){
|
||||
static int sqlite3pager_opentemp(char *zFile, OsFile *fd){
|
||||
int cnt = 8;
|
||||
int rc;
|
||||
do{
|
||||
@ -906,14 +906,14 @@ static int sqlitepager_opentemp(char *zFile, OsFile *fd){
|
||||
/*
|
||||
** Create a new page cache and put a pointer to the page cache in *ppPager.
|
||||
** The file to be cached need not exist. The file is not locked until
|
||||
** the first call to sqlitepager_get() and is only held open until the
|
||||
** last page is released using sqlitepager_unref().
|
||||
** the first call to sqlite3pager_get() and is only held open until the
|
||||
** last page is released using sqlite3pager_unref().
|
||||
**
|
||||
** If zFilename is NULL then a randomly-named temporary file is created
|
||||
** and used as the file to be cached. The file will be deleted
|
||||
** automatically when it is closed.
|
||||
*/
|
||||
int sqlitepager_open(
|
||||
int sqlite3pager_open(
|
||||
Pager **ppPager, /* Return the Pager structure here */
|
||||
const char *zFilename, /* Name of the database file to open */
|
||||
int mxPage, /* Max number of in-memory cache pages */
|
||||
@ -938,7 +938,7 @@ int sqlitepager_open(
|
||||
rc = sqliteOsOpenReadWrite(zFullPathname, &fd, &readOnly);
|
||||
tempFile = 0;
|
||||
}else{
|
||||
rc = sqlitepager_opentemp(zTemp, &fd);
|
||||
rc = sqlite3pager_opentemp(zTemp, &fd);
|
||||
zFilename = zTemp;
|
||||
zFullPathname = sqliteOsFullPathname(zFilename);
|
||||
tempFile = 1;
|
||||
@ -999,10 +999,10 @@ int sqlitepager_open(
|
||||
** when the reference count on each page reaches zero. The destructor can
|
||||
** be used to clean up information in the extra segment appended to each page.
|
||||
**
|
||||
** The destructor is not called as a result sqlitepager_close().
|
||||
** Destructors are only called by sqlitepager_unref().
|
||||
** The destructor is not called as a result sqlite3pager_close().
|
||||
** Destructors are only called by sqlite3pager_unref().
|
||||
*/
|
||||
void sqlitepager_set_destructor(Pager *pPager, void (*xDesc)(void*)){
|
||||
void sqlite3pager_set_destructor(Pager *pPager, void (*xDesc)(void*)){
|
||||
pPager->xDestructor = xDesc;
|
||||
}
|
||||
|
||||
@ -1010,7 +1010,7 @@ void sqlitepager_set_destructor(Pager *pPager, void (*xDesc)(void*)){
|
||||
** Return the total number of pages in the disk file associated with
|
||||
** pPager.
|
||||
*/
|
||||
int sqlitepager_pagecount(Pager *pPager){
|
||||
int sqlite3pager_pagecount(Pager *pPager){
|
||||
off_t n;
|
||||
assert( pPager!=0 );
|
||||
if( pPager->dbSize>=0 ){
|
||||
@ -1035,10 +1035,10 @@ static int syncJournal(Pager*);
|
||||
/*
|
||||
** Truncate the file to the number of pages specified.
|
||||
*/
|
||||
int sqlitepager_truncate(Pager *pPager, Pgno nPage){
|
||||
int sqlite3pager_truncate(Pager *pPager, Pgno nPage){
|
||||
int rc;
|
||||
if( pPager->dbSize<0 ){
|
||||
sqlitepager_pagecount(pPager);
|
||||
sqlite3pager_pagecount(pPager);
|
||||
}
|
||||
if( pPager->errMask!=0 ){
|
||||
rc = pager_errcode(pPager);
|
||||
@ -1064,11 +1064,11 @@ int sqlitepager_truncate(Pager *pPager, Pgno nPage){
|
||||
** with this page cache after this function returns will likely
|
||||
** result in a coredump.
|
||||
*/
|
||||
int sqlitepager_close(Pager *pPager){
|
||||
int sqlite3pager_close(Pager *pPager){
|
||||
PgHdr *pPg, *pNext;
|
||||
switch( pPager->state ){
|
||||
case SQLITE_WRITELOCK: {
|
||||
sqlitepager_rollback(pPager);
|
||||
sqlite3pager_rollback(pPager);
|
||||
sqliteOsUnlock(&pPager->fd);
|
||||
assert( pPager->journalOpen==0 );
|
||||
break;
|
||||
@ -1107,7 +1107,7 @@ int sqlitepager_close(Pager *pPager){
|
||||
/*
|
||||
** Return the page number for the given page data.
|
||||
*/
|
||||
Pgno sqlitepager_pagenumber(void *pData){
|
||||
Pgno sqlite3pager_pagenumber(void *pData){
|
||||
PgHdr *p = DATA_TO_PGHDR(pData);
|
||||
return p->pgno;
|
||||
}
|
||||
@ -1146,7 +1146,7 @@ static void _page_ref(PgHdr *pPg){
|
||||
** Increment the reference count for a page. The input pointer is
|
||||
** a reference to the page data.
|
||||
*/
|
||||
int sqlitepager_ref(void *pData){
|
||||
int sqlite3pager_ref(void *pData){
|
||||
PgHdr *pPg = DATA_TO_PGHDR(pData);
|
||||
page_ref(pPg);
|
||||
return SQLITE_OK;
|
||||
@ -1300,7 +1300,7 @@ static PgHdr *pager_get_all_dirty_pages(Pager *pPager){
|
||||
** The acquisition might fail for several reasons. In all cases,
|
||||
** an appropriate error code is returned and *ppPage is set to NULL.
|
||||
**
|
||||
** See also sqlitepager_lookup(). Both this routine and _lookup() attempt
|
||||
** See also sqlite3pager_lookup(). Both this routine and _lookup() attempt
|
||||
** to find a page in the in-memory cache first. If the page is not already
|
||||
** in memory, this routine goes to disk to read it in whereas _lookup()
|
||||
** just returns 0. This routine acquires a read-lock the first time it
|
||||
@ -1308,7 +1308,7 @@ static PgHdr *pager_get_all_dirty_pages(Pager *pPager){
|
||||
** Since _lookup() never goes to disk, it never has to deal with locks
|
||||
** or journal files.
|
||||
*/
|
||||
int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){
|
||||
int sqlite3pager_get(Pager *pPager, Pgno pgno, void **ppPage){
|
||||
PgHdr *pPg;
|
||||
int rc;
|
||||
|
||||
@ -1414,7 +1414,7 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){
|
||||
if( pPg==0 ){
|
||||
int rc = syncJournal(pPager);
|
||||
if( rc!=0 ){
|
||||
sqlitepager_rollback(pPager);
|
||||
sqlite3pager_rollback(pPager);
|
||||
return SQLITE_IOERR;
|
||||
}
|
||||
pPg = pPager->pFirst;
|
||||
@ -1428,7 +1428,7 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){
|
||||
pPg->pDirty = 0;
|
||||
rc = pager_write_pagelist( pPg );
|
||||
if( rc!=SQLITE_OK ){
|
||||
sqlitepager_rollback(pPager);
|
||||
sqlite3pager_rollback(pPager);
|
||||
return SQLITE_IOERR;
|
||||
}
|
||||
}
|
||||
@ -1491,9 +1491,9 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){
|
||||
}
|
||||
if( pPager->aInCkpt && (int)pgno<=pPager->ckptSize
|
||||
&& (pPager->aInCkpt[pgno/8] & (1<<(pgno&7)))!=0 ){
|
||||
page_add_to_ckpt_list(pPg);
|
||||
page_add_to_stmt_list(pPg);
|
||||
}else{
|
||||
page_remove_from_ckpt_list(pPg);
|
||||
page_remove_from_stmt_list(pPg);
|
||||
}
|
||||
pPg->dirty = 0;
|
||||
pPg->nRef = 1;
|
||||
@ -1509,9 +1509,9 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){
|
||||
if( pPager->nExtra>0 ){
|
||||
memset(PGHDR_TO_EXTRA(pPg), 0, pPager->nExtra);
|
||||
}
|
||||
if( pPager->dbSize<0 ) sqlitepager_pagecount(pPager);
|
||||
if( pPager->dbSize<0 ) sqlite3pager_pagecount(pPager);
|
||||
if( pPager->errMask!=0 ){
|
||||
sqlitepager_unref(PGHDR_TO_DATA(pPg));
|
||||
sqlite3pager_unref(PGHDR_TO_DATA(pPg));
|
||||
rc = pager_errcode(pPager);
|
||||
return rc;
|
||||
}
|
||||
@ -1527,7 +1527,7 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){
|
||||
off_t fileSize;
|
||||
if( sqliteOsFileSize(&pPager->fd,&fileSize)!=SQLITE_OK
|
||||
|| fileSize>=pgno*SQLITE_PAGE_SIZE ){
|
||||
sqlitepager_unref(PGHDR_TO_DATA(pPg));
|
||||
sqlite3pager_unref(PGHDR_TO_DATA(pPg));
|
||||
return rc;
|
||||
}else{
|
||||
memset(PGHDR_TO_DATA(pPg), 0, SQLITE_PAGE_SIZE);
|
||||
@ -1548,13 +1548,13 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){
|
||||
** not read the page from disk. Return a pointer to the page,
|
||||
** or 0 if the page is not in cache.
|
||||
**
|
||||
** See also sqlitepager_get(). The difference between this routine
|
||||
** and sqlitepager_get() is that _get() will go to the disk and read
|
||||
** See also sqlite3pager_get(). The difference between this routine
|
||||
** and sqlite3pager_get() is that _get() will go to the disk and read
|
||||
** in the page if the page is not already in cache. This routine
|
||||
** returns NULL if the page is not in cache or if a disk I/O error
|
||||
** has ever happened.
|
||||
*/
|
||||
void *sqlitepager_lookup(Pager *pPager, Pgno pgno){
|
||||
void *sqlite3pager_lookup(Pager *pPager, Pgno pgno){
|
||||
PgHdr *pPg;
|
||||
|
||||
assert( pPager!=0 );
|
||||
@ -1580,7 +1580,7 @@ void *sqlitepager_lookup(Pager *pPager, Pgno pgno){
|
||||
** are released, a rollback occurs and the lock on the database is
|
||||
** removed.
|
||||
*/
|
||||
int sqlitepager_unref(void *pData){
|
||||
int sqlite3pager_unref(void *pData){
|
||||
PgHdr *pPg;
|
||||
|
||||
/* Decrement the reference count for this page
|
||||
@ -1635,7 +1635,7 @@ static int pager_open_journal(Pager *pPager){
|
||||
assert( pPager->state==SQLITE_WRITELOCK );
|
||||
assert( pPager->journalOpen==0 );
|
||||
assert( pPager->useJournal );
|
||||
sqlitepager_pagecount(pPager);
|
||||
sqlite3pager_pagecount(pPager);
|
||||
pPager->aInJournal = sqliteMalloc( pPager->dbSize/8 + 1 );
|
||||
if( pPager->aInJournal==0 ){
|
||||
sqliteOsReadLock(&pPager->fd);
|
||||
@ -1680,7 +1680,7 @@ static int pager_open_journal(Pager *pPager){
|
||||
rc = write32bits(&pPager->jfd, pPager->dbSize);
|
||||
}
|
||||
if( pPager->ckptAutoopen && rc==SQLITE_OK ){
|
||||
rc = sqlitepager_ckpt_begin(pPager);
|
||||
rc = sqlite3pager_stmt_begin(pPager);
|
||||
}
|
||||
if( rc!=SQLITE_OK ){
|
||||
rc = pager_unwritelock(pPager);
|
||||
@ -1695,10 +1695,10 @@ static int pager_open_journal(Pager *pPager){
|
||||
** Acquire a write-lock on the database. The lock is removed when
|
||||
** the any of the following happen:
|
||||
**
|
||||
** * sqlitepager_commit() is called.
|
||||
** * sqlitepager_rollback() is called.
|
||||
** * sqlitepager_close() is called.
|
||||
** * sqlitepager_unref() is called to on every outstanding page.
|
||||
** * sqlite3pager_commit() is called.
|
||||
** * sqlite3pager_rollback() is called.
|
||||
** * sqlite3pager_close() is called.
|
||||
** * sqlite3pager_unref() is called to on every outstanding page.
|
||||
**
|
||||
** The parameter to this routine is a pointer to any open page of the
|
||||
** database file. Nothing changes about the page - it is used merely
|
||||
@ -1711,7 +1711,7 @@ static int pager_open_journal(Pager *pPager){
|
||||
**
|
||||
** If the database is already write-locked, this routine is a no-op.
|
||||
*/
|
||||
int sqlitepager_begin(void *pData){
|
||||
int sqlite3pager_begin(void *pData){
|
||||
PgHdr *pPg = DATA_TO_PGHDR(pData);
|
||||
Pager *pPager = pPg->pPager;
|
||||
int rc = SQLITE_OK;
|
||||
@ -1747,10 +1747,10 @@ int sqlitepager_begin(void *pData){
|
||||
** If the journal file could not be written because the disk is full,
|
||||
** then this routine returns SQLITE_FULL and does an immediate rollback.
|
||||
** All subsequent write attempts also return SQLITE_FULL until there
|
||||
** is a call to sqlitepager_commit() or sqlitepager_rollback() to
|
||||
** is a call to sqlite3pager_commit() or sqlite3pager_rollback() to
|
||||
** reset.
|
||||
*/
|
||||
int sqlitepager_write(void *pData){
|
||||
int sqlite3pager_write(void *pData){
|
||||
PgHdr *pPg = DATA_TO_PGHDR(pData);
|
||||
Pager *pPager = pPg->pPager;
|
||||
int rc = SQLITE_OK;
|
||||
@ -1781,7 +1781,7 @@ int sqlitepager_write(void *pData){
|
||||
** create it if it does not.
|
||||
*/
|
||||
assert( pPager->state!=SQLITE_UNLOCK );
|
||||
rc = sqlitepager_begin(pData);
|
||||
rc = sqlite3pager_begin(pData);
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
}
|
||||
@ -1818,7 +1818,7 @@ int sqlitepager_write(void *pData){
|
||||
*(u32*)PGHDR_TO_EXTRA(pPg) = saved;
|
||||
}
|
||||
if( rc!=SQLITE_OK ){
|
||||
sqlitepager_rollback(pPager);
|
||||
sqlite3pager_rollback(pPager);
|
||||
pPager->errMask |= PAGER_ERR_FULL;
|
||||
return rc;
|
||||
}
|
||||
@ -1829,7 +1829,7 @@ int sqlitepager_write(void *pData){
|
||||
pPg->inJournal = 1;
|
||||
if( pPager->ckptInUse ){
|
||||
pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7);
|
||||
page_add_to_ckpt_list(pPg);
|
||||
page_add_to_stmt_list(pPg);
|
||||
}
|
||||
}else{
|
||||
pPg->needSync = !pPager->journalStarted && !pPager->noSync;
|
||||
@ -1853,14 +1853,14 @@ int sqlitepager_write(void *pData){
|
||||
TRACE2("CKPT-JOURNAL %d\n", pPg->pgno);
|
||||
CODEC(pPager, pData, pPg->pgno, 0);
|
||||
if( rc!=SQLITE_OK ){
|
||||
sqlitepager_rollback(pPager);
|
||||
sqlite3pager_rollback(pPager);
|
||||
pPager->errMask |= PAGER_ERR_FULL;
|
||||
return rc;
|
||||
}
|
||||
pPager->ckptNRec++;
|
||||
assert( pPager->aInCkpt!=0 );
|
||||
pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7);
|
||||
page_add_to_ckpt_list(pPg);
|
||||
page_add_to_stmt_list(pPg);
|
||||
}
|
||||
|
||||
/* Update the database size and return.
|
||||
@ -1873,10 +1873,10 @@ int sqlitepager_write(void *pData){
|
||||
|
||||
/*
|
||||
** Return TRUE if the page given in the argument was previously passed
|
||||
** to sqlitepager_write(). In other words, return TRUE if it is ok
|
||||
** to sqlite3pager_write(). In other words, return TRUE if it is ok
|
||||
** to change the content of the page.
|
||||
*/
|
||||
int sqlitepager_iswriteable(void *pData){
|
||||
int sqlite3pager_iswriteable(void *pData){
|
||||
PgHdr *pPg = DATA_TO_PGHDR(pData);
|
||||
return pPg->dirty;
|
||||
}
|
||||
@ -1885,17 +1885,17 @@ int sqlitepager_iswriteable(void *pData){
|
||||
** Replace the content of a single page with the information in the third
|
||||
** argument.
|
||||
*/
|
||||
int sqlitepager_overwrite(Pager *pPager, Pgno pgno, void *pData){
|
||||
int sqlite3pager_overwrite(Pager *pPager, Pgno pgno, void *pData){
|
||||
void *pPage;
|
||||
int rc;
|
||||
|
||||
rc = sqlitepager_get(pPager, pgno, &pPage);
|
||||
rc = sqlite3pager_get(pPager, pgno, &pPage);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlitepager_write(pPage);
|
||||
rc = sqlite3pager_write(pPage);
|
||||
if( rc==SQLITE_OK ){
|
||||
memcpy(pPage, pData, SQLITE_PAGE_SIZE);
|
||||
}
|
||||
sqlitepager_unref(pPage);
|
||||
sqlite3pager_unref(pPage);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@ -1910,11 +1910,11 @@ int sqlitepager_overwrite(Pager *pPager, Pgno pgno, void *pData){
|
||||
** that it does not get written to disk.
|
||||
**
|
||||
** Tests show that this optimization, together with the
|
||||
** sqlitepager_dont_rollback() below, more than double the speed
|
||||
** sqlite3pager_dont_rollback() below, more than double the speed
|
||||
** of large INSERT operations and quadruple the speed of large DELETEs.
|
||||
**
|
||||
** When this routine is called, set the alwaysRollback flag to true.
|
||||
** Subsequent calls to sqlitepager_dont_rollback() for the same page
|
||||
** Subsequent calls to sqlite3pager_dont_rollback() for the same page
|
||||
** will thereafter be ignored. This is necessary to avoid a problem
|
||||
** where a page with data is added to the freelist during one part of
|
||||
** a transaction then removed from the freelist during a later part
|
||||
@ -1924,7 +1924,7 @@ int sqlitepager_overwrite(Pager *pPager, Pgno pgno, void *pData){
|
||||
** critical data, we still need to be sure it gets rolled back in spite
|
||||
** of the dont_rollback() call.
|
||||
*/
|
||||
void sqlitepager_dont_write(Pager *pPager, Pgno pgno){
|
||||
void sqlite3pager_dont_write(Pager *pPager, Pgno pgno){
|
||||
PgHdr *pPg;
|
||||
|
||||
pPg = pager_lookup(pPager, pgno);
|
||||
@ -1952,7 +1952,7 @@ void sqlitepager_dont_write(Pager *pPager, Pgno pgno){
|
||||
** means that the pager does not have to record the given page in the
|
||||
** rollback journal.
|
||||
*/
|
||||
void sqlitepager_dont_rollback(void *pData){
|
||||
void sqlite3pager_dont_rollback(void *pData){
|
||||
PgHdr *pPg = DATA_TO_PGHDR(pData);
|
||||
Pager *pPager = pPg->pPager;
|
||||
|
||||
@ -1964,7 +1964,7 @@ void sqlitepager_dont_rollback(void *pData){
|
||||
pPg->inJournal = 1;
|
||||
if( pPager->ckptInUse ){
|
||||
pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7);
|
||||
page_add_to_ckpt_list(pPg);
|
||||
page_add_to_stmt_list(pPg);
|
||||
}
|
||||
TRACE2("DONT_ROLLBACK %d\n", pPg->pgno);
|
||||
}
|
||||
@ -1972,7 +1972,7 @@ void sqlitepager_dont_rollback(void *pData){
|
||||
assert( pPg->inJournal || (int)pPg->pgno>pPager->origDbSize );
|
||||
assert( pPager->aInCkpt!=0 );
|
||||
pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7);
|
||||
page_add_to_ckpt_list(pPg);
|
||||
page_add_to_stmt_list(pPg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1983,12 +1983,12 @@ void sqlitepager_dont_rollback(void *pData){
|
||||
** and an error code is returned. If the commit worked, SQLITE_OK
|
||||
** is returned.
|
||||
*/
|
||||
int sqlitepager_commit(Pager *pPager){
|
||||
int sqlite3pager_commit(Pager *pPager){
|
||||
int rc;
|
||||
PgHdr *pPg;
|
||||
|
||||
if( pPager->errMask==PAGER_ERR_FULL ){
|
||||
rc = sqlitepager_rollback(pPager);
|
||||
rc = sqlite3pager_rollback(pPager);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = SQLITE_FULL;
|
||||
}
|
||||
@ -2029,7 +2029,7 @@ int sqlitepager_commit(Pager *pPager){
|
||||
/* Jump here if anything goes wrong during the commit process.
|
||||
*/
|
||||
commit_abort:
|
||||
rc = sqlitepager_rollback(pPager);
|
||||
rc = sqlite3pager_rollback(pPager);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = SQLITE_FULL;
|
||||
}
|
||||
@ -2048,7 +2048,7 @@ commit_abort:
|
||||
** codes are returned for all these occasions. Otherwise,
|
||||
** SQLITE_OK is returned.
|
||||
*/
|
||||
int sqlitepager_rollback(Pager *pPager){
|
||||
int sqlite3pager_rollback(Pager *pPager){
|
||||
int rc;
|
||||
TRACE1("ROLLBACK\n");
|
||||
if( !pPager->dirtyFile || !pPager->journalOpen ){
|
||||
@ -2079,14 +2079,14 @@ int sqlitepager_rollback(Pager *pPager){
|
||||
** Return TRUE if the database file is opened read-only. Return FALSE
|
||||
** if the database is (in theory) writable.
|
||||
*/
|
||||
int sqlitepager_isreadonly(Pager *pPager){
|
||||
int sqlite3pager_isreadonly(Pager *pPager){
|
||||
return pPager->readOnly;
|
||||
}
|
||||
|
||||
/*
|
||||
** This routine is used for testing and analysis only.
|
||||
*/
|
||||
int *sqlitepager_stats(Pager *pPager){
|
||||
int *sqlite3pager_stats(Pager *pPager){
|
||||
static int a[9];
|
||||
a[0] = pPager->nRef;
|
||||
a[1] = pPager->nPage;
|
||||
@ -2107,7 +2107,7 @@ int *sqlitepager_stats(Pager *pPager){
|
||||
** open. A new checkpoint journal is created that can be used to rollback
|
||||
** changes of a single SQL command within a larger transaction.
|
||||
*/
|
||||
int sqlitepager_ckpt_begin(Pager *pPager){
|
||||
int sqlite3pager_stmt_begin(Pager *pPager){
|
||||
int rc;
|
||||
char zTemp[SQLITE_TEMPNAME_SIZE];
|
||||
if( !pPager->journalOpen ){
|
||||
@ -2131,7 +2131,7 @@ int sqlitepager_ckpt_begin(Pager *pPager){
|
||||
+ JOURNAL_HDR_SZ(journal_format);
|
||||
pPager->ckptSize = pPager->dbSize;
|
||||
if( !pPager->ckptOpen ){
|
||||
rc = sqlitepager_opentemp(zTemp, &pPager->cpfd);
|
||||
rc = sqlite3pager_opentemp(zTemp, &pPager->cpfd);
|
||||
if( rc ) goto ckpt_begin_failed;
|
||||
pPager->ckptOpen = 1;
|
||||
pPager->ckptNRec = 0;
|
||||
@ -2150,7 +2150,7 @@ ckpt_begin_failed:
|
||||
/*
|
||||
** Commit a checkpoint.
|
||||
*/
|
||||
int sqlitepager_ckpt_commit(Pager *pPager){
|
||||
int sqlite3pager_stmt_commit(Pager *pPager){
|
||||
if( pPager->ckptInUse ){
|
||||
PgHdr *pPg, *pNext;
|
||||
sqliteOsSeek(&pPager->cpfd, 0);
|
||||
@ -2174,11 +2174,11 @@ int sqlitepager_ckpt_commit(Pager *pPager){
|
||||
/*
|
||||
** Rollback a checkpoint.
|
||||
*/
|
||||
int sqlitepager_ckpt_rollback(Pager *pPager){
|
||||
int sqlite3pager_stmt_rollback(Pager *pPager){
|
||||
int rc;
|
||||
if( pPager->ckptInUse ){
|
||||
rc = pager_ckpt_playback(pPager);
|
||||
sqlitepager_ckpt_commit(pPager);
|
||||
rc = pager_stmt_playback(pPager);
|
||||
sqlite3pager_stmt_commit(pPager);
|
||||
}else{
|
||||
rc = SQLITE_OK;
|
||||
}
|
||||
@ -2189,14 +2189,14 @@ int sqlitepager_ckpt_rollback(Pager *pPager){
|
||||
/*
|
||||
** Return the full pathname of the database file.
|
||||
*/
|
||||
const char *sqlitepager_filename(Pager *pPager){
|
||||
const char *sqlite3pager_filename(Pager *pPager){
|
||||
return pPager->zFilename;
|
||||
}
|
||||
|
||||
/*
|
||||
** Set the codec for this pager
|
||||
*/
|
||||
void sqlitepager_set_codec(
|
||||
void sqlite3pager_set_codec(
|
||||
Pager *pPager,
|
||||
void (*xCodec)(void*,void*,Pgno,int),
|
||||
void *pCodecArg
|
||||
@ -2209,7 +2209,7 @@ void sqlitepager_set_codec(
|
||||
/*
|
||||
** Print a listing of all referenced pages and their ref count.
|
||||
*/
|
||||
void sqlitepager_refdump(Pager *pPager){
|
||||
void sqlite3pager_refdump(Pager *pPager){
|
||||
PgHdr *pPg;
|
||||
for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){
|
||||
if( pPg->nRef<=0 ) continue;
|
||||
|
66
src/pager.h
66
src/pager.h
@ -13,7 +13,7 @@
|
||||
** subsystem. The page cache subsystem reads and writes a file a page
|
||||
** at a time and provides a journal for rollback.
|
||||
**
|
||||
** @(#) $Id: pager.h,v 1.26 2004/02/11 02:18:07 drh Exp $
|
||||
** @(#) $Id: pager.h,v 1.27 2004/04/26 14:10:22 drh Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -50,8 +50,7 @@
|
||||
#define SQLITE_USABLE_SIZE (SQLITE_PAGE_SIZE-SQLITE_PAGE_RESERVE)
|
||||
|
||||
/*
|
||||
** Maximum number of pages in one database. (This is a limitation of
|
||||
** imposed by 4GB files size limits.)
|
||||
** Maximum number of pages in one database.
|
||||
*/
|
||||
#define SQLITE_MAX_PAGE 1073741823
|
||||
|
||||
@ -70,38 +69,37 @@ typedef struct Pager Pager;
|
||||
** See source code comments for a detailed description of the following
|
||||
** routines:
|
||||
*/
|
||||
int sqlitepager_open(Pager **ppPager, const char *zFilename,
|
||||
int sqlite3pager_open(Pager **ppPager, const char *zFilename,
|
||||
int nPage, int nExtra, int useJournal);
|
||||
void sqlitepager_set_destructor(Pager*, void(*)(void*));
|
||||
void sqlitepager_set_cachesize(Pager*, int);
|
||||
int sqlitepager_close(Pager *pPager);
|
||||
int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage);
|
||||
void *sqlitepager_lookup(Pager *pPager, Pgno pgno);
|
||||
int sqlitepager_ref(void*);
|
||||
int sqlitepager_unref(void*);
|
||||
Pgno sqlitepager_pagenumber(void*);
|
||||
int sqlitepager_write(void*);
|
||||
int sqlitepager_iswriteable(void*);
|
||||
int sqlitepager_overwrite(Pager *pPager, Pgno pgno, void*);
|
||||
int sqlitepager_pagecount(Pager*);
|
||||
int sqlitepager_truncate(Pager*,Pgno);
|
||||
int sqlitepager_begin(void*);
|
||||
int sqlitepager_commit(Pager*);
|
||||
int sqlitepager_rollback(Pager*);
|
||||
int sqlitepager_isreadonly(Pager*);
|
||||
int sqlitepager_ckpt_begin(Pager*);
|
||||
int sqlitepager_ckpt_commit(Pager*);
|
||||
int sqlitepager_ckpt_rollback(Pager*);
|
||||
void sqlitepager_dont_rollback(void*);
|
||||
void sqlitepager_dont_write(Pager*, Pgno);
|
||||
int *sqlitepager_stats(Pager*);
|
||||
void sqlitepager_set_safety_level(Pager*,int);
|
||||
const char *sqlitepager_filename(Pager*);
|
||||
int sqlitepager_rename(Pager*, const char *zNewName);
|
||||
void sqlitepager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*);
|
||||
void sqlite3pager_set_destructor(Pager*, void(*)(void*));
|
||||
void sqlite3pager_set_cachesize(Pager*, int);
|
||||
int sqlite3pager_close(Pager *pPager);
|
||||
int sqlite3pager_get(Pager *pPager, Pgno pgno, void **ppPage);
|
||||
void *sqlite3pager_lookup(Pager *pPager, Pgno pgno);
|
||||
int sqlite3pager_ref(void*);
|
||||
int sqlite3pager_unref(void*);
|
||||
Pgno sqlite3pager_pagenumber(void*);
|
||||
int sqlite3pager_write(void*);
|
||||
int sqlite3pager_iswriteable(void*);
|
||||
int sqlite3pager_overwrite(Pager *pPager, Pgno pgno, void*);
|
||||
int sqlite3pager_pagecount(Pager*);
|
||||
int sqlite3pager_truncate(Pager*,Pgno);
|
||||
int sqlite3pager_begin(void*);
|
||||
int sqlite3pager_commit(Pager*);
|
||||
int sqlite3pager_rollback(Pager*);
|
||||
int sqlite3pager_isreadonly(Pager*);
|
||||
int sqlite3pager_stmt_begin(Pager*);
|
||||
int sqlite3pager_stmt_commit(Pager*);
|
||||
int sqlite3pager_stmt_rollback(Pager*);
|
||||
void sqlite3pager_dont_rollback(void*);
|
||||
void sqlite3pager_dont_write(Pager*, Pgno);
|
||||
int *sqlite3pager_stats(Pager*);
|
||||
void sqlite3pager_set_safety_level(Pager*,int);
|
||||
const char *sqlite3pager_filename(Pager*);
|
||||
int sqlite3pager_rename(Pager*, const char *zNewName);
|
||||
void sqlite3pager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*);
|
||||
|
||||
#ifdef SQLITE_TEST
|
||||
void sqlitepager_refdump(Pager*);
|
||||
int pager_refinfo_enable;
|
||||
int journal_format;
|
||||
void sqlite3pager_refdump(Pager*);
|
||||
int pager3_refinfo_enable;
|
||||
#endif
|
||||
|
@ -11,13 +11,12 @@
|
||||
*************************************************************************
|
||||
** Internal interface definitions for SQLite.
|
||||
**
|
||||
** @(#) $Id: sqliteInt.h,v 1.220 2004/02/25 13:47:33 drh Exp $
|
||||
** @(#) $Id: sqliteInt.h,v 1.221 2004/04/26 14:10:22 drh Exp $
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "sqlite.h"
|
||||
#include "hash.h"
|
||||
#include "parse.h"
|
||||
#include "btree.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -96,6 +95,9 @@
|
||||
**
|
||||
** cc '-DUINTPTR_TYPE=long long int' ...
|
||||
*/
|
||||
#ifndef UINT64_TYPE
|
||||
# define UINT64_TYPE unsigned long long int
|
||||
#endif
|
||||
#ifndef UINT32_TYPE
|
||||
# define UINT32_TYPE unsigned int
|
||||
#endif
|
||||
@ -115,6 +117,7 @@
|
||||
# define INTPTR_TYPE long long
|
||||
# endif
|
||||
#endif
|
||||
typedef UINT64_TYPE u64; /* 8-byte unsigned integer */
|
||||
typedef UINT32_TYPE u32; /* 4-byte unsigned integer */
|
||||
typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
|
||||
typedef UINT8_TYPE u8; /* 1-byte unsigned integer */
|
||||
@ -126,6 +129,7 @@ typedef unsigned INTPTR_TYPE uptr; /* Big enough to hold a pointer */
|
||||
** Defer sourcing vdbe.h until after the "u8" typedef is defined.
|
||||
*/
|
||||
#include "vdbe.h"
|
||||
#include "btree.h"
|
||||
|
||||
/*
|
||||
** Most C compilers these days recognize "long double", don't they?
|
||||
|
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** A TCL Interface to SQLite
|
||||
**
|
||||
** $Id: tclsqlite.c,v 1.59 2004/02/25 22:51:06 rdc Exp $
|
||||
** $Id: tclsqlite.c,v 1.60 2004/04/26 14:10:22 drh Exp $
|
||||
*/
|
||||
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if 0
|
||||
/*
|
||||
** If TCL uses UTF-8 and SQLite is configured to use iso8859, then we
|
||||
** have to do a translation when going between the two. Set the
|
||||
@ -1155,6 +1156,7 @@ int Sqlite_SafeInit(Tcl_Interp *interp){
|
||||
int Tclsqlite_SafeInit(Tcl_Interp *interp){
|
||||
return TCL_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/*
|
||||
@ -1199,7 +1201,7 @@ int TCLSH_MAIN(int argc, char **argv){
|
||||
Tcl_Interp *interp;
|
||||
Tcl_FindExecutable(argv[0]);
|
||||
interp = Tcl_CreateInterp();
|
||||
Sqlite_Init(interp);
|
||||
/* Sqlite_Init(interp); */
|
||||
#ifdef SQLITE_TEST
|
||||
{
|
||||
extern int Sqlitetest1_Init(Tcl_Interp*);
|
||||
@ -1207,10 +1209,10 @@ int TCLSH_MAIN(int argc, char **argv){
|
||||
extern int Sqlitetest3_Init(Tcl_Interp*);
|
||||
extern int Sqlitetest4_Init(Tcl_Interp*);
|
||||
extern int Md5_Init(Tcl_Interp*);
|
||||
Sqlitetest1_Init(interp);
|
||||
/* Sqlitetest1_Init(interp); */
|
||||
Sqlitetest2_Init(interp);
|
||||
Sqlitetest3_Init(interp);
|
||||
Sqlitetest4_Init(interp);
|
||||
/* Sqlitetest3_Init(interp); */
|
||||
/* Sqlitetest4_Init(interp); */
|
||||
Md5_Init(interp);
|
||||
}
|
||||
#endif
|
||||
|
55
src/test2.c
55
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.16 2004/02/10 01:54:28 drh Exp $
|
||||
** $Id: test2.c,v 1.17 2004/04/26 14:10:22 drh Exp $
|
||||
*/
|
||||
#include "os.h"
|
||||
#include "sqliteInt.h"
|
||||
@ -76,7 +76,7 @@ static int pager_open(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[2], &nPage) ) return TCL_ERROR;
|
||||
rc = sqlitepager_open(&pPager, argv[1], nPage, 0, 1);
|
||||
rc = sqlite3pager_open(&pPager, argv[1], nPage, 0, 1);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||
return TCL_ERROR;
|
||||
@ -105,7 +105,7 @@ static int pager_close(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
|
||||
rc = sqlitepager_close(pPager);
|
||||
rc = sqlite3pager_close(pPager);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||
return TCL_ERROR;
|
||||
@ -132,7 +132,7 @@ static int pager_rollback(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
|
||||
rc = sqlitepager_rollback(pPager);
|
||||
rc = sqlite3pager_rollback(pPager);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||
return TCL_ERROR;
|
||||
@ -159,7 +159,7 @@ static int pager_commit(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
|
||||
rc = sqlitepager_commit(pPager);
|
||||
rc = sqlite3pager_commit(pPager);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||
return TCL_ERROR;
|
||||
@ -168,11 +168,11 @@ static int pager_commit(
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: pager_ckpt_begin ID
|
||||
** Usage: pager_stmt_begin ID
|
||||
**
|
||||
** Start a new checkpoint.
|
||||
*/
|
||||
static int pager_ckpt_begin(
|
||||
static int pager_stmt_begin(
|
||||
void *NotUsed,
|
||||
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
|
||||
int argc, /* Number of arguments */
|
||||
@ -186,7 +186,7 @@ static int pager_ckpt_begin(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
|
||||
rc = sqlitepager_ckpt_begin(pPager);
|
||||
rc = sqlite3pager_stmt_begin(pPager);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||
return TCL_ERROR;
|
||||
@ -195,11 +195,11 @@ static int pager_ckpt_begin(
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: pager_ckpt_rollback ID
|
||||
** Usage: pager_stmt_rollback ID
|
||||
**
|
||||
** Rollback changes to a checkpoint
|
||||
*/
|
||||
static int pager_ckpt_rollback(
|
||||
static int pager_stmt_rollback(
|
||||
void *NotUsed,
|
||||
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
|
||||
int argc, /* Number of arguments */
|
||||
@ -213,7 +213,7 @@ static int pager_ckpt_rollback(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
|
||||
rc = sqlitepager_ckpt_rollback(pPager);
|
||||
rc = sqlite3pager_stmt_rollback(pPager);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||
return TCL_ERROR;
|
||||
@ -222,11 +222,11 @@ static int pager_ckpt_rollback(
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: pager_ckpt_commit ID
|
||||
** Usage: pager_stmt_commit ID
|
||||
**
|
||||
** Commit changes to a checkpoint
|
||||
*/
|
||||
static int pager_ckpt_commit(
|
||||
static int pager_stmt_commit(
|
||||
void *NotUsed,
|
||||
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
|
||||
int argc, /* Number of arguments */
|
||||
@ -240,7 +240,7 @@ static int pager_ckpt_commit(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
|
||||
rc = sqlitepager_ckpt_commit(pPager);
|
||||
rc = sqlite3pager_stmt_commit(pPager);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||
return TCL_ERROR;
|
||||
@ -267,7 +267,7 @@ static int pager_stats(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
|
||||
a = sqlitepager_stats(pPager);
|
||||
a = sqlite3pager_stats(pPager);
|
||||
for(i=0; i<9; i++){
|
||||
static char *zName[] = {
|
||||
"ref", "page", "max", "size", "state", "err",
|
||||
@ -300,7 +300,7 @@ static int pager_pagecount(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
|
||||
sprintf(zBuf,"%d",sqlitepager_pagecount(pPager));
|
||||
sprintf(zBuf,"%d",sqlite3pager_pagecount(pPager));
|
||||
Tcl_AppendResult(interp, zBuf, 0);
|
||||
return TCL_OK;
|
||||
}
|
||||
@ -328,7 +328,7 @@ static int page_get(
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
|
||||
if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR;
|
||||
rc = sqlitepager_get(pPager, pgno, &pPage);
|
||||
rc = sqlite3pager_get(pPager, pgno, &pPage);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||
return TCL_ERROR;
|
||||
@ -361,7 +361,7 @@ static int page_lookup(
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[1], (int*)&pPager) ) return TCL_ERROR;
|
||||
if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR;
|
||||
pPage = sqlitepager_lookup(pPager, pgno);
|
||||
pPage = sqlite3pager_lookup(pPager, pgno);
|
||||
if( pPage ){
|
||||
sprintf(zBuf,"0x%x",(int)pPage);
|
||||
Tcl_AppendResult(interp, zBuf, 0);
|
||||
@ -388,7 +388,7 @@ static int page_unref(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[1], (int*)&pPage) ) return TCL_ERROR;
|
||||
rc = sqlitepager_unref(pPage);
|
||||
rc = sqlite3pager_unref(pPage);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||
return TCL_ERROR;
|
||||
@ -439,7 +439,7 @@ static int page_number(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[1], (int*)&pPage) ) return TCL_ERROR;
|
||||
sprintf(zBuf, "%d", sqlitepager_pagenumber(pPage));
|
||||
sprintf(zBuf, "%d", sqlite3pager_pagenumber(pPage));
|
||||
Tcl_AppendResult(interp, zBuf, 0);
|
||||
return TCL_OK;
|
||||
}
|
||||
@ -463,7 +463,7 @@ static int page_write(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( Tcl_GetInt(interp, argv[1], (int*)&pPage) ) return TCL_ERROR;
|
||||
rc = sqlitepager_write(pPage);
|
||||
rc = sqlite3pager_write(pPage);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||
return TCL_ERROR;
|
||||
@ -534,9 +534,9 @@ int Sqlitetest2_Init(Tcl_Interp *interp){
|
||||
{ "pager_close", (Tcl_CmdProc*)pager_close },
|
||||
{ "pager_commit", (Tcl_CmdProc*)pager_commit },
|
||||
{ "pager_rollback", (Tcl_CmdProc*)pager_rollback },
|
||||
{ "pager_ckpt_begin", (Tcl_CmdProc*)pager_ckpt_begin },
|
||||
{ "pager_ckpt_commit", (Tcl_CmdProc*)pager_ckpt_commit },
|
||||
{ "pager_ckpt_rollback", (Tcl_CmdProc*)pager_ckpt_rollback },
|
||||
{ "pager_stmt_begin", (Tcl_CmdProc*)pager_stmt_begin },
|
||||
{ "pager_stmt_commit", (Tcl_CmdProc*)pager_stmt_commit },
|
||||
{ "pager_stmt_rollback", (Tcl_CmdProc*)pager_stmt_rollback },
|
||||
{ "pager_stats", (Tcl_CmdProc*)pager_stats },
|
||||
{ "pager_pagecount", (Tcl_CmdProc*)pager_pagecount },
|
||||
{ "page_get", (Tcl_CmdProc*)page_get },
|
||||
@ -554,8 +554,11 @@ int Sqlitetest2_Init(Tcl_Interp *interp){
|
||||
Tcl_LinkVar(interp, "sqlite_io_error_pending",
|
||||
(char*)&sqlite_io_error_pending, TCL_LINK_INT);
|
||||
#ifdef SQLITE_TEST
|
||||
Tcl_LinkVar(interp, "journal_format",
|
||||
(char*)&journal_format, TCL_LINK_INT);
|
||||
{
|
||||
extern int journal_format;
|
||||
Tcl_LinkVar(interp, "journal_format",
|
||||
(char*)&journal_format, TCL_LINK_INT);
|
||||
}
|
||||
#endif
|
||||
sprintf(zBuf, "%d", SQLITE_PAGE_SIZE);
|
||||
Tcl_SetVar(interp, "SQLITE_PAGE_SIZE", zBuf, TCL_GLOBAL_ONLY);
|
||||
|
@ -14,7 +14,7 @@
|
||||
** This file contains functions for allocating memory, comparing
|
||||
** strings, and stuff like that.
|
||||
**
|
||||
** $Id: util.c,v 1.74 2004/02/22 17:49:34 drh Exp $
|
||||
** $Id: util.c,v 1.75 2004/04/26 14:10:22 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <stdarg.h>
|
||||
@ -405,6 +405,7 @@ void sqliteSetNString(char **pz, ...){
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
** Add an error message to pParse->zErrMsg and increment pParse->nErr.
|
||||
** The following formatting characters are allowed:
|
||||
@ -423,6 +424,7 @@ void sqliteErrorMsg(Parse *pParse, const char *zFormat, ...){
|
||||
pParse->zErrMsg = sqliteVMPrintf(zFormat, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Convert an SQL-style quoted string into a normal string by removing
|
||||
|
@ -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.14 2004/02/25 02:20:42 drh Exp $
|
||||
# $Id: pager.test,v 1.15 2004/04/26 14:10:22 drh Exp $
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -305,7 +305,7 @@ for {set i 1} {$i<20} {incr i} {
|
||||
page_write $gx "Page-$j v$i"
|
||||
page_unref $gx
|
||||
if {$j==$i} {
|
||||
pager_ckpt_begin $p1
|
||||
pager_stmt_begin $p1
|
||||
}
|
||||
}
|
||||
} {}
|
||||
@ -346,12 +346,12 @@ for {set i 1} {$i<20} {incr i} {
|
||||
page_write $gx "Page-$j v$i"
|
||||
page_unref $gx
|
||||
if {$j==$i} {
|
||||
pager_ckpt_begin $p1
|
||||
pager_stmt_begin $p1
|
||||
}
|
||||
}
|
||||
} {}
|
||||
do_test pager-4.5.$i.7 {
|
||||
pager_ckpt_rollback $p1
|
||||
pager_stmt_rollback $p1
|
||||
for {set j 2} {$j<=20} {incr j} {
|
||||
set gx [page_get $p1 $j]
|
||||
set value [page_read $gx]
|
||||
@ -373,12 +373,12 @@ for {set i 1} {$i<20} {incr i} {
|
||||
page_write $gx "Page-$j v$i"
|
||||
page_unref $gx
|
||||
if {$j==$i} {
|
||||
pager_ckpt_begin $p1
|
||||
pager_stmt_begin $p1
|
||||
}
|
||||
}
|
||||
} {}
|
||||
do_test pager-4.5.$i.9 {
|
||||
pager_ckpt_commit $p1
|
||||
pager_stmt_commit $p1
|
||||
for {set j 2} {$j<=20} {incr j} {
|
||||
set gx [page_get $p1 $j]
|
||||
set value [page_read $gx]
|
||||
@ -406,6 +406,7 @@ do_test pager-4.99 {
|
||||
|
||||
} ;# end if( not mem: and has pager_open command );
|
||||
|
||||
if 0 {
|
||||
# Ticket #615: an assertion fault inside the pager. It is a benign
|
||||
# fault, but we might as well test for it.
|
||||
#
|
||||
@ -418,6 +419,6 @@ do_test pager-5.1 {
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
@ -11,8 +11,9 @@
|
||||
# This file implements some common TCL routines used for regression
|
||||
# testing the SQLite library
|
||||
#
|
||||
# $Id: tester.tcl,v 1.28 2004/02/14 01:39:50 drh Exp $
|
||||
# $Id: tester.tcl,v 1.29 2004/04/26 14:10:22 drh Exp $
|
||||
|
||||
if 0 {
|
||||
# Make sure tclsqlite was compiled correctly. Abort now with an
|
||||
# error message if not.
|
||||
#
|
||||
@ -62,6 +63,8 @@ sqlite db ./test.db
|
||||
if {[info exists ::SETUP_SQL]} {
|
||||
db eval $::SETUP_SQL
|
||||
}
|
||||
}
|
||||
proc db {args} {}
|
||||
|
||||
# Abort early if this script has been run before.
|
||||
#
|
||||
@ -180,10 +183,12 @@ proc finalize_testing {} {
|
||||
puts "$nProb probabilistic tests also failed, but this does"
|
||||
puts "not necessarily indicate a malfunction."
|
||||
}
|
||||
if 0 {
|
||||
if {$sqlite_open_file_count} {
|
||||
puts "$sqlite_open_file_count files were left open"
|
||||
incr nErr
|
||||
}
|
||||
}
|
||||
exit [expr {$nErr>0}]
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user