From f3e874868356277074833bb2e0f97ed5c689e58d Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 26 Mar 2015 14:29:51 +0000 Subject: [PATCH 01/21] Fix a harmless compiler warning in FTS3. FossilOrigin-Name: 1688f60c08cc9270948402d98a2333382aa32681 --- ext/fts3/fts3.c | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index c92463204c..46b499e96b 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -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: */ diff --git a/manifest b/manifest index 6fdfb0ad40..c1312f1107 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\san\sunreachable\sbranch\sinto\san\sassert(). -D 2015-03-25T18:29:10.982 +C Fix\sa\sharmless\scompiler\swarning\sin\sFTS3. +D 2015-03-26T14:29:51.209 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -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 @@ -1247,7 +1247,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 37866b4d483296ab9b7fcb9f5486695d4c2b8ddd -R 6f3611ab9d4988693f727ae20dc9c9e5 +P fb076b28c36975ff2e41440f22fe5de115c195da +R 8441601541e00ddcb253d7949a1f1256 U drh -Z 3f028f44e21ab0b1619e9687cba7cf7a +Z efb1de4d37ca897d2a6769bd7d529518 diff --git a/manifest.uuid b/manifest.uuid index 849f782137..5d911793d5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fb076b28c36975ff2e41440f22fe5de115c195da \ No newline at end of file +1688f60c08cc9270948402d98a2333382aa32681 \ No newline at end of file From 21aa6a1acbdd445284f4126178dff4ab078ac7db Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 26 Mar 2015 15:27:32 +0000 Subject: [PATCH 02/21] Provide source code line numbers for errors in the Windows VFS generated by the winLogIoerr() routine. FossilOrigin-Name: b5da0d93cd1a3c0917399af3775a32327b883c8e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index c1312f1107..d6bf4d8b95 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sharmless\scompiler\swarning\sin\sFTS3. -D 2015-03-26T14:29:51.209 +C Provide\ssource\scode\sline\snumbers\sfor\serrors\sin\sthe\sWindows\sVFS\sgenerated\nby\sthe\swinLogIoerr()\sroutine. +D 2015-03-26T15:27:32.905 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -215,7 +215,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 f65255fdc30c90bab195989776797e98dc89d709 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 @@ -1247,7 +1247,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 fb076b28c36975ff2e41440f22fe5de115c195da -R 8441601541e00ddcb253d7949a1f1256 +P 1688f60c08cc9270948402d98a2333382aa32681 +R 24f2e5bf8513d160bb9262017e93ddbd U drh -Z efb1de4d37ca897d2a6769bd7d529518 +Z d3e192564f0add8f7dcb502142bd9b66 diff --git a/manifest.uuid b/manifest.uuid index 5d911793d5..fb109a572d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1688f60c08cc9270948402d98a2333382aa32681 \ No newline at end of file +b5da0d93cd1a3c0917399af3775a32327b883c8e \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 7463778a2f..7a95b77a58 100644 --- a/src/os_win.c +++ b/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 ); } } @@ -2548,7 +2548,7 @@ static int winRead( 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); @@ -2659,7 +2659,7 @@ static int winWrite( 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)); return SQLITE_OK; @@ -4752,7 +4752,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 +4936,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 +4986,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", From 592f0cb15e44e69577d1f72b4586093ca48ea7e6 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 26 Mar 2015 17:04:23 +0000 Subject: [PATCH 03/21] Avoid leaving the malloc subsystem in a partially initialized state if the low-level initialization callback fails. FossilOrigin-Name: 3e872011ff5e27738c282f46d2b5803d94fe4b76 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/malloc.c | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index d6bf4d8b95..2e013a57eb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Provide\ssource\scode\sline\snumbers\sfor\serrors\sin\sthe\sWindows\sVFS\sgenerated\nby\sthe\swinLogIoerr()\sroutine. -D 2015-03-26T15:27:32.905 +C Avoid\sleaving\sthe\smalloc\ssubsystem\sin\sa\spartially\sinitialized\sstate\sif\nthe\slow-level\sinitialization\scallback\sfails. +D 2015-03-26T17:04:23.798 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -196,7 +196,7 @@ F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770 F src/loadext.c 86bd4e2fccd520b748cba52492ab60c4a770f660 F src/main.c 569d45ba9eb4fbdd631d53f440bcdb4a35ab1505 -F src/malloc.c e818a0db9ac0898f9dc74002f3a5baca32232d05 +F src/malloc.c 6a370b83d54e4bbf6f94021221c2a311cff26a18 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987 F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 @@ -1247,7 +1247,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 1688f60c08cc9270948402d98a2333382aa32681 -R 24f2e5bf8513d160bb9262017e93ddbd +P b5da0d93cd1a3c0917399af3775a32327b883c8e +R 9e8f7450055b4cee99317e6c8db6583a U drh -Z d3e192564f0add8f7dcb502142bd9b66 +Z af5a15dd737e6e7d08dff92682723060 diff --git a/manifest.uuid b/manifest.uuid index fb109a572d..22f0d978f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b5da0d93cd1a3c0917399af3775a32327b883c8e \ No newline at end of file +3e872011ff5e27738c282f46d2b5803d94fe4b76 \ No newline at end of file diff --git a/src/malloc.c b/src/malloc.c index 264d046ec8..f06e27d846 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -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; } /* From 56d89cbee327dcd97a129d4c77f01046b20e295a Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 26 Mar 2015 18:24:26 +0000 Subject: [PATCH 04/21] Revise Win32 locking test to account for recent log message changes. FossilOrigin-Name: 1bc76339e8542770bff7829a3dd346680950c0a5 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/win32lock.test | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 2e013a57eb..8c7cd354d7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sleaving\sthe\smalloc\ssubsystem\sin\sa\spartially\sinitialized\sstate\sif\nthe\slow-level\sinitialization\scallback\sfails. -D 2015-03-26T17:04:23.798 +C Revise\sWin32\slocking\stest\sto\saccount\sfor\srecent\slog\smessage\schanges. +D 2015-03-26T18:24:26.716 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1181,7 +1181,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 @@ -1247,7 +1247,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 b5da0d93cd1a3c0917399af3775a32327b883c8e -R 9e8f7450055b4cee99317e6c8db6583a -U drh -Z af5a15dd737e6e7d08dff92682723060 +P 3e872011ff5e27738c282f46d2b5803d94fe4b76 +R 72196f1f01590aeab1e66e07214515fd +U mistachkin +Z 13c90271975eca10437167897808ec14 diff --git a/manifest.uuid b/manifest.uuid index 22f0d978f9..1084c3d448 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3e872011ff5e27738c282f46d2b5803d94fe4b76 \ No newline at end of file +1bc76339e8542770bff7829a3dd346680950c0a5 \ No newline at end of file diff --git a/test/win32lock.test b/test/win32lock.test index cff1ed3d87..d1f3d1a06e 100644 --- a/test/win32lock.test +++ b/test/win32lock.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}} } From ccb43714da0768fc44aa666208236505e5703f53 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 26 Mar 2015 23:36:35 +0000 Subject: [PATCH 05/21] When syncing a memory mapped file on Windows, flush the mapped view as well. FossilOrigin-Name: df204049b9ec8dd3e43ed7dc251eaecedc05af4b --- manifest | 15 +++++++++------ manifest.uuid | 2 +- src/os_win.c | 47 +++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 8c7cd354d7..8ca2cb9aa2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Revise\sWin32\slocking\stest\sto\saccount\sfor\srecent\slog\smessage\schanges. -D 2015-03-26T18:24:26.716 +C When\ssyncing\sa\smemory\smapped\sfile\son\sWindows,\sflush\sthe\smapped\sview\sas\swell. +D 2015-03-26T23:36:35.332 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -215,7 +215,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 f65255fdc30c90bab195989776797e98dc89d709 +F src/os_win.c af359cc1f0acc6b091c971ef0cf77c1280048cd3 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 @@ -1247,7 +1247,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3e872011ff5e27738c282f46d2b5803d94fe4b76 -R 72196f1f01590aeab1e66e07214515fd +P 1bc76339e8542770bff7829a3dd346680950c0a5 +R 8fcf9359fa4528c262f390ec8d494656 +T *branch * winViewFlush +T *sym-winViewFlush * +T -sym-trunk * U mistachkin -Z 13c90271975eca10437167897808ec14 +Z 96541edc57aab968aa95035dbba0935a diff --git a/manifest.uuid b/manifest.uuid index 1084c3d448..e3897a191f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1bc76339e8542770bff7829a3dd346680950c0a5 \ No newline at end of file +df204049b9ec8dd3e43ed7dc251eaecedc05af4b \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 7a95b77a58..3fd310fc17 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -197,8 +197,10 @@ WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T); #endif /* SQLITE_OS_WINRT */ /* -** This file mapping API is common to both Win32 and WinRT. +** These file mapping APIs are common to both Win32 and WinRT. */ + +WINBASEAPI BOOL WINAPI FlushViewOfFile(LPCVOID, SIZE_T); WINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID); #endif /* SQLITE_WIN32_FILEMAPPING_API */ @@ -1083,6 +1085,15 @@ static struct win_syscall { #define osUuidCreateSequential \ ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[78].pCurrent) +#if !defined(SQLITE_NO_SYNC) && SQLITE_MAX_MMAP_SIZE>0 + { "FlushViewOfFile", (SYSCALL)FlushViewOfFile, 0 }, +#else + { "FlushViewOfFile", (SYSCALL)0, 0 }, +#endif + +#define osFlushViewOfFile \ + ((BOOL(WINAPI*)(LPCVOID,SIZE_T))aSyscall[79].pCurrent) + }; /* End of the overrideable system calls */ /* @@ -2753,8 +2764,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,19 +2781,38 @@ 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 +#if SQLITE_MAX_MMAP_SIZE>0 + if( pFile->pMapRegion ){ + if( osFlushViewOfFile(pFile->pMapRegion, 0) ){ + OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, " + "rc=SQLITE_OK\n", osGetCurrentProcessId(), + pFile, pFile->pMapRegion)); + }else{ + pFile->lastErrno = osGetLastError(); + OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, " + "rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(), + pFile, pFile->pMapRegion)); + return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno, + "winSync1", pFile->zPath); + } + } +#endif 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); + "winSync2", pFile->zPath); } #endif } @@ -5555,7 +5586,7 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==79 ); + assert( ArraySize(aSyscall)==80 ); /* get memory map allocation granularity */ memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); From 34a8065f495147ace8564548a97c91579d0b7028 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 27 Mar 2015 00:19:31 +0000 Subject: [PATCH 06/21] In the MSVC Makefile, make the DYNAMIC_SHELL option work without USE_STDCALL. FossilOrigin-Name: 25b46a9c7e03a84bee2ffddc6d7fd6ae280e9d7b --- Makefile.msc | 6 +++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 837fc003c0..7e6a077ffb 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -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 diff --git a/manifest b/manifest index 8c7cd354d7..f180feac72 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Revise\sWin32\slocking\stest\sto\saccount\sfor\srecent\slog\smessage\schanges. -D 2015-03-26T18:24:26.716 +C In\sthe\sMSVC\sMakefile,\smake\sthe\sDYNAMIC_SHELL\soption\swork\swithout\sUSE_STDCALL. +D 2015-03-27T00:19:31.300 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 3481e2dd260968742c715542db178c2bdd5db99f +F Makefile.msc 23e6eaa84569829c3e7f409513caa136e5bcaf2a F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 F VERSION 319eb1ced4b4d17a67730f2b7b85f15c1346cb60 @@ -1247,7 +1247,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 3e872011ff5e27738c282f46d2b5803d94fe4b76 -R 72196f1f01590aeab1e66e07214515fd +P 1bc76339e8542770bff7829a3dd346680950c0a5 +R 0d57eafd4468edd6e6285fb5978d1b4c U mistachkin -Z 13c90271975eca10437167897808ec14 +Z 9f68da42d0682346a204d1bd4bb0b359 diff --git a/manifest.uuid b/manifest.uuid index 1084c3d448..44cdf4be9e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1bc76339e8542770bff7829a3dd346680950c0a5 \ No newline at end of file +25b46a9c7e03a84bee2ffddc6d7fd6ae280e9d7b \ No newline at end of file From 9871a933c143dfe61281aaa6d8107dee7aab4650 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 27 Mar 2015 00:21:52 +0000 Subject: [PATCH 07/21] Using MSVC, get the sqlite3IoTrace variable working with the USE_STDCALL and/or DYNAMIC_SHELL options. FossilOrigin-Name: fe976c9130f6eecfa0a10347ee3f800f32051b89 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/main.c | 2 +- src/shell.c | 4 ++-- src/sqliteInt.h | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index f180feac72..3a717ccebb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sMSVC\sMakefile,\smake\sthe\sDYNAMIC_SHELL\soption\swork\swithout\sUSE_STDCALL. -D 2015-03-27T00:19:31.300 +C Using\sMSVC,\sget\sthe\ssqlite3IoTrace\svariable\sworking\swith\sthe\sUSE_STDCALL\sand/or\sDYNAMIC_SHELL\soptions. +D 2015-03-27T00:21:52.785 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -195,7 +195,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770 F src/loadext.c 86bd4e2fccd520b748cba52492ab60c4a770f660 -F src/main.c 569d45ba9eb4fbdd631d53f440bcdb4a35ab1505 +F src/main.c 40e333960d53f7d50ee8ce09d40431c87ea653f2 F src/malloc.c 6a370b83d54e4bbf6f94021221c2a311cff26a18 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987 @@ -231,11 +231,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 3ae1e53878d2804fe77b8c8f1f6ca287a0e5d80e +F src/shell.c f21e91ab78e7b681e5c3c8d7f7a5b92f5583ed7a F src/sqlite.h.in 278602140d49575e8708e643161f4263e428a02a F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d -F src/sqliteInt.h bedf15914c09bfb5fe3ec4e3f211a4a6fc42cd33 +F src/sqliteInt.h d02d2b85cb02a38bc442cf9302ec8209baf6771d F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179 F src/table.c e7a09215315a978057fb42c640f890160dbcc45e @@ -1247,7 +1247,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 1bc76339e8542770bff7829a3dd346680950c0a5 -R 0d57eafd4468edd6e6285fb5978d1b4c +P 25b46a9c7e03a84bee2ffddc6d7fd6ae280e9d7b +R a3ab1f66556079c5bd7cf506cd3f9f92 U mistachkin -Z 9f68da42d0682346a204d1bd4bb0b359 +Z 0ec554b2258cca84ae33b3fc6f4637d7 diff --git a/manifest.uuid b/manifest.uuid index 44cdf4be9e..88bef69794 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -25b46a9c7e03a84bee2ffddc6d7fd6ae280e9d7b \ No newline at end of file +fe976c9130f6eecfa0a10347ee3f800f32051b89 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 6967131143..d9ee77fab2 100644 --- a/src/main.c +++ b/src/main.c @@ -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 /* diff --git a/src/shell.c b/src/shell.c index b31ea16333..14ac9bc72d 100644 --- a/src/shell.c +++ b/src/shell.c @@ -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; @@ -3144,7 +3144,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 ){ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 9df6d1bc4e..3841c91f14 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3803,7 +3803,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) From 6f5a37a4649b800203006f23dbc63b0514d49517 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 27 Mar 2015 02:27:20 +0000 Subject: [PATCH 08/21] Fix the ".testctrl imposter" command in the command-line shell to be consistent in error reporting and results with the other .testctrl commands. FossilOrigin-Name: 0ec08ba8a0fa188146b071a489908332693ba59a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 3a717ccebb..ddfb25e98b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Using\sMSVC,\sget\sthe\ssqlite3IoTrace\svariable\sworking\swith\sthe\sUSE_STDCALL\sand/or\sDYNAMIC_SHELL\soptions. -D 2015-03-27T00:21:52.785 +C Fix\sthe\s".testctrl\simposter"\scommand\sin\sthe\scommand-line\sshell\sto\sbe\nconsistent\sin\serror\sreporting\sand\sresults\swith\sthe\sother\s.testctrl\ncommands. +D 2015-03-27T02:27:20.756 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -231,7 +231,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c f4d79e31ffa5820c2e3d1740baa5e9b190425f2b F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 72ffb62e2879956302140e9f6e6ae88aee36b0e5 -F src/shell.c f21e91ab78e7b681e5c3c8d7f7a5b92f5583ed7a +F src/shell.c 84a1593bd86aaa14f4da8a8f9b16fbc239d262aa F src/sqlite.h.in 278602140d49575e8708e643161f4263e428a02a F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d @@ -1247,7 +1247,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 25b46a9c7e03a84bee2ffddc6d7fd6ae280e9d7b -R a3ab1f66556079c5bd7cf506cd3f9f92 -U mistachkin -Z 0ec554b2258cca84ae33b3fc6f4637d7 +P fe976c9130f6eecfa0a10347ee3f800f32051b89 +R 13326ac5b127e703532d322e93f2a662 +U drh +Z b2f8062e547cfe60af29856c986c54f4 diff --git a/manifest.uuid b/manifest.uuid index 88bef69794..980d7d833a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fe976c9130f6eecfa0a10347ee3f800f32051b89 \ No newline at end of file +0ec08ba8a0fa188146b071a489908332693ba59a \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 14ac9bc72d..7ff3eb6cb0 100644 --- a/src/shell.c +++ b/src/shell.c @@ -3803,9 +3803,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; From ad1e55e55a869106c181ab278f89cc1bd6705b19 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 27 Mar 2015 18:20:25 +0000 Subject: [PATCH 09/21] Enhancements to OSTRACE usage in the Win32 VFS. FossilOrigin-Name: ab5800291e1908b5b51d912feeacf748dc9be14b --- manifest | 14 ++++++------ manifest.uuid | 2 +- src/os_win.c | 60 +++++++++++++++++++++++++++++++++------------------ 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/manifest b/manifest index ddfb25e98b..98c814021d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\s".testctrl\simposter"\scommand\sin\sthe\scommand-line\sshell\sto\sbe\nconsistent\sin\serror\sreporting\sand\sresults\swith\sthe\sother\s.testctrl\ncommands. -D 2015-03-27T02:27:20.756 +C Enhancements\sto\sOSTRACE\susage\sin\sthe\sWin32\sVFS. +D 2015-03-27T18:20:25.776 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -215,7 +215,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 f65255fdc30c90bab195989776797e98dc89d709 +F src/os_win.c 865ba15878eded98bb29a97ac898f2a799dc481a F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 @@ -1247,7 +1247,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 fe976c9130f6eecfa0a10347ee3f800f32051b89 -R 13326ac5b127e703532d322e93f2a662 -U drh -Z b2f8062e547cfe60af29856c986c54f4 +P 0ec08ba8a0fa188146b071a489908332693ba59a +R 5fa56a67857aa9aa0bfe9c8eabbd7f2b +U mistachkin +Z 22e64f81a05ea0084d0b656c0478e6e9 diff --git a/manifest.uuid b/manifest.uuid index 980d7d833a..50a77b66aa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0ec08ba8a0fa188146b071a489908332693ba59a \ No newline at end of file +ab5800291e1908b5b51d912feeacf748dc9be14b \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 7a95b77a58..e40114000d 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -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( offsetmmapSize ){ 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,7 +2549,8 @@ 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); } @@ -2552,11 +2558,13 @@ static int winRead( 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( offsetmmapSize ){ 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, __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); } From 116f0be0244e2dc92d2a54b6a994f3a080d756ac Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 30 Mar 2015 23:43:56 +0000 Subject: [PATCH 10/21] Prevent a possible infinite loop when trying to DROP a table from a corrupt database. FossilOrigin-Name: 395bb3e677a6551b06ba96fc58c393132b93d1e8 --- manifest | 15 +++++---- manifest.uuid | 2 +- src/btree.c | 7 ++-- test/corruptJ.test | 80 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 test/corruptJ.test diff --git a/manifest b/manifest index 98c814021d..830165f1d1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhancements\sto\sOSTRACE\susage\sin\sthe\sWin32\sVFS. -D 2015-03-27T18:20:25.776 +C Prevent\sa\spossible\sinfinite\sloop\swhen\strying\sto\sDROP\sa\stable\sfrom\na\scorrupt\sdatabase. +D 2015-03-30T23:43:56.191 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -173,7 +173,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 4f305e554d7d207375c3e29ab0335bd5a473a125 +F src/btree.c e565971caa0265d3cabc8b15d7017899a7814051 F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 F src/btreeInt.h 2bfefc01875d8da066504c233ec259fcb3b2ef72 F src/build.c 0419bba592c22f6d00e6d57a2ca7136720d02c1a @@ -433,6 +433,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 @@ -1247,7 +1248,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 0ec08ba8a0fa188146b071a489908332693ba59a -R 5fa56a67857aa9aa0bfe9c8eabbd7f2b -U mistachkin -Z 22e64f81a05ea0084d0b656c0478e6e9 +P ab5800291e1908b5b51d912feeacf748dc9be14b +R 7b7ce803eb05ad2f210c6eb94fdd8e1c +U drh +Z 53c46ef4969a0037acc3578044ba6e9e diff --git a/manifest.uuid b/manifest.uuid index 50a77b66aa..b562506b7f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ab5800291e1908b5b51d912feeacf748dc9be14b \ No newline at end of file +395bb3e677a6551b06ba96fc58c393132b93d1e8 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 52f29428f7..a4eae64025 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7978,6 +7978,7 @@ static int clearDatabasePage( int i; int hdr; u16 szCell; + u8 hasChildren; assert( sqlite3_mutex_held(pBt->mutex) ); if( pgno>btreePagecount(pBt) ){ @@ -7986,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; inCell; 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 ){ diff --git a/test/corruptJ.test b/test/corruptJ.test new file mode 100644 index 0000000000..ec884cc9b4 --- /dev/null +++ b/test/corruptJ.test @@ -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 From bc8a6b31b69b202cd66e6c4f51beb27cf01d9c11 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Mar 2015 11:42:23 +0000 Subject: [PATCH 11/21] Ensure that comparison operators do not mess up the MEM_Dyn flag on registers when reverting affinity changes. FossilOrigin-Name: 02e3c88fbf6abdcf3975fb0fb71972b0ab30da30 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 830165f1d1..8a2a10e6c4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Prevent\sa\spossible\sinfinite\sloop\swhen\strying\sto\sDROP\sa\stable\sfrom\na\scorrupt\sdatabase. -D 2015-03-30T23:43:56.191 +C Ensure\sthat\scomparison\soperators\sdo\snot\smess\sup\sthe\sMEM_Dyn\sflag\son\sregisters\nwhen\sreverting\saffinity\schanges. +D 2015-03-31T11:42:23.599 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -293,7 +293,7 @@ F src/update.c 3c4ecc282accf12d39edb8d524cf089645e55a13 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c 98a7627ca48ad3265b6940915a1d08355eb3fc7e F src/vacuum.c 9460b9de7b2d4e34b0d374894aa6c8a0632be8ec -F src/vdbe.c bbfede5a8a6908b3ddcd55fdb0b2301288dd4754 +F src/vdbe.c 86ae6f4774410868af41bd839b72b7081ff03e78 F src/vdbe.h 6fc69d9c5e146302c56e163cb4b31d1ee64a18c3 F src/vdbeInt.h 9cbaa84f53ddd2d09a0cf61a94337a3a035d08a0 F src/vdbeapi.c 583d56b129dd27f12bed518270de9ebe521e6a75 @@ -1248,7 +1248,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 ab5800291e1908b5b51d912feeacf748dc9be14b -R 7b7ce803eb05ad2f210c6eb94fdd8e1c +P 395bb3e677a6551b06ba96fc58c393132b93d1e8 +R 32fb3cc594bfc0fa1b6de17fb4714420 U drh -Z 53c46ef4969a0037acc3578044ba6e9e +Z 6c9b38c06aabdc797714a509c4f32228 diff --git a/manifest.uuid b/manifest.uuid index b562506b7f..b6c886cfee 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -395bb3e677a6551b06ba96fc58c393132b93d1e8 \ No newline at end of file +02e3c88fbf6abdcf3975fb0fb71972b0ab30da30 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index ec5e6d7442..f2de90d14c 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1920,11 +1920,15 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ testcase( pIn1->flags & MEM_Int ); testcase( pIn1->flags & MEM_Real ); sqlite3VdbeMemStringify(pIn1, encoding, 1); + testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) ); + flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask); } if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){ testcase( pIn3->flags & MEM_Int ); testcase( pIn3->flags & MEM_Real ); sqlite3VdbeMemStringify(pIn3, encoding, 1); + testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) ); + flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask); } } assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); @@ -1961,7 +1965,9 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ } } /* Undo any changes made by applyAffinity() to the input registers. */ + assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) ); pIn1->flags = flags1; + assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) ); pIn3->flags = flags3; break; } From fe0ba71112dc8703ba4fcc1bbef2837b635d210e Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Mar 2015 13:46:13 +0000 Subject: [PATCH 12/21] Add the "mptest" target to Makefile.msc FossilOrigin-Name: 1e814e0bd116ad5a05ab9f0ebed7e21b23ed0681 --- Makefile.msc | 14 ++++++++++++++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 7e6a077ffb..14b49082bd 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1158,6 +1158,20 @@ mptester.exe: $(TOP)\mptest\mptest.c $(SHELL_CORE_DEP) $(LIBRESOBJS) sqlite3.h $(LTLINK) $(SHELL_COMPILE_OPTS) $(TOP)\mptest\mptest.c \ /link $(LTLINKOPTS) $(LTLIBPATHS) $(SHELL_LINK_OPTS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS) +MPTEST1=mptester mptest.db $(TOP)/mptest/crash01.test --repeat 20 +MPTEST2=mptester mptest.db $(TOP)/mptest/multiwrite01.test --repeat 20 +mptest: mptester.exe + del /Q mptest.db + $(MPTEST1) --journalmode DELETE + $(MPTEST2) --journalmode WAL + $(MPTEST1) --journalmode WAL + $(MPTEST2) --journalmode PERSIST + $(MPTEST1) --journalmode PERSIST + $(MPTEST2) --journalmode TRUNCATE + $(MPTEST1) --journalmode TRUNCATE + $(MPTEST2) --journalmode DELETE + + # This target creates a directory named "tsrc" and fills it with # copies of all of the C source code and header files needed to # build on the target system. Some of the C source code and header diff --git a/manifest b/manifest index 8a2a10e6c4..698734f7c6 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Ensure\sthat\scomparison\soperators\sdo\snot\smess\sup\sthe\sMEM_Dyn\sflag\son\sregisters\nwhen\sreverting\saffinity\schanges. -D 2015-03-31T11:42:23.599 +C Add\sthe\s"mptest"\starget\sto\sMakefile.msc +D 2015-03-31T13:46:13.387 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 23e6eaa84569829c3e7f409513caa136e5bcaf2a +F Makefile.msc d7e2bcf6634197e69628e632d441646a84bfdca8 F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 F VERSION 319eb1ced4b4d17a67730f2b7b85f15c1346cb60 @@ -1248,7 +1248,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 395bb3e677a6551b06ba96fc58c393132b93d1e8 -R 32fb3cc594bfc0fa1b6de17fb4714420 +P 02e3c88fbf6abdcf3975fb0fb71972b0ab30da30 +R d91812f133db0a587c3c0ca8a4eb33d5 U drh -Z 6c9b38c06aabdc797714a509c4f32228 +Z 3c6ff9ce8b6355a815c81088cec6c2b3 diff --git a/manifest.uuid b/manifest.uuid index b6c886cfee..37ec8cea3c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -02e3c88fbf6abdcf3975fb0fb71972b0ab30da30 \ No newline at end of file +1e814e0bd116ad5a05ab9f0ebed7e21b23ed0681 \ No newline at end of file From 8773b858e1f59737c2c958a17f67569fd8319254 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Mar 2015 14:18:29 +0000 Subject: [PATCH 13/21] Additional logging information output by mptester. FossilOrigin-Name: 0cbbf6e4571ffef102c0e515f29166f2f2022126 --- manifest | 12 ++++++------ manifest.uuid | 2 +- mptest/mptest.c | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 698734f7c6..34569201a8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"mptest"\starget\sto\sMakefile.msc -D 2015-03-31T13:46:13.387 +C Additional\slogging\sinformation\soutput\sby\smptester. +D 2015-03-31T14:18:29.822 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -160,7 +160,7 @@ F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 F mptest/crash02.subtest f4ef05adcd15d60e5d2bd654204f2c008b519df8 -F mptest/mptest.c 1e464f41f1bbc6578d6925043da56170f83aea96 +F mptest/mptest.c 4691e08e1fc114edd8e1875f88393718f70ba480 F mptest/multiwrite01.test dab5c5f8f9534971efce679152c5146da265222d F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b @@ -1248,7 +1248,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 02e3c88fbf6abdcf3975fb0fb71972b0ab30da30 -R d91812f133db0a587c3c0ca8a4eb33d5 +P 1e814e0bd116ad5a05ab9f0ebed7e21b23ed0681 +R bfc4505f6e856cbd418142922d77fee6 U drh -Z 3c6ff9ce8b6355a815c81088cec6c2b3 +Z 6eef793d1a736aa92f954ef3555b0150 diff --git a/manifest.uuid b/manifest.uuid index 37ec8cea3c..e135de6357 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1e814e0bd116ad5a05ab9f0ebed7e21b23ed0681 \ No newline at end of file +0cbbf6e4571ffef102c0e515f29166f2f2022126 \ No newline at end of file diff --git a/mptest/mptest.c b/mptest/mptest.c index 40c14bc87a..1efdc0319a 100644 --- a/mptest/mptest.c +++ b/mptest/mptest.c @@ -1312,6 +1312,9 @@ int SQLITE_CDECL main(int argc, char **argv){ GETPID(), iClient); }else{ if( g.iTrace>0 ){ + printf("BEGIN: %s", argv[0]); + for(i=1; i0; } From 96e285692a92a82597736c5a89f03ed032b2c0e3 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Mar 2015 14:31:41 +0000 Subject: [PATCH 14/21] Fix the corruptJ.test case so that it works with and without SQLITE_SECURE_DELETE. FossilOrigin-Name: 0c0ecfd68573957553b966229a67bfcd10ce4b99 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/corruptJ.test | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 34569201a8..64f10f7deb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\slogging\sinformation\soutput\sby\smptester. -D 2015-03-31T14:18:29.822 +C Fix\sthe\scorruptJ.test\scase\sso\sthat\sit\sworks\swith\sand\swithout\nSQLITE_SECURE_DELETE. +D 2015-03-31T14:31:41.936 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -433,7 +433,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/corruptJ.test 9e29e7a81ee3b6ac50f77ea7a9e2f3fa03f32d91 F test/cost.test 19d314526616ce4473eb4e4e450fcb94499ce318 F test/count.test 42a251178e32f617eda33f76236a7f79825a50b5 F test/coveridxscan.test cdb47d01acc4a634a34fd25abe85189e0d0f1e62 @@ -1248,7 +1248,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 1e814e0bd116ad5a05ab9f0ebed7e21b23ed0681 -R bfc4505f6e856cbd418142922d77fee6 +P 0cbbf6e4571ffef102c0e515f29166f2f2022126 +R 855ca787fb7bd1ab9ab088557a4f09bc U drh -Z 6eef793d1a736aa92f954ef3555b0150 +Z 3d4ee993730e7b33e6803497c50a3fdc diff --git a/manifest.uuid b/manifest.uuid index e135de6357..5400bc696e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0cbbf6e4571ffef102c0e515f29166f2f2022126 \ No newline at end of file +0c0ecfd68573957553b966229a67bfcd10ce4b99 \ No newline at end of file diff --git a/test/corruptJ.test b/test/corruptJ.test index ec884cc9b4..c08e628e2d 100644 --- a/test/corruptJ.test +++ b/test/corruptJ.test @@ -74,7 +74,7 @@ do_test 2.2 { do_test 2.2b { hexio_write test.db [expr {9*1024+391}] 00000002 sqlite3 db test.db - catchsql { DROP TABLE t1 } -} {0 {}} + catchsql { PRAGMA secure_delete=ON; DROP TABLE t1; } +} {1 {database disk image is malformed}} finish_test From 1cc0d11a167a1d25a1784c3ef4a6896636889299 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Mar 2015 15:15:48 +0000 Subject: [PATCH 15/21] Fix harmless compiler warnings in lemon.c FossilOrigin-Name: bbe7dcda689a25860f2104804f00ba0a720c1372 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lemon.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 64f10f7deb..f76a238037 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\scorruptJ.test\scase\sso\sthat\sit\sworks\swith\sand\swithout\nSQLITE_SECURE_DELETE. -D 2015-03-31T14:31:41.936 +C Fix\sharmless\scompiler\swarnings\sin\slemon.c +D 2015-03-31T15:15:48.726 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1206,7 +1206,7 @@ F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c 1864c4fe4a72b1bb28f1792b60504804fe82c5d2 +F tool/lemon.c ae5f61e3b164d35955777b20d6febcbaf0950702 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/logest.c eef612f8adf4d0993dafed0416064cf50d5d33c6 F tool/mkautoconfamal.sh d1a2da0e15b2ed33d60af35c7e9d483f13a8eb9f @@ -1248,7 +1248,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 0cbbf6e4571ffef102c0e515f29166f2f2022126 -R 855ca787fb7bd1ab9ab088557a4f09bc +P 0c0ecfd68573957553b966229a67bfcd10ce4b99 +R f295c13e7a998be1a5a78140716d3389 U drh -Z 3d4ee993730e7b33e6803497c50a3fdc +Z 1c953be9eacdcbbbb1c665e7b3932b7e diff --git a/manifest.uuid b/manifest.uuid index 5400bc696e..544169567d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0c0ecfd68573957553b966229a67bfcd10ce4b99 \ No newline at end of file +bbe7dcda689a25860f2104804f00ba0a720c1372 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 4ada425d69..cc3066bec0 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -1731,7 +1731,7 @@ static char *msort( char *ep; char *set[LISTSIZE]; int i; - offset = (unsigned long)next - (unsigned long)list; + offset = (unsigned long)((char*)next - (char*)list); for(i=0; i Date: Tue, 31 Mar 2015 16:33:08 +0000 Subject: [PATCH 16/21] Handle very large URI pathnames for in-memory shared-cache databases. FossilOrigin-Name: 586a94e85bc13700a2093734711c1367fa814b8c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/btree.c | 6 ++++-- test/attach.test | 12 ++++++++++++ 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index f76a238037..a38babcf26 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\slemon.c -D 2015-03-31T15:15:48.726 +C Handle\svery\slarge\sURI\spathnames\sfor\sin-memory\sshared-cache\sdatabases. +D 2015-03-31T16:33:08.816 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -173,7 +173,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 e565971caa0265d3cabc8b15d7017899a7814051 +F src/btree.c 525f19f01d5976dbc12e83e7339e41488de79183 F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 F src/btreeInt.h 2bfefc01875d8da066504c233ec259fcb3b2ef72 F src/build.c 0419bba592c22f6d00e6d57a2ca7136720d02c1a @@ -340,7 +340,7 @@ F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7 F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a F test/async5.test 383ab533fdb9f7ad228cc99ee66e1acb34cc0dc0 F test/atof1.test 08a61df9365c341f334a65f4348897312d8f3db7 -F test/attach.test 0d112b7713611fdf0340260192749737135fda5f +F test/attach.test 437107943f14d131cf5efc2ae5305a94d7cb1d58 F test/attach2.test 0ec5defa340363de6cd50fd595046465e9aaba2d F test/attach3.test 359eb65d00102cdfcef6fa4e81dc1648f8f80b27 F test/attach4.test 53bf502f17647c6d6c5add46dda6bac8b6f4665c @@ -1248,7 +1248,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 0c0ecfd68573957553b966229a67bfcd10ce4b99 -R f295c13e7a998be1a5a78140716d3389 +P bbe7dcda689a25860f2104804f00ba0a720c1372 +R 6f0e4814d1e4f882b35ba2b9dccc56cc U drh -Z 1c953be9eacdcbbbb1c665e7b3932b7e +Z d85481fb8858c2d74f205f2246e5afa6 diff --git a/manifest.uuid b/manifest.uuid index 544169567d..7c14a1b036 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bbe7dcda689a25860f2104804f00ba0a720c1372 \ No newline at end of file +586a94e85bc13700a2093734711c1367fa814b8c \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index a4eae64025..b497cd7468 100644 --- a/src/btree.c +++ b/src/btree.c @@ -1959,16 +1959,18 @@ int sqlite3BtreeOpen( */ if( isTempDb==0 && (isMemdb==0 || (vfsFlags&SQLITE_OPEN_URI)!=0) ){ if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){ + int nFilename = sqlite3Strlen30(zFilename)+1; int nFullPathname = pVfs->mxPathname+1; - char *zFullPathname = sqlite3Malloc(nFullPathname); + char *zFullPathname = sqlite3Malloc(MAX(nFullPathname,nFilename)); MUTEX_LOGIC( sqlite3_mutex *mutexShared; ) + p->sharable = 1; if( !zFullPathname ){ sqlite3_free(p); return SQLITE_NOMEM; } if( isMemdb ){ - memcpy(zFullPathname, zFilename, sqlite3Strlen30(zFilename)+1); + memcpy(zFullPathname, zFilename, nFilename); }else{ rc = sqlite3OsFullPathname(pVfs, zFilename, nFullPathname, zFullPathname); diff --git a/test/attach.test b/test/attach.test index be5f9881c3..31c24e61d9 100644 --- a/test/attach.test +++ b/test/attach.test @@ -859,4 +859,16 @@ do_test attach-10.2 { }] 9 end } {4 noname {} 5 inmem {}} +# Attach with a very long URI filename. +# +db close +sqlite3 db test.db -uri 1 +do_execsql_test attach-11.1 { + ATTACH printf('file:%09000x/x.db?mode=memory&cache=shared',1) AS aux1; + CREATE TABLE aux1.t1(x,y); + INSERT INTO aux1.t1(x,y) VALUES(1,2),(3,4); + SELECT * FROM aux1.t1; +} {1 2 3 4} + + finish_test From 4d2daba467b1d1c53cb1d1d471df9126ae4b6873 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 31 Mar 2015 16:42:16 +0000 Subject: [PATCH 17/21] Minor tweaks to the MSVC Makefile. FossilOrigin-Name: 7244ea59ede8aa2c7d1dc2c85268e12ddd452e27 --- Makefile.msc | 8 ++++---- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 14b49082bd..5330f8962f 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1158,10 +1158,11 @@ mptester.exe: $(TOP)\mptest\mptest.c $(SHELL_CORE_DEP) $(LIBRESOBJS) sqlite3.h $(LTLINK) $(SHELL_COMPILE_OPTS) $(TOP)\mptest\mptest.c \ /link $(LTLINKOPTS) $(LTLIBPATHS) $(SHELL_LINK_OPTS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS) -MPTEST1=mptester mptest.db $(TOP)/mptest/crash01.test --repeat 20 -MPTEST2=mptester mptest.db $(TOP)/mptest/multiwrite01.test --repeat 20 +MPTEST1 = mptester mptest.db $(TOP)/mptest/crash01.test --repeat 20 +MPTEST2 = mptester mptest.db $(TOP)/mptest/multiwrite01.test --repeat 20 + mptest: mptester.exe - del /Q mptest.db + del /Q mptest.db 2>NUL $(MPTEST1) --journalmode DELETE $(MPTEST2) --journalmode WAL $(MPTEST1) --journalmode WAL @@ -1171,7 +1172,6 @@ mptest: mptester.exe $(MPTEST1) --journalmode TRUNCATE $(MPTEST2) --journalmode DELETE - # This target creates a directory named "tsrc" and fills it with # copies of all of the C source code and header files needed to # build on the target system. Some of the C source code and header diff --git a/manifest b/manifest index a38babcf26..78a4b72821 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Handle\svery\slarge\sURI\spathnames\sfor\sin-memory\sshared-cache\sdatabases. -D 2015-03-31T16:33:08.816 +C Minor\stweaks\sto\sthe\sMSVC\sMakefile. +D 2015-03-31T16:42:16.959 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc d7e2bcf6634197e69628e632d441646a84bfdca8 +F Makefile.msc a8d817fa486d8c88dfbd19ae6a6567d9d350de39 F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 F VERSION 319eb1ced4b4d17a67730f2b7b85f15c1346cb60 @@ -1248,7 +1248,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 bbe7dcda689a25860f2104804f00ba0a720c1372 -R 6f0e4814d1e4f882b35ba2b9dccc56cc -U drh -Z d85481fb8858c2d74f205f2246e5afa6 +P 586a94e85bc13700a2093734711c1367fa814b8c +R dda30a84a02345c3ad5a29c2256cdbe0 +U mistachkin +Z 140263b8fa48f28f6823c13e70219b7f diff --git a/manifest.uuid b/manifest.uuid index 7c14a1b036..6d3dfcae53 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -586a94e85bc13700a2093734711c1367fa814b8c \ No newline at end of file +7244ea59ede8aa2c7d1dc2c85268e12ddd452e27 \ No newline at end of file From d881ce8fa74bc5bf5734cda3f045a0bc2a804574 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Mar 2015 17:01:52 +0000 Subject: [PATCH 18/21] Fix configure.ac and Makefile.in so that they generate pkgIndex.tcl correctly. FossilOrigin-Name: 3deff25249c59b7fc1b6eb65dda39736955679c6 --- Makefile.in | 2 +- configure | 30 ++++++++++++++++-------------- configure.ac | 1 + manifest | 18 +++++++++--------- manifest.uuid | 2 +- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Makefile.in b/Makefile.in index 4ac06938fd..2177488f9b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1059,7 +1059,7 @@ install: sqlite3$(BEXE) lib_install sqlite3.h sqlite3.pc ${HAVE_TCL:1=tcl_instal $(INSTALL) -m 0644 sqlite3.pc $(DESTDIR)$(pkgconfigdir) pkgIndex.tcl: - echo 'package ifneeded sqlite3 $(RELEASE) [list load $(TCLLIBDIR)/libtclsqlite3.so sqlite3]' > $@ + echo 'package ifneeded sqlite3 $(RELEASE) [list load $(TCLLIBDIR)/libtclsqlite3$(SHLIB_SUFFIX) sqlite3]' > $@ tcl_install: lib_install libtclsqlite3.la pkgIndex.tcl $(INSTALL) -d $(DESTDIR)$(TCLLIBDIR) $(LTINSTALL) libtclsqlite3.la $(DESTDIR)$(TCLLIBDIR) diff --git a/configure b/configure index 0c519e2216..d259324bdd 100755 --- a/configure +++ b/configure @@ -884,6 +884,7 @@ TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC +TCL_SHLIB_SUFFIX HAVE_TCL TARGET_READLINE_LIBS TARGET_READLINE_INC @@ -3724,13 +3725,13 @@ if test "${lt_cv_nm_interface+set}" = set; then else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3727: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3728: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3730: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3731: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3733: output\"" >&5) + (eval echo "\"\$as_me:3734: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -4952,7 +4953,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 4955 "configure"' > conftest.$ac_ext + echo '#line 4956 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6821,11 +6822,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6824: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6825: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6828: \$? = $ac_status" >&5 + echo "$as_me:6829: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7160,11 +7161,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7163: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7164: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7167: \$? = $ac_status" >&5 + echo "$as_me:7168: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7265,11 +7266,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7268: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7269: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7272: \$? = $ac_status" >&5 + echo "$as_me:7273: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7320,11 +7321,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7323: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7324: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7327: \$? = $ac_status" >&5 + echo "$as_me:7328: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -10133,7 +10134,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10136 "configure" +#line 10137 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10229,7 +10230,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10232 "configure" +#line 10233 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12827,6 +12828,7 @@ $as_echo "file not found" >&6; } + fi fi if test "${use_tcl}" = "no" ; then diff --git a/configure.ac b/configure.ac index 00ecf453af..6a1188842a 100644 --- a/configure.ac +++ b/configure.ac @@ -430,6 +430,7 @@ if test "${use_tcl}" = "yes" ; then AC_SUBST(TCL_STUB_LIB_FILE) AC_SUBST(TCL_STUB_LIB_FLAG) AC_SUBST(TCL_STUB_LIB_SPEC) + AC_SUBST(TCL_SHLIB_SUFFIX) fi fi if test "${use_tcl}" = "no" ; then diff --git a/manifest b/manifest index 78a4b72821..9e2a939d3b 100644 --- a/manifest +++ b/manifest @@ -1,7 +1,7 @@ -C Minor\stweaks\sto\sthe\sMSVC\sMakefile. -D 2015-03-31T16:42:16.959 +C Fix\sconfigure.ac\sand\sMakefile.in\sso\sthat\sthey\sgenerate\spkgIndex.tcl\scorrectly. +D 2015-03-31T17:01:52.572 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb +F Makefile.in 00d12636df7a5b08af09116bcd6c7bfd49b8b3b4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.msc a8d817fa486d8c88dfbd19ae6a6567d9d350de39 F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 @@ -38,8 +38,8 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 42b71ad3fe21c9e88fa59e8458ca1a6bc72eb0c0 F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 613b220c2f2c7adcd50eb5ee4144ab581a150b47 x -F configure.ac 6a8d145aea6d81f0b90013340780e43ed74fd5f4 +F configure 8b18c2378805a1d8aaca85d293671f450dd3c723 x +F configure.ac 0b775d383c536bbaafc1e46dd3cbb81a7ea11aeb F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html 334dbf6621b8fb8790297ec1abf3cfa4621709d1 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 @@ -1248,7 +1248,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 586a94e85bc13700a2093734711c1367fa814b8c -R dda30a84a02345c3ad5a29c2256cdbe0 -U mistachkin -Z 140263b8fa48f28f6823c13e70219b7f +P 7244ea59ede8aa2c7d1dc2c85268e12ddd452e27 +R 975c1f85d87faa80fd42aac5b24ed9ba +U drh +Z 016bf5cf61fe366d051895307d7b2ae3 diff --git a/manifest.uuid b/manifest.uuid index 6d3dfcae53..d92c73c696 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7244ea59ede8aa2c7d1dc2c85268e12ddd452e27 \ No newline at end of file +3deff25249c59b7fc1b6eb65dda39736955679c6 \ No newline at end of file From 8237f6d180d0233a4abac22e12e5f52f6497fd8f Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Mar 2015 17:32:06 +0000 Subject: [PATCH 19/21] Change the sqlite3_log() message generated on a retry after delay in os_win to be an SQLITE_NOTICE instead of SQLITE_IOERR. FossilOrigin-Name: 5d533eee049e63b3700f5ef7c28c588afccde57a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 9e2a939d3b..d5d1701f1e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sconfigure.ac\sand\sMakefile.in\sso\sthat\sthey\sgenerate\spkgIndex.tcl\scorrectly. -D 2015-03-31T17:01:52.572 +C Change\sthe\ssqlite3_log()\smessage\sgenerated\son\sa\sretry\safter\sdelay\sin\sos_win\nto\sbe\san\sSQLITE_NOTICE\sinstead\sof\sSQLITE_IOERR. +D 2015-03-31T17:32:06.290 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 00d12636df7a5b08af09116bcd6c7bfd49b8b3b4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -215,7 +215,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 865ba15878eded98bb29a97ac898f2a799dc481a +F src/os_win.c 23c2d1fab9b44e728e7d3ac0c82d5ac2a96de290 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 @@ -1248,7 +1248,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 7244ea59ede8aa2c7d1dc2c85268e12ddd452e27 -R 975c1f85d87faa80fd42aac5b24ed9ba +P 3deff25249c59b7fc1b6eb65dda39736955679c6 +R 5464b14f38d360ccc6fa7360d378f7df U drh -Z 016bf5cf61fe366d051895307d7b2ae3 +Z f2a2061ec6a7f778916e1fed0b96d2ff diff --git a/manifest.uuid b/manifest.uuid index d92c73c696..1069e22d85 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3deff25249c59b7fc1b6eb65dda39736955679c6 \ No newline at end of file +5d533eee049e63b3700f5ef7c28c588afccde57a \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index e40114000d..e685e20fab 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1968,7 +1968,7 @@ static int winRetryIoerr(int *pnRetry, DWORD *pError){ */ static void winLogIoerr(int nRetry, int lineno){ if( nRetry ){ - sqlite3_log(SQLITE_IOERR, + sqlite3_log(SQLITE_NOTICE, "delayed %dms for lock/sharing conflict at line %d", winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno ); From 4c45196a76c92309980cdbd7fd570e183c272c36 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Mar 2015 18:05:49 +0000 Subject: [PATCH 20/21] Add the "mptest" target to main.mk. Change TRUNCATE and PERSIST to DELETE for mptest.c on Windows because of problems trying to delete the journal. FossilOrigin-Name: ea697e6d9ff1f4d77774589a02ba4a18feafbf03 --- main.mk | 13 +++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- mptest/mptest.c | 12 +++++++++++- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/main.mk b/main.mk index 7d21dbb25e..57bb35c486 100644 --- a/main.mk +++ b/main.mk @@ -408,6 +408,19 @@ mptester$(EXE): sqlite3.c $(TOP)/mptest/mptest.c $(TCCX) -o $@ -I. $(TOP)/mptest/mptest.c sqlite3.c \ $(TLIBS) $(THREADLIB) +MPTEST1=./mptester$(EXE) mptest.db $(TOP)/mptest/crash01.test --repeat 20 +MPTEST2=./mptester$(EXE) mptest.db $(TOP)/mptest/multiwrite01.test --repeat 20 +mptest: mptester$(EXE) + rm -f mptest.db + $(MPTEST1) --journalmode DELETE + $(MPTEST2) --journalmode WAL + $(MPTEST1) --journalmode WAL + $(MPTEST2) --journalmode PERSIST + $(MPTEST1) --journalmode PERSIST + $(MPTEST2) --journalmode TRUNCATE + $(MPTEST1) --journalmode TRUNCATE + $(MPTEST2) --journalmode DELETE + sqlite3.o: sqlite3.c $(TCCX) -I. -c sqlite3.c diff --git a/manifest b/manifest index d5d1701f1e..74afeab247 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\ssqlite3_log()\smessage\sgenerated\son\sa\sretry\safter\sdelay\sin\sos_win\nto\sbe\san\sSQLITE_NOTICE\sinstead\sof\sSQLITE_IOERR. -D 2015-03-31T17:32:06.290 +C Add\sthe\s"mptest"\starget\sto\smain.mk.\s\sChange\sTRUNCATE\sand\sPERSIST\sto\sDELETE\nfor\smptest.c\son\sWindows\sbecause\sof\sproblems\strying\sto\sdelete\sthe\sjournal. +D 2015-03-31T18:05:49.317 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 00d12636df7a5b08af09116bcd6c7bfd49b8b3b4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -152,7 +152,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 04c49c495795b18a7b70053eef285be1e4d43fa4 +F main.mk 997eee18387a3e69394f2f948c9c6ccf079655a4 F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea F mkopcodeh.awk c6b3fa301db6ef7ac916b14c60868aeaec1337b5 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 @@ -160,7 +160,7 @@ F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 F mptest/crash02.subtest f4ef05adcd15d60e5d2bd654204f2c008b519df8 -F mptest/mptest.c 4691e08e1fc114edd8e1875f88393718f70ba480 +F mptest/mptest.c dae6de83eddac3ef97fc4111632f6066760f939a F mptest/multiwrite01.test dab5c5f8f9534971efce679152c5146da265222d F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b @@ -1248,7 +1248,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 3deff25249c59b7fc1b6eb65dda39736955679c6 -R 5464b14f38d360ccc6fa7360d378f7df +P 5d533eee049e63b3700f5ef7c28c588afccde57a +R 9e646d8c9c851fc471bfbde27cfe2ec7 U drh -Z f2a2061ec6a7f778916e1fed0b96d2ff +Z 7401f8256f1a048a9f3296d27a2e41e1 diff --git a/manifest.uuid b/manifest.uuid index 1069e22d85..9e31354eac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5d533eee049e63b3700f5ef7c28c588afccde57a \ No newline at end of file +ea697e6d9ff1f4d77774589a02ba4a18feafbf03 \ No newline at end of file diff --git a/mptest/mptest.c b/mptest/mptest.c index 1efdc0319a..52ff6a4c83 100644 --- a/mptest/mptest.c +++ b/mptest/mptest.c @@ -1327,6 +1327,17 @@ int SQLITE_CDECL main(int argc, char **argv){ } rc = sqlite3_open_v2(g.zDbFile, &g.db, openFlags, g.zVfs); if( rc ) fatalError("cannot open [%s]", g.zDbFile); + if( zJMode ){ +#if defined(_WIN32) + if( sqlite3_stricmp(zJMode,"persist")==0 + || sqlite3_stricmp(zJMode,"truncate")==0 + ){ + printf("Changing journal mode to DELETE from %s", zJMode); + zJMode = "DELETE"; + } +#endif + runSql("PRAGMA journal_mode=%Q;", zJMode); + } sqlite3_enable_load_extension(g.db, 1); sqlite3_busy_handler(g.db, busyHandler, 0); sqlite3_create_function(g.db, "vfsname", 0, SQLITE_UTF8, 0, @@ -1358,7 +1369,6 @@ int SQLITE_CDECL main(int argc, char **argv){ fatalError("missing script filename"); } if( n>1 ) unrecognizedArguments(argv[0], n, argv+2); - if( zJMode ) runSql("PRAGMA journal_mode=%Q;", zJMode); runSql( "DROP TABLE IF EXISTS task;\n" "DROP TABLE IF EXISTS counters;\n" From ccf46d0b9020d88fddbdc2dd9b9104b403f7d615 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 1 Apr 2015 13:21:33 +0000 Subject: [PATCH 21/21] Improved detection and suppression of endless loops in clearDatabasePage(). FossilOrigin-Name: 30011ad2f55cfcacaf23a58ebcc17b17a7b9355e --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/btree.c | 14 ++++++++------ src/btreeInt.h | 1 + 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 63d5d9eccf..83880531e8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C On\swindows,\sflush\sthe\smapping\sview\swhen\ssyncing\scontent\sto\sdisk. -D 2015-03-31T19:40:05.313 +C Improved\sdetection\sand\ssuppression\sof\sendless\sloops\sin\sclearDatabasePage(). +D 2015-04-01T13:21:33.901 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 00d12636df7a5b08af09116bcd6c7bfd49b8b3b4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -173,9 +173,9 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c ff743689c4d6c5cb55ad42ed9d174b2b3e71f1e3 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c 525f19f01d5976dbc12e83e7339e41488de79183 +F src/btree.c 2caf598165f3608fde8abac2b243826616ce54b7 F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 -F src/btreeInt.h 2bfefc01875d8da066504c233ec259fcb3b2ef72 +F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4 F src/build.c 0419bba592c22f6d00e6d57a2ca7136720d02c1a F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c 198a0066ba60ab06fc00fba1998d870a4d575463 @@ -1248,8 +1248,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 ea697e6d9ff1f4d77774589a02ba4a18feafbf03 45acf6a85150839d591316418dad59ae20ce3aa4 -R 00dcdcdf447a25afe74cb2a2ac195e0b -T +closed 45acf6a85150839d591316418dad59ae20ce3aa4 +P a828e73dc1ae50189bdf73f60caeb7308738ad7a +R 9ae26e7b05df4833a239ec9186729882 U drh -Z e131d4f6392434ebe038899ef79bd289 +Z b113a7338e765a6278a4e0ffd57f1cf8 diff --git a/manifest.uuid b/manifest.uuid index 6301587c11..925ee38b4d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a828e73dc1ae50189bdf73f60caeb7308738ad7a \ No newline at end of file +30011ad2f55cfcacaf23a58ebcc17b17a7b9355e \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index b497cd7468..789796d55a 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7980,28 +7980,29 @@ static int clearDatabasePage( int i; int hdr; u16 szCell; - u8 hasChildren; assert( sqlite3_mutex_held(pBt->mutex) ); if( pgno>btreePagecount(pBt) ){ return SQLITE_CORRUPT_BKPT; } - rc = getAndInitPage(pBt, pgno, &pPage, 0); if( rc ) return rc; - hasChildren = !pPage->leaf; - pPage->leaf = 1; /* Block looping if the database is corrupt */ + if( pPage->bBusy ){ + rc = SQLITE_CORRUPT_BKPT; + goto cleardatabasepage_out; + } + pPage->bBusy = 1; hdr = pPage->hdrOffset; for(i=0; inCell; i++){ pCell = findCell(pPage, i); - if( hasChildren ){ + if( !pPage->leaf ){ rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange); if( rc ) goto cleardatabasepage_out; } rc = clearCell(pPage, pCell, &szCell); if( rc ) goto cleardatabasepage_out; } - if( hasChildren ){ + if( !pPage->leaf ){ rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange); if( rc ) goto cleardatabasepage_out; }else if( pnChange ){ @@ -8015,6 +8016,7 @@ static int clearDatabasePage( } cleardatabasepage_out: + pPage->bBusy = 0; releasePage(pPage); return rc; } diff --git a/src/btreeInt.h b/src/btreeInt.h index 87d0ef1bb8..33ef641059 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -280,6 +280,7 @@ struct MemPage { u8 hdrOffset; /* 100 for page 1. 0 otherwise */ u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */ u8 max1bytePayload; /* min(maxLocal,127) */ + u8 bBusy; /* Prevent endless loops on corrupt database files */ u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */ u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */ u16 cellOffset; /* Index in aData of first cell pointer */