mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Merge all recent trunk enhancements and fixes into the sessions branch.
FossilOrigin-Name: df94e61f93da390cb75c48975c50e9d62096ea0b
This commit is contained in:
14
Makefile.msc
14
Makefile.msc
@@ -312,12 +312,12 @@ RCC = $(RC) -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src
|
||||
#
|
||||
!IF $(USE_STDCALL)!=0
|
||||
!IF "$(PLATFORM)"=="x86"
|
||||
CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl
|
||||
SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl
|
||||
CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
|
||||
SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
|
||||
!ELSE
|
||||
!IFNDEF PLATFORM
|
||||
CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl
|
||||
SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl
|
||||
CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
|
||||
SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
|
||||
!ELSE
|
||||
CORE_CCONV_OPTS =
|
||||
SHELL_CCONV_OPTS =
|
||||
@@ -331,7 +331,7 @@ SHELL_CCONV_OPTS =
|
||||
# These are additional compiler options used for the core library.
|
||||
#
|
||||
!IFNDEF CORE_COMPILE_OPTS
|
||||
!IF $(USE_STDCALL)!=0
|
||||
!IF $(DYNAMIC_SHELL)!=0
|
||||
CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS) -DSQLITE_API=__declspec(dllexport)
|
||||
!ELSE
|
||||
CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS)
|
||||
@@ -342,7 +342,7 @@ CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS)
|
||||
# when linking.
|
||||
#
|
||||
!IFNDEF CORE_LINK_DEP
|
||||
!IF $(USE_STDCALL)!=0
|
||||
!IF $(DYNAMIC_SHELL)!=0
|
||||
CORE_LINK_DEP =
|
||||
!ELSE
|
||||
CORE_LINK_DEP = sqlite3.def
|
||||
@@ -352,7 +352,7 @@ CORE_LINK_DEP = sqlite3.def
|
||||
# These are additional linker options used for the core library.
|
||||
#
|
||||
!IFNDEF CORE_LINK_OPTS
|
||||
!IF $(USE_STDCALL)!=0
|
||||
!IF $(DYNAMIC_SHELL)!=0
|
||||
CORE_LINK_OPTS =
|
||||
!ELSE
|
||||
CORE_LINK_OPTS = /DEF:sqlite3.def
|
||||
|
@@ -1108,7 +1108,7 @@ static int fts3InitVtab(
|
||||
const char **aCol; /* Array of column names */
|
||||
sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
|
||||
|
||||
int nIndex; /* Size of aIndex[] array */
|
||||
int nIndex = 0; /* Size of aIndex[] array */
|
||||
struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
|
||||
|
||||
/* The results of parsing supported FTS4 key=value options: */
|
||||
|
38
manifest
38
manifest
@@ -1,9 +1,9 @@
|
||||
C Merge\sall\srecent\strunk\senhancements\sinto\sthe\ssessions\sbranch.
|
||||
D 2015-03-24T19:02:13.346
|
||||
C Merge\sall\srecent\strunk\senhancements\sand\sfixes\sinto\sthe\ssessions\sbranch.
|
||||
D 2015-03-31T00:10:21.692
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 1bf4de5d0809e0ed046d6f2671ea46d1d6c69608
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
F Makefile.msc 9547047d5f1b55326a195323ee41cd86281a5d9e
|
||||
F Makefile.msc da7e7ac0949d78930b7b0adc3862aef9a9439b2e
|
||||
F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858
|
||||
F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866
|
||||
F VERSION 319eb1ced4b4d17a67730f2b7b85f15c1346cb60
|
||||
@@ -78,7 +78,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51
|
||||
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
|
||||
F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314
|
||||
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
|
||||
F ext/fts3/fts3.c 2a1cf23133d0c75ce296d17440c44115f8413ec7
|
||||
F ext/fts3/fts3.c d3f6f0e95d366f3c2028d916c36a0844bf805840
|
||||
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
|
||||
F ext/fts3/fts3Int.h 394858c12a17740f7a1f6bd372c4606d4425a8d1
|
||||
F ext/fts3/fts3_aux.c 5c211e17a64885faeb16b9ba7772f9d5445c2365
|
||||
@@ -190,7 +190,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240
|
||||
F src/backup.c ff743689c4d6c5cb55ad42ed9d174b2b3e71f1e3
|
||||
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
|
||||
F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79
|
||||
F src/btree.c 3e320cac836546c905bd90007074d887980aa70e
|
||||
F src/btree.c e565971caa0265d3cabc8b15d7017899a7814051
|
||||
F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1
|
||||
F src/btreeInt.h 2bfefc01875d8da066504c233ec259fcb3b2ef72
|
||||
F src/build.c 0419bba592c22f6d00e6d57a2ca7136720d02c1a
|
||||
@@ -212,8 +212,8 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
|
||||
F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e
|
||||
F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770
|
||||
F src/loadext.c 86bd4e2fccd520b748cba52492ab60c4a770f660
|
||||
F src/main.c e404037a74cc37251e54c7b71a9a25b48b21e884
|
||||
F src/malloc.c e818a0db9ac0898f9dc74002f3a5baca32232d05
|
||||
F src/main.c 4eecdeb7b3f6be5aa336252f71208344b5edd196
|
||||
F src/malloc.c 6a370b83d54e4bbf6f94021221c2a311cff26a18
|
||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||
F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987
|
||||
F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3
|
||||
@@ -232,7 +232,7 @@ F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
|
||||
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
|
||||
F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
|
||||
F src/os_unix.c a4dadbc2da41599e99093e91e276c38c17a73b89
|
||||
F src/os_win.c 8223e7db5b7c4a81d8b161098ac3959400434cdb
|
||||
F src/os_win.c 865ba15878eded98bb29a97ac898f2a799dc481a
|
||||
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
|
||||
F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c
|
||||
F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77
|
||||
@@ -248,11 +248,11 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
|
||||
F src/resolve.c f4d79e31ffa5820c2e3d1740baa5e9b190425f2b
|
||||
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
|
||||
F src/select.c 72ffb62e2879956302140e9f6e6ae88aee36b0e5
|
||||
F src/shell.c 560f5ceec3a1855c1aa474a52b75dea112d548b4
|
||||
F src/sqlite.h.in 690648d5c676eb3ded09f635fc8d0aeb22235df0
|
||||
F src/shell.c c4d839ad62f4986891601a21ce629a760f226682
|
||||
F src/sqlite.h.in 64287a2b3432550264a743addbf4162a692fdd1c
|
||||
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
||||
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
|
||||
F src/sqliteInt.h d2804bd5a9c270bc60fe096c9c416123425ebdde
|
||||
F src/sqliteInt.h e974c4f98eba7c578da160dd76a7a34d62d61af2
|
||||
F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46
|
||||
F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179
|
||||
F src/table.c e7a09215315a978057fb42c640f890160dbcc45e
|
||||
@@ -401,6 +401,7 @@ F test/boundary3.test 56ef82096b4329aca2be74fa1e2b0f762ea0eb45
|
||||
F test/boundary4.tcl 0bb4b1a94f4fc5ae59b79b9a2b7a140c405e2983
|
||||
F test/boundary4.test 89e02fa66397b8a325d5eb102b5806f961f8ec4b
|
||||
F test/btree01.test e08b3613540145b353f20c81cb18ead54ff12e0f
|
||||
F test/btree02.test fe69453d474d8154d19b904157ff1db4812fed99
|
||||
F test/btreefault.test c2bcb542685eea44621275cfedbd8a13f65201e3
|
||||
F test/busy.test 76b4887f8b9160ba903c1ac22e8ff406ad6ae2f0
|
||||
F test/cache.test 13bc046b26210471ca6f2889aceb1ea52dc717de
|
||||
@@ -449,6 +450,7 @@ F test/corruptF.test be9fde98e4c93648f1ba52b74e5318edc8f59fe4
|
||||
F test/corruptG.test 1ab3bf97ee7bdba70e0ff3ba2320657df55d1804
|
||||
F test/corruptH.test 5dd4fa98c6c1ed33b178f9e8a48c4fdd3cfc9067
|
||||
F test/corruptI.test 221ad8b7f0a9ac6b80fc577e73b5ad8cdea31243
|
||||
F test/corruptJ.test 8f584eb97b88e7b160d03edfe2f814c64e56b4ac
|
||||
F test/cost.test 19d314526616ce4473eb4e4e450fcb94499ce318
|
||||
F test/count.test 42a251178e32f617eda33f76236a7f79825a50b5
|
||||
F test/coveridxscan.test cdb47d01acc4a634a34fd25abe85189e0d0f1e62
|
||||
@@ -1198,7 +1200,7 @@ F test/whereK.test f8e3cf26a8513ecc7f514f54df9f0572c046c42b
|
||||
F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
|
||||
F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c
|
||||
F test/win32heap.test ea19770974795cff26e11575e12d422dbd16893c
|
||||
F test/win32lock.test 71642fa56e9b06e5cfffe6bad67cb8c1eb2c555a
|
||||
F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972
|
||||
F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d
|
||||
F test/with1.test 9df5cd8a62148b3d9ef8597aea563e3863018bcd
|
||||
F test/with2.test ee227a663586aa09771cafd4fa269c5217eaf775
|
||||
@@ -1230,9 +1232,9 @@ F tool/mkkeywordhash.c dfff09dbbfaf950e89af294f48f902181b144670
|
||||
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
|
||||
F tool/mkpragmatab.tcl 94f196c9961e0ca3513e29f57125a3197808be2d
|
||||
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
|
||||
F tool/mksqlite3c-noext.tcl 9ef48e1748dce7b844f67e2450ff9dfeb0fb4ab5
|
||||
F tool/mksqlite3c.tcl 87d0000c12cfb0a8c5438f9a754fb45ab0aeb2e2
|
||||
F tool/mksqlite3h.tcl 2d0f1b3768f8d000b7881217d5fd4c776eb27467
|
||||
F tool/mksqlite3c-noext.tcl 69bae8ce4aa52d2ff82d4a8a856bf283ec035b2e
|
||||
F tool/mksqlite3c.tcl ebbf1198e19d84b4c34cca077d8f727a06ff8a11
|
||||
F tool/mksqlite3h.tcl 96d92fcac21c6037d9db20c7cb2e06b534b550ac
|
||||
F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b
|
||||
F tool/mkvsix.tcl 52a4c613707ac34ae9c226e5ccc69cb948556105
|
||||
F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091
|
||||
@@ -1264,7 +1266,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 1d1c57c3566d86cd44f146688b620131b3b57e52 436314b5728c9413f9ac2d837e1c19364f31be72
|
||||
R b5b5e91935316c7c5da3a524cb5abdb1
|
||||
P 54aaa6f29ad1bf84148c2403eed77e8311f68d66 395bb3e677a6551b06ba96fc58c393132b93d1e8
|
||||
R 5157faacf9bba75d7e337c0159334ea0
|
||||
U drh
|
||||
Z a1e013db0b150b015d815c843c8a5cc9
|
||||
Z 1371361ad4cf3707e5f673fcbbe81867
|
||||
|
@@ -1 +1 @@
|
||||
54aaa6f29ad1bf84148c2403eed77e8311f68d66
|
||||
df94e61f93da390cb75c48975c50e9d62096ea0b
|
40
src/btree.c
40
src/btree.c
@@ -600,10 +600,15 @@ static void btreeReleaseAllCursorPages(BtCursor *pCur){
|
||||
static int saveCursorPosition(BtCursor *pCur){
|
||||
int rc;
|
||||
|
||||
assert( CURSOR_VALID==pCur->eState );
|
||||
assert( CURSOR_VALID==pCur->eState || CURSOR_SKIPNEXT==pCur->eState );
|
||||
assert( 0==pCur->pKey );
|
||||
assert( cursorHoldsMutex(pCur) );
|
||||
|
||||
if( pCur->eState==CURSOR_SKIPNEXT ){
|
||||
pCur->eState = CURSOR_VALID;
|
||||
}else{
|
||||
pCur->skipNext = 0;
|
||||
}
|
||||
rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
|
||||
assert( rc==SQLITE_OK ); /* KeySize() cannot fail */
|
||||
|
||||
@@ -674,7 +679,7 @@ static int SQLITE_NOINLINE saveCursorsOnList(
|
||||
){
|
||||
do{
|
||||
if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){
|
||||
if( p->eState==CURSOR_VALID ){
|
||||
if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){
|
||||
int rc = saveCursorPosition(p);
|
||||
if( SQLITE_OK!=rc ){
|
||||
return rc;
|
||||
@@ -746,17 +751,19 @@ static int btreeMoveto(
|
||||
*/
|
||||
static int btreeRestoreCursorPosition(BtCursor *pCur){
|
||||
int rc;
|
||||
int skipNext;
|
||||
assert( cursorHoldsMutex(pCur) );
|
||||
assert( pCur->eState>=CURSOR_REQUIRESEEK );
|
||||
if( pCur->eState==CURSOR_FAULT ){
|
||||
return pCur->skipNext;
|
||||
}
|
||||
pCur->eState = CURSOR_INVALID;
|
||||
rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &pCur->skipNext);
|
||||
rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);
|
||||
if( rc==SQLITE_OK ){
|
||||
sqlite3_free(pCur->pKey);
|
||||
pCur->pKey = 0;
|
||||
assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
|
||||
pCur->skipNext |= skipNext;
|
||||
if( pCur->skipNext && pCur->eState==CURSOR_VALID ){
|
||||
pCur->eState = CURSOR_SKIPNEXT;
|
||||
}
|
||||
@@ -808,9 +815,10 @@ int sqlite3BtreeCursorRestore(BtCursor *pCur, int *pDifferentRow){
|
||||
*pDifferentRow = 1;
|
||||
return rc;
|
||||
}
|
||||
if( pCur->eState!=CURSOR_VALID || NEVER(pCur->skipNext!=0) ){
|
||||
if( pCur->eState!=CURSOR_VALID ){
|
||||
*pDifferentRow = 1;
|
||||
}else{
|
||||
assert( pCur->skipNext==0 );
|
||||
*pDifferentRow = 0;
|
||||
}
|
||||
return SQLITE_OK;
|
||||
@@ -3625,7 +3633,7 @@ int sqlite3BtreeTripAllCursors(Btree *pBtree, int errCode, int writeOnly){
|
||||
for(p=pBtree->pBt->pCursor; p; p=p->pNext){
|
||||
int i;
|
||||
if( writeOnly && (p->curFlags & BTCF_WriteFlag)==0 ){
|
||||
if( p->eState==CURSOR_VALID ){
|
||||
if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){
|
||||
rc = saveCursorPosition(p);
|
||||
if( rc!=SQLITE_OK ){
|
||||
(void)sqlite3BtreeTripAllCursors(pBtree, rc, 0);
|
||||
@@ -4031,6 +4039,8 @@ int sqlite3BtreeKeySize(BtCursor *pCur, i64 *pSize){
|
||||
int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
|
||||
assert( cursorHoldsMutex(pCur) );
|
||||
assert( pCur->eState==CURSOR_VALID );
|
||||
assert( pCur->iPage>=0 );
|
||||
assert( pCur->iPage<BTCURSOR_MAX_DEPTH );
|
||||
assert( pCur->apPage[pCur->iPage]->intKeyLeaf==1 );
|
||||
getCellInfo(pCur);
|
||||
*pSize = pCur->info.nPayload;
|
||||
@@ -4509,7 +4519,7 @@ static int moveToChild(BtCursor *pCur, u32 newPgno){
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#if SQLITE_DEBUG
|
||||
/*
|
||||
** Page pParent is an internal (non-leaf) tree page. This function
|
||||
** asserts that page number iChild is the left-child if the iIdx'th
|
||||
@@ -4518,6 +4528,8 @@ static int moveToChild(BtCursor *pCur, u32 newPgno){
|
||||
** the page.
|
||||
*/
|
||||
static void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){
|
||||
if( CORRUPT_DB ) return; /* The conditions tested below might not be true
|
||||
** in a corrupt database */
|
||||
assert( iIdx<=pParent->nCell );
|
||||
if( iIdx==pParent->nCell ){
|
||||
assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );
|
||||
@@ -4542,19 +4554,11 @@ static void moveToParent(BtCursor *pCur){
|
||||
assert( pCur->eState==CURSOR_VALID );
|
||||
assert( pCur->iPage>0 );
|
||||
assert( pCur->apPage[pCur->iPage] );
|
||||
|
||||
/* UPDATE: It is actually possible for the condition tested by the assert
|
||||
** below to be untrue if the database file is corrupt. This can occur if
|
||||
** one cursor has modified page pParent while a reference to it is held
|
||||
** by a second cursor. Which can only happen if a single page is linked
|
||||
** into more than one b-tree structure in a corrupt database. */
|
||||
#if 0
|
||||
assertParentIndex(
|
||||
pCur->apPage[pCur->iPage-1],
|
||||
pCur->aiIdx[pCur->iPage-1],
|
||||
pCur->apPage[pCur->iPage]->pgno
|
||||
);
|
||||
#endif
|
||||
testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell );
|
||||
|
||||
releasePage(pCur->apPage[pCur->iPage]);
|
||||
@@ -7502,6 +7506,7 @@ static int balance(BtCursor *pCur){
|
||||
/* The next iteration of the do-loop balances the parent page. */
|
||||
releasePage(pPage);
|
||||
pCur->iPage--;
|
||||
assert( pCur->iPage>=0 );
|
||||
}
|
||||
}while( rc==SQLITE_OK );
|
||||
|
||||
@@ -7973,6 +7978,7 @@ static int clearDatabasePage(
|
||||
int i;
|
||||
int hdr;
|
||||
u16 szCell;
|
||||
u8 hasChildren;
|
||||
|
||||
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||
if( pgno>btreePagecount(pBt) ){
|
||||
@@ -7981,17 +7987,19 @@ static int clearDatabasePage(
|
||||
|
||||
rc = getAndInitPage(pBt, pgno, &pPage, 0);
|
||||
if( rc ) return rc;
|
||||
hasChildren = !pPage->leaf;
|
||||
pPage->leaf = 1; /* Block looping if the database is corrupt */
|
||||
hdr = pPage->hdrOffset;
|
||||
for(i=0; i<pPage->nCell; i++){
|
||||
pCell = findCell(pPage, i);
|
||||
if( !pPage->leaf ){
|
||||
if( hasChildren ){
|
||||
rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
|
||||
if( rc ) goto cleardatabasepage_out;
|
||||
}
|
||||
rc = clearCell(pPage, pCell, &szCell);
|
||||
if( rc ) goto cleardatabasepage_out;
|
||||
}
|
||||
if( !pPage->leaf ){
|
||||
if( hasChildren ){
|
||||
rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
|
||||
if( rc ) goto cleardatabasepage_out;
|
||||
}else if( pnChange ){
|
||||
|
@@ -62,7 +62,7 @@ int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
|
||||
** I/O active are written using this function. These messages
|
||||
** are intended for debugging activity only.
|
||||
*/
|
||||
/* not-private */ void (*sqlite3IoTrace)(const char*, ...) = 0;
|
||||
SQLITE_API void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...) = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@@ -162,6 +162,7 @@ void sqlite3_soft_heap_limit(int n){
|
||||
** Initialize the memory allocation subsystem.
|
||||
*/
|
||||
int sqlite3MallocInit(void){
|
||||
int rc;
|
||||
if( sqlite3GlobalConfig.m.xMalloc==0 ){
|
||||
sqlite3MemSetDefault();
|
||||
}
|
||||
@@ -197,7 +198,9 @@ int sqlite3MallocInit(void){
|
||||
sqlite3GlobalConfig.szPage = 0;
|
||||
sqlite3GlobalConfig.nPage = 0;
|
||||
}
|
||||
return sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
|
||||
rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
|
||||
if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
|
76
src/os_win.c
76
src/os_win.c
@@ -1966,11 +1966,11 @@ static int winRetryIoerr(int *pnRetry, DWORD *pError){
|
||||
/*
|
||||
** Log a I/O error retry episode.
|
||||
*/
|
||||
static void winLogIoerr(int nRetry){
|
||||
static void winLogIoerr(int nRetry, int lineno){
|
||||
if( nRetry ){
|
||||
sqlite3_log(SQLITE_IOERR,
|
||||
"delayed %dms for lock/sharing conflict",
|
||||
winIoerrRetryDelay*nRetry*(nRetry+1)/2
|
||||
"delayed %dms for lock/sharing conflict at line %d",
|
||||
winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2450,7 +2450,8 @@ static int winClose(sqlite3_file *id){
|
||||
assert( pFile->pShm==0 );
|
||||
#endif
|
||||
assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
|
||||
OSTRACE(("CLOSE file=%p\n", pFile->h));
|
||||
OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h));
|
||||
|
||||
#if SQLITE_MAX_MMAP_SIZE>0
|
||||
winUnmapfile(pFile);
|
||||
@@ -2479,7 +2480,8 @@ static int winClose(sqlite3_file *id){
|
||||
pFile->h = NULL;
|
||||
}
|
||||
OpenCounter(-1);
|
||||
OSTRACE(("CLOSE file=%p, rc=%s\n", pFile->h, rc ? "ok" : "failed"));
|
||||
OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p, rc=%s\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h, rc ? "ok" : "failed"));
|
||||
return rc ? SQLITE_OK
|
||||
: winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
|
||||
"winClose", pFile->zPath);
|
||||
@@ -2507,7 +2509,8 @@ static int winRead(
|
||||
assert( amt>0 );
|
||||
assert( offset>=0 );
|
||||
SimulateIOError(return SQLITE_IOERR_READ);
|
||||
OSTRACE(("READ file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
|
||||
OSTRACE(("READ pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
|
||||
"offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
|
||||
pFile->h, pBuf, amt, offset, pFile->locktype));
|
||||
|
||||
#if SQLITE_MAX_MMAP_SIZE>0
|
||||
@@ -2516,7 +2519,8 @@ static int winRead(
|
||||
if( offset<pFile->mmapSize ){
|
||||
if( offset+amt <= pFile->mmapSize ){
|
||||
memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);
|
||||
OSTRACE(("READ-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
|
||||
OSTRACE(("READ-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h));
|
||||
return SQLITE_OK;
|
||||
}else{
|
||||
int nCopy = (int)(pFile->mmapSize - offset);
|
||||
@@ -2530,7 +2534,8 @@ static int winRead(
|
||||
|
||||
#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
|
||||
if( winSeekFile(pFile, offset) ){
|
||||
OSTRACE(("READ file=%p, rc=SQLITE_FULL\n", pFile->h));
|
||||
OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h));
|
||||
return SQLITE_FULL;
|
||||
}
|
||||
while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
|
||||
@@ -2544,19 +2549,22 @@ static int winRead(
|
||||
DWORD lastErrno;
|
||||
if( winRetryIoerr(&nRetry, &lastErrno) ) continue;
|
||||
pFile->lastErrno = lastErrno;
|
||||
OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h));
|
||||
OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_READ\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h));
|
||||
return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
|
||||
"winRead", pFile->zPath);
|
||||
}
|
||||
winLogIoerr(nRetry);
|
||||
winLogIoerr(nRetry, __LINE__);
|
||||
if( nRead<(DWORD)amt ){
|
||||
/* Unread parts of the buffer must be zero-filled */
|
||||
memset(&((char*)pBuf)[nRead], 0, amt-nRead);
|
||||
OSTRACE(("READ file=%p, rc=SQLITE_IOERR_SHORT_READ\n", pFile->h));
|
||||
OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_SHORT_READ\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h));
|
||||
return SQLITE_IOERR_SHORT_READ;
|
||||
}
|
||||
|
||||
OSTRACE(("READ file=%p, rc=SQLITE_OK\n", pFile->h));
|
||||
OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h));
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
@@ -2579,7 +2587,8 @@ static int winWrite(
|
||||
SimulateIOError(return SQLITE_IOERR_WRITE);
|
||||
SimulateDiskfullError(return SQLITE_FULL);
|
||||
|
||||
OSTRACE(("WRITE file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
|
||||
OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
|
||||
"offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
|
||||
pFile->h, pBuf, amt, offset, pFile->locktype));
|
||||
|
||||
#if SQLITE_MAX_MMAP_SIZE>0
|
||||
@@ -2588,7 +2597,8 @@ static int winWrite(
|
||||
if( offset<pFile->mmapSize ){
|
||||
if( offset+amt <= pFile->mmapSize ){
|
||||
memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);
|
||||
OSTRACE(("WRITE-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
|
||||
OSTRACE(("WRITE-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h));
|
||||
return SQLITE_OK;
|
||||
}else{
|
||||
int nCopy = (int)(pFile->mmapSize - offset);
|
||||
@@ -2651,17 +2661,20 @@ static int winWrite(
|
||||
if( rc ){
|
||||
if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
|
||||
|| ( pFile->lastErrno==ERROR_DISK_FULL )){
|
||||
OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h));
|
||||
OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h));
|
||||
return winLogError(SQLITE_FULL, pFile->lastErrno,
|
||||
"winWrite1", pFile->zPath);
|
||||
}
|
||||
OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h));
|
||||
OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_WRITE\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h));
|
||||
return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
|
||||
"winWrite2", pFile->zPath);
|
||||
}else{
|
||||
winLogIoerr(nRetry);
|
||||
winLogIoerr(nRetry, __LINE__);
|
||||
}
|
||||
OSTRACE(("WRITE file=%p, rc=SQLITE_OK\n", pFile->h));
|
||||
OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h));
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
@@ -2675,8 +2688,8 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
|
||||
|
||||
assert( pFile );
|
||||
SimulateIOError(return SQLITE_IOERR_TRUNCATE);
|
||||
OSTRACE(("TRUNCATE file=%p, size=%lld, lock=%d\n",
|
||||
pFile->h, nByte, pFile->locktype));
|
||||
OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype));
|
||||
|
||||
/* If the user has configured a chunk-size for this file, truncate the
|
||||
** file so that it consists of an integer number of chunks (i.e. the
|
||||
@@ -2708,7 +2721,8 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
|
||||
}
|
||||
#endif
|
||||
|
||||
OSTRACE(("TRUNCATE file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
|
||||
OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -2753,8 +2767,9 @@ static int winSync(sqlite3_file *id, int flags){
|
||||
*/
|
||||
SimulateDiskfullError( return SQLITE_FULL );
|
||||
|
||||
OSTRACE(("SYNC file=%p, flags=%x, lock=%d\n",
|
||||
pFile->h, flags, pFile->locktype));
|
||||
OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, flags=%x, lock=%d\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h, flags,
|
||||
pFile->locktype));
|
||||
|
||||
#ifndef SQLITE_TEST
|
||||
UNUSED_PARAMETER(flags);
|
||||
@@ -2769,17 +2784,20 @@ static int winSync(sqlite3_file *id, int flags){
|
||||
** no-op
|
||||
*/
|
||||
#ifdef SQLITE_NO_SYNC
|
||||
OSTRACE(("SYNC-NOP file=%p, rc=SQLITE_OK\n", pFile->h));
|
||||
OSTRACE(("SYNC-NOP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h));
|
||||
return SQLITE_OK;
|
||||
#else
|
||||
rc = osFlushFileBuffers(pFile->h);
|
||||
SimulateIOError( rc=FALSE );
|
||||
if( rc ){
|
||||
OSTRACE(("SYNC file=%p, rc=SQLITE_OK\n", pFile->h));
|
||||
OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h));
|
||||
return SQLITE_OK;
|
||||
}else{
|
||||
pFile->lastErrno = osGetLastError();
|
||||
OSTRACE(("SYNC file=%p, rc=SQLITE_IOERR_FSYNC\n", pFile->h));
|
||||
OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\n",
|
||||
osGetCurrentProcessId(), pFile, pFile->h));
|
||||
return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
|
||||
"winSync", pFile->zPath);
|
||||
}
|
||||
@@ -4752,7 +4770,7 @@ static int winOpen(
|
||||
}
|
||||
}
|
||||
#endif
|
||||
winLogIoerr(cnt);
|
||||
winLogIoerr(cnt, __LINE__);
|
||||
|
||||
OSTRACE(("OPEN file=%p, name=%s, access=%lx, rc=%s\n", h, zUtf8Name,
|
||||
dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
|
||||
@@ -4936,7 +4954,7 @@ static int winDelete(
|
||||
if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
|
||||
rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename);
|
||||
}else{
|
||||
winLogIoerr(cnt);
|
||||
winLogIoerr(cnt, __LINE__);
|
||||
}
|
||||
sqlite3_free(zConverted);
|
||||
OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
|
||||
@@ -4986,7 +5004,7 @@ static int winAccess(
|
||||
attr = sAttrData.dwFileAttributes;
|
||||
}
|
||||
}else{
|
||||
winLogIoerr(cnt);
|
||||
winLogIoerr(cnt, __LINE__);
|
||||
if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){
|
||||
sqlite3_free(zConverted);
|
||||
return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess",
|
||||
|
@@ -370,7 +370,7 @@ static FILE *iotrace = 0;
|
||||
** is written to iotrace.
|
||||
*/
|
||||
#ifdef SQLITE_ENABLE_IOTRACE
|
||||
static void iotracePrintf(const char *zFormat, ...){
|
||||
static void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){
|
||||
va_list ap;
|
||||
char *z;
|
||||
if( iotrace==0 ) return;
|
||||
@@ -3233,7 +3233,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
|
||||
#ifdef SQLITE_ENABLE_IOTRACE
|
||||
if( c=='i' && strncmp(azArg[0], "iotrace", n)==0 ){
|
||||
extern void (*sqlite3IoTrace)(const char*, ...);
|
||||
SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...);
|
||||
if( iotrace && iotrace!=stdout ) fclose(iotrace);
|
||||
iotrace = 0;
|
||||
if( nArg<2 ){
|
||||
@@ -4084,9 +4084,9 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
azArg[2],
|
||||
integerValue(azArg[3]),
|
||||
integerValue(azArg[4]));
|
||||
fprintf(p->out, "%d (0x%08x)\n", rc, rc);
|
||||
}else{
|
||||
fprintf(stderr,"Usage: .testctrl initmode dbName onoff tnum\n");
|
||||
rc = 1;
|
||||
fprintf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n");
|
||||
}
|
||||
break;
|
||||
|
||||
|
@@ -43,18 +43,20 @@ extern "C" {
|
||||
|
||||
|
||||
/*
|
||||
** Add the ability to override 'extern'
|
||||
** Provide the ability to override linkage features of the interface.
|
||||
*/
|
||||
#ifndef SQLITE_EXTERN
|
||||
# define SQLITE_EXTERN extern
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Add the ability to override 'cdecl'
|
||||
*/
|
||||
#ifndef SQLITE_API
|
||||
# define SQLITE_API
|
||||
#endif
|
||||
#ifndef SQLITE_CDECL
|
||||
# define SQLITE_CDECL
|
||||
#endif
|
||||
#ifndef SQLITE_STDCALL
|
||||
# define SQLITE_STDCALL
|
||||
#endif
|
||||
|
||||
/*
|
||||
** These no-op macros are used in front of interfaces to mark those
|
||||
|
@@ -3815,7 +3815,7 @@ void sqlite3Put4byte(u8*, u32);
|
||||
#ifdef SQLITE_ENABLE_IOTRACE
|
||||
# define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; }
|
||||
void sqlite3VdbeIOTraceSql(Vdbe*);
|
||||
SQLITE_EXTERN void (*sqlite3IoTrace)(const char*,...);
|
||||
SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);
|
||||
#else
|
||||
# define IOTRACE(A)
|
||||
# define sqlite3VdbeIOTraceSql(X)
|
||||
|
52
test/btree02.test
Normal file
52
test/btree02.test
Normal file
@@ -0,0 +1,52 @@
|
||||
# 2015-03-25
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library.
|
||||
#
|
||||
# The focus of this script is making multiple calls to saveCursorPosition()
|
||||
# and restoreCursorPosition() when cursors have eState==CURSOR_SKIPNEXT
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
load_static_extension db eval
|
||||
do_execsql_test btree02-100 {
|
||||
CREATE TABLE t1(a TEXT, ax INTEGER, b INT, PRIMARY KEY(a,ax)) WITHOUT ROWID;
|
||||
WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10)
|
||||
INSERT INTO t1(a,ax,b) SELECT printf('%02x',i), random(), i FROM c;
|
||||
CREATE INDEX t1a ON t1(a);
|
||||
CREATE TABLE t2(x,y);
|
||||
CREATE TABLE t3(cnt);
|
||||
WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<4)
|
||||
INSERT INTO t3(cnt) SELECT i FROM c;
|
||||
SELECT count(*) FROM t1;
|
||||
} {10}
|
||||
do_test btree02-110 {
|
||||
db eval BEGIN
|
||||
set i 0
|
||||
db eval {SELECT a, ax, b, cnt FROM t1 CROSS JOIN t3 WHERE b IS NOT NULL} {
|
||||
db eval {INSERT INTO t2(x,y) VALUES($b,$cnt)}
|
||||
# puts "a,b,cnt = ($a,$b,$cnt)"
|
||||
incr i
|
||||
if {$i%2==1} {
|
||||
set bx [expr {$b+1000}]
|
||||
# puts "INSERT ($a),$bx"
|
||||
db eval {INSERT INTO t1(a,ax,b) VALUES(printf('(%s)',$a),random(),$bx)}
|
||||
} else {
|
||||
# puts "DELETE a=$a"
|
||||
db eval {DELETE FROM t1 WHERE a=$a}
|
||||
}
|
||||
db eval {COMMIT; BEGIN}
|
||||
}
|
||||
db one {COMMIT; SELECT count(*) FROM t1;}
|
||||
} {20}
|
||||
|
||||
finish_test
|
80
test/corruptJ.test
Normal file
80
test/corruptJ.test
Normal file
@@ -0,0 +1,80 @@
|
||||
# 2015-03-30
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# Corruption consisting of a database page that thinks it is a child
|
||||
# of itself.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix corruptJ
|
||||
|
||||
if {[permutation]=="mmap"} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
# Do not use a codec for tests in this file, as the database file is
|
||||
# manipulated directly using tcl scripts (using the [hexio_write] command).
|
||||
#
|
||||
do_not_use_codec
|
||||
database_may_be_corrupt
|
||||
|
||||
# Initialize the database.
|
||||
#
|
||||
do_execsql_test 1.1 {
|
||||
PRAGMA page_size=1024;
|
||||
PRAGMA auto_vacuum=0;
|
||||
CREATE TABLE t1(a,b);
|
||||
WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10)
|
||||
INSERT INTO t1(a,b) SELECT i, zeroblob(700) FROM c;
|
||||
} {}
|
||||
db close
|
||||
|
||||
# Corrupt the root page of the t1 table such that the left-child pointer
|
||||
# for the very first cell points back to the root. Then try to DROP the
|
||||
# table. The clearDatabasePage() routine should not loop.
|
||||
#
|
||||
do_test 1.2 {
|
||||
hexio_write test.db [expr {2*1024-2}] 02
|
||||
sqlite3 db test.db
|
||||
catchsql { DROP TABLE t1 }
|
||||
} {1 {database disk image is malformed}}
|
||||
|
||||
# Similar test using a WITHOUT ROWID table
|
||||
#
|
||||
do_test 2.1 {
|
||||
db close
|
||||
forcedelete test.db
|
||||
sqlite3 db test.db
|
||||
db eval {
|
||||
PRAGMA page_size=1024;
|
||||
PRAGMA auto_vacuum=0;
|
||||
CREATE TABLE t1(a,b,PRIMARY KEY(a,b)) WITHOUT ROWID;
|
||||
WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100)
|
||||
INSERT INTO t1(a,b) SELECT i, zeroblob(200) FROM c;
|
||||
}
|
||||
} {}
|
||||
|
||||
# The table is three levels deep. Corrupt the left child of an intermediate
|
||||
# page so that it points back to the root page.
|
||||
#
|
||||
do_test 2.2 {
|
||||
db close
|
||||
hexio_read test.db [expr {9*1024+391}] 8
|
||||
} {00000008814D0401}
|
||||
do_test 2.2b {
|
||||
hexio_write test.db [expr {9*1024+391}] 00000002
|
||||
sqlite3 db test.db
|
||||
catchsql { DROP TABLE t1 }
|
||||
} {0 {}}
|
||||
|
||||
finish_test
|
@@ -64,6 +64,7 @@ while {1} {
|
||||
if {[info exists ::log] && $::log!=""} {
|
||||
do_test win32lock-1.2-$delay1-log1 {
|
||||
regsub {\d+} $::log # x
|
||||
regsub { at line \d+} $x "" x
|
||||
set x
|
||||
} {{delayed #ms for lock/sharing conflict}}
|
||||
}
|
||||
@@ -112,6 +113,7 @@ while {1} {
|
||||
if {[info exists ::log] && $::log!=""} {
|
||||
do_test win32lock-2.2-$delay1-log1 {
|
||||
regsub {\d+} $::log # x
|
||||
regsub { at line \d+} $x "" x
|
||||
set x
|
||||
} {{delayed #ms for lock/sharing conflict}}
|
||||
}
|
||||
|
@@ -17,13 +17,13 @@
|
||||
# After the "tsrc" directory has been created and populated, run
|
||||
# this script:
|
||||
#
|
||||
# tclsh mksqlite3c.tcl
|
||||
# tclsh mksqlite3c-noext.tcl
|
||||
#
|
||||
# The amalgamated SQLite code will be written into sqlite3.c
|
||||
#
|
||||
|
||||
# Begin by reading the "sqlite3.h" header file. Extract the version number
|
||||
# from in this file. The versioon number is needed to generate the header
|
||||
# from in this file. The version number is needed to generate the header
|
||||
# comment of the amalgamation.
|
||||
#
|
||||
if {[lsearch $argv --nostatic]>=0} {
|
||||
@@ -80,9 +80,6 @@ if {$addstatic} {
|
||||
puts $out \
|
||||
{#ifndef SQLITE_PRIVATE
|
||||
# define SQLITE_PRIVATE static
|
||||
#endif
|
||||
#ifndef SQLITE_API
|
||||
# define SQLITE_API
|
||||
#endif}
|
||||
}
|
||||
|
||||
@@ -106,6 +103,7 @@ foreach hdr {
|
||||
pager.h
|
||||
parse.h
|
||||
pcache.h
|
||||
pragma.h
|
||||
sqlite3ext.h
|
||||
sqlite3.h
|
||||
sqliteicu.h
|
||||
@@ -113,12 +111,31 @@ foreach hdr {
|
||||
sqliteLimit.h
|
||||
vdbe.h
|
||||
vdbeInt.h
|
||||
vxworks.h
|
||||
wal.h
|
||||
whereInt.h
|
||||
} {
|
||||
set available_hdr($hdr) 1
|
||||
}
|
||||
set available_hdr(sqliteInt.h) 0
|
||||
|
||||
# These headers should be copied into the amalgamation without modifying any
|
||||
# of their function declarations or definitions.
|
||||
set varonly_hdr(sqlite3.h) 1
|
||||
|
||||
# These are the functions that accept a variable number of arguments. They
|
||||
# always need to use the "cdecl" calling convention even when another calling
|
||||
# convention (e.g. "stcall") is being used for the rest of the library.
|
||||
set cdecllist {
|
||||
sqlite3_config
|
||||
sqlite3_db_config
|
||||
sqlite3_log
|
||||
sqlite3_mprintf
|
||||
sqlite3_snprintf
|
||||
sqlite3_test_control
|
||||
sqlite3_vtab_config
|
||||
}
|
||||
|
||||
# 78 stars used for comment formatting.
|
||||
set s78 \
|
||||
{*****************************************************************************}
|
||||
@@ -135,21 +152,21 @@ proc section_comment {text} {
|
||||
|
||||
# Read the source file named $filename and write it into the
|
||||
# sqlite3.c output file. If any #include statements are seen,
|
||||
# process them approprately.
|
||||
# process them appropriately.
|
||||
#
|
||||
proc copy_file {filename} {
|
||||
global seen_hdr available_hdr out addstatic linemacros
|
||||
global seen_hdr available_hdr varonly_hdr cdecllist out addstatic linemacros
|
||||
set ln 0
|
||||
set tail [file tail $filename]
|
||||
section_comment "Begin file $tail"
|
||||
if {$linemacros} {puts $out "#line 1 \"$filename\""}
|
||||
set in [open $filename r]
|
||||
set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)}
|
||||
set declpattern {[a-zA-Z][a-zA-Z_0-9 ]+ \**(sqlite3[_a-zA-Z0-9]+)\(}
|
||||
set declpattern {([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3[_a-zA-Z0-9]+)(\(.*)}
|
||||
if {[file extension $filename]==".h"} {
|
||||
set declpattern " *$declpattern"
|
||||
}
|
||||
set declpattern ^$declpattern
|
||||
set declpattern ^$declpattern\$
|
||||
while {![eof $in]} {
|
||||
set line [gets $in]
|
||||
incr ln
|
||||
@@ -165,28 +182,51 @@ proc copy_file {filename} {
|
||||
if {$linemacros} {puts $out "#line [expr {$ln+1}] \"$filename\""}
|
||||
}
|
||||
} elseif {![info exists seen_hdr($hdr)]} {
|
||||
if {![regexp {/\*\s+amalgamator:\s+dontcache\s+\*/} $line]} {
|
||||
set seen_hdr($hdr) 1
|
||||
}
|
||||
puts $out $line
|
||||
} elseif {[regexp {/\*\s+amalgamator:\s+keep\s+\*/} $line]} {
|
||||
# This include file must be kept because there was a "keep"
|
||||
# directive inside of a line comment.
|
||||
puts $out $line
|
||||
} else {
|
||||
puts $out "/* $line */"
|
||||
# Comment out the entire line, replacing any nested comment
|
||||
# begin/end markers with the harmless substring "**".
|
||||
puts $out "/* [string map [list /* ** */ **] $line] */"
|
||||
}
|
||||
} elseif {[regexp {^#ifdef __cplusplus} $line]} {
|
||||
puts $out "#if 0"
|
||||
} elseif {!$linemacros && [regexp {^#line} $line]} {
|
||||
# Skip #line directives.
|
||||
} elseif {$addstatic && ![regexp {^(static|typedef)} $line]} {
|
||||
# Skip adding the SQLITE_PRIVATE or SQLITE_API keyword before
|
||||
# functions if this header file does not need it.
|
||||
if {![info exists varonly_hdr($tail)]
|
||||
&& [regexp $declpattern $line all rettype funcname rest]} {
|
||||
regsub {^SQLITE_API } $line {} line
|
||||
if {[regexp $declpattern $line all funcname]} {
|
||||
# Add the SQLITE_PRIVATE or SQLITE_API keyword before functions.
|
||||
# so that linkage can be modified at compile-time.
|
||||
if {[regexp {^sqlite3_} $funcname]} {
|
||||
puts $out "SQLITE_API $line"
|
||||
set line SQLITE_API
|
||||
append line " " [string trim $rettype]
|
||||
if {[string index $rettype end] ne "*"} {
|
||||
append line " "
|
||||
}
|
||||
if {[lsearch -exact $cdecllist $funcname] >= 0} {
|
||||
append line SQLITE_CDECL
|
||||
} else {
|
||||
append line SQLITE_STDCALL
|
||||
}
|
||||
append line " " $funcname $rest
|
||||
puts $out $line
|
||||
} else {
|
||||
puts $out "SQLITE_PRIVATE $line"
|
||||
}
|
||||
} elseif {[regexp $varpattern $line all varname]} {
|
||||
# Add the SQLITE_PRIVATE before variable declarations or
|
||||
# definitions for internal use
|
||||
regsub {^SQLITE_API } $line {} line
|
||||
if {![regexp {^sqlite3_} $varname]} {
|
||||
regsub {^extern } $line {} line
|
||||
puts $out "SQLITE_PRIVATE $line"
|
||||
@@ -198,9 +238,11 @@ proc copy_file {filename} {
|
||||
puts $out "SQLITE_API $line"
|
||||
}
|
||||
} elseif {[regexp {^(SQLITE_EXTERN )?void \(\*sqlite3IoTrace\)} $line]} {
|
||||
regsub {^SQLITE_API } $line {} line
|
||||
regsub {^SQLITE_EXTERN } $line {} line
|
||||
puts $out "SQLITE_PRIVATE $line"
|
||||
puts $out $line
|
||||
} elseif {[regexp {^void \(\*sqlite3Os} $line]} {
|
||||
regsub {^SQLITE_API } $line {} line
|
||||
puts $out "SQLITE_PRIVATE $line"
|
||||
} else {
|
||||
puts $out $line
|
||||
|
@@ -80,9 +80,6 @@ if {$addstatic} {
|
||||
puts $out \
|
||||
{#ifndef SQLITE_PRIVATE
|
||||
# define SQLITE_PRIVATE static
|
||||
#endif
|
||||
#ifndef SQLITE_API
|
||||
# define SQLITE_API
|
||||
#endif}
|
||||
}
|
||||
|
||||
@@ -129,6 +126,23 @@ foreach hdr {
|
||||
set available_hdr(sqliteInt.h) 0
|
||||
set available_hdr(sqlite3session.h) 0
|
||||
|
||||
# These headers should be copied into the amalgamation without modifying any
|
||||
# of their function declarations or definitions.
|
||||
set varonly_hdr(sqlite3.h) 1
|
||||
|
||||
# These are the functions that accept a variable number of arguments. They
|
||||
# always need to use the "cdecl" calling convention even when another calling
|
||||
# convention (e.g. "stcall") is being used for the rest of the library.
|
||||
set cdecllist {
|
||||
sqlite3_config
|
||||
sqlite3_db_config
|
||||
sqlite3_log
|
||||
sqlite3_mprintf
|
||||
sqlite3_snprintf
|
||||
sqlite3_test_control
|
||||
sqlite3_vtab_config
|
||||
}
|
||||
|
||||
# 78 stars used for comment formatting.
|
||||
set s78 \
|
||||
{*****************************************************************************}
|
||||
@@ -148,18 +162,18 @@ proc section_comment {text} {
|
||||
# process them appropriately.
|
||||
#
|
||||
proc copy_file {filename} {
|
||||
global seen_hdr available_hdr out addstatic linemacros
|
||||
global seen_hdr available_hdr varonly_hdr cdecllist out addstatic linemacros
|
||||
set ln 0
|
||||
set tail [file tail $filename]
|
||||
section_comment "Begin file $tail"
|
||||
if {$linemacros} {puts $out "#line 1 \"$filename\""}
|
||||
set in [open $filename r]
|
||||
set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)}
|
||||
set declpattern {[a-zA-Z][a-zA-Z_0-9 ]+ \**(sqlite3[_a-zA-Z0-9]+)\(}
|
||||
set declpattern {([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3[_a-zA-Z0-9]+)(\(.*)}
|
||||
if {[file extension $filename]==".h"} {
|
||||
set declpattern " *$declpattern"
|
||||
}
|
||||
set declpattern ^$declpattern
|
||||
set declpattern ^$declpattern\$
|
||||
while {![eof $in]} {
|
||||
set line [gets $in]
|
||||
incr ln
|
||||
@@ -193,18 +207,33 @@ proc copy_file {filename} {
|
||||
} elseif {!$linemacros && [regexp {^#line} $line]} {
|
||||
# Skip #line directives.
|
||||
} elseif {$addstatic && ![regexp {^(static|typedef)} $line]} {
|
||||
# Skip adding the SQLITE_PRIVATE or SQLITE_API keyword before
|
||||
# functions if this header file does not need it.
|
||||
if {![info exists varonly_hdr($tail)]
|
||||
&& [regexp $declpattern $line all rettype funcname rest]} {
|
||||
regsub {^SQLITE_API } $line {} line
|
||||
if {[regexp $declpattern $line all funcname]} {
|
||||
# Add the SQLITE_PRIVATE or SQLITE_API keyword before functions.
|
||||
# so that linkage can be modified at compile-time.
|
||||
if {[regexp {^sqlite3[a-z]*_} $funcname]} {
|
||||
puts $out "SQLITE_API $line"
|
||||
set line SQLITE_API
|
||||
append line " " [string trim $rettype]
|
||||
if {[string index $rettype end] ne "*"} {
|
||||
append line " "
|
||||
}
|
||||
if {[lsearch -exact $cdecllist $funcname] >= 0} {
|
||||
append line SQLITE_CDECL
|
||||
} else {
|
||||
append line SQLITE_STDCALL
|
||||
}
|
||||
append line " " $funcname $rest
|
||||
puts $out $line
|
||||
} else {
|
||||
puts $out "SQLITE_PRIVATE $line"
|
||||
}
|
||||
} elseif {[regexp $varpattern $line all varname]} {
|
||||
# Add the SQLITE_PRIVATE before variable declarations or
|
||||
# definitions for internal use
|
||||
regsub {^SQLITE_API } $line {} line
|
||||
if {![regexp {^sqlite3_} $varname]} {
|
||||
regsub {^extern } $line {} line
|
||||
puts $out "SQLITE_PRIVATE $line"
|
||||
@@ -216,9 +245,11 @@ proc copy_file {filename} {
|
||||
puts $out "SQLITE_API $line"
|
||||
}
|
||||
} elseif {[regexp {^(SQLITE_EXTERN )?void \(\*sqlite3IoTrace\)} $line]} {
|
||||
regsub {^SQLITE_API } $line {} line
|
||||
regsub {^SQLITE_EXTERN } $line {} line
|
||||
puts $out $line
|
||||
} elseif {[regexp {^void \(\*sqlite3Os} $line]} {
|
||||
regsub {^SQLITE_API } $line {} line
|
||||
puts $out "SQLITE_PRIVATE $line"
|
||||
} else {
|
||||
puts $out $line
|
||||
|
@@ -63,7 +63,7 @@ close $in
|
||||
# Set up patterns for recognizing API declarations.
|
||||
#
|
||||
set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+sqlite3_[_a-zA-Z0-9]+(\[|;| =)}
|
||||
set declpattern {^ *[a-zA-Z][a-zA-Z_0-9 ]+ \**sqlite3_[_a-zA-Z0-9]+\(}
|
||||
set declpattern {^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3_[_a-zA-Z0-9]+)(\(.*)$}
|
||||
|
||||
# Force the output to use unix line endings, even on Windows.
|
||||
fconfigure stdout -translation lf
|
||||
@@ -74,6 +74,19 @@ set filelist [subst {
|
||||
$TOP/ext/session/sqlite3session.h
|
||||
}]
|
||||
|
||||
# These are the functions that accept a variable number of arguments. They
|
||||
# always need to use the "cdecl" calling convention even when another calling
|
||||
# convention (e.g. "stcall") is being used for the rest of the library.
|
||||
set cdecllist {
|
||||
sqlite3_config
|
||||
sqlite3_db_config
|
||||
sqlite3_log
|
||||
sqlite3_mprintf
|
||||
sqlite3_snprintf
|
||||
sqlite3_test_control
|
||||
sqlite3_vtab_config
|
||||
}
|
||||
|
||||
# Process the source files.
|
||||
#
|
||||
foreach file $filelist {
|
||||
@@ -94,20 +107,22 @@ foreach file $filelist {
|
||||
regsub -- --VERSION-NUMBER-- $line $nVersion line
|
||||
regsub -- --SOURCE-ID-- $line "$zDate $zUuid" line
|
||||
|
||||
if {[regexp {define SQLITE_EXTERN extern} $line]} {
|
||||
puts $line
|
||||
puts [gets $in]
|
||||
puts ""
|
||||
puts "#ifndef SQLITE_API"
|
||||
puts "# define SQLITE_API"
|
||||
puts "#endif"
|
||||
set line ""
|
||||
}
|
||||
|
||||
if {([regexp $varpattern $line] && ![regexp {^ *typedef} $line])
|
||||
|| ([regexp $declpattern $line])
|
||||
} {
|
||||
if {[regexp $varpattern $line] && ![regexp {^ *typedef} $line]} {
|
||||
set line "SQLITE_API $line"
|
||||
} else {
|
||||
if {[regexp $declpattern $line all rettype funcname rest]} {
|
||||
set line SQLITE_API
|
||||
append line " " [string trim $rettype]
|
||||
if {[string index $rettype end] ne "*"} {
|
||||
append line " "
|
||||
}
|
||||
if {[lsearch -exact $cdecllist $funcname] >= 0} {
|
||||
append line SQLITE_CDECL
|
||||
} else {
|
||||
append line SQLITE_STDCALL
|
||||
}
|
||||
append line " " $funcname $rest
|
||||
}
|
||||
}
|
||||
puts $line
|
||||
}
|
||||
|
Reference in New Issue
Block a user