diff --git a/Makefile.in b/Makefile.in index b1f83bb4af..4006a22073 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1075,7 +1075,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/Makefile.msc b/Makefile.msc index 09aa606ee6..f8746eebfe 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1182,6 +1182,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 2>NUL + $(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/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/main.mk b/main.mk index 612f419176..9c1ff3fc45 100644 --- a/main.mk +++ b/main.mk @@ -416,6 +416,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 30127bd0ff..b591f4846d 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Merge\sall\srecent\strunk\senhancements\sand\sfixes\sinto\sthe\ssessions\sbranch. -D 2015-03-31T00:10:21.692 +C Merge\srecent\senhancements\sfrom\strunk. +D 2015-04-01T16:39:06.530 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 1bf4de5d0809e0ed046d6f2671ea46d1d6c69608 +F Makefile.in 3083cf0c2bc6618e532b9478ce735bb512322985 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc da7e7ac0949d78930b7b0adc3862aef9a9439b2e +F Makefile.msc ffb3a33f21fcc6f7d4b0cc76a981f62f17c62b24 F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 F VERSION 319eb1ced4b4d17a67730f2b7b85f15c1346cb60 @@ -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 @@ -169,7 +169,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 758bb6ffbe5fbfe676c150dd1c3332eba8f42135 +F main.mk 3876195fb0d4a873f643a3ee8ae4dc29b7bbb96b F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea F mkopcodeh.awk c6b3fa301db6ef7ac916b14c60868aeaec1337b5 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 @@ -177,7 +177,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 dae6de83eddac3ef97fc4111632f6066760f939a F mptest/multiwrite01.test dab5c5f8f9534971efce679152c5146da265222d F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b @@ -190,9 +190,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 e565971caa0265d3cabc8b15d7017899a7814051 +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 @@ -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 865ba15878eded98bb29a97ac898f2a799dc481a +F src/os_win.c 03d27be3a20048ef52a648d5f0a15f5edda9f2a3 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 @@ -310,7 +310,7 @@ F src/update.c d207deb7a031f698104bee879de0632b611e72dd F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c 98a7627ca48ad3265b6940915a1d08355eb3fc7e F src/vacuum.c 9460b9de7b2d4e34b0d374894aa6c8a0632be8ec -F src/vdbe.c 334c39a26214270555f4b5f9ba490aaf9a9e2601 +F src/vdbe.c 503f4f9396e1109bc9ff0fa6ee01c58e12bc782b F src/vdbe.h b434bb75fbec973d18d49225a59833ae39ee2afc F src/vdbeInt.h 96e4303a96c6f983e36e1fe32657b2c547f5c8f1 F src/vdbeapi.c d95f2bb43d01a91d93231cde181811b38182202e @@ -357,7 +357,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 @@ -450,7 +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/corruptJ.test 9e29e7a81ee3b6ac50f77ea7a9e2f3fa03f32d91 F test/cost.test 19d314526616ce4473eb4e4e450fcb94499ce318 F test/count.test 42a251178e32f617eda33f76236a7f79825a50b5 F test/coveridxscan.test cdb47d01acc4a634a34fd25abe85189e0d0f1e62 @@ -1224,7 +1224,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 @@ -1266,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 54aaa6f29ad1bf84148c2403eed77e8311f68d66 395bb3e677a6551b06ba96fc58c393132b93d1e8 -R 5157faacf9bba75d7e337c0159334ea0 +P df94e61f93da390cb75c48975c50e9d62096ea0b 30011ad2f55cfcacaf23a58ebcc17b17a7b9355e +R 04f33d7b68cc1c223f924b4251ca247b U drh -Z 1371361ad4cf3707e5f673fcbbe81867 +Z 60b6a96a3758bc5b32bc62eb74cab985 diff --git a/manifest.uuid b/manifest.uuid index 5b1dd1a687..bc291e8b17 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -df94e61f93da390cb75c48975c50e9d62096ea0b \ No newline at end of file +aea439bdc6d4d3a8568423171abf381843188826 \ No newline at end of file diff --git a/mptest/mptest.c b/mptest/mptest.c index 40c14bc87a..52ff6a4c83 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; i1 ) 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" @@ -1409,6 +1422,9 @@ int SQLITE_CDECL main(int argc, char **argv){ maybeClose(g.pErrLog); if( iClient==0 ){ printf("Summary: %d errors out of %d tests\n", g.nError, g.nTest); + printf("END: %s", argv[0]); + for(i=1; i0; } diff --git a/src/btree.c b/src/btree.c index a4eae64025..789796d55a 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); @@ -7978,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 ){ @@ -8013,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 */ diff --git a/src/os_win.c b/src/os_win.c index e40114000d..ef2f553f33 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 */ /* @@ -1968,7 +1979,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 ); @@ -2788,6 +2799,22 @@ static int winSync(sqlite3_file *id, int flags){ 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 ){ @@ -2799,7 +2826,7 @@ static int winSync(sqlite3_file *id, int flags){ 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 } @@ -5573,7 +5600,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)); diff --git a/src/vdbe.c b/src/vdbe.c index 5ac9d61b3d..ce492eaced 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1930,11 +1930,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 ); @@ -1971,7 +1975,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; } 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 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 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