From eb48b062a162f8fa3e514e1776450cd0a0f75d47 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 31 Mar 2015 17:45:44 +0000 Subject: [PATCH 01/74] Testing enhancements on Windows. FossilOrigin-Name: 9cc70eee2e365dd390210f436b893b9d80a19b04 --- Makefile.msc | 8 ++++---- manifest | 25 ++++++++++++++----------- manifest.uuid | 2 +- mptest/mptest.c | 4 +++- src/main.c | 3 ++- src/os_common.h | 3 ++- src/sqliteInt.h | 3 ++- 7 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 5330f8962f..d3a40a811b 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -480,8 +480,8 @@ RCC = $(RCC) -DSQLITE_DEBUG !ENDIF !IF $(DEBUG)>4 -TCC = $(TCC) -DSQLITE_DEBUG_OS_TRACE=1 -RCC = $(RCC) -DSQLITE_DEBUG_OS_TRACE=1 +TCC = $(TCC) -DSQLITE_DEBUG_OS_TRACE=1 -DSQLITE_FORCE_OS_TRACE=1 +RCC = $(RCC) -DSQLITE_DEBUG_OS_TRACE=1 -DSQLITE_FORCE_OS_TRACE=1 !ENDIF !IF $(DEBUG)>5 @@ -1158,8 +1158,8 @@ 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 2>NUL diff --git a/manifest b/manifest index d5d1701f1e..8eb1667b6f 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -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 Testing\senhancements\son\sWindows. +D 2015-03-31T17:45:44.088 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 00d12636df7a5b08af09116bcd6c7bfd49b8b3b4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc a8d817fa486d8c88dfbd19ae6a6567d9d350de39 +F Makefile.msc c3744ee851d76d2be0ff247f5a89a74c88f2ece2 F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 F VERSION 319eb1ced4b4d17a67730f2b7b85f15c1346cb60 @@ -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 5360b7a1fd85e3b39daa03d98a81eaa4096a93f5 F mptest/multiwrite01.test dab5c5f8f9534971efce679152c5146da265222d F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b @@ -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 40e333960d53f7d50ee8ce09d40431c87ea653f2 +F src/main.c 1cc847aae38c804427f155441c1b73c3f9144c9a F src/malloc.c 6a370b83d54e4bbf6f94021221c2a311cff26a18 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987 @@ -212,7 +212,7 @@ F src/mutex_w32.c 61660ada28d8308ad190f444c2170c4f2a590c2f F src/notify.c 9711a7575036f0d3040ba61bc6e217f13a9888e7 F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf -F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 +F src/os_common.h 75309c5996a3d201d59ccde946caef1651f206e2 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a4dadbc2da41599e99093e91e276c38c17a73b89 F src/os_win.c 23c2d1fab9b44e728e7d3ac0c82d5ac2a96de290 @@ -235,7 +235,7 @@ F src/shell.c 84a1593bd86aaa14f4da8a8f9b16fbc239d262aa F src/sqlite.h.in 278602140d49575e8708e643161f4263e428a02a F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d -F src/sqliteInt.h d02d2b85cb02a38bc442cf9302ec8209baf6771d +F src/sqliteInt.h b54a3815ab5a353aac0e6f94c02c51a065fa7fab F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179 F src/table.c e7a09215315a978057fb42c640f890160dbcc45e @@ -1248,7 +1248,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 3deff25249c59b7fc1b6eb65dda39736955679c6 -R 5464b14f38d360ccc6fa7360d378f7df -U drh -Z f2a2061ec6a7f778916e1fed0b96d2ff +P 5d533eee049e63b3700f5ef7c28c588afccde57a +R 9184ed6faa90f29bd59d243ded83d06c +T *branch * winTest +T *sym-winTest * +T -sym-trunk * +U mistachkin +Z fd6cc612eddf1c1ec4736ef8e7fda9d3 diff --git a/manifest.uuid b/manifest.uuid index 1069e22d85..76b24fff16 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5d533eee049e63b3700f5ef7c28c588afccde57a \ No newline at end of file +9cc70eee2e365dd390210f436b893b9d80a19b04 \ No newline at end of file diff --git a/mptest/mptest.c b/mptest/mptest.c index 1efdc0319a..6a37231e64 100644 --- a/mptest/mptest.c +++ b/mptest/mptest.c @@ -1335,10 +1335,11 @@ int SQLITE_CDECL main(int argc, char **argv){ evalFunc, 0, 0); g.iTimeout = DEFAULT_TIMEOUT; if( g.bSqlTrace ) sqlite3_trace(g.db, sqlTraceCallback, 0); - if( !g.bSync ) trySql("PRAGMA synchronous=OFF"); if( iClient>0 ){ if( n>0 ) unrecognizedArguments(argv[0], n, argv+2); if( g.iTrace ) logMessage("start-client"); + if( !g.bSync ) trySql("PRAGMA synchronous=OFF"); + if( zJMode ) runSql("PRAGMA journal_mode=%Q;", zJMode); while(1){ char *zTaskName = 0; rc = startScript(iClient, &zScript, &taskId, &zTaskName); @@ -1358,6 +1359,7 @@ int SQLITE_CDECL main(int argc, char **argv){ fatalError("missing script filename"); } if( n>1 ) unrecognizedArguments(argv[0], n, argv+2); + if( !g.bSync ) trySql("PRAGMA synchronous=OFF"); if( zJMode ) runSql("PRAGMA journal_mode=%Q;", zJMode); runSql( "DROP TABLE IF EXISTS task;\n" diff --git a/src/main.c b/src/main.c index d9ee77fab2..46823a2d93 100644 --- a/src/main.c +++ b/src/main.c @@ -1194,7 +1194,8 @@ void sqlite3RollbackAll(sqlite3 *db, int tripCode){ ** Return a static string containing the name corresponding to the error code ** specified in the argument. */ -#if (defined(SQLITE_DEBUG) && SQLITE_OS_WIN) || defined(SQLITE_TEST) +#if defined(SQLITE_DEBUG) && \ + (defined(SQLITE_TEST) || defined(SQLITE_FORCE_OS_TRACE)) const char *sqlite3ErrName(int rc){ const char *zName = 0; int i, origRc = rc; diff --git a/src/os_common.h b/src/os_common.h index f6c3e7ff89..b5ecb9bbff 100644 --- a/src/os_common.h +++ b/src/os_common.h @@ -29,7 +29,8 @@ # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead." #endif -#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG) +#if defined(SQLITE_DEBUG) && \ + (defined(SQLITE_TEST) || defined(SQLITE_FORCE_OS_TRACE)) # ifndef SQLITE_DEBUG_OS_TRACE # define SQLITE_DEBUG_OS_TRACE 0 # endif diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 3841c91f14..92df2b703a 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3491,7 +3491,8 @@ void *sqlite3HexToBlob(sqlite3*, const char *z, int n); u8 sqlite3HexToInt(int h); int sqlite3TwoPartName(Parse *, Token *, Token *, Token **); -#if defined(SQLITE_TEST) +#if defined(SQLITE_DEBUG) && \ + (defined(SQLITE_TEST) || defined(SQLITE_FORCE_OS_TRACE)) const char *sqlite3ErrName(int); #endif From 25a72de917a2c197ffa2a2982b4c4370506874d2 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 31 Mar 2015 17:58:13 +0000 Subject: [PATCH 02/74] Path handling portability enhancements for mptester. FossilOrigin-Name: da49634b331812fa4d6e33d72c9661aeab203ae8 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- mptest/mptest.c | 15 +++++++++++---- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 8eb1667b6f..c8faf609ad 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Testing\senhancements\son\sWindows. -D 2015-03-31T17:45:44.088 +C Path\shandling\sportability\senhancements\sfor\smptester. +D 2015-03-31T17:58:13.315 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 00d12636df7a5b08af09116bcd6c7bfd49b8b3b4 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 5360b7a1fd85e3b39daa03d98a81eaa4096a93f5 +F mptest/mptest.c d1e8ff5488bda5ff51407d6e86b4f6e8de7ff443 F mptest/multiwrite01.test dab5c5f8f9534971efce679152c5146da265222d F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b @@ -1248,10 +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 5d533eee049e63b3700f5ef7c28c588afccde57a -R 9184ed6faa90f29bd59d243ded83d06c -T *branch * winTest -T *sym-winTest * -T -sym-trunk * +P 9cc70eee2e365dd390210f436b893b9d80a19b04 +R be2bc38a728d3b9a8c390950640aab4e U mistachkin -Z fd6cc612eddf1c1ec4736ef8e7fda9d3 +Z 01af2fb4ec1ab808dcf4522c94181a8f diff --git a/manifest.uuid b/manifest.uuid index 76b24fff16..eb12a9de38 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9cc70eee2e365dd390210f436b893b9d80a19b04 \ No newline at end of file +da49634b331812fa4d6e33d72c9661aeab203ae8 \ No newline at end of file diff --git a/mptest/mptest.c b/mptest/mptest.c index 6a37231e64..366375424b 100644 --- a/mptest/mptest.c +++ b/mptest/mptest.c @@ -53,6 +53,13 @@ # define GETPID getpid #endif +/* The directory separator character(s) */ +#if defined(_WIN32) +# define isDirSep(c) (((c) == '/') || ((c) == '\\')) +#else +# define isDirSep(c) ((c) == '/') +#endif + /* Mark a parameter as unused to suppress compiler warnings */ #define UNUSED_PARAMETER(x) (void)x @@ -824,7 +831,7 @@ static void waitForClient(int iClient, int iTimeout, char *zErrPrefix){ */ static char *filenameTail(char *z){ int i, j; - for(i=j=0; z[i]; i++) if( z[i]=='/' ) j = i+1; + for(i=j=0; z[i]; i++) if( isDirSep(z[i]) ) j = i+1; return z+j; } @@ -1021,9 +1028,9 @@ static void runScript( char *zNewFile, *zNewScript; char *zToDel = 0; zNewFile = azArg[0]; - if( zNewFile[0]!='/' ){ + if( !isDirSep(zNewFile[0]) ){ int k; - for(k=(int)strlen(zFilename)-1; k>=0 && zFilename[k]!='/'; k--){} + for(k=(int)strlen(zFilename)-1; k>=0 && !isDirSep(zFilename[k]); k--){} if( k>0 ){ zNewFile = zToDel = sqlite3_mprintf("%.*s/%s", k,zFilename,zNewFile); } @@ -1231,7 +1238,7 @@ static void usage(const char *argv0){ int i; const char *zTail = argv0; for(i=0; argv0[i]; i++){ - if( argv0[i]=='/' ) zTail = argv0+i+1; + if( isDirSep(argv0[i]) ) zTail = argv0+i+1; } fprintf(stderr,"Usage: %s DATABASE ?OPTIONS? ?SCRIPT?\n", zTail); exit(1); From d25675f8978e9d8dc662421f17a0405fcddde3f9 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 31 Mar 2015 19:06:46 +0000 Subject: [PATCH 03/74] Build fixes for OSTRACE enhancements. FossilOrigin-Name: f79c236fc537ecee1ea7448a3e3216a2415561a1 --- manifest | 23 +++++++++++------------ manifest.uuid | 2 +- src/main.c | 2 +- src/os_common.h | 2 +- src/os_win.c | 12 ++++++++++-- src/printf.c | 3 ++- src/sqliteInt.h | 2 +- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index f1aa496dd8..e3db2ee4c4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Path\sportability\senhancements\sfor\smptester.exe. -D 2015-03-31T18:18:53.022 +C Build\sfixes\sfor\sOSTRACE\senhancements. +D 2015-03-31T19:06:46.659 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 00d12636df7a5b08af09116bcd6c7bfd49b8b3b4 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 1cc847aae38c804427f155441c1b73c3f9144c9a +F src/main.c cc3ac7793d38cb3e7e185edbc1f53ca311621a3a F src/malloc.c 6a370b83d54e4bbf6f94021221c2a311cff26a18 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987 @@ -212,10 +212,10 @@ F src/mutex_w32.c 61660ada28d8308ad190f444c2170c4f2a590c2f F src/notify.c 9711a7575036f0d3040ba61bc6e217f13a9888e7 F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf -F src/os_common.h 75309c5996a3d201d59ccde946caef1651f206e2 +F src/os_common.h 4fccbf81ef328c9ac231211de379e753b1365313 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a4dadbc2da41599e99093e91e276c38c17a73b89 -F src/os_win.c 23c2d1fab9b44e728e7d3ac0c82d5ac2a96de290 +F src/os_win.c 6c4752b58c0b795ef9c2ea667b7ea0966937a796 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 @@ -226,7 +226,7 @@ F src/pcache1.c 69d137620a305f814398bd29a0c998038c0695e9 F src/pragma.c ac4f3f856b4234e85f55b0f069698a4766011100 F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f F src/prepare.c 173a5a499138451b2561614ecb87d78f9f4644b9 -F src/printf.c 8da9a2687a396daa19860f4dc90975d319304744 +F src/printf.c 8fff88d299f00e114e1a5afc90aa4c8744bf8877 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c f4d79e31ffa5820c2e3d1740baa5e9b190425f2b F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e @@ -235,7 +235,7 @@ F src/shell.c 84a1593bd86aaa14f4da8a8f9b16fbc239d262aa F src/sqlite.h.in 278602140d49575e8708e643161f4263e428a02a F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d -F src/sqliteInt.h b54a3815ab5a353aac0e6f94c02c51a065fa7fab +F src/sqliteInt.h 75e86ef580cae23a36c4acfc2f664f528f8aee91 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179 F src/table.c e7a09215315a978057fb42c640f890160dbcc45e @@ -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 da49634b331812fa4d6e33d72c9661aeab203ae8 -R 126147c160c4bad0e1b7fe3417e6316b -T +closed da49634b331812fa4d6e33d72c9661aeab203ae8 -U drh -Z 3bf817d5b936af30f76c04f3a5290142 +P c8694657bdc5d0917d8fe78fd3937d8e9cd9d04b +R 7fff6ef631e32e4acabaf29648c7d2ea +U mistachkin +Z 26798f0cab8ceff11e56a6de19170f96 diff --git a/manifest.uuid b/manifest.uuid index 012d207f50..90215aece6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c8694657bdc5d0917d8fe78fd3937d8e9cd9d04b \ No newline at end of file +f79c236fc537ecee1ea7448a3e3216a2415561a1 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 46823a2d93..0e2f2bdc03 100644 --- a/src/main.c +++ b/src/main.c @@ -1194,7 +1194,7 @@ void sqlite3RollbackAll(sqlite3 *db, int tripCode){ ** Return a static string containing the name corresponding to the error code ** specified in the argument. */ -#if defined(SQLITE_DEBUG) && \ +#if (defined(SQLITE_DEBUG) && SQLITE_OS_WIN) || \ (defined(SQLITE_TEST) || defined(SQLITE_FORCE_OS_TRACE)) const char *sqlite3ErrName(int rc){ const char *zName = 0; diff --git a/src/os_common.h b/src/os_common.h index b5ecb9bbff..0f5f779438 100644 --- a/src/os_common.h +++ b/src/os_common.h @@ -29,7 +29,7 @@ # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead." #endif -#if defined(SQLITE_DEBUG) && \ +#if (defined(SQLITE_DEBUG) && SQLITE_OS_WIN) || \ (defined(SQLITE_TEST) || defined(SQLITE_FORCE_OS_TRACE)) # ifndef SQLITE_DEBUG_OS_TRACE # define SQLITE_DEBUG_OS_TRACE 0 diff --git a/src/os_win.c b/src/os_win.c index e685e20fab..acb06c69e9 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -25,6 +25,14 @@ */ #include "os_win.h" +/* +** Is the OSTRACE macro defined to actually do something? +*/ +#if (defined(SQLITE_DEBUG) && SQLITE_OS_WIN) || \ + (defined(SQLITE_TEST) || defined(SQLITE_FORCE_OS_TRACE)) +# define SQLITE_WIN32_HAS_OS_TRACE +#endif + /* ** Compiling and using WAL mode requires several APIs that are only ** available in Windows platforms based on the NT kernel. @@ -2746,7 +2754,7 @@ static int winSync(sqlite3_file *id, int flags){ BOOL rc; #endif #if !defined(NDEBUG) || !defined(SQLITE_NO_SYNC) || \ - (defined(SQLITE_TEST) && defined(SQLITE_DEBUG)) + defined(SQLITE_WIN32_HAS_OS_TRACE) /* ** Used when SQLITE_NO_SYNC is not defined and by the assert() and/or ** OSTRACE() macros. @@ -3438,7 +3446,7 @@ struct winShm { u8 hasMutex; /* True if holding the winShmNode mutex */ u16 sharedMask; /* Mask of shared locks held */ u16 exclMask; /* Mask of exclusive locks held */ -#ifdef SQLITE_DEBUG +#if defined(SQLITE_DEBUG) || defined(SQLITE_WIN32_HAS_OS_TRACE) u8 id; /* Id of this connection with its winShmNode */ #endif }; diff --git a/src/printf.c b/src/printf.c index 81efa057fc..b559e9dfc3 100644 --- a/src/printf.c +++ b/src/printf.c @@ -1045,7 +1045,8 @@ void sqlite3_log(int iErrCode, const char *zFormat, ...){ } } -#if defined(SQLITE_DEBUG) +#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) || \ + defined(SQLITE_FORCE_OS_TRACE) /* ** A version of printf() that understands %lld. Used for debugging. ** The printf() built into some versions of windows does not understand %lld diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 92df2b703a..45250bfd10 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3491,7 +3491,7 @@ void *sqlite3HexToBlob(sqlite3*, const char *z, int n); u8 sqlite3HexToInt(int h); int sqlite3TwoPartName(Parse *, Token *, Token *, Token **); -#if defined(SQLITE_DEBUG) && \ +#if (defined(SQLITE_DEBUG) && SQLITE_OS_WIN) || \ (defined(SQLITE_TEST) || defined(SQLITE_FORCE_OS_TRACE)) const char *sqlite3ErrName(int); #endif From 98f1c4086df052634215cf5f071be8d33cc34e5f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 31 Mar 2015 19:17:44 +0000 Subject: [PATCH 04/74] Set the winShm.id member when it is going to be traced. FossilOrigin-Name: fa7916b67efbc44e6f115bb0d32d8b92fd0acf3c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index e3db2ee4c4..0a765e257a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Build\sfixes\sfor\sOSTRACE\senhancements. -D 2015-03-31T19:06:46.659 +C Set\sthe\swinShm.id\smember\swhen\sit\sis\sgoing\sto\sbe\straced. +D 2015-03-31T19:17:44.993 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 4fccbf81ef328c9ac231211de379e753b1365313 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a4dadbc2da41599e99093e91e276c38c17a73b89 -F src/os_win.c 6c4752b58c0b795ef9c2ea667b7ea0966937a796 +F src/os_win.c 87ae49ff973c3e01fff4cd002e1bbc135a63107e 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 c8694657bdc5d0917d8fe78fd3937d8e9cd9d04b -R 7fff6ef631e32e4acabaf29648c7d2ea +P f79c236fc537ecee1ea7448a3e3216a2415561a1 +R c0e6ffe8bce6c29d87c8228cd21b6e7e U mistachkin -Z 26798f0cab8ceff11e56a6de19170f96 +Z c7f453d4a005311b5f674545bd39b5a8 diff --git a/manifest.uuid b/manifest.uuid index 90215aece6..5fdcfe2a1c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f79c236fc537ecee1ea7448a3e3216a2415561a1 \ No newline at end of file +fa7916b67efbc44e6f115bb0d32d8b92fd0acf3c \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index acb06c69e9..abfa454bd9 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -3415,7 +3415,7 @@ struct winShmNode { int nRef; /* Number of winShm objects pointing to this */ winShm *pFirst; /* All winShm objects pointing to this */ winShmNode *pNext; /* Next in list of all winShmNode objects */ -#ifdef SQLITE_DEBUG +#if defined(SQLITE_DEBUG) || defined(SQLITE_WIN32_HAS_OS_TRACE) u8 nextShmId; /* Next available winShm.id value */ #endif }; @@ -3637,7 +3637,7 @@ static int winOpenSharedMemory(winFile *pDbFd){ /* Make the new connection a child of the winShmNode */ p->pShmNode = pShmNode; -#ifdef SQLITE_DEBUG +#if defined(SQLITE_DEBUG) || defined(SQLITE_WIN32_HAS_OS_TRACE) p->id = pShmNode->nextShmId++; #endif pShmNode->nRef++; From 34cf25830249a17e665e0ad22c95928cfaf9e1dc Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 2 Apr 2015 17:46:52 +0000 Subject: [PATCH 05/74] Fix build with OSTRACE enabled on Windows when building using separate source files. FossilOrigin-Name: 5f6e35802fcf7b5e9fc3dd4424e9074523fa8ad3 --- manifest | 17 ++++++++--------- manifest.uuid | 2 +- src/main.c | 13 +++++++++++++ src/os_common.h | 8 ++++---- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 5d40a858f2..dabb61374f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\stracing\sand\sdebugging\ssupport\son\swindows. -D 2015-04-01T01:26:12.429 +C Fix\sbuild\swith\sOSTRACE\senabled\son\sWindows\swhen\sbuilding\susing\sseparate\ssource\sfiles. +D 2015-04-02T17:46:52.559 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 00d12636df7a5b08af09116bcd6c7bfd49b8b3b4 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 cc3ac7793d38cb3e7e185edbc1f53ca311621a3a +F src/main.c 1ce947628ff241608fd4a122976fa29d36b8838f F src/malloc.c 6a370b83d54e4bbf6f94021221c2a311cff26a18 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987 @@ -212,7 +212,7 @@ F src/mutex_w32.c 61660ada28d8308ad190f444c2170c4f2a590c2f F src/notify.c 9711a7575036f0d3040ba61bc6e217f13a9888e7 F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf -F src/os_common.h 4fccbf81ef328c9ac231211de379e753b1365313 +F src/os_common.h 05c8d05b4f1bce4262c9e2e74ab10c2d0dec964a F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a4dadbc2da41599e99093e91e276c38c17a73b89 F src/os_win.c eeb317cd504f39ef2dbcf50eb228bc9dd301d024 @@ -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 a828e73dc1ae50189bdf73f60caeb7308738ad7a fa7916b67efbc44e6f115bb0d32d8b92fd0acf3c -R 7fa87c853794881c54344291c71c3804 -T +closed fa7916b67efbc44e6f115bb0d32d8b92fd0acf3c -U drh -Z ed8d955d5896e461a30bebb3cc60c312 +P 5c965a71b957fdb0310ac1af9bf2fc3b418af668 +R a13de84916db5713aa965bbf949c399f +U mistachkin +Z d93e90a8dd0c05d351cfea868c3bfa91 diff --git a/manifest.uuid b/manifest.uuid index d53ff492b9..15bc18f89e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5c965a71b957fdb0310ac1af9bf2fc3b418af668 \ No newline at end of file +5f6e35802fcf7b5e9fc3dd4424e9074523fa8ad3 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 0e2f2bdc03..a2177fd796 100644 --- a/src/main.c +++ b/src/main.c @@ -55,6 +55,19 @@ int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; } */ int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; } +/* +** When compiling the test fixture or with debugging enabled (on Win32), +** this variable being set to non-zero will cause OSTRACE macros to emit +** extra diagnostic information. +*/ +#if (defined(SQLITE_DEBUG) && SQLITE_OS_WIN) || \ + (defined(SQLITE_TEST) || defined(SQLITE_FORCE_OS_TRACE)) +# ifndef SQLITE_DEBUG_OS_TRACE +# define SQLITE_DEBUG_OS_TRACE 0 +# endif + int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE; +#endif + #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE) /* ** If the following function pointer is not NULL and if diff --git a/src/os_common.h b/src/os_common.h index 0f5f779438..3ff4411992 100644 --- a/src/os_common.h +++ b/src/os_common.h @@ -29,12 +29,12 @@ # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead." #endif +/* +** Declarations used for tracing the operating system interfaces. +*/ #if (defined(SQLITE_DEBUG) && SQLITE_OS_WIN) || \ (defined(SQLITE_TEST) || defined(SQLITE_FORCE_OS_TRACE)) -# ifndef SQLITE_DEBUG_OS_TRACE -# define SQLITE_DEBUG_OS_TRACE 0 -# endif - int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE; + extern int sqlite3OSTrace; # define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X #else # define OSTRACE(X) From 00eb70d89c427a6d0e86788346c8ddd6f93d6ec5 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 4 Apr 2015 00:02:07 +0000 Subject: [PATCH 06/74] Enhance the 'releasetest.tcl' tool to support MSVC. FossilOrigin-Name: f664bfdc82597a4530d4f4938bb96557b43b171b --- Makefile.msc | 3 ++ manifest | 14 ++++----- manifest.uuid | 2 +- test/releasetest.tcl | 75 ++++++++++++++++++++++++++++++++++++++------ 4 files changed, 77 insertions(+), 17 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index d3a40a811b..e68fb78717 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1608,6 +1608,9 @@ queryplantest: testfixture.exe sqlite3.exe test: testfixture.exe sqlite3.exe .\testfixture.exe $(TOP)\test\veryquick.test +smoketest: testfixture.exe + .\testfixture.exe $(TOP)\test\main.test + sqlite3_analyzer.c: $(SQLITE3C) $(TOP)\src\test_stat.c $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl copy $(SQLITE3C) + $(TOP)\src\test_stat.c + $(TOP)\src\tclsqlite.c $@ echo static const char *tclsh_main_loop(void){ >> $@ diff --git a/manifest b/manifest index dabb61374f..e2d9993f0b 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Fix\sbuild\swith\sOSTRACE\senabled\son\sWindows\swhen\sbuilding\susing\sseparate\ssource\sfiles. -D 2015-04-02T17:46:52.559 +C Enhance\sthe\s'releasetest.tcl'\stool\sto\ssupport\sMSVC. +D 2015-04-04T00:02:07.856 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 00d12636df7a5b08af09116bcd6c7bfd49b8b3b4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc c3744ee851d76d2be0ff247f5a89a74c88f2ece2 +F Makefile.msc a95303d8bd37f8cf176be19cb5542355cc3c243b F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 F VERSION 319eb1ced4b4d17a67730f2b7b85f15c1346cb60 @@ -812,7 +812,7 @@ F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 -F test/releasetest.tcl 13f401c10dd4fe1a2fb811ae6ed27fd7d1300d3c +F test/releasetest.tcl a37cd82092c8be438255d65804b5951d6e3ecdae F test/resolver01.test 33abf37ff8335e6bf98f2b45a0af3e06996ccd9a F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea F test/rollback2.test fc14cf6d1a2b250d2735ef16124b971bce152f14 @@ -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 5c965a71b957fdb0310ac1af9bf2fc3b418af668 -R a13de84916db5713aa965bbf949c399f +P 5f6e35802fcf7b5e9fc3dd4424e9074523fa8ad3 +R beb5360693babbdb25b957a67e8a7b0e U mistachkin -Z d93e90a8dd0c05d351cfea868c3bfa91 +Z 6aedfad85a42d725bf8ce314c14e99d1 diff --git a/manifest.uuid b/manifest.uuid index 15bc18f89e..3312a66aa2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5f6e35802fcf7b5e9fc3dd4424e9074523fa8ad3 \ No newline at end of file +f664bfdc82597a4530d4f4938bb96557b43b171b \ No newline at end of file diff --git a/test/releasetest.tcl b/test/releasetest.tcl index 746fc9bb35..95cacf590f 100644 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -14,6 +14,7 @@ optional) are: --config CONFIGNAME (Run only CONFIGNAME) --quick (Run "veryquick.test" only) --veryquick (Run "make smoketest" only) + --msvc (Use MSVC as the compiler) --buildonly (Just build testfixture - do not run) --dryrun (Print what would have happened) --info (Show diagnostic info) @@ -22,8 +23,9 @@ The default value for --srcdir is the parent of the directory holding this script. The script determines the default value for --platform using the -$tcl_platform(os) and $tcl_platform(machine) variables. Supported -platforms are "Linux-x86", "Linux-x86_64" and "Darwin-i386". +$tcl_platform(os) and $tcl_platform(machine) variables. Supported +platforms are "Linux-x86", "Linux-x86_64", "Darwin-i386", +"Darwin-x86_64", "Windows NT-intel", and "Windows NT-amd64". Every test begins with a fresh run of the configure script at the top of the SQLite source tree. @@ -238,6 +240,10 @@ array set ::Platforms [strip_comments { "Default" "mptest fulltestonly" "Have-Not" test } + "Windows NT-amd64" { + "Default" "mptest fulltestonly" + "Have-Not" test + } # The Failure-Detection platform runs various tests that deliberately # fail. This is used as a test of this script to verify that this script @@ -296,6 +302,13 @@ proc count_tests_and_errors {logfile rcVar errmsgVar} { set errmsg $msg } } + if {[regexp {fatal error +(.*)} $line all msg]} { + incr ::NERRCASE + if {$rc==0} { + set rc 1 + set errmsg $msg + } + } if {[regexp {ERROR SUMMARY: (\d+) errors.*} $line all cnt] && $cnt>0} { incr ::NERRCASE if {$rc==0} { @@ -314,7 +327,13 @@ proc count_tests_and_errors {logfile rcVar errmsgVar} { } } close $fd - if {!$seen} { + if {$::BUILDONLY} { + if {$rc==0} { + set errmsg "Build complete" + } else { + set errmsg "Build failed" + } + } elseif {!$seen} { set rc 1 set errmsg "Test did not complete" if {[file readable core]} { @@ -329,7 +348,7 @@ proc run_test_suite {name testtarget config} { # CFLAGS. The makefile will pass OPTS to both gcc and lemon, but # CFLAGS is only passed to gcc. # - set cflags "-g" + set cflags [expr {$::MSVC ? "-Zi" : "-g"}] set opts "" set title ${name}($testtarget) set configOpts "" @@ -349,7 +368,14 @@ proc run_test_suite {name testtarget config} { set cflags [join $cflags " "] set opts [join $opts " "] - append opts " -DSQLITE_NO_SYNC=1 -DHAVE_USLEEP" + append opts " -DSQLITE_NO_SYNC=1" + + # Some configurations already set HAVE_USLEEP; in that case, skip it. + # + if {![regexp { -DHAVE_USLEEP$} $opts] + && ![regexp { -DHAVE_USLEEP[ =]+} $opts]} { + append opts " -DHAVE_USLEEP=1" + } # Set the sub-directory to use. # @@ -390,10 +416,10 @@ proc run_test_suite {name testtarget config} { if {$rc} { puts " FAIL $tm" incr ::NERR - if {$errmsg!=""} {puts " $errmsg"} } else { puts " Ok $tm" } + if {$errmsg!=""} {puts " $errmsg"} } } @@ -401,6 +427,7 @@ proc run_test_suite {name testtarget config} { # the current platform, which may be Windows (via MinGW, etc). # proc configureCommand {opts} { + if {$::MSVC} return [list]; # This is not needed for MSVC. set result [list trace_cmd exec] if {$::tcl_platform(platform)=="windows"} { lappend result sh @@ -414,7 +441,14 @@ proc configureCommand {opts} { # specified targets, compiler flags, and options. # proc makeCommand { targets cflags opts } { - set result [list trace_cmd exec make clean] + set result [list trace_cmd exec] + if {$::MSVC} { + set nmakeDir [file nativename $::SRCDIR] + set nmakeFile [file join $nmakeDir Makefile.msc] + lappend result nmake /f $nmakeFile TOP=$nmakeDir clean + } else { + lappend result make clean + } foreach target $targets { lappend result $target } @@ -443,6 +477,7 @@ proc trace_cmd {args} { proc process_options {argv} { set ::SRCDIR [file normalize [file dirname [file dirname $::argv0]]] set ::QUICK 0 + set ::MSVC 0 set ::BUILDONLY 0 set ::DRYRUN 0 set ::EXEC exec @@ -476,6 +511,10 @@ proc process_options {argv} { set config [lindex $argv $i] } + -msvc { + set ::MSVC 1 + } + -buildonly { set ::BUILDONLY 1 } @@ -494,6 +533,7 @@ proc process_options {argv} { puts " --platform [list $platform]" puts " --config [list $config]" if {$::QUICK} {puts " --quick"} + if {$::MSVC} {puts " --msvc"} if {$::BUILDONLY} {puts " --buildonly"} if {$::DRYRUN} {puts " --dryrun"} if {$::TRACE} {puts " --trace"} @@ -507,7 +547,15 @@ proc process_options {argv} { } exit } - -g - + + -g { + if {$::MSVC} { + lappend ::EXTRACONFIG -Zi + } else { + lappend ::EXTRACONFIG [lindex $argv $i] + } + } + -D* - -O* - -enable-* - @@ -547,6 +595,7 @@ proc process_options {argv} { puts -nonewline "Flags:" if {$::DRYRUN} {puts -nonewline " --dryrun"} if {$::BUILDONLY} {puts -nonewline " --buildonly"} + if {$::MSVC} {puts -nonewline " --msvc"} switch -- $::QUICK { 1 {puts -nonewline " --quick"} 2 {puts -nonewline " --veryquick"} @@ -570,12 +619,20 @@ proc main {argv} { set ::SQLITE_VERSION {} set STARTTIME [clock seconds] foreach {zConfig target} $::CONFIGLIST { + if {$::MSVC && ($zConfig eq "Sanitize" || "checksymbols" in $target + || "valgrindtest" in $target)} { + puts "Skipping $zConfig / $target for MSVC..." + continue + } if {$target ne "checksymbols"} { switch -- $::QUICK { 1 {set target test} 2 {set target smoketest} } - if {$::BUILDONLY} {set target testfixture} + if {$::BUILDONLY} { + set target testfixture + if {$::MSVC} {append target .exe} + } } set config_options [concat $::Configs($zConfig) $::EXTRACONFIG] From 748c7357ab3906c8a70c4fa53f247560c13c3411 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 15:29:05 +0000 Subject: [PATCH 07/74] Enhance the showdb utility program so that it can read the last partial page of a truncated database file. FossilOrigin-Name: 61d72e17916bc043ce53c64e5ba7050a9bae554e --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/showdb.c | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c374496704..35f1031e63 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s--msvc\scommand-line\soption\sto\sthe\sreleasetest.tcl\sscript.\s\sThis\sis\nonly\sa\spartial\smerge\sfrom\sthe\swinTest\sbranch\sas\sthe\sOS_TRACE\schanges\sare\nomitted. -D 2015-04-15T14:52:05.457 +C Enhance\sthe\sshowdb\sutility\sprogram\sso\sthat\sit\scan\sread\sthe\slast\spartial\spage\nof\sa\struncated\sdatabase\sfile. +D 2015-04-15T15:29:05.938 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1225,7 +1225,7 @@ F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 -F tool/showdb.c 63cdef19e7fbca0c164b096ef8aef3bb9e9dd222 +F tool/showdb.c 3b5d335d537e4dc44d0c86967023819453c87dc6 F tool/showjournal.c 053eb1cc774710c6890b7dd6293300cc297b16a5 F tool/showlocks.c 9920bcc64f58378ff1118caead34147201f48c68 F tool/showstat4.c 9515faa8ec176599d4a8288293ba8ec61f7b728a @@ -1250,7 +1250,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 bd06eeb8d06237dc2d54d8a03e8bf525cb811c9e f664bfdc82597a4530d4f4938bb96557b43b171b -R b50245239bcc99605991067d21ad645b +P b8768f124ef7d79e500b60a3ede288d46a0f529d +R ba09996f8bd767f4c42736f26f8bc5d1 U drh -Z 4acea00deaa3e67c61c8980097c82958 +Z aee37f07b2a30818108be904ab58fa7c diff --git a/manifest.uuid b/manifest.uuid index 89bd95a649..be87706afb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8768f124ef7d79e500b60a3ede288d46a0f529d \ No newline at end of file +61d72e17916bc043ce53c64e5ba7050a9bae554e \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index 7fdf7c91ad..c90f410d95 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -64,11 +64,13 @@ static void out_of_memory(void){ */ static unsigned char *getContent(int ofst, int nByte){ unsigned char *aData; + int got; aData = malloc(nByte+32); if( aData==0 ) out_of_memory(); memset(aData, 0, nByte+32); lseek(db, ofst, SEEK_SET); - if( read(db, aData, nByte)0 && got Date: Wed, 15 Apr 2015 17:26:55 +0000 Subject: [PATCH 08/74] Prevent the fetchPayload() routine from reporting a cell size that extends off the end of the page on a pathologically corrupted database file. FossilOrigin-Name: f71053cf658b3260a32ac06f8ba5c2cde0ea54dd --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 7 ++++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 35f1031e63..2bcb4fd1f2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\sshowdb\sutility\sprogram\sso\sthat\sit\scan\sread\sthe\slast\spartial\spage\nof\sa\struncated\sdatabase\sfile. -D 2015-04-15T15:29:05.938 +C Prevent\sthe\sfetchPayload()\sroutine\sfrom\sreporting\sa\scell\ssize\sthat\sextends\noff\sthe\send\sof\sthe\spage\son\sa\spathologically\scorrupted\sdatabase\sfile. +D 2015-04-15T17:26:55.979 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a 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 67648f6532c2da79d3b3fb6853aa1a0c3ba0e1ad +F src/btree.c c6e32d84442f79d5b96965265d65b3baa231dffc F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4 F src/build.c 01b969b20a44a3d9620e597d9af8242348123540 @@ -1250,7 +1250,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 b8768f124ef7d79e500b60a3ede288d46a0f529d -R ba09996f8bd767f4c42736f26f8bc5d1 +P 61d72e17916bc043ce53c64e5ba7050a9bae554e +R a75e3890d67000037a79bd4d7c9f248e U drh -Z aee37f07b2a30818108be904ab58fa7c +Z c0a93418012c7dd834fb5d24bb6e0682 diff --git a/manifest.uuid b/manifest.uuid index be87706afb..ec95ab78c0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -61d72e17916bc043ce53c64e5ba7050a9bae554e \ No newline at end of file +f71053cf658b3260a32ac06f8ba5c2cde0ea54dd \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 9faf624235..51fca4b4be 100644 --- a/src/btree.c +++ b/src/btree.c @@ -4451,13 +4451,18 @@ static const void *fetchPayload( BtCursor *pCur, /* Cursor pointing to entry to read from */ u32 *pAmt /* Write the number of available bytes here */ ){ + u32 amt; assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]); assert( pCur->eState==CURSOR_VALID ); assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); assert( cursorHoldsMutex(pCur) ); assert( pCur->aiIdx[pCur->iPage]apPage[pCur->iPage]->nCell ); assert( pCur->info.nSize>0 ); - *pAmt = pCur->info.nLocal; + assert( pCur->info.pPayload>pCur->apPage[pCur->iPage]->aData || CORRUPT_DB ); + assert( pCur->info.pPayloadapPage[pCur->iPage]->aDataEnd ||CORRUPT_DB); + amt = (int)(pCur->apPage[pCur->iPage]->aDataEnd - pCur->info.pPayload); + if( pCur->info.nLocalinfo.nLocal; + *pAmt = amt; return (void*)pCur->info.pPayload; } From 4b608038b0d3b00c42c84faa1414ae1d037027b5 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 19:25:25 +0000 Subject: [PATCH 09/74] Fix a potential one-byte buffer overread in the command-line shell. FossilOrigin-Name: e018f4bf1f27f7838342940ad89a12d7f1536e8e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 2bcb4fd1f2..a7f5fc07e9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Prevent\sthe\sfetchPayload()\sroutine\sfrom\sreporting\sa\scell\ssize\sthat\sextends\noff\sthe\send\sof\sthe\spage\son\sa\spathologically\scorrupted\sdatabase\sfile. -D 2015-04-15T17:26:55.979 +C Fix\sa\spotential\sone-byte\sbuffer\soverread\sin\sthe\scommand-line\sshell. +D 2015-04-15T19:25:25.409 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -231,7 +231,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 66cfe49a9c3b449ef13b89a8c47036a4ed167eab F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 93260bc9e7e0e6dfe1b7cb8815b0ed4cad8be9e3 -F src/shell.c 84a1593bd86aaa14f4da8a8f9b16fbc239d262aa +F src/shell.c 72b61a9d41ba12b67ea06fe9267abcc012c6c5bb F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d @@ -1250,7 +1250,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 61d72e17916bc043ce53c64e5ba7050a9bae554e -R a75e3890d67000037a79bd4d7c9f248e +P f71053cf658b3260a32ac06f8ba5c2cde0ea54dd +R eab6e1273b6697560bfb82b228385932 U drh -Z c0a93418012c7dd834fb5d24bb6e0682 +Z 6d428eedf5ae6fc2d3dc612cb5905085 diff --git a/manifest.uuid b/manifest.uuid index ec95ab78c0..5482423efa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f71053cf658b3260a32ac06f8ba5c2cde0ea54dd \ No newline at end of file +e018f4bf1f27f7838342940ad89a12d7f1536e8e \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 7ff3eb6cb0..0f7234c47f 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1944,7 +1944,7 @@ static void resolve_backslashes(char *z){ char c; while( *z && *z!='\\' ) z++; for(i=j=0; (c = z[i])!=0; i++, j++){ - if( c=='\\' ){ + if( c=='\\' && z[i+1]!=0 ){ c = z[++i]; if( c=='n' ){ c = '\n'; From 22ecef5c20e007ae5121d9febb3bb3d7f56097b0 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 00:26:03 +0000 Subject: [PATCH 10/74] When parsing the schema, ignore any SQL that does not begin with "CREATE". FossilOrigin-Name: d3c00d61581c8ba6dce5618391432d3af8d324d4 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/prepare.c | 6 +++--- test/analyze.test | 2 +- test/index3.test | 2 +- test/trigger7.test | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index a7f5fc07e9..5e32fe4ffc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spotential\sone-byte\sbuffer\soverread\sin\sthe\scommand-line\sshell. -D 2015-04-15T19:25:25.409 +C When\sparsing\sthe\sschema,\signore\sany\sSQL\sthat\sdoes\snot\sbegin\swith\s"CREATE". +D 2015-04-16T00:26:03.247 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -225,7 +225,7 @@ F src/pcache.h b44658c9c932d203510279439d891a2a83e12ba8 F src/pcache1.c 69d137620a305f814398bd29a0c998038c0695e9 F src/pragma.c 3965ae4e82bed39fb97ce04c5fe18c9bc3ee6a88 F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f -F src/prepare.c 173a5a499138451b2561614ecb87d78f9f4644b9 +F src/prepare.c 1fffbdcd6f8a0173a8f70d71f22528f4c0e1e3d3 F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 66cfe49a9c3b449ef13b89a8c47036a4ed167eab @@ -320,7 +320,7 @@ F test/alter3.test 49c9d9fba2b8fcdce2dedeca97bbf1f369cc548d F test/alter4.test c461150723ac957f3b2214aa0b11552cd72023ec F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f -F test/analyze.test 1772936d66471c65221e437b6d1999c3a03166c4 +F test/analyze.test 3eb35a4af972f98422e5dc0586501b17d103d321 F test/analyze3.test 75b9e42ea1e4edc919250450dc5762186965d4e6 F test/analyze4.test eff2df19b8dd84529966420f29ea52edc6b56213 F test/analyze5.test 765c4e284aa69ca172772aa940946f55629bc8c4 @@ -655,7 +655,7 @@ F test/incrvacuum3.test 75256fb1377e7c39ef2de62bfc42bbff67be295a F test/incrvacuum_ioerr.test 6ae2f783424e47a0033304808fe27789cf93e635 F test/index.test 4d990005a67a36984e4f1a5f1bdccea8d08da4ee F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 -F test/index3.test 55a90cff99834305e8141df7afaef39674b57062 +F test/index3.test b6ec456cf3b81d9a32123fe7e449bde434db338b F test/index4.test ab92e736d5946840236cd61ac3191f91a7856bf6 F test/index5.test 25b0b451aceed4ac5f7d49f856f6de7257470b3e F test/index6.test 3ae54e53c53f2adcacda269237d8e52bdb05a481 @@ -1082,7 +1082,7 @@ F test/trigger3.test aa640bb2bbb03edd5ff69c055117ea088f121945 F test/trigger4.test 74700b76ebf3947b2f7a92405141eb2cf2a5d359 F test/trigger5.test 619391a3e9fc194081d22cefd830d811e7badf83 F test/trigger6.test 0e411654f122552da6590f0b4e6f781048a4a9b9 -F test/trigger7.test b39e6dee1debe0ff9c2ef66326668f149f07c9c4 +F test/trigger7.test 200dd51e728c9cdc20c72d99d9e9d45c667248f8 F test/trigger8.test 30cb0530bd7c4728055420e3f739aa00412eafa4 F test/trigger9.test 2226ec795a33b0460ab5cf8891e9054cc7edef41 F test/triggerA.test fe5597f47ee21bacb4936dc827994ed94161e332 @@ -1250,7 +1250,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 f71053cf658b3260a32ac06f8ba5c2cde0ea54dd -R eab6e1273b6697560bfb82b228385932 +P e018f4bf1f27f7838342940ad89a12d7f1536e8e +R 9772cd879deb52a3e48d7b6cb0b29092 U drh -Z 6d428eedf5ae6fc2d3dc612cb5905085 +Z 089490261a72224f9edd48b4acf9b866 diff --git a/manifest.uuid b/manifest.uuid index 5482423efa..e0b027b22a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e018f4bf1f27f7838342940ad89a12d7f1536e8e \ No newline at end of file +d3c00d61581c8ba6dce5618391432d3af8d324d4 \ No newline at end of file diff --git a/src/prepare.c b/src/prepare.c index 97be900d68..a55a0fee43 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -67,7 +67,7 @@ int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){ if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */ if( argv[1]==0 ){ corruptSchema(pData, argv[0], 0); - }else if( argv[2] && argv[2][0] ){ + }else if( sqlite3_strnicmp(argv[2],"create ",7)==0 ){ /* Call the parser to process a CREATE TABLE, INDEX or VIEW. ** But because db->init.busy is set to 1, no VDBE code is generated ** or executed. All the parser does is build the internal data @@ -98,8 +98,8 @@ int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){ } } sqlite3_finalize(pStmt); - }else if( argv[0]==0 ){ - corruptSchema(pData, 0, 0); + }else if( argv[0]==0 || (argv[2]!=0 && argv[2][0]!=0) ){ + corruptSchema(pData, argv[0], 0); }else{ /* If the SQL column is blank it means this is an index that ** was created to be the PRIMARY KEY or to fulfill a UNIQUE diff --git a/test/analyze.test b/test/analyze.test index c445084263..af277cc835 100644 --- a/test/analyze.test +++ b/test/analyze.test @@ -359,6 +359,6 @@ do_test analyze-99.1 { catchsql { ANALYZE } -} {1 {malformed database schema (sqlite_stat1) - near "nonsense": syntax error}} +} {1 {malformed database schema (sqlite_stat1)}} finish_test diff --git a/test/index3.test b/test/index3.test index a9f9b7ae6f..0cdc6e088d 100644 --- a/test/index3.test +++ b/test/index3.test @@ -51,6 +51,6 @@ do_test index3-99.1 { db close catch { sqlite3 db test.db } catchsql { DROP INDEX i1 } -} {1 {malformed database schema (t1) - near "nonsense": syntax error}} +} {1 {malformed database schema (t1)}} finish_test diff --git a/test/trigger7.test b/test/trigger7.test index 8fde2004f8..221962406b 100644 --- a/test/trigger7.test +++ b/test/trigger7.test @@ -114,6 +114,6 @@ do_test trigger7-99.1 { db close catch { sqlite3 db test.db } catchsql { DROP TRIGGER t2r5 } -} {1 {malformed database schema (t2r12) - near "nonsense": syntax error}} +} {1 {malformed database schema (t2r12)}} finish_test From 5b1c07e7fb84f3106276bcbd8c400b88f18aabff Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 16 Apr 2015 07:19:23 +0000 Subject: [PATCH 11/74] Ensure the sqlite3Select() routine always returns non-zero if an error has occurred. FossilOrigin-Name: b51028ed2f57f4245a7ebd9bdb99d1bcfaf1a01b --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/select.c | 7 +++---- test/select1.test | 3 +++ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 5e32fe4ffc..a26119df8c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sparsing\sthe\sschema,\signore\sany\sSQL\sthat\sdoes\snot\sbegin\swith\s"CREATE". -D 2015-04-16T00:26:03.247 +C Ensure\sthe\ssqlite3Select()\sroutine\salways\sreturns\snon-zero\sif\san\serror\shas\soccurred. +D 2015-04-16T07:19:23.819 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +230,7 @@ F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 66cfe49a9c3b449ef13b89a8c47036a4ed167eab F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c 93260bc9e7e0e6dfe1b7cb8815b0ed4cad8be9e3 +F src/select.c fdac71edb73206488b44cfc0f78708e83f99f591 F src/shell.c 72b61a9d41ba12b67ea06fe9267abcc012c6c5bb F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -836,7 +836,7 @@ F test/schema4.test e6a66e20cc69f0e306667c08be7fda3d11707dc5 F test/schema5.test 29699b4421f183c8f0e88bd28ce7d75d13ea653e F test/securedel.test 21749c32ccc30f1ea9e4b9f33295a6521ec20fa0 F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5 -F test/select1.test fc2a61f226a649393664ad54bc5376631801517c +F test/select1.test 53c3a5228b099601eafc7f3cc0e9cd682b07d9d5 F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054 F test/select4.test 16fa1cafb942f42294ec85cbb78954c2f2d15a44 @@ -1250,7 +1250,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 e018f4bf1f27f7838342940ad89a12d7f1536e8e -R 9772cd879deb52a3e48d7b6cb0b29092 -U drh -Z 089490261a72224f9edd48b4acf9b866 +P d3c00d61581c8ba6dce5618391432d3af8d324d4 +R 8123505062f70927e7be9214d0f6d5b6 +U dan +Z fd48a7f3e42fad2b9442aa5a1e6cf7ce diff --git a/manifest.uuid b/manifest.uuid index e0b027b22a..66f4c95a45 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d3c00d61581c8ba6dce5618391432d3af8d324d4 \ No newline at end of file +b51028ed2f57f4245a7ebd9bdb99d1bcfaf1a01b \ No newline at end of file diff --git a/src/select.c b/src/select.c index bed1f80be0..8e85ebadbf 100644 --- a/src/select.c +++ b/src/select.c @@ -5483,10 +5483,9 @@ int sqlite3Select( */ sqlite3VdbeResolveLabel(v, iEnd); - /* The SELECT was successfully coded. Set the return code to 0 - ** to indicate no errors. - */ - rc = 0; + /* The SELECT has been coded. If there is an error in the Parse structure, + ** set the return code to 1. Otherwise 0. */ + rc = (pParse->nErr>0); /* Control jumps to here if an error is encountered above, or upon ** successful coding of the SELECT. diff --git a/test/select1.test b/test/select1.test index 875c87c84a..2ae91dc0fd 100644 --- a/test/select1.test +++ b/test/select1.test @@ -307,6 +307,9 @@ do_test select1-4.4 { set v [catch {execsql {SELECT f1 FROM test1 ORDER BY min(f1)}} msg] lappend v $msg } {1 {misuse of aggregate: min()}} +do_catchsql_test select1-4.5 { + INSERT INTO test1(f1) SELECT f1 FROM test1 ORDER BY min(f1); +} {1 {misuse of aggregate: min()}} # The restriction not allowing constants in the ORDER BY clause # has been removed. See ticket #1768 From 0d2e2f2b101a12d98ee147500a5bdd65b0fe945f Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 16 Apr 2015 08:54:01 +0000 Subject: [PATCH 12/74] Fix a problem in test file e_reindex.test. FossilOrigin-Name: 5b3de9390f2ffc4c530fd47c71c70e87972cf74b --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/e_reindex.test | 8 ++++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index a26119df8c..5e08cf7fd9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthe\ssqlite3Select()\sroutine\salways\sreturns\snon-zero\sif\san\serror\shas\soccurred. -D 2015-04-16T07:19:23.819 +C Fix\sa\sproblem\sin\stest\sfile\se_reindex.test. +D 2015-04-16T08:54:01.766 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -476,7 +476,7 @@ F test/e_expr.test 8f5fdd7261e2d746813b0c6a1c0e34824ad3c5ad F test/e_fkey.test a1783fe1f759e1990e6a11adfcf0702dac4d0707 F test/e_fts3.test 5c02288842e4f941896fd44afdef564dd5fc1459 F test/e_insert.test 0e63edc037afe738bb81a626a676811ed7862c90 -F test/e_reindex.test 396b7b4f0a66863b4e95116a67d93b227193e589 +F test/e_reindex.test 57d439f6c644befc8274ac93cf2f5449cf2736c1 F test/e_resolve.test dcce9308fb13b934ce29591105d031d3e14fbba6 F test/e_select.test 52692ff3849541e828ad4661fe3773a9b8711763 F test/e_select2.test aceb80ab927d46fba5ce7586ebabf23e2bb0604f @@ -1250,7 +1250,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 d3c00d61581c8ba6dce5618391432d3af8d324d4 -R 8123505062f70927e7be9214d0f6d5b6 +P b51028ed2f57f4245a7ebd9bdb99d1bcfaf1a01b +R 2161c4b29e95b81d422e85f30c2d6731 U dan -Z fd48a7f3e42fad2b9442aa5a1e6cf7ce +Z 154b9b38eeade2d6cb79a81e5bb9fb34 diff --git a/manifest.uuid b/manifest.uuid index 66f4c95a45..833d348a2f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b51028ed2f57f4245a7ebd9bdb99d1bcfaf1a01b \ No newline at end of file +5b3de9390f2ffc4c530fd47c71c70e87972cf74b \ No newline at end of file diff --git a/test/e_reindex.test b/test/e_reindex.test index 4b86787a05..fa66aa7a1f 100644 --- a/test/e_reindex.test +++ b/test/e_reindex.test @@ -48,8 +48,11 @@ do_execsql_test e_reindex-1.1 { INSERT INTO t1 VALUES(1, 2); INSERT INTO t1 VALUES(3, 4); INSERT INTO t1 VALUES(5, 6); + + CREATE TABLE saved(a,b,c,d,e); + INSERT INTO saved SELECT * FROM sqlite_master WHERE type = 'index'; PRAGMA writable_schema = 1; - UPDATE sqlite_master SET sql = '-- ' || sql WHERE type = 'index'; + DELETE FROM sqlite_master WHERE type = 'index'; } {} db close @@ -59,7 +62,8 @@ do_execsql_test e_reindex-1.2 { INSERT INTO t1 VALUES(7, 8); INSERT INTO t1 VALUES(9, 10); PRAGMA writable_schema = 1; - UPDATE sqlite_master SET sql = substr(sql, 4) WHERE type = 'index'; + INSERT INTO sqlite_master SELECT * FROM saved; + DROP TABLE saved; } {} db close From 67731a97a25fda22915df3507e8802aee8a93a51 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 11:56:03 +0000 Subject: [PATCH 13/74] Use a heap instead of a bitmap for cell overlap and coverage testing of btree pages in PRAGMA integrity_check. FossilOrigin-Name: 5619c959bf7babb19fd8ba8b228be7f090fe0ce3 --- manifest | 15 +++++---- manifest.uuid | 2 +- src/btree.c | 85 ++++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 81 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 5e32fe4ffc..b0560fd036 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sparsing\sthe\sschema,\signore\sany\sSQL\sthat\sdoes\snot\sbegin\swith\s"CREATE". -D 2015-04-16T00:26:03.247 +C Use\sa\sheap\sinstead\sof\sa\sbitmap\sfor\scell\soverlap\sand\scoverage\stesting\sof\nbtree\spages\sin\sPRAGMA\sintegrity_check. +D 2015-04-16T11:56:03.678 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a 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 c6e32d84442f79d5b96965265d65b3baa231dffc +F src/btree.c c0e7a97c1125b7b0791ced5fc7ab82adb1b47861 F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4 F src/build.c 01b969b20a44a3d9620e597d9af8242348123540 @@ -1250,7 +1250,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 e018f4bf1f27f7838342940ad89a12d7f1536e8e -R 9772cd879deb52a3e48d7b6cb0b29092 +P d3c00d61581c8ba6dce5618391432d3af8d324d4 +R 47f1d98f50d53f3c70bce340530e7599 +T *branch * integrity-check-heap +T *sym-integrity-check-heap * +T -sym-trunk * U drh -Z 089490261a72224f9edd48b4acf9b866 +Z 60d66e717d835dfb89af877c15f0d57c diff --git a/manifest.uuid b/manifest.uuid index e0b027b22a..025d2170ab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d3c00d61581c8ba6dce5618391432d3af8d324d4 \ No newline at end of file +5619c959bf7babb19fd8ba8b228be7f090fe0ce3 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 51fca4b4be..1383193982 100644 --- a/src/btree.c +++ b/src/btree.c @@ -8528,6 +8528,57 @@ static void checkList( } #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ +/* +** An implementation of a min-heap. +** +** aHeap[0] is the number of elements on the heap. aHeap[1] is the +** root element. For element aHeap[N] the daughter nodes are aHeap[N*2] +** and aHeap[N*2+1]. +** +** The heap property is this: Every node is less than or equal to both +** of its daughter nodes. A consequence of the heap property is that the +** root node aHeap[1] is always the minimum value current in the heap. +** +** The btreeHeapInsert() routine inserts an unsigned 32-bit number onto +** the heap, preserving the heap property. The btreeHeapPull() routine +** removes the root element from the heap (the minimum value in the heap) +** and then move other nodes around as necessary to preserve the heap +** property. +** +** This heap is used for cell overlap and coverage testing. Each u32 +** entry represents the span of a cell or freeblock on a btree page. +** The upper 16 bits are the index of the first byte of a range and the +** lower 16 bits are the index of the last byte of that range. +*/ +static void btreeHeapInsert(u32 *aHeap, u32 x){ + u32 j, i = ++aHeap[0]; + aHeap[i] = x; + while( i>1 && aHeap[j=i/2]>aHeap[i] ){ + x = aHeap[j]; + aHeap[j] = aHeap[i]; + aHeap[i] = x; + i = j; + } +} +static int btreeHeapPull(u32 *aHeap, u32 *pOut){ + u32 j, i, x; + if( (x = aHeap[0])==0 ) return 0; + *pOut = aHeap[1]; + aHeap[1] = aHeap[x]; + aHeap[x] = 0xffffffff; + aHeap[0]--; + i = 1; + while( (j = i*2)<=aHeap[0] ){ + if( aHeap[j]>aHeap[j+1] ) j++; + if( aHeap[i]zPfx; @@ -8705,15 +8757,15 @@ static int checkTreePage( */ data = pPage->aData; hdr = pPage->hdrOffset; - hit = sqlite3PageMalloc( pBt->pageSize ); + heap = (u32*)sqlite3PageMalloc( pBt->pageSize ); pCheck->zPfx = 0; - if( hit==0 ){ + if( heap==0 ){ pCheck->mallocFailed = 1; }else{ int contentOffset = get2byteNotZero(&data[hdr+5]); assert( contentOffset<=usableSize ); /* Enforced by btreeInitPage() */ - memset(hit+contentOffset, 0, usableSize-contentOffset); - memset(hit, 1, contentOffset); + heap[0] = 0; + btreeHeapInsert(heap, contentOffset-1); /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the ** number of cells on the page. */ nCell = get2byte(&data[hdr+3]); @@ -8725,7 +8777,6 @@ static int checkTreePage( for(i=0; i=pc; j--) hit[j]++; + btreeHeapInsert(heap, (pc<<16)|(pc+size-1)); } } /* EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header @@ -8746,7 +8797,7 @@ static int checkTreePage( assert( i<=usableSize-4 ); /* Enforced by btreeInitPage() */ size = get2byte(&data[i+2]); assert( i+size<=usableSize ); /* Enforced by btreeInitPage() */ - for(j=i+size-1; j>=i; j--) hit[j]++; + btreeHeapInsert(heap, (i<<16)|(i+size-1)); /* EVIDENCE-OF: R-58208-19414 The first 2 bytes of a freeblock are a ** big-endian integer which is the offset in the b-tree page of the next ** freeblock in the chain, or zero if the freeblock is the last on the @@ -8758,15 +8809,21 @@ static int checkTreePage( assert( j<=usableSize-4 ); /* Enforced by btreeInitPage() */ i = j; } - for(i=cnt=0; i1 ){ + cnt = 0; + assert( heap[0]>0 ); + assert( (heap[1]>>16)==0 ); + btreeHeapPull(heap,&prev); + while( btreeHeapPull(heap,&x) ){ + if( (prev&0xffff)+1>(x>>16) ){ checkAppendMsg(pCheck, - "Multiple uses for byte %d of page %d", i, iPage); + "Multiple uses for byte %u of page %d", x>>16, iPage); break; + }else{ + cnt += (x>>16) - (prev&0xffff) - 1; + prev = x; } } + cnt += usableSize - (prev&0xffff) - 1; /* EVIDENCE-OF: R-43263-13491 The total number of bytes in all fragments ** is stored in the fifth field of the b-tree page header. ** EVIDENCE-OF: R-07161-27322 The one-byte integer at offset 7 gives the @@ -8778,7 +8835,7 @@ static int checkTreePage( cnt, data[hdr+7], iPage); } } - sqlite3PageFree(hit); + sqlite3PageFree(heap); releasePage(pPage); end_of_check: From b073771cdfc16bfc781f400d3d518498e2690b83 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 12:12:07 +0000 Subject: [PATCH 14/74] Fix the corruptC.test module due to a change in error message text. FossilOrigin-Name: 7c0deed25762a954c78d98412d8f4a265a437d06 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/corruptC.test | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 5e08cf7fd9..93195dbcb1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\stest\sfile\se_reindex.test. -D 2015-04-16T08:54:01.766 +C Fix\sthe\scorruptC.test\smodule\sdue\sto\sa\schange\sin\serror\smessage\stext. +D 2015-04-16T12:12:07.953 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -426,7 +426,7 @@ F test/corrupt8.test 2399dfe40d2c0c63af86706e30f3e6302a8d0516 F test/corrupt9.test 730a3db08d4ab9aa43392ea30d9c2b4879cbff85 F test/corruptA.test 53e56dafd180addcdadb402244b8cb9771d2ba26 F test/corruptB.test 73a8d6c0b9833697ecf16b63e3c5c05c945b5dec -F test/corruptC.test 02405cf7ed0c1e989060e1aab6d02ffbc3906fbb +F test/corruptC.test 3fcc0f73d2cf2d69befe2d96332b942426a6aae2 F test/corruptD.test b3c205fac7952b1de645ce44bb02335cd9e3e040 F test/corruptE.test 193b4ca4e927e77c1d5f4f56203ddc998432a7ee F test/corruptF.test be9fde98e4c93648f1ba52b74e5318edc8f59fe4 @@ -1250,7 +1250,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 b51028ed2f57f4245a7ebd9bdb99d1bcfaf1a01b -R 2161c4b29e95b81d422e85f30c2d6731 -U dan -Z 154b9b38eeade2d6cb79a81e5bb9fb34 +P 5b3de9390f2ffc4c530fd47c71c70e87972cf74b +R 52f7fd6b33b7cf36f49fd780c8e11ee8 +U drh +Z 89ad7719122c7a76b704b370103ce659 diff --git a/manifest.uuid b/manifest.uuid index 833d348a2f..c65ebcbe96 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5b3de9390f2ffc4c530fd47c71c70e87972cf74b \ No newline at end of file +7c0deed25762a954c78d98412d8f4a265a437d06 \ No newline at end of file diff --git a/test/corruptC.test b/test/corruptC.test index adf6f44c44..a7f93c46d2 100644 --- a/test/corruptC.test +++ b/test/corruptC.test @@ -292,7 +292,7 @@ do_test corruptC-2.15 { hexio_write test.db 986 b9 sqlite3 db test.db catchsql {SELECT count(*) FROM sqlite_master;} -} {1 {malformed database schema (t1i1) - no such table: main.t1}} +} {1 {database disk image is malformed}} # # Now test for a series of quasi-random seeds. From 772460fd4c73cb810c11a12ea77f3d74602f4041 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 14:13:12 +0000 Subject: [PATCH 15/74] Improvements to the way VALUES clauses are parsed. FossilOrigin-Name: ec5a493ad27593ca78899b3001630c1898b940ff --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/expr.c | 2 +- src/parse.y | 44 ++++++++++++++++++++++++++++---------------- src/select.c | 7 +++---- src/sqliteInt.h | 2 +- test/select4.test | 10 +++++++++- 7 files changed, 53 insertions(+), 34 deletions(-) diff --git a/manifest b/manifest index 93195dbcb1..e9c5d46443 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\scorruptC.test\smodule\sdue\sto\sa\schange\sin\serror\smessage\stext. -D 2015-04-16T12:12:07.953 +C Improvements\sto\sthe\sway\sVALUES\sclauses\sare\sparsed. +D 2015-04-16T14:13:12.394 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -182,7 +182,7 @@ F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e -F src/expr.c 8800584340a9b4f4c0ca55c360de751c6da0b11a +F src/expr.c f37d5eb44a1fad4ca4faa6b0c4f1230f233e3835 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 3343d551a8d810782257244fb33f2ce191493c39 F src/func.c 1414c24c873c48796ad45942257a179a423ba42f @@ -219,7 +219,7 @@ F src/os_win.c 03d27be3a20048ef52a648d5f0a15f5edda9f2a3 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 -F src/parse.y 1299c66e7b1707322ccd8af43a359b8fb0d46d72 +F src/parse.y b5c16bc5aa5e59a7ceb0fe94defa9dce3a6b1d3c F src/pcache.c 10539fb959849ad6efff80050541cab3d25089d4 F src/pcache.h b44658c9c932d203510279439d891a2a83e12ba8 F src/pcache1.c 69d137620a305f814398bd29a0c998038c0695e9 @@ -230,12 +230,12 @@ F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 66cfe49a9c3b449ef13b89a8c47036a4ed167eab F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c fdac71edb73206488b44cfc0f78708e83f99f591 +F src/select.c e24bd1a7b6bf2256cf8df115d01e308c94ad9c05 F src/shell.c 72b61a9d41ba12b67ea06fe9267abcc012c6c5bb F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d -F src/sqliteInt.h 90b7bfd89d7307cd0750663da419ba4bb81e7379 +F src/sqliteInt.h af228df2a02bf1a608d678b312d46aa480470b3c F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179 F src/table.c e7a09215315a978057fb42c640f890160dbcc45e @@ -839,7 +839,7 @@ F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5 F test/select1.test 53c3a5228b099601eafc7f3cc0e9cd682b07d9d5 F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054 -F test/select4.test 16fa1cafb942f42294ec85cbb78954c2f2d15a44 +F test/select4.test d4330ee0e24e52fa21c62c6bbf999dbfcbb7dfd0 F test/select5.test e758b8ef94f69b111df4cb819008856655dcd535 F test/select6.test 39eac4a5c03650b2b473c532882273283ee8b7a0 F test/select7.test 7fd2ef598cfabb6b9ff6ac13973b91d0527df49d @@ -1250,7 +1250,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 5b3de9390f2ffc4c530fd47c71c70e87972cf74b -R 52f7fd6b33b7cf36f49fd780c8e11ee8 +P 7c0deed25762a954c78d98412d8f4a265a437d06 +R 611a860661173119865e499e8c5f5052 U drh -Z 89ad7719122c7a76b704b370103ce659 +Z f1f791a01fc19f4f892a113c0900910a diff --git a/manifest.uuid b/manifest.uuid index c65ebcbe96..c43e827164 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c0deed25762a954c78d98412d8f4a265a437d06 \ No newline at end of file +ec5a493ad27593ca78899b3001630c1898b940ff \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 77eb35aa74..418881ffd9 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2016,7 +2016,7 @@ int sqlite3CodeSubselect( pSel->pLimit = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[1]); pSel->iLimit = 0; - pSel->selFlags &= ~SF_AllValues; + pSel->selFlags &= ~SF_MultiValue; if( sqlite3Select(pParse, pSel, &dest) ){ return 0; } diff --git a/src/parse.y b/src/parse.y index b8ef26810c..ac15c3ce71 100644 --- a/src/parse.y +++ b/src/parse.y @@ -409,28 +409,35 @@ cmd ::= select(X). { %type oneselect {Select*} %destructor oneselect {sqlite3SelectDelete(pParse->db, $$);} -select(A) ::= with(W) selectnowith(X). { - Select *p = X, *pNext, *pLoop; - if( p ){ - int cnt = 0, mxSelect; - p->pWith = W; +%include { + /* + ** For a compound SELECT statement, make sure p->pPrior->pNext==p for + ** all elements in the list. And make sure list length does not exceed + ** SQLITE_LIMIT_COMPOUND_SELECT. + */ + void parserDoubleLinkSelect(Parse *pParse, Select *p){ if( p->pPrior ){ - u16 allValues = SF_Values; - pNext = 0; + Select *pNext = 0, *pLoop; + int mxSelect, cnt = 0; for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){ pLoop->pNext = pNext; pLoop->selFlags |= SF_Compound; - allValues &= pLoop->selFlags; } - if( allValues ){ - p->selFlags |= SF_AllValues; - }else if( - (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 - && cnt>mxSelect + if( (p->selFlags & SF_MultiValue)==0 && + (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 && + cnt>mxSelect ){ sqlite3ErrorMsg(pParse, "too many terms in compound SELECT"); } } + } +} + +select(A) ::= with(W) selectnowith(X). { + Select *p = X; + if( p ){ + p->pWith = W; + parserDoubleLinkSelect(pParse, p); }else{ sqlite3WithDelete(pParse->db, W); } @@ -445,12 +452,14 @@ selectnowith(A) ::= selectnowith(X) multiselect_op(Y) oneselect(Z). { SrcList *pFrom; Token x; x.n = 0; + parserDoubleLinkSelect(pParse, pRhs); pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0); pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0); } if( pRhs ){ pRhs->op = (u8)Y; pRhs->pPrior = X; + pRhs->selFlags &= ~SF_MultiValue; if( Y!=TK_ALL ) pParse->hasCompound = 1; }else{ sqlite3SelectDelete(pParse->db, X); @@ -498,13 +507,16 @@ values(A) ::= VALUES LP nexprlist(X) RP. { A = sqlite3SelectNew(pParse,X,0,0,0,0,0,SF_Values,0,0); } values(A) ::= values(X) COMMA LP exprlist(Y) RP. { - Select *pRight = sqlite3SelectNew(pParse,Y,0,0,0,0,0,SF_Values,0,0); + Select *pRight, *pLeft = X; + pRight = sqlite3SelectNew(pParse,Y,0,0,0,0,0,SF_Values|SF_MultiValue,0,0); + if( pLeft ) pLeft->selFlags &= ~SF_MultiValue; if( pRight ){ pRight->op = TK_ALL; - pRight->pPrior = X; + pLeft = X; + pRight->pPrior = pLeft; A = pRight; }else{ - A = X; + A = pLeft; } } diff --git a/src/select.c b/src/select.c index 8e85ebadbf..298ad90a1c 100644 --- a/src/select.c +++ b/src/select.c @@ -2108,8 +2108,7 @@ static int multiSelectValues( int nExpr = p->pEList->nExpr; int nRow = 1; int rc = 0; - assert( p->pNext==0 ); - assert( p->selFlags & SF_AllValues ); + assert( p->selFlags & SF_MultiValue ); do{ assert( p->selFlags & SF_Values ); assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) ); @@ -2218,7 +2217,7 @@ static int multiSelect( /* Special handling for a compound-select that originates as a VALUES clause. */ - if( p->selFlags & SF_AllValues ){ + if( p->selFlags & SF_MultiValue ){ rc = multiSelectValues(pParse, p, &dest); goto multi_select_end; } @@ -4422,7 +4421,7 @@ static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){ sqlite3WalkSelect(&w, pSelect); } w.xSelectCallback = selectExpander; - if( (pSelect->selFlags & SF_AllValues)==0 ){ + if( (pSelect->selFlags & SF_MultiValue)==0 ){ w.xSelectCallback2 = selectPopWith; } sqlite3WalkSelect(&w, pSelect); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index ee24342919..b1a2db3a28 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2385,7 +2385,7 @@ struct Select { #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */ #define SF_Compound 0x0040 /* Part of a compound query */ #define SF_Values 0x0080 /* Synthesized from VALUES clause */ -#define SF_AllValues 0x0100 /* All terms of compound are VALUES */ +#define SF_MultiValue 0x0100 /* Single VALUES term with multiple rows */ #define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */ #define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */ #define SF_Recursive 0x0800 /* The recursive part of a recursive CTE */ diff --git a/test/select4.test b/test/select4.test index 2f3ddbe96a..ce09ba71d4 100644 --- a/test/select4.test +++ b/test/select4.test @@ -874,6 +874,14 @@ do_execsql_test select4-14.10 { do_execsql_test select4-14.11 { SELECT (SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4) } {1} - +do_execsql_test select4-14.12 { + VALUES(1) UNION VALUES(2); +} {1 2} +do_execsql_test select4-14.13 { + VALUES(1),(2),(3) EXCEPT VALUES(2); +} {1 3} +do_execsql_test select4-14.14 { + VALUES(1),(2),(3) EXCEPT VALUES(1),(3); +} {2} finish_test From 6736618a8f9368629a7d9510a549bb591d9d7d20 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 14:33:35 +0000 Subject: [PATCH 16/74] Fix a faulty assert() in the compound select code generator. FossilOrigin-Name: 9d336be1b16aa9bd5c9e4132bb645874993c7d96 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/select.c | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index e9c5d46443..86969a411c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\sway\sVALUES\sclauses\sare\sparsed. -D 2015-04-16T14:13:12.394 +C Fix\sa\sfaulty\sassert()\sin\sthe\scompound\sselect\scode\sgenerator. +D 2015-04-16T14:33:35.359 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +230,7 @@ F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 66cfe49a9c3b449ef13b89a8c47036a4ed167eab F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c e24bd1a7b6bf2256cf8df115d01e308c94ad9c05 +F src/select.c b7b91db829464db6ebba4cd6a878a0ef688b847d F src/shell.c 72b61a9d41ba12b67ea06fe9267abcc012c6c5bb F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -1250,7 +1250,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 7c0deed25762a954c78d98412d8f4a265a437d06 -R 611a860661173119865e499e8c5f5052 +P ec5a493ad27593ca78899b3001630c1898b940ff +R 11ac4c431272562d678d3132e12f4ff6 U drh -Z f1f791a01fc19f4f892a113c0900910a +Z 9969aaea0bee219926e4d05bec4ccd67 diff --git a/manifest.uuid b/manifest.uuid index c43e827164..523f920fa3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ec5a493ad27593ca78899b3001630c1898b940ff \ No newline at end of file +9d336be1b16aa9bd5c9e4132bb645874993c7d96 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 298ad90a1c..c7c7095032 100644 --- a/src/select.c +++ b/src/select.c @@ -2859,8 +2859,10 @@ static int multiSelectOrderBy( if( aPermute ){ struct ExprList_item *pItem; for(i=0, pItem=pOrderBy->a; iu.x.iOrderByCol>0 - && pItem->u.x.iOrderByCol<=p->pEList->nExpr ); + assert( pItem->u.x.iOrderByCol>0 ); + /* assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr ) is also true + ** but only for well-formed SELECT statements. */ + testcase( pItem->u.x.iOrderByCol > p->pEList->nExpr ); aPermute[i] = pItem->u.x.iOrderByCol - 1; } pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1); From 9569f60e18282e33dd78c63c8b842c3392bb576d Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 15:05:04 +0000 Subject: [PATCH 17/74] Add the --backslash option to the command-line shell for testing purposes. FossilOrigin-Name: dd96211e8022365637286b146120cc5db44a9923 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 9 +++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 86969a411c..93103be3ba 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sfaulty\sassert()\sin\sthe\scompound\sselect\scode\sgenerator. -D 2015-04-16T14:33:35.359 +C Add\sthe\s--backslash\soption\sto\sthe\scommand-line\sshell\sfor\stesting\spurposes. +D 2015-04-16T15:05:04.946 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -231,7 +231,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 66cfe49a9c3b449ef13b89a8c47036a4ed167eab F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c b7b91db829464db6ebba4cd6a878a0ef688b847d -F src/shell.c 72b61a9d41ba12b67ea06fe9267abcc012c6c5bb +F src/shell.c 28b3e1174a7fc00155d7d00880a33589a88508c9 F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d @@ -1250,7 +1250,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 ec5a493ad27593ca78899b3001630c1898b940ff -R 11ac4c431272562d678d3132e12f4ff6 +P 9d336be1b16aa9bd5c9e4132bb645874993c7d96 +R 5fbffaa37b14ccf06bc3b95dfad9c618 U drh -Z 9969aaea0bee219926e4d05bec4ccd67 +Z e400cf12f450b0a1df16da05ddca199b diff --git a/manifest.uuid b/manifest.uuid index 523f920fa3..57720c5916 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9d336be1b16aa9bd5c9e4132bb645874993c7d96 \ No newline at end of file +dd96211e8022365637286b146120cc5db44a9923 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 0f7234c47f..0d83084741 100644 --- a/src/shell.c +++ b/src/shell.c @@ -527,6 +527,7 @@ struct ShellState { int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */ int statsOn; /* True to display memory stats before each finalize */ int scanstatsOn; /* True to display scan stats before each finalize */ + int backslashOn; /* Resolve C-style \x escapes in SQL input text */ int outCount; /* Revert to stdout when reaching zero */ int cnt; /* Number of records displayed so far */ FILE *out; /* Write results here */ @@ -4111,6 +4112,7 @@ static int process_input(ShellState *p, FILE *in){ && sqlite3_complete(zSql) ){ p->cnt = 0; open_db(p, 0); + if( p->backslashOn ) resolve_backslashes(zSql); BEGIN_TIMER; rc = shell_exec(p->db, zSql, shell_callback, p, &zErrMsg); END_TIMER; @@ -4577,6 +4579,13 @@ int SQLITE_CDECL main(int argc, char **argv){ data.statsOn = 1; }else if( strcmp(z,"-scanstats")==0 ){ data.scanstatsOn = 1; + }else if( strcmp(z,"-backslash")==0 ){ + /* Undocumented command-line option: -backslash + ** Causes C-style backslash escapes to be evaluated in SQL statements + ** prior to sending the SQL into SQLite. Useful for injecting + ** crazy bytes in the middle of SQL statements for testing and debugging. + */ + data.backslashOn = 1; }else if( strcmp(z,"-bail")==0 ){ bail_on_error = 1; }else if( strcmp(z,"-version")==0 ){ From e06874eaa10b153add74507b0d6ad5027cee2dba Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 15:47:06 +0000 Subject: [PATCH 18/74] Make sure errors in coding triggers are propagated back up to the parser. FossilOrigin-Name: 928f973ca9adc7933015b2fb6b6fcb8e3154cb9c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/trigger.c | 1 + test/fkey2.test | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 93103be3ba..d7954dddf7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s--backslash\soption\sto\sthe\scommand-line\sshell\sfor\stesting\spurposes. -D 2015-04-16T15:05:04.946 +C Make\ssure\serrors\sin\scoding\striggers\sare\spropagated\sback\sup\sto\sthe\sparser. +D 2015-04-16T15:47:06.148 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -288,7 +288,7 @@ F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 6bbcc9fe50c917864d48287b4792d46d6e873481 F src/tokenize.c a8234a67577308935cdf13e618cd66556f5f45d1 -F src/trigger.c 69a91bed7c94e46223e37ffccfeeb35e34b999ac +F src/trigger.c a261da05e2ba65035d6f4b85d1fe6d4f363c1f1f F src/update.c 3c4ecc282accf12d39edb8d524cf089645e55a13 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c 98a7627ca48ad3265b6940915a1d08355eb3fc7e @@ -505,7 +505,7 @@ F test/fallocate.test 3e979af17dfa7e5e9dda5eba1a696c04fa9d47f7 F test/filectrl.test 14fa712e42c4cb791e09dfd58a6a03efb47ef13a F test/filefmt.test cb34663f126cbc2d358af552dcaf5c72769b0146 F test/fkey1.test e1d1fa84cde579185ea01358436839703e415a5b -F test/fkey2.test 223c624e7eccee21e89c98d4d127ac88d774b940 +F test/fkey2.test 043692a609d513f8f230ca3064e8074f8643b60e F test/fkey3.test 76d475c80b84ee7a5d062e56ccb6ea68882e2b49 F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d F test/fkey5.test 56bcb5a6e8b725b17febc267fb041a6695e86853 @@ -1250,7 +1250,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 9d336be1b16aa9bd5c9e4132bb645874993c7d96 -R 5fbffaa37b14ccf06bc3b95dfad9c618 +P dd96211e8022365637286b146120cc5db44a9923 +R 046f14926b5af5dfc4416003fb47b3d1 U drh -Z e400cf12f450b0a1df16da05ddca199b +Z 6ea7be360982608826bd8c7c45584988 diff --git a/manifest.uuid b/manifest.uuid index 57720c5916..7832a2dde8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dd96211e8022365637286b146120cc5db44a9923 \ No newline at end of file +928f973ca9adc7933015b2fb6b6fcb8e3154cb9c \ No newline at end of file diff --git a/src/trigger.c b/src/trigger.c index ed152d2a8a..d29f509a8d 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -795,6 +795,7 @@ static void transferParseError(Parse *pTo, Parse *pFrom){ if( pTo->nErr==0 ){ pTo->zErrMsg = pFrom->zErrMsg; pTo->nErr = pFrom->nErr; + pTo->rc = pFrom->rc; }else{ sqlite3DbFree(pFrom->db, pFrom->zErrMsg); } diff --git a/test/fkey2.test b/test/fkey2.test index 8b2871e5a6..d0b284b780 100644 --- a/test/fkey2.test +++ b/test/fkey2.test @@ -2014,4 +2014,18 @@ do_test fkey2-ce7c13.1.6 { } } {1 {FOREIGN KEY constraint failed}} +# 2015-04-16: Foreign key errors propagate back up to the parser. +# +do_test fkey2-20150416-100 { + db close + sqlite3 db :memory: + catchsql { + PRAGMA foreign_keys=1; + CREATE TABLE t1(x PRIMARY KEY); + CREATE TABLE t(y REFERENCES t0(x)ON DELETE SET DEFAULT); + CREATE TABLE t0(y REFERENCES t1 ON DELETE SET NULL); + REPLACE INTO t1 SELECT(0);CREATE TABLE t2(x);CREATE TABLE t3; + } +} {1 {foreign key mismatch - "t" referencing "t0"}} + finish_test From 59ac655d028c744b13d079e8a06e8f56b6ae8092 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 16:04:39 +0000 Subject: [PATCH 19/74] Silently ignore requests to change the PRAGMA synchronous setting to an illegal integer value, rather than raising an assertion. FossilOrigin-Name: e0a88176fcfbed7b554a036948261a332c920053 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pragma.c | 4 +++- test/pragma.test | 12 ++++++++++++ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d7954dddf7..2370ea266a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\serrors\sin\scoding\striggers\sare\spropagated\sback\sup\sto\sthe\sparser. -D 2015-04-16T15:47:06.148 +C Silently\signore\srequests\sto\schange\sthe\sPRAGMA\ssynchronous\ssetting\sto\san\nillegal\sinteger\svalue,\srather\sthan\sraising\san\sassertion. +D 2015-04-16T16:04:39.846 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -223,7 +223,7 @@ F src/parse.y b5c16bc5aa5e59a7ceb0fe94defa9dce3a6b1d3c F src/pcache.c 10539fb959849ad6efff80050541cab3d25089d4 F src/pcache.h b44658c9c932d203510279439d891a2a83e12ba8 F src/pcache1.c 69d137620a305f814398bd29a0c998038c0695e9 -F src/pragma.c 3965ae4e82bed39fb97ce04c5fe18c9bc3ee6a88 +F src/pragma.c 633cb355ab30b197d4e8e9976f94378199439b76 F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f F src/prepare.c 1fffbdcd6f8a0173a8f70d71f22528f4c0e1e3d3 F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f @@ -794,7 +794,7 @@ F test/pcache.test b09104b03160aca0d968d99e8cd2c5b1921a993d F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff F test/permutations.test f9cc1dd987986c9d4949211c7a4ed55ec9aecba1 -F test/pragma.test e6605ce89c66db930aef561e43a22281a09ffc66 +F test/pragma.test 2e3d20785e463d7eeed636cba16e742b5df88073 F test/pragma2.test f624a496a95ee878e81e59961eade66d5c00c028 F test/pragma3.test 6f849ccffeee7e496d2f2b5e74152306c0b8757c F test/printf.test b3ff34e73d59124140eaf89f7672e21bc2ca5fcc @@ -1250,7 +1250,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 dd96211e8022365637286b146120cc5db44a9923 -R 046f14926b5af5dfc4416003fb47b3d1 +P 928f973ca9adc7933015b2fb6b6fcb8e3154cb9c +R f9e99024211f275c6c5be92b169c1ffa U drh -Z 6ea7be360982608826bd8c7c45584988 +Z 092fd595f2813758c3267ca51aac5606 diff --git a/manifest.uuid b/manifest.uuid index 7832a2dde8..91ff8f2a2e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -928f973ca9adc7933015b2fb6b6fcb8e3154cb9c \ No newline at end of file +e0a88176fcfbed7b554a036948261a332c920053 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 8f6ac64754..3cecd8dda5 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -946,7 +946,9 @@ void sqlite3Pragma( sqlite3ErrorMsg(pParse, "Safety level may not be changed inside a transaction"); }else{ - pDb->safety_level = getSafetyLevel(zRight,0,1)+1; + testcase( (getSafetyLevel(zRight,0,1)+1) & ~PAGER_SYNCHRONOUS_MASK ); + pDb->safety_level = (getSafetyLevel(zRight,0,1)+1) + & PAGER_SYNCHRONOUS_MASK; setAllPagerFlags(db); } } diff --git a/test/pragma.test b/test/pragma.test index e8a53f442d..a45dc45a44 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -219,6 +219,18 @@ do_test pragma-1.14 { PRAGMA synchronous; } } {2} +do_test pragma-1.14.1 { + execsql { + PRAGMA synchronous=4; + PRAGMA synchronous; + } +} {0} +do_test pragma-1.14.2 { + execsql { + PRAGMA synchronous=10; + PRAGMA synchronous; + } +} {2} } ;# ifcapable pager_pragmas # Test turning "flag" pragmas on and off. From a276e3fd4d28adb49b39235b1f87d51ba406e673 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 16:22:27 +0000 Subject: [PATCH 20/74] Fix a faulty assert() in the compound-SELECT code generator. FossilOrigin-Name: 10715b05f2201a63dca317f99ce39d3ce182e182 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 2 +- test/select4.test | 4 ++++ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 2370ea266a..8446774a73 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Silently\signore\srequests\sto\schange\sthe\sPRAGMA\ssynchronous\ssetting\sto\san\nillegal\sinteger\svalue,\srather\sthan\sraising\san\sassertion. -D 2015-04-16T16:04:39.846 +C Fix\sa\sfaulty\sassert()\sin\sthe\scompound-SELECT\scode\sgenerator. +D 2015-04-16T16:22:27.087 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +230,7 @@ F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 66cfe49a9c3b449ef13b89a8c47036a4ed167eab F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c b7b91db829464db6ebba4cd6a878a0ef688b847d +F src/select.c d66970749a9d5a5b04950c9a26d6d0ea1320f91b F src/shell.c 28b3e1174a7fc00155d7d00880a33589a88508c9 F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -839,7 +839,7 @@ F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5 F test/select1.test 53c3a5228b099601eafc7f3cc0e9cd682b07d9d5 F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054 -F test/select4.test d4330ee0e24e52fa21c62c6bbf999dbfcbb7dfd0 +F test/select4.test 4b2df48129369a2a426f0f710fb94c50f75b31fb F test/select5.test e758b8ef94f69b111df4cb819008856655dcd535 F test/select6.test 39eac4a5c03650b2b473c532882273283ee8b7a0 F test/select7.test 7fd2ef598cfabb6b9ff6ac13973b91d0527df49d @@ -1250,7 +1250,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 928f973ca9adc7933015b2fb6b6fcb8e3154cb9c -R f9e99024211f275c6c5be92b169c1ffa +P e0a88176fcfbed7b554a036948261a332c920053 +R 0b75ab69a90f92b9d27a639039ba6734 U drh -Z 092fd595f2813758c3267ca51aac5606 +Z 2a30576e418c5afefa31fbc64fb3a4fe diff --git a/manifest.uuid b/manifest.uuid index 91ff8f2a2e..7c6fbacdd3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e0a88176fcfbed7b554a036948261a332c920053 \ No newline at end of file +10715b05f2201a63dca317f99ce39d3ce182e182 \ No newline at end of file diff --git a/src/select.c b/src/select.c index c7c7095032..e4e5d6da8d 100644 --- a/src/select.c +++ b/src/select.c @@ -2628,7 +2628,7 @@ static int generateOutputSubroutine( ** of the scan loop. */ case SRT_Mem: { - assert( pIn->nSdst==1 ); + assert( pIn->nSdst==1 || pParse->nErr>0 ); testcase( pIn->nSdst!=1 ); sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1); /* The LIMIT clause will jump out of the loop for us */ break; diff --git a/test/select4.test b/test/select4.test index ce09ba71d4..7718901c0c 100644 --- a/test/select4.test +++ b/test/select4.test @@ -118,6 +118,10 @@ do_test select4-1.3 { }} msg] lappend v $msg } {1 {ORDER BY clause should come after UNION ALL not before}} +do_catchsql_test select4-1.4 { + SELECT (VALUES(0) INTERSECT SELECT(0) UNION SELECT(0) ORDER BY (0) UNION + SELECT 0 UNION SELECT 0 ORDER BY 1); +} {1 {ORDER BY clause should come after UNION not before}} # Union operator # From 6dc4148547a0e3e60b4688fb7d142ae55181460d Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 17:31:02 +0000 Subject: [PATCH 21/74] Fix the VDBE so that it always uses the original opcode for profiling and debugging even after the pOp pointer has been updated due to a jump. FossilOrigin-Name: 647495cf12b656f6a2f028dc1fb459d667153cf2 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 20 +++++++++++++------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 8446774a73..926e070400 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sfaulty\sassert()\sin\sthe\scompound-SELECT\scode\sgenerator. -D 2015-04-16T16:22:27.087 +C Fix\sthe\sVDBE\sso\sthat\sit\salways\suses\sthe\soriginal\sopcode\sfor\sprofiling\sand\ndebugging\seven\safter\sthe\spOp\spointer\shas\sbeen\supdated\sdue\sto\sa\sjump. +D 2015-04-16T17:31:02.931 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a 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 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 3f3afd12d4794cb51fe13dc948b1172a5eb71a94 +F src/vdbe.c 55650cb03d26ce5955cffcdc6568e046680b1fd4 F src/vdbe.h 7e538ecf47dccb307ea2d087c3ddc2dd8d70e79d F src/vdbeInt.h 9cbaa84f53ddd2d09a0cf61a94337a3a035d08a0 F src/vdbeapi.c 583d56b129dd27f12bed518270de9ebe521e6a75 @@ -1250,7 +1250,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 e0a88176fcfbed7b554a036948261a332c920053 -R 0b75ab69a90f92b9d27a639039ba6734 +P 10715b05f2201a63dca317f99ce39d3ce182e182 +R a3daab05325b2d95fe679d302a2d11e4 U drh -Z 2a30576e418c5afefa31fbc64fb3a4fe +Z 9f3c109ab0871adbf8f7030a7a0d36ce diff --git a/manifest.uuid b/manifest.uuid index 7c6fbacdd3..e49cab3edf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -10715b05f2201a63dca317f99ce39d3ce182e182 \ No newline at end of file +647495cf12b656f6a2f028dc1fb459d667153cf2 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 3bd4222c8b..0890df11a5 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -539,6 +539,9 @@ int sqlite3VdbeExec( ){ Op *aOp = p->aOp; /* Copy of p->aOp */ Op *pOp = aOp; /* Current operation */ +#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE) + Op *pOrigOp; /* Value of pOp at the top of the loop */ +#endif int rc = SQLITE_OK; /* Value to return */ sqlite3 *db = p->db; /* The database */ u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */ @@ -681,6 +684,9 @@ int sqlite3VdbeExec( memAboutToChange(p, &aMem[pOp->p3]); } #endif +#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE) + pOrigOp = pOp; +#endif switch( pOp->opcode ){ @@ -6489,8 +6495,8 @@ default: { /* This is really OP_Noop and OP_Explain */ #ifdef VDBE_PROFILE { u64 endTime = sqlite3Hwtime(); - if( endTime>start ) pOp->cycles += endTime - start; - pOp->cnt++; + if( endTime>start ) pOrigOp->cycles += endTime - start; + pOrigOp->cnt++; } #endif @@ -6500,16 +6506,16 @@ default: { /* This is really OP_Noop and OP_Explain */ ** the evaluator loop. So we can leave it out when NDEBUG is defined. */ #ifndef NDEBUG - assert( pOp>=&aOp[-1] && pOp<&aOp[p->nOp] ); + assert( pOp>=&aOp[-1] && pOp<&aOp[p->nOp-1] ); #ifdef SQLITE_DEBUG if( db->flags & SQLITE_VdbeTrace ){ if( rc!=0 ) printf("rc=%d\n",rc); - if( pOp->opflags & (OPFLG_OUT2) ){ - registerTrace(pOp->p2, &aMem[pOp->p2]); + if( pOrigOp->opflags & (OPFLG_OUT2) ){ + registerTrace(pOrigOp->p2, &aMem[pOrigOp->p2]); } - if( pOp->opflags & OPFLG_OUT3 ){ - registerTrace(pOp->p3, &aMem[pOp->p3]); + if( pOrigOp->opflags & OPFLG_OUT3 ){ + registerTrace(pOrigOp->p3, &aMem[pOrigOp->p3]); } } #endif /* SQLITE_DEBUG */ From ab4e7f3337e8a7942492b09813826f6ae0cdc43f Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 18:11:50 +0000 Subject: [PATCH 22/74] Make sure all cursors are closed when returning from a VDBE subprogram that implements a foreign-key construct. FossilOrigin-Name: d04d354d8e423961c3091b6ebcfbbbf10d3ecb04 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 29 ++++++++++++++++++----------- test/fkey2.test | 5 +++++ 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 926e070400..fbd6b0739e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sVDBE\sso\sthat\sit\salways\suses\sthe\soriginal\sopcode\sfor\sprofiling\sand\ndebugging\seven\safter\sthe\spOp\spointer\shas\sbeen\supdated\sdue\sto\sa\sjump. -D 2015-04-16T17:31:02.931 +C Make\ssure\sall\scursors\sare\sclosed\swhen\sreturning\sfrom\sa\sVDBE\ssubprogram\sthat\nimplements\sa\sforeign-key\sconstruct. +D 2015-04-16T18:11:50.067 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -297,7 +297,7 @@ F src/vdbe.c 55650cb03d26ce5955cffcdc6568e046680b1fd4 F src/vdbe.h 7e538ecf47dccb307ea2d087c3ddc2dd8d70e79d F src/vdbeInt.h 9cbaa84f53ddd2d09a0cf61a94337a3a035d08a0 F src/vdbeapi.c 583d56b129dd27f12bed518270de9ebe521e6a75 -F src/vdbeaux.c a20504ae52392459fa08402fda3f195f19d7c79d +F src/vdbeaux.c 03591cca98ec50e1493043f0ff7abbece0b9c83d F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90 F src/vdbemem.c c0dc81285b7571b0a31c40f17846fe2397ec1cd9 F src/vdbesort.c 2e7f683464fd5db3be4beaa1ff2d39e24fcb64b8 @@ -505,7 +505,7 @@ F test/fallocate.test 3e979af17dfa7e5e9dda5eba1a696c04fa9d47f7 F test/filectrl.test 14fa712e42c4cb791e09dfd58a6a03efb47ef13a F test/filefmt.test cb34663f126cbc2d358af552dcaf5c72769b0146 F test/fkey1.test e1d1fa84cde579185ea01358436839703e415a5b -F test/fkey2.test 043692a609d513f8f230ca3064e8074f8643b60e +F test/fkey2.test f3d27ecba480a348c328965d154214719bb158a9 F test/fkey3.test 76d475c80b84ee7a5d062e56ccb6ea68882e2b49 F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d F test/fkey5.test 56bcb5a6e8b725b17febc267fb041a6695e86853 @@ -1250,7 +1250,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 10715b05f2201a63dca317f99ce39d3ce182e182 -R a3daab05325b2d95fe679d302a2d11e4 +P 647495cf12b656f6a2f028dc1fb459d667153cf2 +R a757fbed701cb5d24ccca7b2844fe222 U drh -Z 9f3c109ab0871adbf8f7030a7a0d36ce +Z 3babb77db24db798d253708de47714ee diff --git a/manifest.uuid b/manifest.uuid index e49cab3edf..3c86d5dfe0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -647495cf12b656f6a2f028dc1fb459d667153cf2 \ No newline at end of file +d04d354d8e423961c3091b6ebcfbbbf10d3ecb04 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 1c10bab0b8..2c32038564 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1789,6 +1789,22 @@ void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){ #endif } +/* +** Close all cursors in the current frame. +*/ +static void closeCursorsInFrame(Vdbe *p){ + if( p->apCsr ){ + int i; + for(i=0; inCursor; i++){ + VdbeCursor *pC = p->apCsr[i]; + if( pC ){ + sqlite3VdbeFreeCursor(p, pC); + p->apCsr[i] = 0; + } + } + } +} + /* ** Copy the values stored in the VdbeFrame structure to its Vdbe. This ** is used, for example, when a trigger sub-program is halted to restore @@ -1796,6 +1812,7 @@ void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){ */ int sqlite3VdbeFrameRestore(VdbeFrame *pFrame){ Vdbe *v = pFrame->v; + closeCursorsInFrame(v); #ifdef SQLITE_ENABLE_STMT_SCANSTATUS v->anExec = pFrame->anExec; #endif @@ -1830,17 +1847,7 @@ static void closeAllCursors(Vdbe *p){ p->nFrame = 0; } assert( p->nFrame==0 ); - - if( p->apCsr ){ - int i; - for(i=0; inCursor; i++){ - VdbeCursor *pC = p->apCsr[i]; - if( pC ){ - sqlite3VdbeFreeCursor(p, pC); - p->apCsr[i] = 0; - } - } - } + closeCursorsInFrame(p); if( p->aMem ){ releaseMemArray(&p->aMem[1], p->nMem); } diff --git a/test/fkey2.test b/test/fkey2.test index d0b284b780..aec75ed693 100644 --- a/test/fkey2.test +++ b/test/fkey2.test @@ -676,6 +676,11 @@ do_test fkey2-9.2.3 { SELECT * FROM cc; } } {{} A {} {} B {} 3 A 2 3 B 2} +do_execsql_test fkey2-9.3.0 { + CREATE TABLE t3(x PRIMARY KEY REFERENCES t3 ON DELETE SET NULL); + INSERT INTO t3(x) VALUES(12345); + DROP TABLE t3; +} {} #------------------------------------------------------------------------- # The following tests, fkey2-10.*, test "foreign key mismatch" and From a4bb7764fe5af31cd71215d17327aebd0c32417d Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 20:10:17 +0000 Subject: [PATCH 23/74] Fix a boundry-value condition in the phrase poslist extractor of FTS3/4. FossilOrigin-Name: 55d10baf0bffdb1a34bf5627ed8f25e4a4efd942 --- ext/fts3/fts3.c | 3 ++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index eab8ad63ad..0555025f1a 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -5765,7 +5765,8 @@ int sqlite3Fts3EvalPhrasePoslist( pIter = pPhrase->pOrPoslist; iDocid = pPhrase->iOrDocid; if( pCsr->bDesc==bDescDoclist ){ - bEof = (pIter >= (pPhrase->doclist.aAll + pPhrase->doclist.nAll)); + bEof = !pPhrase->doclist.nAll || + (pIter >= (pPhrase->doclist.aAll + pPhrase->doclist.nAll)); while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){ sqlite3Fts3DoclistNext( bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll, diff --git a/manifest b/manifest index fbd6b0739e..e2292c4541 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sall\scursors\sare\sclosed\swhen\sreturning\sfrom\sa\sVDBE\ssubprogram\sthat\nimplements\sa\sforeign-key\sconstruct. -D 2015-04-16T18:11:50.067 +C Fix\sa\sboundry-value\scondition\sin\sthe\sphrase\sposlist\sextractor\sof\sFTS3/4. +D 2015-04-16T20:10:17.867 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a 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 4bd75289875b63c04f943d6ed7c31737da99cd74 +F ext/fts3/fts3.c cb5019020e1ca8e999beb2a63100563c17def8ae F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 3626655d6ba903a3919bb44e1c38e5f0f9d6be82 F ext/fts3/fts3_aux.c 5c211e17a64885faeb16b9ba7772f9d5445c2365 @@ -1250,7 +1250,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 647495cf12b656f6a2f028dc1fb459d667153cf2 -R a757fbed701cb5d24ccca7b2844fe222 +P d04d354d8e423961c3091b6ebcfbbbf10d3ecb04 +R 7d25758eea33f4a370736317991c770a U drh -Z 3babb77db24db798d253708de47714ee +Z 4086867d1a0bc88e855064836598b64d diff --git a/manifest.uuid b/manifest.uuid index 3c86d5dfe0..7320463437 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d04d354d8e423961c3091b6ebcfbbbf10d3ecb04 \ No newline at end of file +55d10baf0bffdb1a34bf5627ed8f25e4a4efd942 \ No newline at end of file From f3151f0a0d251d70a606aa25983d2261811e1e65 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 20:27:09 +0000 Subject: [PATCH 24/74] Fix a couple of unreachable branches. FossilOrigin-Name: 8f391dffcfe068d48f854784648610d8a86f6bc8 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/parse.y | 2 +- src/tokenize.c | 4 +--- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index e2292c4541..4eae8fd3c1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sboundry-value\scondition\sin\sthe\sphrase\sposlist\sextractor\sof\sFTS3/4. -D 2015-04-16T20:10:17.867 +C Fix\sa\scouple\sof\sunreachable\sbranches. +D 2015-04-16T20:27:09.079 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -219,7 +219,7 @@ F src/os_win.c 03d27be3a20048ef52a648d5f0a15f5edda9f2a3 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 -F src/parse.y b5c16bc5aa5e59a7ceb0fe94defa9dce3a6b1d3c +F src/parse.y 5944031bd7660589a7bb340cef5e134b55f01ec0 F src/pcache.c 10539fb959849ad6efff80050541cab3d25089d4 F src/pcache.h b44658c9c932d203510279439d891a2a83e12ba8 F src/pcache1.c 69d137620a305f814398bd29a0c998038c0695e9 @@ -287,7 +287,7 @@ F src/test_vfs.c b7e6831e6fcf04c5090accff30640ec5c9630739 F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 6bbcc9fe50c917864d48287b4792d46d6e873481 -F src/tokenize.c a8234a67577308935cdf13e618cd66556f5f45d1 +F src/tokenize.c b7fb584c2be5ec39b6fdf04b185e7c6f33f8dc15 F src/trigger.c a261da05e2ba65035d6f4b85d1fe6d4f363c1f1f F src/update.c 3c4ecc282accf12d39edb8d524cf089645e55a13 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c @@ -1250,7 +1250,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 d04d354d8e423961c3091b6ebcfbbbf10d3ecb04 -R 7d25758eea33f4a370736317991c770a +P 55d10baf0bffdb1a34bf5627ed8f25e4a4efd942 +R 114fb2d7e0df7ea2622d3974dda61e5a U drh -Z 4086867d1a0bc88e855064836598b64d +Z 08da3cff84a49c68f76471919d394d1c diff --git a/manifest.uuid b/manifest.uuid index 7320463437..8ae628632f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -55d10baf0bffdb1a34bf5627ed8f25e4a4efd942 \ No newline at end of file +8f391dffcfe068d48f854784648610d8a86f6bc8 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index ac15c3ce71..a2ad10eb5f 100644 --- a/src/parse.y +++ b/src/parse.y @@ -509,7 +509,7 @@ values(A) ::= VALUES LP nexprlist(X) RP. { values(A) ::= values(X) COMMA LP exprlist(Y) RP. { Select *pRight, *pLeft = X; pRight = sqlite3SelectNew(pParse,Y,0,0,0,0,0,SF_Values|SF_MultiValue,0,0); - if( pLeft ) pLeft->selFlags &= ~SF_MultiValue; + if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue; if( pRight ){ pRight->op = TK_ALL; pLeft = X; diff --git a/src/tokenize.c b/src/tokenize.c index 2f8fd98ede..076acb0209 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -516,8 +516,6 @@ abort_parse: pParse->pZombieTab = p->pNextZombie; sqlite3DeleteTable(db, p); } - if( nErr>0 && pParse->rc==SQLITE_OK ){ - pParse->rc = SQLITE_ERROR; - } + assert( nErr==0 || pParse->rc!=SQLITE_OK ); return nErr; } From e318a7f84c90003309cf7b518524bad9b8d50492 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Apr 2015 23:04:17 +0000 Subject: [PATCH 25/74] Restrict the scope of a local-use function in the parser. FossilOrigin-Name: cd6598f47480a6189df3e4283231833fd246d7fb --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/parse.y | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 7fd7cbd6c6..6bc57d0ca6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sa\sheap\srather\sthan\sa\sbitmap\sfor\scell\scoverage\sand\soverlap\stesting\son\nbtree\spages\sin\sPRAGMA\sintegrity_check. -D 2015-04-16T21:57:37.861 +C Restrict\sthe\sscope\sof\sa\slocal-use\sfunction\sin\sthe\sparser. +D 2015-04-16T23:04:17.948 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -219,7 +219,7 @@ F src/os_win.c 03d27be3a20048ef52a648d5f0a15f5edda9f2a3 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 -F src/parse.y 5944031bd7660589a7bb340cef5e134b55f01ec0 +F src/parse.y c4e0387bc88c8e21e5ba653e2578959a1f3cdbc7 F src/pcache.c 10539fb959849ad6efff80050541cab3d25089d4 F src/pcache.h b44658c9c932d203510279439d891a2a83e12ba8 F src/pcache1.c 69d137620a305f814398bd29a0c998038c0695e9 @@ -1250,8 +1250,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 8f391dffcfe068d48f854784648610d8a86f6bc8 5619c959bf7babb19fd8ba8b228be7f090fe0ce3 -R 72a6fa603587f85ee318933146285087 -T +closed 5619c959bf7babb19fd8ba8b228be7f090fe0ce3 +P e94b2ef2242d716379a35dba3d2df1ac512c8d30 +R 70b7123ef26fc35932871334bf1b767b U drh -Z e48be2bfe822e32604f22d78d2be1c02 +Z 97923746cc2f7b18a22c50ab5601a1cf diff --git a/manifest.uuid b/manifest.uuid index 9dea5b13da..7189dc2e98 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e94b2ef2242d716379a35dba3d2df1ac512c8d30 \ No newline at end of file +cd6598f47480a6189df3e4283231833fd246d7fb \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index a2ad10eb5f..6a64206ac0 100644 --- a/src/parse.y +++ b/src/parse.y @@ -415,7 +415,7 @@ cmd ::= select(X). { ** all elements in the list. And make sure list length does not exceed ** SQLITE_LIMIT_COMPOUND_SELECT. */ - void parserDoubleLinkSelect(Parse *pParse, Select *p){ + static void parserDoubleLinkSelect(Parse *pParse, Select *p){ if( p->pPrior ){ Select *pNext = 0, *pLoop; int mxSelect, cnt = 0; From 50be9c4b288a3d07b2ff11b377ce84bbd288dc26 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 17 Apr 2015 12:16:09 +0000 Subject: [PATCH 26/74] Fix the header comment on the sqldiff utility program. No code changes. FossilOrigin-Name: b355ca3a3f617cd6d4c45c8e27ecd75d9e68b792 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/sqldiff.c | 7 ++++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 6bc57d0ca6..319d197291 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Restrict\sthe\sscope\sof\sa\slocal-use\sfunction\sin\sthe\sparser. -D 2015-04-16T23:04:17.948 +C Fix\sthe\sheader\scomment\son\sthe\ssqldiff\sutility\sprogram.\s\sNo\scode\schanges. +D 2015-04-17T12:16:09.669 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1239,7 +1239,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c -F tool/sqldiff.c 5c16cf3a1f566873abbdecac0d13a6691437564f +F tool/sqldiff.c 393b0f5b17ef29341664563a90d40ee63a0a18f7 F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f @@ -1250,7 +1250,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 e94b2ef2242d716379a35dba3d2df1ac512c8d30 -R 70b7123ef26fc35932871334bf1b767b +P cd6598f47480a6189df3e4283231833fd246d7fb +R bfdce473d247dbaaedf4cb00e3a28380 U drh -Z 97923746cc2f7b18a22c50ab5601a1cf +Z c972653cce57a7491204b613b522cd75 diff --git a/manifest.uuid b/manifest.uuid index 7189dc2e98..e7fbfbeb71 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cd6598f47480a6189df3e4283231833fd246d7fb \ No newline at end of file +b355ca3a3f617cd6d4c45c8e27ecd75d9e68b792 \ No newline at end of file diff --git a/tool/sqldiff.c b/tool/sqldiff.c index c7b59400df..ad19b8cf24 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -10,8 +10,13 @@ ** ************************************************************************* ** -** This is a utility problem that computes the differences in content +** This is a utility program that computes the differences in content ** between two SQLite databases. +** +** To compile, simply link against SQLite. +** +** See the showHelp() routine below for a brief description of how to +** run the utility. */ #include #include From 268e72f936f49fba9660e52d781085f515f2cf45 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 17 Apr 2015 14:30:49 +0000 Subject: [PATCH 27/74] Add the tool/fuzzershell.c utility program. FossilOrigin-Name: db8d9af4d04ee862995ffa13ae6dcd9a1fc72855 --- Makefile.in | 3 + Makefile.msc | 3 + main.mk | 4 + manifest | 17 +-- manifest.uuid | 2 +- tool/fuzzershell.c | 294 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 314 insertions(+), 9 deletions(-) create mode 100644 tool/fuzzershell.c diff --git a/Makefile.in b/Makefile.in index 295a6bc9c1..6b3f18c35c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -539,6 +539,9 @@ sqlite3$(TEXE): $(TOP)/src/shell.c libsqlite3.la sqlite3.h sqldiff$(EXE): $(TOP)/tool/sqldiff.c sqlite3.c sqlite3.h $(LTLINK) -o $@ $(TOP)/tool/sqldiff.c sqlite3.c $(TLIBS) +fuzzershell$(EXE): $(TOP)/tool/fuzzershell.c sqlite3.c sqlite3.h + $(LTLINK) -o $@ $(TOP)/tool/fuzzershell.c sqlite3.c $(TLIBS) + mptester$(EXE): sqlite3.c $(TOP)/mptest/mptest.c $(LTLINK) -o $@ -I. $(TOP)/mptest/mptest.c sqlite3.c \ $(TLIBS) -rpath "$(libdir)" diff --git a/Makefile.msc b/Makefile.msc index f13418ffb7..914bb1e7ad 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1159,6 +1159,9 @@ sqlite3.exe: $(TOP)\src\shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) sqlite3.h sqldiff.exe: $(TOP)\tool\sqldiff.c sqlite3.c sqlite3.h $(LTLINK) $(TOP)\tool\sqldiff.c sqlite3.c +fuzzershell.exe: $(TOP)\tool\fuzzershell.c sqlite3.c sqlite3.h + $(LTLINK) $(TOP)\tool\fuzzershell.c sqlite3.c + 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) diff --git a/main.mk b/main.mk index c5328dc6c7..22c4f3e02d 100644 --- a/main.mk +++ b/main.mk @@ -408,6 +408,10 @@ sqldiff$(EXE): $(TOP)/tool/sqldiff.c sqlite3.c sqlite3.h $(TCCX) -o sqldiff$(EXE) -DSQLITE_THREADSAFE=0 \ $(TOP)/tool/sqldiff.c sqlite3.c $(TLIBS) $(THREADLIB) +fuzzershell$(EXE): $(TOP)/tool/fuzzershell.c sqlite3.c sqlite3.h + $(TCCX) -o fuzzershell$(EXE) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION\ + $(TOP)/tool/fuzzershell.c sqlite3.c $(TLIBS) $(THREADLIB) + mptester$(EXE): sqlite3.c $(TOP)/mptest/mptest.c $(TCCX) -o $@ -I. $(TOP)/mptest/mptest.c sqlite3.c \ $(TLIBS) $(THREADLIB) diff --git a/manifest b/manifest index 319d197291..d8d547e501 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Fix\sthe\sheader\scomment\son\sthe\ssqldiff\sutility\sprogram.\s\sNo\scode\schanges. -D 2015-04-17T12:16:09.669 +C Add\sthe\stool/fuzzershell.c\sutility\sprogram. +D 2015-04-17T14:30:49.931 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a +F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 11cb5361e34b80e9c5b417ed6a6deee099c5b5f3 +F Makefile.msc a19bceec468fa18bb54df52257b1a2211e69172d F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 F VERSION 2e244662b71e6e68a5c29b014ebc5b7564f4cc5a @@ -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 ddffac494a82d42772df9fe30d3a78acf4f7cb41 +F main.mk 60aba7d38b9bd73e249693344dd8405aa24ac02a F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea F mkopcodeh.awk d5e22023b5238985bb54a72d33e0ac71fe4f8a32 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 @@ -1203,6 +1203,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 +F tool/fuzzershell.c 9e7e273da203037154b433bb67f10b0d9772b370 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce @@ -1250,7 +1251,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 cd6598f47480a6189df3e4283231833fd246d7fb -R bfdce473d247dbaaedf4cb00e3a28380 +P b355ca3a3f617cd6d4c45c8e27ecd75d9e68b792 +R d4d32c82236775154903bd68de367067 U drh -Z c972653cce57a7491204b613b522cd75 +Z b7bf748b01ea8ab50dc7b538dea6204b diff --git a/manifest.uuid b/manifest.uuid index e7fbfbeb71..b1fc9a1168 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b355ca3a3f617cd6d4c45c8e27ecd75d9e68b792 \ No newline at end of file +db8d9af4d04ee862995ffa13ae6dcd9a1fc72855 \ No newline at end of file diff --git a/tool/fuzzershell.c b/tool/fuzzershell.c new file mode 100644 index 0000000000..a44a722505 --- /dev/null +++ b/tool/fuzzershell.c @@ -0,0 +1,294 @@ +/* +** 2015-04-17 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This is a utility program designed to aid running the SQLite library +** against an external fuzzer, such as American Fuzzy Lop (AFL) +** (http://lcamtuf.coredump.cx/afl/). Basically, this program reads +** SQL text from standard input and passes it through to SQLite for evaluation, +** just like the "sqlite3" command-line shell. Differences from the +** command-line shell: +** +** (1) The complex "dot-command" extensions are omitted. This +** prevents the fuzzer from discovering that it can run things +** like ".shell rm -rf ~" +** +** (2) The database is opened with the SQLITE_OPEN_MEMORY flag so that +** no disk I/O from the database is permitted. The ATTACH command +** with a filename still uses an in-memory database. +** +** (3) The main in-memory database can be initialized from a template +** disk database so that the fuzzer starts with a database containing +** content. +** +** (4) The eval() SQL function is added, allowing the fuzzer to do +** interesting recursive operations. +*/ +#include +#include +#include +#include +#include "sqlite3.h" + +/* +** All global variables are gathered into the "g" singleton. +*/ +struct GlobalVars { + const char *zArgv0; /* Name of program */ +} g; + + + +/* +** Print an error message and abort in such a way to indicate to the +** fuzzer that this counts as a crash. +*/ +static void abendError(const char *zFormat, ...){ + va_list ap; + fprintf(stderr, "%s: ", g.zArgv0); + va_start(ap, zFormat); + vfprintf(stderr, zFormat, ap); + va_end(ap); + fprintf(stderr, "\n"); + abort(); +} +/* +** Print an error message and quit, but not in a way that would look +** like a crash. +*/ +static void fatalError(const char *zFormat, ...){ + va_list ap; + fprintf(stderr, "%s: ", g.zArgv0); + va_start(ap, zFormat); + vfprintf(stderr, zFormat, ap); + va_end(ap); + fprintf(stderr, "\n"); + exit(1); +} + +/* +** This callback is invoked by sqlite3_log(). +*/ +static void shellLog(void *pNotUsed, int iErrCode, const char *zMsg){ + printf("LOG: (%d) %s\n", iErrCode, zMsg); +} + +/* +** This callback is invoked by sqlite3_exec() to return query results. +*/ +static int execCallback(void *NotUsed, int argc, char **argv, char **colv){ + int i; + static unsigned cnt = 0; + printf("ROW #%u:\n", ++cnt); + for(i=0; inUsed+p->szSep+1 > p->nAlloc ){ + char *zNew; + p->nAlloc = p->nAlloc*2 + sz + p->szSep + 1; + /* Using sqlite3_realloc64() would be better, but it is a recent + ** addition and will cause a segfault if loaded by an older version + ** of SQLite. */ + zNew = p->nAlloc<=0x7fffffff ? sqlite3_realloc(p->z, (int)p->nAlloc) : 0; + if( zNew==0 ){ + sqlite3_free(p->z); + memset(p, 0, sizeof(*p)); + return 1; + } + p->z = zNew; + } + if( p->nUsed>0 ){ + memcpy(&p->z[p->nUsed], p->zSep, p->szSep); + p->nUsed += p->szSep; + } + memcpy(&p->z[p->nUsed], z, sz); + p->nUsed += sz; + } + return 0; +} + +/* +** Implementation of the eval(X) and eval(X,Y) SQL functions. +** +** Evaluate the SQL text in X. Return the results, using string +** Y as the separator. If Y is omitted, use a single space character. +*/ +static void sqlEvalFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + const char *zSql; + sqlite3 *db; + char *zErr = 0; + int rc; + struct EvalResult x; + + memset(&x, 0, sizeof(x)); + x.zSep = " "; + zSql = (const char*)sqlite3_value_text(argv[0]); + if( zSql==0 ) return; + if( argc>1 ){ + x.zSep = (const char*)sqlite3_value_text(argv[1]); + if( x.zSep==0 ) return; + } + x.szSep = (int)strlen(x.zSep); + db = sqlite3_context_db_handle(context); + rc = sqlite3_exec(db, zSql, callback, &x, &zErr); + if( rc!=SQLITE_OK ){ + sqlite3_result_error(context, zErr, -1); + sqlite3_free(zErr); + }else if( x.zSep==0 ){ + sqlite3_result_error_nomem(context); + sqlite3_free(x.z); + }else{ + sqlite3_result_text(context, x.z, (int)x.nUsed, sqlite3_free); + } +} +/* End of the eval() implementation +******************************************************************************/ + +/* +** Print sketchy documentation for this utility program +*/ +static void showHelp(void){ + printf("Usage: %s [options]\n", g.zArgv0); + printf( +"Read SQL text from standard input and evaluate it.\n" +"Options:\n" +" -f FILE Read SQL text from FILE instead of standard input\n" +" --help Show this help text\n" +" --initdb DBFILE Initialize the in-memory database using template DBFILE\n" + ); +} + + +int main(int argc, char **argv){ + char *zIn = 0; /* Input text */ + int nAlloc = 0; /* Number of bytes allocated for zIn[] */ + int nIn = 0; /* Number of bytes of zIn[] used */ + size_t got; /* Bytes read from input */ + FILE *in = stdin; /* Where to read SQL text from */ + int rc = SQLITE_OK; /* Result codes from API functions */ + int i; /* Loop counter */ + sqlite3 *db; /* Open database */ + sqlite3 *dbInit; /* On-disk database used to initialize the in-memory db */ + const char *zInitDb = 0;/* Name of the initialization database file */ + char *zErrMsg = 0; /* Error message returned from sqlite3_exec() */ + + g.zArgv0 = argv[0]; + for(i=1; i Date: Fri, 17 Apr 2015 15:16:58 +0000 Subject: [PATCH 28/74] Fix a faulty assert() in sqlite3SelectNew(). FossilOrigin-Name: 620d19c3b462f5c4763ebd26513321431f21dd72 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 3 +-- test/select1.test | 5 +++++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index d8d547e501..0fba60c8e9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\stool/fuzzershell.c\sutility\sprogram. -D 2015-04-17T14:30:49.931 +C Fix\sa\sfaulty\sassert()\sin\ssqlite3SelectNew(). +D 2015-04-17T15:16:58.290 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +230,7 @@ F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 66cfe49a9c3b449ef13b89a8c47036a4ed167eab F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c d66970749a9d5a5b04950c9a26d6d0ea1320f91b +F src/select.c e7d3f26dd2bb513049c6c585919aa195c862a287 F src/shell.c 28b3e1174a7fc00155d7d00880a33589a88508c9 F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -836,7 +836,7 @@ F test/schema4.test e6a66e20cc69f0e306667c08be7fda3d11707dc5 F test/schema5.test 29699b4421f183c8f0e88bd28ce7d75d13ea653e F test/securedel.test 21749c32ccc30f1ea9e4b9f33295a6521ec20fa0 F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5 -F test/select1.test 53c3a5228b099601eafc7f3cc0e9cd682b07d9d5 +F test/select1.test be62204d2bd9a5a8a149e9974cfddce893d8f686 F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054 F test/select4.test 4b2df48129369a2a426f0f710fb94c50f75b31fb @@ -1251,7 +1251,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 b355ca3a3f617cd6d4c45c8e27ecd75d9e68b792 -R d4d32c82236775154903bd68de367067 +P db8d9af4d04ee862995ffa13ae6dcd9a1fc72855 +R a2d46793733766d02a97971b373ce378 U drh -Z b7bf748b01ea8ab50dc7b538dea6204b +Z 3bc04f03d72aa5c77d969deb6f174a4e diff --git a/manifest.uuid b/manifest.uuid index b1fc9a1168..bc2b8b9300 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -db8d9af4d04ee862995ffa13ae6dcd9a1fc72855 \ No newline at end of file +620d19c3b462f5c4763ebd26513321431f21dd72 \ No newline at end of file diff --git a/src/select.c b/src/select.c index e4e5d6da8d..fc5740e80f 100644 --- a/src/select.c +++ b/src/select.c @@ -111,7 +111,6 @@ Select *sqlite3SelectNew( Select standin; sqlite3 *db = pParse->db; pNew = sqlite3DbMallocZero(db, sizeof(*pNew) ); - assert( db->mallocFailed || !pOffset || pLimit ); /* OFFSET implies LIMIT */ if( pNew==0 ){ assert( db->mallocFailed ); pNew = &standin; @@ -131,7 +130,7 @@ Select *sqlite3SelectNew( pNew->op = TK_SELECT; pNew->pLimit = pLimit; pNew->pOffset = pOffset; - assert( pOffset==0 || pLimit!=0 ); + assert( pOffset==0 || pLimit!=0 || pParse->nErr>0 || db->mallocFailed!=0 ); pNew->addrOpenEphm[0] = -1; pNew->addrOpenEphm[1] = -1; if( db->mallocFailed ) { diff --git a/test/select1.test b/test/select1.test index 2ae91dc0fd..4d6c07f2d0 100644 --- a/test/select1.test +++ b/test/select1.test @@ -1075,5 +1075,10 @@ if {[db one {PRAGMA locking_mode}]=="normal"} { do_test select1-16.1 { catchsql {SELECT 1 FROM (SELECT *)} } {1 {no tables specified}} + +# 2015-04-17: assertion fix. +do_catchsql_test select1-16.2 { + SELECT 1 FROM sqlite_master LIMIT 1,#1; +} {1 {near "#1": syntax error}} finish_test From d99d28361eb6022b46e4e45924088913f082f6f7 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 17 Apr 2015 15:58:33 +0000 Subject: [PATCH 29/74] Ensure that semantic SQL errors are always reported back up to the syntax parser. Also: Improve the defense against invalid PRAGMA synchronous settings. FossilOrigin-Name: 7aeade9a07f29bf26e50394042ea18d0121fe7a3 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/build.c | 6 ++++-- src/pragma.c | 6 +++--- test/pragma.test | 6 ++++++ 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 0fba60c8e9..23cf01f4c5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sfaulty\sassert()\sin\ssqlite3SelectNew(). -D 2015-04-17T15:16:58.290 +C Ensure\sthat\ssemantic\sSQL\serrors\sare\salways\sreported\sback\sup\sto\sthe\ssyntax\nparser.\s\sAlso:\s\sImprove\sthe\sdefense\sagainst\sinvalid\sPRAGMA\ssynchronous\ssettings. +D 2015-04-17T15:58:33.364 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -176,7 +176,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 127aceb71ba93f59bc9c6ba810e992a04299e98a F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4 -F src/build.c 01b969b20a44a3d9620e597d9af8242348123540 +F src/build.c f82d394b9ad94be03a13d04edc2b6309ad5274e8 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 @@ -223,7 +223,7 @@ F src/parse.y c4e0387bc88c8e21e5ba653e2578959a1f3cdbc7 F src/pcache.c 10539fb959849ad6efff80050541cab3d25089d4 F src/pcache.h b44658c9c932d203510279439d891a2a83e12ba8 F src/pcache1.c 69d137620a305f814398bd29a0c998038c0695e9 -F src/pragma.c 633cb355ab30b197d4e8e9976f94378199439b76 +F src/pragma.c 2a81f312cdb78bf0672a0484478ca3c1083028e9 F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f F src/prepare.c 1fffbdcd6f8a0173a8f70d71f22528f4c0e1e3d3 F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f @@ -794,7 +794,7 @@ F test/pcache.test b09104b03160aca0d968d99e8cd2c5b1921a993d F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff F test/permutations.test f9cc1dd987986c9d4949211c7a4ed55ec9aecba1 -F test/pragma.test 2e3d20785e463d7eeed636cba16e742b5df88073 +F test/pragma.test be7195f0aa72bdb8a512133e9640ac40f15b57a2 F test/pragma2.test f624a496a95ee878e81e59961eade66d5c00c028 F test/pragma3.test 6f849ccffeee7e496d2f2b5e74152306c0b8757c F test/printf.test b3ff34e73d59124140eaf89f7672e21bc2ca5fcc @@ -1251,7 +1251,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 db8d9af4d04ee862995ffa13ae6dcd9a1fc72855 -R a2d46793733766d02a97971b373ce378 +P 620d19c3b462f5c4763ebd26513321431f21dd72 +R 3232d5345bb2d152e6d22cf04db83714 U drh -Z 3bc04f03d72aa5c77d969deb6f174a4e +Z c636e6bb9960db85c57f7546f9b2327e diff --git a/manifest.uuid b/manifest.uuid index bc2b8b9300..aa1a8ea294 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -620d19c3b462f5c4763ebd26513321431f21dd72 \ No newline at end of file +7aeade9a07f29bf26e50394042ea18d0121fe7a3 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 3021ad4e51..803c33461a 100644 --- a/src/build.c +++ b/src/build.c @@ -142,9 +142,11 @@ void sqlite3FinishCoding(Parse *pParse){ assert( pParse->pToplevel==0 ); db = pParse->db; - if( db->mallocFailed ) return; if( pParse->nested ) return; - if( pParse->nErr ) return; + if( db->mallocFailed || pParse->nErr ){ + if( pParse->rc==SQLITE_OK ) pParse->rc = SQLITE_ERROR; + return; + } /* Begin by generating some termination code at the end of the ** vdbe program diff --git a/src/pragma.c b/src/pragma.c index 3cecd8dda5..614daa54df 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -946,9 +946,9 @@ void sqlite3Pragma( sqlite3ErrorMsg(pParse, "Safety level may not be changed inside a transaction"); }else{ - testcase( (getSafetyLevel(zRight,0,1)+1) & ~PAGER_SYNCHRONOUS_MASK ); - pDb->safety_level = (getSafetyLevel(zRight,0,1)+1) - & PAGER_SYNCHRONOUS_MASK; + int iLevel = (getSafetyLevel(zRight,0,1)+1) & PAGER_SYNCHRONOUS_MASK; + if( iLevel==0 ) iLevel = 1; + pDb->safety_level = iLevel; setAllPagerFlags(db); } } diff --git a/test/pragma.test b/test/pragma.test index a45dc45a44..587a03c8a6 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -226,6 +226,12 @@ do_test pragma-1.14.1 { } } {0} do_test pragma-1.14.2 { + execsql { + PRAGMA synchronous=3; + PRAGMA synchronous; + } +} {0} +do_test pragma-1.14.3 { execsql { PRAGMA synchronous=10; PRAGMA synchronous; From c50c8f40433384c5b18401a0798fb0b74483c574 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 17 Apr 2015 16:12:03 +0000 Subject: [PATCH 30/74] Remove an ALWAYS() that turns out to be false when there is a semantic error on a compound SELECT. FossilOrigin-Name: ad67a67c03078a2bc65d28f2b880b29bf02067c1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/select.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 23cf01f4c5..643aef0dc4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\ssemantic\sSQL\serrors\sare\salways\sreported\sback\sup\sto\sthe\ssyntax\nparser.\s\sAlso:\s\sImprove\sthe\sdefense\sagainst\sinvalid\sPRAGMA\ssynchronous\ssettings. -D 2015-04-17T15:58:33.364 +C Remove\san\sALWAYS()\sthat\sturns\sout\sto\sbe\sfalse\swhen\sthere\sis\sa\ssemantic\nerror\son\sa\scompound\sSELECT. +D 2015-04-17T16:12:03.870 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +230,7 @@ F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 66cfe49a9c3b449ef13b89a8c47036a4ed167eab F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c e7d3f26dd2bb513049c6c585919aa195c862a287 +F src/select.c 361dfc32244656bbe3f0e53d8ed791b3ec0c4be8 F src/shell.c 28b3e1174a7fc00155d7d00880a33589a88508c9 F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -1251,7 +1251,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 620d19c3b462f5c4763ebd26513321431f21dd72 -R 3232d5345bb2d152e6d22cf04db83714 +P 7aeade9a07f29bf26e50394042ea18d0121fe7a3 +R 4ffb47078274895143770c4805431d69 U drh -Z c636e6bb9960db85c57f7546f9b2327e +Z 423cc03f9b773c1e0bc4b6f9fa63f5b6 diff --git a/manifest.uuid b/manifest.uuid index aa1a8ea294..1505561f94 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7aeade9a07f29bf26e50394042ea18d0121fe7a3 \ No newline at end of file +ad67a67c03078a2bc65d28f2b880b29bf02067c1 \ No newline at end of file diff --git a/src/select.c b/src/select.c index fc5740e80f..c49f327893 100644 --- a/src/select.c +++ b/src/select.c @@ -1380,7 +1380,7 @@ static const char *columnTypeImpl( ** of the SELECT statement. Return the declaration type and origin ** data for the result-set column of the sub-select. */ - if( iCol>=0 && ALWAYS(iColpEList->nExpr) ){ + if( iCol>=0 && iColpEList->nExpr ){ /* If iCol is less than zero, then the expression requests the ** rowid of the sub-select or view. This expression is legal (see ** test case misc2.2.2) - it always evaluates to NULL. From 97ab32bcd3cb14cedca0dcea055ef3b6d3caea47 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 17 Apr 2015 18:22:53 +0000 Subject: [PATCH 31/74] Remove unnecessary parser error count increments. Let the sqlite3ErrorMsg() take care of doing that. FossilOrigin-Name: 3f3b0f683af2fbee83811536f6bef770ff919385 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/attach.c | 1 - src/build.c | 2 -- src/trigger.c | 1 - test/table.test | 19 +++++++++++++++++++ 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 643aef0dc4..6ad8797b37 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sALWAYS()\sthat\sturns\sout\sto\sbe\sfalse\swhen\sthere\sis\sa\ssemantic\nerror\son\sa\scompound\sSELECT. -D 2015-04-17T16:12:03.870 +C Remove\sunnecessary\sparser\serror\scount\sincrements.\s\sLet\sthe\ssqlite3ErrorMsg()\ntake\scare\sof\sdoing\sthat. +D 2015-04-17T18:22:53.635 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -168,7 +168,7 @@ F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c d23d6b6991f66b383934f137fd4384d93fb98c81 F src/analyze.c 91540f835163d5369ccbae78e2e6c74d0dd53c1d -F src/attach.c 3c1053a4cf1c3ca05c8c1d74a94cb688d763cef2 +F src/attach.c c38ac5a520a231d5d0308fd7f2ad95191c867bae F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c ff743689c4d6c5cb55ad42ed9d174b2b3e71f1e3 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb @@ -176,7 +176,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 127aceb71ba93f59bc9c6ba810e992a04299e98a F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4 -F src/build.c f82d394b9ad94be03a13d04edc2b6309ad5274e8 +F src/build.c 8c4cbff225db37add6351496696151a69965c0b9 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 @@ -288,7 +288,7 @@ F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 6bbcc9fe50c917864d48287b4792d46d6e873481 F src/tokenize.c b7fb584c2be5ec39b6fdf04b185e7c6f33f8dc15 -F src/trigger.c a261da05e2ba65035d6f4b85d1fe6d4f363c1f1f +F src/trigger.c bc647c712454c9b209fac082bb82870b5fd6fa54 F src/update.c 3c4ecc282accf12d39edb8d524cf089645e55a13 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c 98a7627ca48ad3265b6940915a1d08355eb3fc7e @@ -908,7 +908,7 @@ F test/superlock.test 1cde669f68d2dd37d6c9bd35eee1d95491ae3fc2 F test/sync.test a34cd43e98b7fb84eabbf38f7ed8f7349b3f3d85 F test/syscall.test d2fdaad713f103ac611fe7ef9b724c7b69f8149c F test/sysfault.test fa776e60bf46bdd3ae69f0b73e46ee3977a58ae6 -F test/table.test 06271d61eb13871490d38168433c1ef3dd82bb2a +F test/table.test bd841e8df69b99172ce9c7d53587463913d711ca F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 F test/tclsqlite.test 7fb866443c7deceed22b63948ccd6f76b52ad054 @@ -1251,7 +1251,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 7aeade9a07f29bf26e50394042ea18d0121fe7a3 -R 4ffb47078274895143770c4805431d69 +P ad67a67c03078a2bc65d28f2b880b29bf02067c1 +R b18dfa3e7e5ddb8a0e9d36234afbeb5d U drh -Z 423cc03f9b773c1e0bc4b6f9fa63f5b6 +Z 77598d348cd54fccd8be37637dc84656 diff --git a/manifest.uuid b/manifest.uuid index 1505561f94..3f288d1a15 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ad67a67c03078a2bc65d28f2b880b29bf02067c1 \ No newline at end of file +3f3b0f683af2fbee83811536f6bef770ff919385 \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index 11296d02ad..efc9eb9a81 100644 --- a/src/attach.c +++ b/src/attach.c @@ -332,7 +332,6 @@ static void codeAttach( SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) || SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey)) ){ - pParse->nErr++; goto attach_end; } diff --git a/src/build.c b/src/build.c index 803c33461a..e5e4515618 100644 --- a/src/build.c +++ b/src/build.c @@ -763,14 +763,12 @@ int sqlite3TwoPartName( if( ALWAYS(pName2!=0) && pName2->n>0 ){ if( db->init.busy ) { sqlite3ErrorMsg(pParse, "corrupt database"); - pParse->nErr++; return -1; } *pUnqual = pName2; iDb = sqlite3FindDb(db, pName1); if( iDb<0 ){ sqlite3ErrorMsg(pParse, "unknown database %T", pName1); - pParse->nErr++; return -1; } }else{ diff --git a/src/trigger.c b/src/trigger.c index d29f509a8d..1bc232727f 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -193,7 +193,6 @@ void sqlite3BeginTrigger( /* Do not create a trigger on a system table */ if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){ sqlite3ErrorMsg(pParse, "cannot create trigger on system table"); - pParse->nErr++; goto trigger_cleanup; } diff --git a/test/table.test b/test/table.test index 69f105aa6c..faa9712bf7 100644 --- a/test/table.test +++ b/test/table.test @@ -272,6 +272,25 @@ do_test table-5.2.1 { } } {} +do_test table-5.2.2 { + db close + forcedelete test.db + sqlite3 db test.db + db eval { + CREATE TABLE t0(a,b); + CREATE INDEX t ON t0(a); + PRAGMA writable_schema=ON; + UPDATE sqlite_master SET sql='CREATE TABLE a.b(a UNIQUE'; + BEGIN; + CREATE TABLE t1(x); + ROLLBACK; + DROP TABLE IF EXISTS t99; + } +} {} +db close +forcedelete test.db +sqlite3 db test.db + # Make sure an EXPLAIN does not really create a new table # do_test table-5.3 { From 7b4da150da7615c380e1ce3bd142ff66e817d962 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 17 Apr 2015 18:52:37 +0000 Subject: [PATCH 32/74] Always resolve symbols in all ORDER BY clauses of a compound-SELECT, even illegal ORDER BY clauses. FossilOrigin-Name: 6c39ef73d5899eabdb46db50c2b00c2d8381a41a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/resolve.c | 9 ++++++++- test/select4.test | 8 +++++++- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 6ad8797b37..b91d23703e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunnecessary\sparser\serror\scount\sincrements.\s\sLet\sthe\ssqlite3ErrorMsg()\ntake\scare\sof\sdoing\sthat. -D 2015-04-17T18:22:53.635 +C Always\sresolve\ssymbols\sin\sall\sORDER\sBY\sclauses\sof\sa\scompound-SELECT,\seven\nillegal\sORDER\sBY\sclauses. +D 2015-04-17T18:52:37.624 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -228,7 +228,7 @@ F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f F src/prepare.c 1fffbdcd6f8a0173a8f70d71f22528f4c0e1e3d3 F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 -F src/resolve.c 66cfe49a9c3b449ef13b89a8c47036a4ed167eab +F src/resolve.c 1ab0bd187f5590d10d51838b64976d6fb7da1ac1 F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 361dfc32244656bbe3f0e53d8ed791b3ec0c4be8 F src/shell.c 28b3e1174a7fc00155d7d00880a33589a88508c9 @@ -839,7 +839,7 @@ F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5 F test/select1.test be62204d2bd9a5a8a149e9974cfddce893d8f686 F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054 -F test/select4.test 4b2df48129369a2a426f0f710fb94c50f75b31fb +F test/select4.test a3201fa921fdfc1397cc629e78c7a976e198a40d F test/select5.test e758b8ef94f69b111df4cb819008856655dcd535 F test/select6.test 39eac4a5c03650b2b473c532882273283ee8b7a0 F test/select7.test 7fd2ef598cfabb6b9ff6ac13973b91d0527df49d @@ -1251,7 +1251,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 ad67a67c03078a2bc65d28f2b880b29bf02067c1 -R b18dfa3e7e5ddb8a0e9d36234afbeb5d +P 3f3b0f683af2fbee83811536f6bef770ff919385 +R 2ffa33d8e1ee81a06afa86726c2d9478 U drh -Z 77598d348cd54fccd8be37637dc84656 +Z 2bc4a70be377f4bd80ade4dfaae10be0 diff --git a/manifest.uuid b/manifest.uuid index 3f288d1a15..dc86d8653f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3f3b0f683af2fbee83811536f6bef770ff919385 \ No newline at end of file +6c39ef73d5899eabdb46db50c2b00c2d8381a41a \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index 6294ba26e1..f7e68ff4f0 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -1300,8 +1300,15 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ ** The ORDER BY clause for compounds SELECT statements is handled ** below, after all of the result-sets for all of the elements of ** the compound have been resolved. + ** + ** If there is an ORDER BY clause on a term of a compound-select other + ** than the right-most term, then that is a syntax error. But the error + ** is not detected until much later, and so we need to go ahead and + ** resolve those symbols on the incorrect ORDER BY for consistency. */ - if( !isCompound && resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER") ){ + if( isCompound<=nCompound /* Defer right-most ORDER BY of a compound */ + && resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER") + ){ return WRC_Abort; } if( db->mallocFailed ){ diff --git a/test/select4.test b/test/select4.test index 7718901c0c..ce7e7e7b0d 100644 --- a/test/select4.test +++ b/test/select4.test @@ -119,7 +119,7 @@ do_test select4-1.3 { lappend v $msg } {1 {ORDER BY clause should come after UNION ALL not before}} do_catchsql_test select4-1.4 { - SELECT (VALUES(0) INTERSECT SELECT(0) UNION SELECT(0) ORDER BY (0) UNION + SELECT (VALUES(0) INTERSECT SELECT(0) UNION SELECT(0) ORDER BY 1 UNION SELECT 0 UNION SELECT 0 ORDER BY 1); } {1 {ORDER BY clause should come after UNION not before}} @@ -152,6 +152,12 @@ do_test select4-2.3 { }} msg] lappend v $msg } {1 {ORDER BY clause should come after UNION not before}} +do_test select4-2.4 { + set v [catch {execsql { + SELECT 0 ORDER BY (SELECT 0) UNION SELECT 0; + }} msg] + lappend v $msg +} {1 {ORDER BY clause should come after UNION not before}} # Except operator # From 7693c42f1a01fe414fcc2b74721efe3c93aee88a Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 17 Apr 2015 19:41:37 +0000 Subject: [PATCH 33/74] In the expression-tree comparison routine, do not compiler Expr.iColumn and Expr.iTable for TK_STRING expressions. FossilOrigin-Name: b67bb16c72c3e015ea82665ada9b5d3289ef6fb2 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 2 +- src/resolve.c | 1 - test/expr.test | 8 ++++++++ 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index b91d23703e..ce4a75dce1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Always\sresolve\ssymbols\sin\sall\sORDER\sBY\sclauses\sof\sa\scompound-SELECT,\seven\nillegal\sORDER\sBY\sclauses. -D 2015-04-17T18:52:37.624 +C In\sthe\sexpression-tree\scomparison\sroutine,\sdo\snot\scompiler\sExpr.iColumn\nand\sExpr.iTable\sfor\sTK_STRING\sexpressions. +D 2015-04-17T19:41:37.324 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -182,7 +182,7 @@ F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e -F src/expr.c f37d5eb44a1fad4ca4faa6b0c4f1230f233e3835 +F src/expr.c 55e7ce8f7e6c98402365e253b277377fe567772a F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 3343d551a8d810782257244fb33f2ce191493c39 F src/func.c 1414c24c873c48796ad45942257a179a423ba42f @@ -228,7 +228,7 @@ F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f F src/prepare.c 1fffbdcd6f8a0173a8f70d71f22528f4c0e1e3d3 F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 -F src/resolve.c 1ab0bd187f5590d10d51838b64976d6fb7da1ac1 +F src/resolve.c 53486a98c17b7ae09b8c2b398013e973ce4c1aae F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 361dfc32244656bbe3f0e53d8ed791b3ec0c4be8 F src/shell.c 28b3e1174a7fc00155d7d00880a33589a88508c9 @@ -499,7 +499,7 @@ F test/exclusive.test c7ebbc756eacf544c108b15eed64d7d4e5f86b75 F test/exclusive2.test 32798111aae78a5deec980eee383213f189df308 F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7 F test/exists.test 8f7b27b61c2fbe5822f0a1f899c715d14e416e30 -F test/expr.test c4b9bf0cc60b26862475e19999fbd2609ca8259c +F test/expr.test 79c3e7502d9e571553b85f0ecc8ff2ac7d0e4931 F test/extension01.test 00d13cec817f331a687a243e0e5a2d87b0e358c9 F test/fallocate.test 3e979af17dfa7e5e9dda5eba1a696c04fa9d47f7 F test/filectrl.test 14fa712e42c4cb791e09dfd58a6a03efb47ef13a @@ -1251,7 +1251,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 3f3b0f683af2fbee83811536f6bef770ff919385 -R 2ffa33d8e1ee81a06afa86726c2d9478 +P 6c39ef73d5899eabdb46db50c2b00c2d8381a41a +R 040960ee1fc741cd8f8eec5fca5d25c5 U drh -Z 2bc4a70be377f4bd80ade4dfaae10be0 +Z 6cc887a5a4d09f0ddeeb5f3fd5032470 diff --git a/manifest.uuid b/manifest.uuid index dc86d8653f..82a61e13be 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6c39ef73d5899eabdb46db50c2b00c2d8381a41a \ No newline at end of file +b67bb16c72c3e015ea82665ada9b5d3289ef6fb2 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 418881ffd9..6a5ecfe4f2 100644 --- a/src/expr.c +++ b/src/expr.c @@ -4017,7 +4017,7 @@ int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){ if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2; if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2; if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2; - if( ALWAYS((combinedFlags & EP_Reduced)==0) ){ + if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){ if( pA->iColumn!=pB->iColumn ) return 2; if( pA->iTable!=pB->iTable && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2; diff --git a/src/resolve.c b/src/resolve.c index f7e68ff4f0..32e0a98fd7 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -460,7 +460,6 @@ static int lookupName( if( cnt==0 && zTab==0 && ExprHasProperty(pExpr,EP_DblQuoted) ){ pExpr->op = TK_STRING; pExpr->pTab = 0; - pExpr->iTable = -1; return WRC_Prune; } diff --git a/test/expr.test b/test/expr.test index 8d913d2a1a..7d7b8ce5a7 100644 --- a/test/expr.test +++ b/test/expr.test @@ -943,5 +943,13 @@ do_realnum_test expr-13.7 { } } {9.22337203685478e+18} +do_execsql_test expr-13.8 { + SELECT "" <= ''; +} {1} +do_execsql_test expr-13.9 { + SELECT '' <= ""; +} {1} + + finish_test From 1586699cfc6ee55bdf726216df9995f2d86128b1 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 17 Apr 2015 20:51:55 +0000 Subject: [PATCH 34/74] Fix a problem affecting some fts3 UPDATE and DELETE statements on order=DESC tables. FossilOrigin-Name: 284c1623f81704ef80edb9324954525cb2b72172 --- ext/fts3/fts3.c | 22 +++++++++++++++++++++- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/fts3aa.test | 22 ++++++++++++++++++++++ 4 files changed, 52 insertions(+), 10 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 0555025f1a..3037719e9d 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -3459,11 +3459,31 @@ static void fts3ReversePoslist(char *pStart, char **ppPoslist){ char *p = &(*ppPoslist)[-2]; char c = 0; + /* Skip backwards passed any trailing 0x00 bytes added by NearTrim() */ while( p>pStart && (c=*p--)==0 ); + + /* Search backwards for a varint with value zero (the end of the previous + ** poslist). This is an 0x00 byte preceded by some byte that does not + ** have the 0x80 bit set. */ while( p>pStart && (*p & 0x80) | c ){ c = *p--; } - if( p>pStart ){ p = &p[2]; } + assert( p==pStart || c==0 ); + + /* At this point p points to that preceding byte without the 0x80 bit + ** set. So to find the start of the poslist, skip forward 2 bytes then + ** over a varint. + ** + ** Normally. The other case is that p==pStart and the poslist to return + ** is the first in the doclist. In this case do not skip forward 2 bytes. + ** The second part of the if condition (c==0 && *ppPoslist>&p[2]) + ** is required for cases where the first byte of a doclist and the + ** doclist is empty. For example, if the first docid is 10, a doclist + ** that begins with: + ** + ** 0x0A 0x00 + */ + if( p>pStart || (c==0 && *ppPoslist>&p[2]) ){ p = &p[2]; } while( *p++&0x80 ); *ppPoslist = p; } diff --git a/manifest b/manifest index ce4a75dce1..1fee776303 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sexpression-tree\scomparison\sroutine,\sdo\snot\scompiler\sExpr.iColumn\nand\sExpr.iTable\sfor\sTK_STRING\sexpressions. -D 2015-04-17T19:41:37.324 +C Fix\sa\sproblem\saffecting\ssome\sfts3\sUPDATE\sand\sDELETE\sstatements\son\sorder=DESC\stables. +D 2015-04-17T20:51:55.807 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 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 cb5019020e1ca8e999beb2a63100563c17def8ae +F ext/fts3/fts3.c 29300a76fabbbb8fc30bb261c27d421df9f40c76 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 3626655d6ba903a3919bb44e1c38e5f0f9d6be82 F ext/fts3/fts3_aux.c 5c211e17a64885faeb16b9ba7772f9d5445c2365 @@ -551,7 +551,7 @@ F test/fts2r.test b154c30b63061d8725e320fba1a39e2201cadd5e F test/fts2token.test d8070b241a15ff13592a9ae4a8b7c171af6f445a F test/fts3.test 672a040ea57036fb4b6fdc09027c18d7d24ab654 F test/fts3_common.tcl 99cf6659b87c0f74f55963c2aea03b3a7d66ceb0 -F test/fts3aa.test edd20ddbbc5b6015ab340abf2ca278ae11ec387d +F test/fts3aa.test 6c263a6f8845205ee02550981a94c2e8dc1e7058 F test/fts3ab.test 7f6cf260ae80dda064023df8e8e503e9a412b91f F test/fts3ac.test 636ed7486043055d4f126a0e385f2d5a82ebbf63 F test/fts3ad.test e40570cb6f74f059129ad48bcef3d7cbc20dda49 @@ -1251,7 +1251,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 6c39ef73d5899eabdb46db50c2b00c2d8381a41a -R 040960ee1fc741cd8f8eec5fca5d25c5 -U drh -Z 6cc887a5a4d09f0ddeeb5f3fd5032470 +P b67bb16c72c3e015ea82665ada9b5d3289ef6fb2 +R e2e6547f1f65a23306e35eed7a1b5202 +U dan +Z 1c324a552a5080240054761e4e92cb4f diff --git a/manifest.uuid b/manifest.uuid index 82a61e13be..afb90c6137 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b67bb16c72c3e015ea82665ada9b5d3289ef6fb2 \ No newline at end of file +284c1623f81704ef80edb9324954525cb2b72172 \ No newline at end of file diff --git a/test/fts3aa.test b/test/fts3aa.test index 6ff384a0d3..08d825dd17 100644 --- a/test/fts3aa.test +++ b/test/fts3aa.test @@ -16,6 +16,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix fts3aa # If SQLITE_ENABLE_FTS3 is defined, omit this file. ifcapable !fts3 { @@ -221,5 +222,26 @@ do_catchsql_test fts3aa-7.5 { CREATE VIRTUAL TABLE t4 USING fts4(tokenize=simple, tokenize=simple); } {1 {unrecognized parameter: tokenize=simple}} +do_execsql_test 8.0 { + CREATE VIRTUAL TABLE t0 USING fts4(order=desc); + BEGIN; + INSERT INTO t0(rowid, content) VALUES(1, 'abc'); + UPDATE t0 SET docid=5 WHERE docid=1; + INSERT INTO t0(rowid, content) VALUES(6, 'abc'); +} +do_execsql_test 8.1 { + SELECT docid FROM t0 WHERE t0 MATCH 'abc'; +} {6 5} +do_execsql_test 8.2 { + SELECT docid FROM t0 WHERE t0 MATCH '"abc abc"'; +} {} +do_execsql_test 8.3 { COMMIT } +do_execsql_test 8.4 { + SELECT docid FROM t0 WHERE t0 MATCH 'abc'; +} {6 5} +do_execsql_test 8.5 { + SELECT docid FROM t0 WHERE t0 MATCH '"abc abc"'; +} {} + finish_test From c982844097e7daa4a19e474fc95ee53d9d791d40 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 18 Apr 2015 00:22:17 +0000 Subject: [PATCH 35/74] Fix an incorrect assert() in the sqlite3_trace() logic. FossilOrigin-Name: eabde33997b5b2ffc0067930305d6fed5951a234 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbetrace.c | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 1fee776303..f0df9f9723 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\saffecting\ssome\sfts3\sUPDATE\sand\sDELETE\sstatements\son\sorder=DESC\stables. -D 2015-04-17T20:51:55.807 +C Fix\san\sincorrect\sassert()\sin\sthe\ssqlite3_trace()\slogic. +D 2015-04-18T00:22:17.023 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -301,7 +301,7 @@ F src/vdbeaux.c 03591cca98ec50e1493043f0ff7abbece0b9c83d F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90 F src/vdbemem.c c0dc81285b7571b0a31c40f17846fe2397ec1cd9 F src/vdbesort.c 2e7f683464fd5db3be4beaa1ff2d39e24fcb64b8 -F src/vdbetrace.c 7e4222955e07dd707a2f360c0eb73452be1cb010 +F src/vdbetrace.c e41a50837d694ddd8434533964058e82f0ee7288 F src/vtab.c 9ca557215e8591ceb66e0b7c0a579c6df1e54b2d F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 753995db83247f20361a8e8a874990b21a75abd9 @@ -1251,7 +1251,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 b67bb16c72c3e015ea82665ada9b5d3289ef6fb2 -R e2e6547f1f65a23306e35eed7a1b5202 -U dan -Z 1c324a552a5080240054761e4e92cb4f +P 284c1623f81704ef80edb9324954525cb2b72172 +R b9c1303fd29cc013899d58614b64ee34 +U drh +Z 1ad4f2ae3e13af8994ef4437fb3cca3c diff --git a/manifest.uuid b/manifest.uuid index afb90c6137..a0240a8cac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -284c1623f81704ef80edb9324954525cb2b72172 \ No newline at end of file +eabde33997b5b2ffc0067930305d6fed5951a234 \ No newline at end of file diff --git a/src/vdbetrace.c b/src/vdbetrace.c index 507c2f12fc..aeda6aabb1 100644 --- a/src/vdbetrace.c +++ b/src/vdbetrace.c @@ -111,10 +111,12 @@ char *sqlite3VdbeExpandSql( idx = nextIndex; } }else{ - assert( zRawSql[0]==':' || zRawSql[0]=='$' || zRawSql[0]=='@' ); + assert( zRawSql[0]==':' || zRawSql[0]=='$' || + zRawSql[0]=='@' || zRawSql[0]=='#' ); testcase( zRawSql[0]==':' ); testcase( zRawSql[0]=='$' ); testcase( zRawSql[0]=='@' ); + testcase( zRawSql[0]=='#' ); idx = sqlite3VdbeParameterIndex(p, zRawSql, nToken); assert( idx>0 ); } From 935f2e70745b083784bd45d74b5afdbf25ddca80 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 18 Apr 2015 04:45:00 +0000 Subject: [PATCH 36/74] Disregard leading zeros when converting strings to 32-bit integers. FossilOrigin-Name: 691cc201e135a01c4cc4057be7e5d99285ab392d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/util.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index f0df9f9723..67282b8375 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sincorrect\sassert()\sin\sthe\ssqlite3_trace()\slogic. -D 2015-04-18T00:22:17.023 +C Disregard\sleading\szeros\swhen\sconverting\sstrings\sto\s32-bit\sintegers. +D 2015-04-18T04:45:00.010 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -291,7 +291,7 @@ F src/tokenize.c b7fb584c2be5ec39b6fdf04b185e7c6f33f8dc15 F src/trigger.c bc647c712454c9b209fac082bb82870b5fd6fa54 F src/update.c 3c4ecc282accf12d39edb8d524cf089645e55a13 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c -F src/util.c 98a7627ca48ad3265b6940915a1d08355eb3fc7e +F src/util.c a6431c92803b975b7322724a7b433e538d243539 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 F src/vdbe.c 55650cb03d26ce5955cffcdc6568e046680b1fd4 F src/vdbe.h 7e538ecf47dccb307ea2d087c3ddc2dd8d70e79d @@ -1251,7 +1251,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 284c1623f81704ef80edb9324954525cb2b72172 -R b9c1303fd29cc013899d58614b64ee34 +P eabde33997b5b2ffc0067930305d6fed5951a234 +R 531a7d098945303938ecac96381b796d U drh -Z 1ad4f2ae3e13af8994ef4437fb3cca3c +Z 9c19b8dbab6a9d466a77ca5cd049d2a1 diff --git a/manifest.uuid b/manifest.uuid index a0240a8cac..05a45e30f7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eabde33997b5b2ffc0067930305d6fed5951a234 \ No newline at end of file +691cc201e135a01c4cc4057be7e5d99285ab392d \ No newline at end of file diff --git a/src/util.c b/src/util.c index 6e64242e87..0bc1eeacf4 100644 --- a/src/util.c +++ b/src/util.c @@ -655,6 +655,7 @@ int sqlite3GetInt32(const char *zNum, int *pValue){ } } #endif + while( zNum[0]=='0' ) zNum++; for(i=0; i<11 && (c = zNum[i] - '0')>=0 && c<=9; i++){ v = v*10 + c; } From ea8562edce7bc9c0f0273452dfe1378b5bb423b4 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 18 Apr 2015 16:25:54 +0000 Subject: [PATCH 37/74] Ensure that if a "ROLLBACK TO" statement is used to rollback (but not close) theoutermost transaction, the xRollbackTo() method of any virtual tables involved in the transaction is invoked. FossilOrigin-Name: e98d481d84ef31b6ed154f14deae9b261f722616 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/vdbe.c | 2 +- src/vtab.c | 2 +- test/vtab1.test | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 67282b8375..5e69d46cdc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disregard\sleading\szeros\swhen\sconverting\sstrings\sto\s32-bit\sintegers. -D 2015-04-18T04:45:00.010 +C Ensure\sthat\sif\sa\s"ROLLBACK\sTO"\sstatement\sis\sused\sto\srollback\s(but\snot\sclose)\stheoutermost\stransaction,\sthe\sxRollbackTo()\smethod\sof\sany\svirtual\stables\sinvolved\sin\sthe\stransaction\sis\sinvoked. +D 2015-04-18T16:25:54.955 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -293,7 +293,7 @@ F src/update.c 3c4ecc282accf12d39edb8d524cf089645e55a13 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c a6431c92803b975b7322724a7b433e538d243539 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 55650cb03d26ce5955cffcdc6568e046680b1fd4 +F src/vdbe.c f0cf3cf527d5a40b8d5d2324fdbb31da6c90cd8b F src/vdbe.h 7e538ecf47dccb307ea2d087c3ddc2dd8d70e79d F src/vdbeInt.h 9cbaa84f53ddd2d09a0cf61a94337a3a035d08a0 F src/vdbeapi.c 583d56b129dd27f12bed518270de9ebe521e6a75 @@ -302,7 +302,7 @@ F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90 F src/vdbemem.c c0dc81285b7571b0a31c40f17846fe2397ec1cd9 F src/vdbesort.c 2e7f683464fd5db3be4beaa1ff2d39e24fcb64b8 F src/vdbetrace.c e41a50837d694ddd8434533964058e82f0ee7288 -F src/vtab.c 9ca557215e8591ceb66e0b7c0a579c6df1e54b2d +F src/vtab.c be741af2a377bd894104d62504796e7394a04916 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 753995db83247f20361a8e8a874990b21a75abd9 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 @@ -1113,7 +1113,7 @@ F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 F test/view.test f311691d696a5cc27e3c1b875cec1b0866b4ccd9 -F test/vtab1.test c9dc2a73e93331d70b37ce4b246ef6dc18412fef +F test/vtab1.test d1e5ec7a818f1d3f0402382b6a1d0c06071b770f F test/vtab2.test 3644649aa8d1daac57fd541f6a5f914cac59203e F test/vtab3.test b45f47d20f225ccc9c28dc915d92740c2dee311e F test/vtab4.test 942f8b8280b3ea8a41dae20e7822d065ca1cb275 @@ -1251,7 +1251,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 eabde33997b5b2ffc0067930305d6fed5951a234 -R 531a7d098945303938ecac96381b796d -U drh -Z 9c19b8dbab6a9d466a77ca5cd049d2a1 +P 691cc201e135a01c4cc4057be7e5d99285ab392d +R a45b779d489ba296bfd31a8dac248aa9 +U dan +Z 69dcdf9b3e64dbdf271ca541915d8dc9 diff --git a/manifest.uuid b/manifest.uuid index 05a45e30f7..72715a7cf0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -691cc201e135a01c4cc4057be7e5d99285ab392d \ No newline at end of file +e98d481d84ef31b6ed154f14deae9b261f722616 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 0890df11a5..52b4830577 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2925,7 +2925,7 @@ case OP_Savepoint: { db->nDeferredImmCons = pSavepoint->nDeferredImmCons; } - if( !isTransaction ){ + if( !isTransaction || p1==SAVEPOINT_ROLLBACK ){ rc = sqlite3VtabSavepoint(db, p1, iSavepoint); if( rc!=SQLITE_OK ) goto abort_due_to_error; } diff --git a/src/vtab.c b/src/vtab.c index 9629a00dcb..530c3f305e 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -957,7 +957,7 @@ int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){ int rc = SQLITE_OK; assert( op==SAVEPOINT_RELEASE||op==SAVEPOINT_ROLLBACK||op==SAVEPOINT_BEGIN ); - assert( iSavepoint>=0 ); + assert( iSavepoint>=-1 ); if( db->aVTrans ){ int i; for(i=0; rc==SQLITE_OK && inVTrans; i++){ diff --git a/test/vtab1.test b/test/vtab1.test index dfc989a643..c0cf3e4e8d 100644 --- a/test/vtab1.test +++ b/test/vtab1.test @@ -1491,4 +1491,41 @@ do_test 23.3.1 { } {1 {database table is locked}} do_execsql_test 23.3.2 { SELECT * FROM t1e } {1 2 3 4} +#------------------------------------------------------------------------- +# At one point SQL like this: +# +# SAVEPOINT xyz; -- Opens SQL transaction +# INSERT INTO vtab -- Write to virtual table +# ROLLBACK TO xyz; +# RELEASE xyz; +# +# was not invoking the xRollbackTo() callback for the ROLLBACK TO +# operation. Which meant that virtual tables like FTS3 would incorrectly +# commit the results of the INSERT as part of the "RELEASE xyz" command. +# +# The following tests check that this has been fixed. +# +ifcapable fts3 { + do_execsql_test 24.0 { + CREATE VIRTUAL TABLE t4 USING fts3(); + SAVEPOINT a; + INSERT INTO t4 VALUES('a b c'); + ROLLBACK TO a; + RELEASE a; + SELECT * FROM t4; + } {} + + do_execsql_test 24.1 { SELECT * FROM t4 WHERE t4 MATCH 'b' } {} + do_execsql_test 24.2 { INSERT INTO t4(t4) VALUES('integrity-check') } {} + + do_execsql_test 24.3 { + SAVEPOINT a; + CREATE VIRTUAL TABLE t5 USING fts3(); + SAVEPOINT b; + ROLLBACK TO a; + SAVEPOINT c; + RELEASE a; + } +} + finish_test From 7088d50109868b1d7a352e8d41a5539ad1196699 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 18 Apr 2015 17:43:29 +0000 Subject: [PATCH 38/74] Fix an incorrect assert() statement in the CREATE INDEX code generator. FossilOrigin-Name: 2eed41fda068f2cbac55e63d7c1875ddaa331508 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/build.c | 3 +-- test/index7.test | 4 ++++ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 5e69d46cdc..57c689678e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sif\sa\s"ROLLBACK\sTO"\sstatement\sis\sused\sto\srollback\s(but\snot\sclose)\stheoutermost\stransaction,\sthe\sxRollbackTo()\smethod\sof\sany\svirtual\stables\sinvolved\sin\sthe\stransaction\sis\sinvoked. -D 2015-04-18T16:25:54.955 +C Fix\san\sincorrect\sassert()\sstatement\sin\sthe\sCREATE\sINDEX\scode\sgenerator. +D 2015-04-18T17:43:29.222 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -176,7 +176,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 127aceb71ba93f59bc9c6ba810e992a04299e98a F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4 -F src/build.c 8c4cbff225db37add6351496696151a69965c0b9 +F src/build.c 2d43ee768a3678eaeed203ba5b55490b970f0a5e F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 @@ -659,7 +659,7 @@ F test/index3.test b6ec456cf3b81d9a32123fe7e449bde434db338b F test/index4.test ab92e736d5946840236cd61ac3191f91a7856bf6 F test/index5.test 25b0b451aceed4ac5f7d49f856f6de7257470b3e F test/index6.test 3ae54e53c53f2adcacda269237d8e52bdb05a481 -F test/index7.test 3d54dce09344c4530ea39a458aa304da044c887a +F test/index7.test 9c6765a74fc3fcde7aebc5b3bd40d98df14a527c F test/indexedby.test 5f527a78bae74c61b8046ae3037f9dfb0bf0c353 F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 @@ -1251,7 +1251,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 691cc201e135a01c4cc4057be7e5d99285ab392d -R a45b779d489ba296bfd31a8dac248aa9 -U dan -Z 69dcdf9b3e64dbdf271ca541915d8dc9 +P e98d481d84ef31b6ed154f14deae9b261f722616 +R 56d8c8ddd6b4abbbd3e6fe39eaafa28b +U drh +Z bd5e83def6fd1c67c4a5e49c1b029978 diff --git a/manifest.uuid b/manifest.uuid index 72715a7cf0..d89b9a35bd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e98d481d84ef31b6ed154f14deae9b261f722616 \ No newline at end of file +2eed41fda068f2cbac55e63d7c1875ddaa331508 \ No newline at end of file diff --git a/src/build.c b/src/build.c index e5e4515618..9e4adcb21b 100644 --- a/src/build.c +++ b/src/build.c @@ -2857,8 +2857,7 @@ Index *sqlite3CreateIndex( char *zExtra = 0; /* Extra space after the Index object */ Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */ - assert( pParse->nErr==0 ); /* Never called with prior errors */ - if( db->mallocFailed || IN_DECLARE_VTAB ){ + if( db->mallocFailed || IN_DECLARE_VTAB || pParse->nErr>0 ){ goto exit_create_index; } if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){ diff --git a/test/index7.test b/test/index7.test index 9a2444a87e..557fe21324 100644 --- a/test/index7.test +++ b/test/index7.test @@ -311,5 +311,9 @@ do_eqp_test index7-6.4 { } { 0 0 0 {SEARCH TABLE t4 USING INDEX i4 (c=?)} } +do_catchsql_test index7-6.5 { + CREATE INDEX t5a ON t5(a) WHERE a=#1; +} {1 {near "#1": syntax error}} + finish_test From 816070cf5ca2e547e105400ea79104f206f00db7 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 18 Apr 2015 19:20:14 +0000 Subject: [PATCH 39/74] The sqlite3_trace() callback does not try to expand parameters in statements that have no parameter. FossilOrigin-Name: 917e3c36293a1bf052a16116c93e5037ed712f96 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbetrace.c | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 57c689678e..f1a2f3bac8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sincorrect\sassert()\sstatement\sin\sthe\sCREATE\sINDEX\scode\sgenerator. -D 2015-04-18T17:43:29.222 +C The\ssqlite3_trace()\scallback\sdoes\snot\stry\sto\sexpand\sparameters\sin\sstatements\nthat\shave\sno\sparameter. +D 2015-04-18T19:20:14.612 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -301,7 +301,7 @@ F src/vdbeaux.c 03591cca98ec50e1493043f0ff7abbece0b9c83d F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90 F src/vdbemem.c c0dc81285b7571b0a31c40f17846fe2397ec1cd9 F src/vdbesort.c 2e7f683464fd5db3be4beaa1ff2d39e24fcb64b8 -F src/vdbetrace.c e41a50837d694ddd8434533964058e82f0ee7288 +F src/vdbetrace.c f95c2dff9041fcf07f871789c22ebb0648ea0b7c F src/vtab.c be741af2a377bd894104d62504796e7394a04916 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 753995db83247f20361a8e8a874990b21a75abd9 @@ -1251,7 +1251,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 e98d481d84ef31b6ed154f14deae9b261f722616 -R 56d8c8ddd6b4abbbd3e6fe39eaafa28b +P 2eed41fda068f2cbac55e63d7c1875ddaa331508 +R fe8a360bbce7dedd87d096d07c896e4c U drh -Z bd5e83def6fd1c67c4a5e49c1b029978 +Z 768a04b82f6060145bfe8edb7197ea08 diff --git a/manifest.uuid b/manifest.uuid index d89b9a35bd..98458ab03b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2eed41fda068f2cbac55e63d7c1875ddaa331508 \ No newline at end of file +917e3c36293a1bf052a16116c93e5037ed712f96 \ No newline at end of file diff --git a/src/vdbetrace.c b/src/vdbetrace.c index aeda6aabb1..fe0dfd3f7a 100644 --- a/src/vdbetrace.c +++ b/src/vdbetrace.c @@ -95,6 +95,8 @@ char *sqlite3VdbeExpandSql( assert( (zRawSql - zStart) > 0 ); sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart)); } + }else if( p->nVar==0 ){ + sqlite3StrAccumAppend(&out, zRawSql, sqlite3Strlen30(zRawSql)); }else{ while( zRawSql[0] ){ n = findNextHostParameter(zRawSql, &nToken); From 6bbe3dfaf2155e5a07cf6fd5fd4ae015f9901f17 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sun, 19 Apr 2015 06:18:10 +0000 Subject: [PATCH 40/74] Work in progress on making VSIX packages for the Visual Studio 2015 CTP. FossilOrigin-Name: 8469d651a0442a2bc572a869a0457a6ea8c06bc7 --- Makefile.msc | 5 ++++ manifest | 19 +++++++------ manifest.uuid | 2 +- tool/build-all-msvc.bat | 63 +++++++++++++++++++++++++++++++++++------ 4 files changed, 71 insertions(+), 18 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 914bb1e7ad..bf290d0040 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -288,6 +288,11 @@ BCC = $(BCC) -FAcs # !IF $(USE_NATIVE_LIBPATHS)!=0 NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)" + +!IFDEF NUCRTLIBPATH +NUCRTLIBPATH = $(NUCRTLIBPATH:\\=\) +NLTLIBPATHS = $(NLTLIBPATHS) "/LIBPATH:$(NUCRTLIBPATH)" +!ENDIF !ENDIF # C compiler and options for use in building executables that diff --git a/manifest b/manifest index f1a2f3bac8..594e27b7eb 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C The\ssqlite3_trace()\scallback\sdoes\snot\stry\sto\sexpand\sparameters\sin\sstatements\nthat\shave\sno\sparameter. -D 2015-04-18T19:20:14.612 +C Work\sin\sprogress\son\smaking\sVSIX\spackages\sfor\sthe\sVisual\sStudio\s2015\sCTP. +D 2015-04-19T06:18:10.467 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc a19bceec468fa18bb54df52257b1a2211e69172d +F Makefile.msc 513abdaff333b04ef68775ec25ceb6053b4ecafd F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 F VERSION 2e244662b71e6e68a5c29b014ebc5b7564f4cc5a @@ -1196,7 +1196,7 @@ F test/without_rowid6.test db0dbf03c49030aa3c1ba5f618620334bd2baf5f F test/wordcount.c 9915e06cb33d8ca8109b8700791afe80d305afda F test/zeroblob.test fb3c0e4ab172d386954deda24c03f500e121d80d F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac -F tool/build-all-msvc.bat 72e05bc8deca39a547884485c086b915f50a91ed x +F tool/build-all-msvc.bat 62f4f74b55781757d5b20e12651650d5d94ef2cf x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b @@ -1251,7 +1251,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 2eed41fda068f2cbac55e63d7c1875ddaa331508 -R fe8a360bbce7dedd87d096d07c896e4c -U drh -Z 768a04b82f6060145bfe8edb7197ea08 +P 917e3c36293a1bf052a16116c93e5037ed712f96 +R db56dc9284c6212139225593eec3e32c +T *branch * vsix2015 +T *sym-vsix2015 * +T -sym-trunk * +U mistachkin +Z af05882e14ca6800d4b8b20f52645692 diff --git a/manifest.uuid b/manifest.uuid index 98458ab03b..b8085cc5cf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -917e3c36293a1bf052a16116c93e5037ed712f96 \ No newline at end of file +8469d651a0442a2bc572a869a0457a6ea8c06bc7 \ No newline at end of file diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index 728183629b..5fe343c074 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -217,8 +217,20 @@ SET TOOLPATH=%gawk.exe_PATH%;%tclsh85.exe_PATH% %_VECHO% ToolPath = '%TOOLPATH%' REM -REM NOTE: Check for MSVC 2012/2013 because the Windows SDK directory handling -REM is slightly different for those versions. +REM NOTE: Setting the Windows SDK library path is only required for MSVC +REM 2012, 2013, and 2015. +REM +CALL :fn_UnsetVariable SET_NSDKLIBPATH + +REM +REM NOTE: Setting the Universal CRT library path is only required for MSVC +REM 2015. +REM +CALL :fn_UnsetVariable SET_NUCRTLIBPATH + +REM +REM NOTE: Check for MSVC 2012, 2013, and 2015 specially because the Windows +REM SDK directory handling is slightly different for those versions. REM IF "%VisualStudioVersion%" == "11.0" ( REM @@ -236,8 +248,22 @@ IF "%VisualStudioVersion%" == "11.0" ( IF NOT DEFINED NSDKLIBPATH ( SET SET_NSDKLIBPATH=1 ) -) ELSE ( - CALL :fn_UnsetVariable SET_NSDKLIBPATH +) ELSE IF "%VisualStudioVersion%" == "14.0" ( + REM + REM NOTE: If the Windows SDK library path has already been set, do not set + REM it to something else later on. + REM + IF NOT DEFINED NSDKLIBPATH ( + SET SET_NSDKLIBPATH=1 + ) + + REM + REM NOTE: If the Universal CRT library path has already been set, do not set + REM it to something else later on. + REM + IF NOT DEFINED NUCRTLIBPATH ( + SET SET_NUCRTLIBPATH=1 + ) ) REM @@ -294,6 +320,7 @@ FOR %%P IN (%PLATFORMS%) DO ( CALL :fn_UnsetVariable LIB CALL :fn_UnsetVariable LIBPATH CALL :fn_UnsetVariable Platform + CALL :fn_UnsetVariable UniversalCRTSdkDir REM CALL :fn_UnsetVariable VCINSTALLDIR CALL :fn_UnsetVariable VSINSTALLDIR CALL :fn_UnsetVariable WindowsPhoneKitDir @@ -385,8 +412,8 @@ FOR %%P IN (%PLATFORMS%) DO ( ) REM - REM NOTE: When using MSVC 2012 and/or 2013, the native SDK path cannot - REM simply use the "lib" sub-directory beneath the location + REM NOTE: When using MSVC 2012, 2013, or 2015, the native SDK path + REM cannot simply be the "lib" sub-directory beneath the location REM specified in the WindowsSdkDir environment variable because REM that location does not actually contain the necessary library REM files for x86. This must be done for each iteration because @@ -405,19 +432,37 @@ FOR %%P IN (%PLATFORMS%) DO ( CALL :fn_CopyVariable WindowsSdkDir NSDKLIBPATH REM - REM NOTE: The Windows 8.1 SDK has a slightly different directory - REM naming convention. + REM NOTE: The Windows 8.x and Windows 10 SDKs have a slightly + REM different directory naming conventions. REM - IF DEFINED USE_WINV63_NSDKLIBPATH ( + IF DEFINED USE_WINV100_NSDKLIBPATH ( + CALL :fn_AppendVariable NSDKLIBPATH \..\10\lib\10.0.10030.0\um\x86 + ) ELSE IF DEFINED USE_WINV63_NSDKLIBPATH ( CALL :fn_AppendVariable NSDKLIBPATH \lib\winv6.3\um\x86 ) ELSE IF "%VisualStudioVersion%" == "12.0" ( CALL :fn_AppendVariable NSDKLIBPATH \..\8.0\lib\win8\um\x86 + ) ELSE IF "%VisualStudioVersion%" == "14.0" ( + CALL :fn_AppendVariable NSDKLIBPATH \..\8.0\lib\win8\um\x86 ) ELSE ( CALL :fn_AppendVariable NSDKLIBPATH \lib\win8\um\x86 ) ) ) + REM + REM NOTE: When using MSVC 2015, setting the Universal CRT library path + REM for x86 may be required as well. This must also be done for + REM each iteration because it relies upon the UniversalCRTSdkDir + REM environment variable being set by the batch file used to + REM setup the MSVC environment. + REM + IF DEFINED SET_NUCRTLIBPATH ( + IF DEFINED UniversalCRTSdkDir ( + CALL :fn_CopyVariable UniversalCRTSdkDir NUCRTLIBPATH + CALL :fn_AppendVariable NUCRTLIBPATH \lib\winv10.0\ucrt\x86 + ) + ) + REM REM NOTE: Unless prevented from doing so, invoke NMAKE with the MSVC REM makefile to clean any stale build output from previous From a21f78b93fab3fa00b594fcab91c1b8e599547f0 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 19 Apr 2015 18:32:43 +0000 Subject: [PATCH 41/74] Bring comments on the INSERT code generator up-to-date. Fix the INSERT code generator so that it correctly handles inserts from a SELECT into a virtual table with non-terminal hidden columns. FossilOrigin-Name: 4ac81fac6c6302c042be3df493a41630b733fff0 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/insert.c | 33 +++++++++++++++++++-------------- src/sqliteInt.h | 7 +++++++ src/vtab.c | 9 ++++++++- test/vtabA.test | 23 +++++++++++++++++------ 6 files changed, 61 insertions(+), 31 deletions(-) diff --git a/manifest b/manifest index f1a2f3bac8..3f642604b2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\ssqlite3_trace()\scallback\sdoes\snot\stry\sto\sexpand\sparameters\sin\sstatements\nthat\shave\sno\sparameter. -D 2015-04-18T19:20:14.612 +C Bring\scomments\son\sthe\sINSERT\scode\sgenerator\sup-to-date.\s\sFix\sthe\sINSERT\scode\ngenerator\sso\sthat\sit\scorrectly\shandles\sinserts\sfrom\sa\sSELECT\sinto\sa\svirtual\ntable\swith\snon-terminal\shidden\scolumns. +D 2015-04-19T18:32:43.531 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -190,7 +190,7 @@ F src/global.c 4f77cadbc5427d00139ba43d0f3979804cbb700e F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c 305dd3f9539d0affa4bf1c14cc7dffb34867e040 +F src/insert.c 9f5f25a9d645089973d2f451711b7402bfde6ab5 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770 @@ -235,7 +235,7 @@ F src/shell.c 28b3e1174a7fc00155d7d00880a33589a88508c9 F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d -F src/sqliteInt.h af228df2a02bf1a608d678b312d46aa480470b3c +F src/sqliteInt.h 3a1fccc2bb62ab16750730b6f6f24305e686a0ce F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179 F src/table.c e7a09215315a978057fb42c640f890160dbcc45e @@ -302,7 +302,7 @@ F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90 F src/vdbemem.c c0dc81285b7571b0a31c40f17846fe2397ec1cd9 F src/vdbesort.c 2e7f683464fd5db3be4beaa1ff2d39e24fcb64b8 F src/vdbetrace.c f95c2dff9041fcf07f871789c22ebb0648ea0b7c -F src/vtab.c be741af2a377bd894104d62504796e7394a04916 +F src/vtab.c 4feb365e2688dd02474e671e37f27e35784d2cff F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 753995db83247f20361a8e8a874990b21a75abd9 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 @@ -1122,7 +1122,7 @@ F test/vtab6.test 5f5380c425e52993560ab4763db4f826d2ba7b09 F test/vtab7.test ae560ebea870ed04e9aa4177cc302f910faaabb5 F test/vtab8.test e19fa4a538fcd1bb66c22825fa8f71618fb13583 F test/vtab9.test ea58d2b95d61955f87226381716b2d0b1d4e4f9b -F test/vtabA.test c86e1990b7e1e2bb34602a06fffa4c69f2b516dc +F test/vtabA.test 1317f06a03597eee29f40a49b6c21e1aaba4285f F test/vtabB.test 04df5dc531b9f44d9ca65b9c1b79f12b5922a796 F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 @@ -1251,7 +1251,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 2eed41fda068f2cbac55e63d7c1875ddaa331508 -R fe8a360bbce7dedd87d096d07c896e4c +P 917e3c36293a1bf052a16116c93e5037ed712f96 +R b611a70a7a5e6fee6ae7534de091ac22 U drh -Z 768a04b82f6060145bfe8edb7197ea08 +Z cc4a9846aabfd76674510baafeb05d26 diff --git a/manifest.uuid b/manifest.uuid index 98458ab03b..c59b152783 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -917e3c36293a1bf052a16116c93e5037ed712f96 \ No newline at end of file +4ac81fac6c6302c042be3df493a41630b733fff0 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index fc8895bbd6..73c550b832 100644 --- a/src/insert.c +++ b/src/insert.c @@ -342,20 +342,23 @@ static int xferOptimization( /* ** This routine is called to handle SQL of the following forms: ** -** insert into TABLE (IDLIST) values(EXPRLIST) +** insert into TABLE (IDLIST) values(EXPRLIST),(EXPRLIST),... ** insert into TABLE (IDLIST) select +** insert into TABLE (IDLIST) default values ** ** The IDLIST following the table name is always optional. If omitted, -** then a list of all columns for the table is substituted. The IDLIST -** appears in the pColumn parameter. pColumn is NULL if IDLIST is omitted. +** then a list of all (non-hidden) columns for the table is substituted. +** The IDLIST appears in the pColumn parameter. pColumn is NULL if IDLIST +** is omitted. ** -** The pList parameter holds EXPRLIST in the first form of the INSERT -** statement above, and pSelect is NULL. For the second form, pList is -** NULL and pSelect is a pointer to the select statement used to generate -** data for the insert. +** For the pSelect parameter holds the values to be inserted for the +** first two forms shown above. A VALUES clause is really just short-hand +** for a SELECT statement that omits the FROM clause and everything else +** that follows. If the pSelect parameter is NULL, that means that the +** DEFAULT VALUES form of the INSERT statement is intended. ** ** The code generated follows one of four templates. For a simple -** insert with data coming from a VALUES clause, the code executes +** insert with data coming from a single-row VALUES clause, the code executes ** once straight down through. Pseudo-code follows (we call this ** the "1st template"): ** @@ -462,7 +465,7 @@ void sqlite3Insert( u8 useTempTable = 0; /* Store SELECT results in intermediate table */ u8 appendFlag = 0; /* True if the insert is likely to be an append */ u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */ - u8 bIdListInOrder = 1; /* True if IDLIST is in table order */ + u8 bIdListInOrder; /* True if IDLIST is in table order */ ExprList *pList = 0; /* List of VALUES() to be inserted */ /* Register allocations */ @@ -487,8 +490,8 @@ void sqlite3Insert( } /* If the Select object is really just a simple VALUES() list with a - ** single row values (the common case) then keep that one row of values - ** and go ahead and discard the Select object + ** single row (the common case) then keep that one row of values + ** and discard the other (unused) parts of the pSelect object */ if( pSelect && (pSelect->selFlags & SF_Values)!=0 && pSelect->pPrior==0 ){ pList = pSelect->pEList; @@ -596,6 +599,7 @@ void sqlite3Insert( ** is appears in the original table. (The index of the INTEGER ** PRIMARY KEY in the original table is pTab->iPKey.) */ + bIdListInOrder = (pTab->tabFlags & TF_OOOHidden)==0; if( pColumn ){ for(i=0; inId; i++){ pColumn->a[i].idx = -1; @@ -631,7 +635,8 @@ void sqlite3Insert( ** co-routine is the common header to the 3rd and 4th templates. */ if( pSelect ){ - /* Data is coming from a SELECT. Generate a co-routine to run the SELECT */ + /* Data is coming from a SELECT or from a multi-row VALUES clause. + ** Generate a co-routine to run the SELECT. */ int regYield; /* Register holding co-routine entry-point */ int addrTop; /* Top of the co-routine */ int rc; /* Result code */ @@ -693,8 +698,8 @@ void sqlite3Insert( sqlite3ReleaseTempReg(pParse, regTempRowid); } }else{ - /* This is the case if the data for the INSERT is coming from a VALUES - ** clause + /* This is the case if the data for the INSERT is coming from a + ** single-row VALUES clause */ NameContext sNC; memset(&sNC, 0, sizeof(sNC)); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index b1a2db3a28..deab70fc48 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1622,6 +1622,12 @@ struct Table { /* ** Allowed values for Table.tabFlags. +** +** TF_OOOHidden applies to virtual tables that have hidden columns that are +** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING +** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden, +** the TF_OOOHidden attribute would apply in this case. Such tables require +** special handling during INSERT processing. */ #define TF_Readonly 0x01 /* Read-only system table */ #define TF_Ephemeral 0x02 /* An ephemeral table */ @@ -1629,6 +1635,7 @@ struct Table { #define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */ #define TF_Virtual 0x10 /* Is a virtual table */ #define TF_WithoutRowid 0x20 /* No rowid used. PRIMARY KEY is the key */ +#define TF_OOOHidden 0x40 /* Out-of-Order hidden columns */ /* diff --git a/src/vtab.c b/src/vtab.c index 530c3f305e..ad65cdf7f4 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -559,6 +559,7 @@ static int vtabCallConstructor( rc = SQLITE_ERROR; }else{ int iCol; + u8 oooHidden = 0; /* If everything went according to plan, link the new VTable structure ** into the linked list headed by pTab->pVTable. Then loop through the ** columns of the table to see if any of them contain the token "hidden". @@ -571,7 +572,10 @@ static int vtabCallConstructor( char *zType = pTab->aCol[iCol].zType; int nType; int i = 0; - if( !zType ) continue; + if( !zType ){ + pTab->tabFlags |= oooHidden; + continue; + } nType = sqlite3Strlen30(zType); if( sqlite3StrNICmp("hidden", zType, 6)||(zType[6] && zType[6]!=' ') ){ for(i=0; iaCol[iCol].colFlags |= COLFLAG_HIDDEN; + oooHidden = TF_OOOHidden; + }else{ + pTab->tabFlags |= oooHidden; } } } diff --git a/test/vtabA.test b/test/vtabA.test index 928cc2b703..eddaa70d1f 100644 --- a/test/vtabA.test +++ b/test/vtabA.test @@ -74,28 +74,39 @@ do_test vtabA-1.6 { SELECT * FROM t1e; } } {{value a} {value c}} +do_execsql_test vtabA-1.7 { + DELETE FROM t1e; + INSERT INTO t1e SELECT 'abc','def'; +} {} +do_execsql_test vtabA-1.8 { + INSERT INTO t1e VALUES('ghi','jkl'),('mno','pqr'),('stu','vwx'); +} {} +do_execsql_test vtabA-1.9 { + SELECT a,b,c, '|' FROM t1e ORDER BY 1; +} {abc {} def | ghi {} jkl | mno {} pqr | stu {} vwx |} + # Test that the expansion of a '*' expression in the result set of # a SELECT does not include the hidden column. # -do_test vtabA-1.7 { +do_test vtabA-1.20 { execsql { INSERT INTO t1e SELECT * FROM t1e; } } {} -do_test vtabA-1.8 { +do_test vtabA-1.21 { execsql { - SELECT * FROM t1e; + SELECT * FROM t1e ORDER BY 1; } -} {{value a} {value c} {value a} {value c}} +} {abc def abc def ghi jkl ghi jkl mno pqr mno pqr stu vwx stu vwx} # Test that the declaration type of the hidden column does not include # the token "HIDDEN". # -do_test vtabA-1.9 { +do_test vtabA-1.22 { get_decltype t1e b } {VARCHAR} -do_test vtabA-1.10 { +do_test vtabA-1.23 { get_collist t1e } {a c} From 88eb7fa3286cf2d6ca9476be00f0d82e7e0e828c Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sun, 19 Apr 2015 18:58:29 +0000 Subject: [PATCH 42/74] Improve documentation and comments in the MSVC batch build tool. FossilOrigin-Name: ca64ef079811006f3e0526919871ffd286c3e714 --- manifest | 15 +++++------ manifest.uuid | 2 +- tool/build-all-msvc.bat | 60 +++++++++++++++++++++++++++++++++-------- 3 files changed, 56 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 594e27b7eb..3bd105c4f7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Work\sin\sprogress\son\smaking\sVSIX\spackages\sfor\sthe\sVisual\sStudio\s2015\sCTP. -D 2015-04-19T06:18:10.467 +C Improve\sdocumentation\sand\scomments\sin\sthe\sMSVC\sbatch\sbuild\stool. +D 2015-04-19T18:58:29.991 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1196,7 +1196,7 @@ F test/without_rowid6.test db0dbf03c49030aa3c1ba5f618620334bd2baf5f F test/wordcount.c 9915e06cb33d8ca8109b8700791afe80d305afda F test/zeroblob.test fb3c0e4ab172d386954deda24c03f500e121d80d F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac -F tool/build-all-msvc.bat 62f4f74b55781757d5b20e12651650d5d94ef2cf x +F tool/build-all-msvc.bat 78d530f024c22828ce882a3f0b892490aaaf3201 x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b @@ -1251,10 +1251,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 917e3c36293a1bf052a16116c93e5037ed712f96 -R db56dc9284c6212139225593eec3e32c -T *branch * vsix2015 -T *sym-vsix2015 * -T -sym-trunk * +P 8469d651a0442a2bc572a869a0457a6ea8c06bc7 +R 05d8b709a19efc6c268ced1a9d746700 U mistachkin -Z af05882e14ca6800d4b8b20f52645692 +Z 13c315b8e34663ea44d46ce0d67e7224 diff --git a/manifest.uuid b/manifest.uuid index b8085cc5cf..f0b5233751 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8469d651a0442a2bc572a869a0457a6ea8c06bc7 \ No newline at end of file +ca64ef079811006f3e0526919871ffd286c3e714 \ No newline at end of file diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index 5fe343c074..090c6266d1 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -28,6 +28,11 @@ REM In the example above, "C:\dev\sqlite\core" represents the root of the REM source tree for SQLite and "C:\Temp" represents the final destination REM directory for the generated output files. REM +REM Please note that the SQLite build process performed by the Makefile +REM associated with this batch script requires both Gawk ^(gawk.exe^) and Tcl +REM 8.5 ^(tclsh85.exe^) to be present in a directory contained in the PATH +REM environment variable unless a pre-existing amalgamation file is used. +REM REM There are several environment variables that may be set to modify the REM behavior of this batch script and its associated Makefile. The list of REM platforms to build may be overriden by using the PLATFORMS environment @@ -37,17 +42,50 @@ REM being used. The list of configurations to build may be overridden by REM setting the CONFIGURATIONS environment variable, which should contain a REM list of configurations to build ^(e.g. Debug Retail^). Neither of these REM variable values may contain any double quotes, surrounding or embedded. -REM Finally, the NCRTLIBPATH and NSDKLIBPATH environment variables may be set -REM to specify the location of the CRT and SDK, respectively, needed to compile -REM executables native to the architecture of the build machine during any -REM cross-compilation that may be necessary, depending on the platforms to be -REM built. These values in these two variables should be surrounded by double -REM quotes if they contain spaces. REM -REM Please note that the SQLite build process performed by the Makefile -REM associated with this batch script requires both Gawk ^(gawk.exe^) and Tcl -REM 8.5 ^(tclsh85.exe^) to be present in a directory contained in the PATH -REM environment variable unless a pre-existing amalgamation file is used. +REM Finally, the NCRTLIBPATH, NUCRTLIBPATH, and NSDKLIBPATH environment +REM variables may be set to specify the location of the CRT, Universal CRT, and +REM Windows SDK, respectively, that may be needed to compile executables native +REM to the architecture of the build machine during any cross-compilation that +REM may be necessary, depending on the platforms to be built. These values in +REM these three variables should be surrounded by double quotes if they contain +REM spaces. +REM +REM There are a few other environment variables that impact the build process +REM when set ^(to anything^), they are: +REM +REM NOCLEAN +REM +REM When set, the "clean" target will not be used during each build iteration. +REM However, the target binaries, if any, will still be deleted manually prior +REM to being rebuilt. Setting this environment variable is only rarely needed +REM and could cause issues in some circumstances; therefore, setting it is not +REM recommended. +REM +REM NOSYMBOLS +REM +REM When set, copying of symbol files ^(*.pdb^) created during the build will +REM be skipped and they will not appear in the final destination directory. +REM Setting this environment variable is never strictly needed and could cause +REM issues in some circumstances; therefore, setting it is not recommended. +REM +REM BUILD_ALL_SHELL +REM +REM When set, the command line shell will be built for each selected platform +REM and configuration as well. In addition, the command line shell binaries +REM will be copied, with their symbols, to the final destination directory. +REM +REM USE_WINV63_NSDKLIBPATH +REM +REM When set, modifies how the NSDKLIBPATH environment variable is built, based +REM on the WindowsSdkDir environment variable. It forces this batch script to +REM assume the Windows 8.1 SDK location should be used. +REM +REM USE_WINV100_NSDKLIBPATH +REM +REM When set, modifies how the NSDKLIBPATH environment variable is built, based +REM on the WindowsSdkDir environment variable. It causes this batch script to +REM assume the Windows 10.0 SDK location should be used. REM SETLOCAL @@ -432,7 +470,7 @@ FOR %%P IN (%PLATFORMS%) DO ( CALL :fn_CopyVariable WindowsSdkDir NSDKLIBPATH REM - REM NOTE: The Windows 8.x and Windows 10 SDKs have a slightly + REM NOTE: The Windows 8.x and Windows 10.0 SDKs have a slightly REM different directory naming conventions. REM IF DEFINED USE_WINV100_NSDKLIBPATH ( From d0c73053132e0d54952c04730f2749d6760ff9f6 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 19 Apr 2015 19:21:19 +0000 Subject: [PATCH 43/74] Fix a potential NULL pointer deference on a corrupt database schema. FossilOrigin-Name: dc61b292d8eaf422ca8a2b18f1caccef1a5389fd --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/expr.c | 3 ++- test/misc1.test | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 3f642604b2..05699e70af 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Bring\scomments\son\sthe\sINSERT\scode\sgenerator\sup-to-date.\s\sFix\sthe\sINSERT\scode\ngenerator\sso\sthat\sit\scorrectly\shandles\sinserts\sfrom\sa\sSELECT\sinto\sa\svirtual\ntable\swith\snon-terminal\shidden\scolumns. -D 2015-04-19T18:32:43.531 +C Fix\sa\spotential\sNULL\spointer\sdeference\son\sa\scorrupt\sdatabase\sschema. +D 2015-04-19T19:21:19.025 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -182,7 +182,7 @@ F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e -F src/expr.c 55e7ce8f7e6c98402365e253b277377fe567772a +F src/expr.c 25a732f30ba391dfb00bbdc9ec079056c2fbced5 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 3343d551a8d810782257244fb33f2ce191493c39 F src/func.c 1414c24c873c48796ad45942257a179a423ba42f @@ -743,7 +743,7 @@ F test/minmax.test 42fbad0e81afaa6e0de41c960329f2b2c3526efd F test/minmax2.test b44bae787fc7b227597b01b0ca5575c7cb54d3bc F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 F test/minmax4.test 936941484ebdceb8adec7c86b6cd9b6e5e897c1f -F test/misc1.test 9abcae9a0b8785d6fa92925dbb19c309ae9ea077 +F test/misc1.test 623405f6da1ea0b78b68c0549ee6c2cc027668f2 F test/misc2.test 00d7de54eda90e237fc9a38b9e5ccc769ebf6d4d F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6 @@ -1251,7 +1251,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 917e3c36293a1bf052a16116c93e5037ed712f96 -R b611a70a7a5e6fee6ae7534de091ac22 +P 4ac81fac6c6302c042be3df493a41630b733fff0 +R 217c2ee5ae382a4066646fde6de10d74 U drh -Z cc4a9846aabfd76674510baafeb05d26 +Z 68ce861ea89d3d58ce69aec04612a1ea diff --git a/manifest.uuid b/manifest.uuid index c59b152783..18c9f61d96 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4ac81fac6c6302c042be3df493a41630b733fff0 \ No newline at end of file +dc61b292d8eaf422ca8a2b18f1caccef1a5389fd \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 6a5ecfe4f2..660fbff7b6 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1251,7 +1251,8 @@ u32 sqlite3ExprListFlags(const ExprList *pList){ u32 m = 0; if( pList ){ for(i=0; inExpr; i++){ - m |= pList->a[i].pExpr->flags; + Expr *pExpr = pList->a[i].pExpr; + if( pExpr ) m |= pList->a[i].pExpr->flags; } } return m; diff --git a/test/misc1.test b/test/misc1.test index 1b98eafc6a..9408f2a8a2 100644 --- a/test/misc1.test +++ b/test/misc1.test @@ -644,4 +644,18 @@ do_execsql_test misc1-22.1 { SELECT ""+3 FROM (SELECT ""+5); } {3} +# 2015-04-19: NULL pointer dereference on a corrupt schema +# +do_execsql_test misc1-23.1 { + DROP TABLE IF EXISTS t1; + DROP TABLE IF EXISTS t2; + CREATE TABLE t1(x); + PRAGMA writable_schema=ON; + UPDATE sqlite_master SET sql='CREATE table t(d CHECK(T(#0)'; + BEGIN; + CREATE TABLE t2(y); + ROLLBACK; + DROP TABLE IF EXISTS t3; +} {} + finish_test From 1c89a7710e5c0704cfd41d01a74e3c58ee6e3364 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sun, 19 Apr 2015 19:53:43 +0000 Subject: [PATCH 44/74] Document the NMAKE_ARGS environment variable as well. FossilOrigin-Name: 977fd39c1509edec2e28cc8bac64e0994699f398 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/build-all-msvc.bat | 8 ++++++++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 3bd105c4f7..0180ba625a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sdocumentation\sand\scomments\sin\sthe\sMSVC\sbatch\sbuild\stool. -D 2015-04-19T18:58:29.991 +C Document\sthe\sNMAKE_ARGS\senvironment\svariable\sas\swell. +D 2015-04-19T19:53:43.925 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1196,7 +1196,7 @@ F test/without_rowid6.test db0dbf03c49030aa3c1ba5f618620334bd2baf5f F test/wordcount.c 9915e06cb33d8ca8109b8700791afe80d305afda F test/zeroblob.test fb3c0e4ab172d386954deda24c03f500e121d80d F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac -F tool/build-all-msvc.bat 78d530f024c22828ce882a3f0b892490aaaf3201 x +F tool/build-all-msvc.bat 19be654f72b0b0ed4d2451a998c603a4eb65a60f x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b @@ -1251,7 +1251,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 8469d651a0442a2bc572a869a0457a6ea8c06bc7 -R 05d8b709a19efc6c268ced1a9d746700 +P ca64ef079811006f3e0526919871ffd286c3e714 +R 52d9f3383650b84247283bfd77621eab U mistachkin -Z 13c315b8e34663ea44d46ce0d67e7224 +Z 4ecdfe31e09fefcd24da72e520807bdb diff --git a/manifest.uuid b/manifest.uuid index f0b5233751..1edabded57 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ca64ef079811006f3e0526919871ffd286c3e714 \ No newline at end of file +977fd39c1509edec2e28cc8bac64e0994699f398 \ No newline at end of file diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index 090c6266d1..534ea75be6 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -87,6 +87,14 @@ REM When set, modifies how the NSDKLIBPATH environment variable is built, based REM on the WindowsSdkDir environment variable. It causes this batch script to REM assume the Windows 10.0 SDK location should be used. REM +REM NMAKE_ARGS +REM +REM When set, the value is expanded and passed to the NMAKE command line, after +REM its other arguments. This is used to specify additional NMAKE options, for +REM example: +REM +REM SET NMAKE_ARGS=FOR_WINRT=1 +REM SETLOCAL REM SET __ECHO=ECHO From 33c59ecafb82f60dc75df4c82c72d99e59a350fa Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 19 Apr 2015 20:39:17 +0000 Subject: [PATCH 45/74] Fix a faulty assert in the schema parsing logic. FossilOrigin-Name: b1ed949584a2526c04952b98c3aa283427f45e10 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/build.c | 2 +- test/misc1.test | 19 +++++++++++++++++-- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 05699e70af..45fb2ca55d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spotential\sNULL\spointer\sdeference\son\sa\scorrupt\sdatabase\sschema. -D 2015-04-19T19:21:19.025 +C Fix\sa\sfaulty\sassert\sin\sthe\sschema\sparsing\slogic. +D 2015-04-19T20:39:17.335 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -176,7 +176,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 127aceb71ba93f59bc9c6ba810e992a04299e98a F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4 -F src/build.c 2d43ee768a3678eaeed203ba5b55490b970f0a5e +F src/build.c bc3a513a57b0962aa98b38ab9c850f3987457885 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 @@ -743,7 +743,7 @@ F test/minmax.test 42fbad0e81afaa6e0de41c960329f2b2c3526efd F test/minmax2.test b44bae787fc7b227597b01b0ca5575c7cb54d3bc F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 F test/minmax4.test 936941484ebdceb8adec7c86b6cd9b6e5e897c1f -F test/misc1.test 623405f6da1ea0b78b68c0549ee6c2cc027668f2 +F test/misc1.test e908edf5c6e02dcc7453c1519e59625c67cc099e F test/misc2.test 00d7de54eda90e237fc9a38b9e5ccc769ebf6d4d F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6 @@ -1251,7 +1251,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 4ac81fac6c6302c042be3df493a41630b733fff0 -R 217c2ee5ae382a4066646fde6de10d74 +P dc61b292d8eaf422ca8a2b18f1caccef1a5389fd +R cfb6006d4eb96e8b001f7f44f28a3f5a U drh -Z 68ce861ea89d3d58ce69aec04612a1ea +Z 30562fcecce8e59f5b0c8b52be03b8fe diff --git a/manifest.uuid b/manifest.uuid index 18c9f61d96..496f912ba1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dc61b292d8eaf422ca8a2b18f1caccef1a5389fd \ No newline at end of file +b1ed949584a2526c04952b98c3aa283427f45e10 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 9e4adcb21b..52f4e27e32 100644 --- a/src/build.c +++ b/src/build.c @@ -927,7 +927,7 @@ void sqlite3StartTable( if( !noErr ){ sqlite3ErrorMsg(pParse, "table %T already exists", pName); }else{ - assert( !db->init.busy ); + assert( !db->init.busy || CORRUPT_DB ); sqlite3CodeVerifySchema(pParse, iDb); } goto begin_table_error; diff --git a/test/misc1.test b/test/misc1.test index 9408f2a8a2..0dc4d81347 100644 --- a/test/misc1.test +++ b/test/misc1.test @@ -646,9 +646,9 @@ do_execsql_test misc1-22.1 { # 2015-04-19: NULL pointer dereference on a corrupt schema # +db close +sqlite3 db :memory: do_execsql_test misc1-23.1 { - DROP TABLE IF EXISTS t1; - DROP TABLE IF EXISTS t2; CREATE TABLE t1(x); PRAGMA writable_schema=ON; UPDATE sqlite_master SET sql='CREATE table t(d CHECK(T(#0)'; @@ -658,4 +658,19 @@ do_execsql_test misc1-23.1 { DROP TABLE IF EXISTS t3; } {} +# 2015-04-19: Faulty assert() statement +# +db close +database_may_be_corrupt +sqlite3 db :memory: +do_catchsql_test misc1-23.2 { + CREATE TABLE t1(x UNIQUE); + PRAGMA writable_schema=ON; + UPDATE sqlite_master SET sql='CREATE TABLE IF not EXISTS t(c)'; + BEGIN; + CREATE TABLE t2(x); + ROLLBACK; + DROP TABLE F; +} {1 {no such table: F}} + finish_test From 8e18922f12426bd781b5113be9398d59393d77d6 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sun, 19 Apr 2015 21:43:16 +0000 Subject: [PATCH 46/74] Fix harmless compiler warnings seen with MSVC 2015. FossilOrigin-Name: d05becd873a03a366843a34e7f4c732dd8f88c86 --- ext/fts3/fts3_tokenizer.c | 6 +-- ext/misc/fuzzer.c | 2 +- manifest | 36 +++++++------- manifest.uuid | 2 +- src/insert.c | 1 - src/pager.c | 4 -- src/pragma.c | 12 ++--- src/shell.c | 102 +++++++++++++++++++------------------- src/tclsqlite.c | 10 ++-- src/test_malloc.c | 10 ++-- src/test_multiplex.c | 14 +++--- src/test_onefile.c | 6 +-- src/test_osinst.c | 3 -- src/test_vfs.c | 3 +- tool/lemon.c | 72 +++++++++++++-------------- 15 files changed, 136 insertions(+), 147 deletions(-) diff --git a/ext/fts3/fts3_tokenizer.c b/ext/fts3/fts3_tokenizer.c index 2b985f5f33..2a8e18aa67 100644 --- a/ext/fts3/fts3_tokenizer.c +++ b/ext/fts3/fts3_tokenizer.c @@ -279,9 +279,9 @@ static void testFunc( p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1); if( !p ){ - char *zErr = sqlite3_mprintf("unknown tokenizer: %s", zName); - sqlite3_result_error(context, zErr, -1); - sqlite3_free(zErr); + char *zErr2 = sqlite3_mprintf("unknown tokenizer: %s", zName); + sqlite3_result_error(context, zErr2, -1); + sqlite3_free(zErr2); return; } diff --git a/ext/misc/fuzzer.c b/ext/misc/fuzzer.c index dc03161aaf..3ed4b0a977 100644 --- a/ext/misc/fuzzer.c +++ b/ext/misc/fuzzer.c @@ -876,7 +876,7 @@ static fuzzer_stem *fuzzerNewStem( if( pNew==0 ) return 0; memset(pNew, 0, sizeof(*pNew)); pNew->zBasis = (char*)&pNew[1]; - pNew->nBasis = (int)strlen(zWord); + pNew->nBasis = (fuzzer_len)strlen(zWord); memcpy(pNew->zBasis, zWord, pNew->nBasis+1); pRule = pCur->pVtab->pRule; while( fuzzerSkipRule(pRule, pNew, pCur->iRuleset) ){ diff --git a/manifest b/manifest index 0180ba625a..a250a05f62 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Document\sthe\sNMAKE_ARGS\senvironment\svariable\sas\swell. -D 2015-04-19T19:53:43.925 +C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC\s2015. +D 2015-04-19T21:43:16.561 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -91,7 +91,7 @@ F ext/fts3/fts3_snippet.c 52c2dcf410b1f9af5a44d81a2cf8c68ed1cb5283 F ext/fts3/fts3_term.c a521f75132f9a495bdca1bdd45949b3191c52763 F ext/fts3/fts3_test.c 8a3a78c4458b2d7c631fcf4b152a5cd656fa7038 F ext/fts3/fts3_tokenize_vtab.c becc661223db7898b213f9e8a23d75bac02408c9 -F ext/fts3/fts3_tokenizer.c b7e586baeb8d0a061cf01a0f7081d88f3935eecf +F ext/fts3/fts3_tokenizer.c 9afd223b07740b14dd589edd3116acacf951fd78 F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 F ext/fts3/fts3_unicode.c a93f5edc0aff44ef8b06d7cb55b52026541ca145 @@ -111,7 +111,7 @@ F ext/misc/closure.c 636024302cde41b2bf0c542f81c40c624cfb7012 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f -F ext/misc/fuzzer.c e3e18f47252c151b5553d7e806f38e757d37c4cc +F ext/misc/fuzzer.c 4c84635c71c26cfa7c2e5848cf49fe2d2cfcd767 F ext/misc/ieee754.c b0362167289170627659e84173f5d2e8fee8566e F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 @@ -190,7 +190,7 @@ F src/global.c 4f77cadbc5427d00139ba43d0f3979804cbb700e F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c 305dd3f9539d0affa4bf1c14cc7dffb34867e040 +F src/insert.c f43325e75175e3ca325f164464bb6475e3653d6d F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770 @@ -217,13 +217,13 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 5ed7e2e453c2980909a6b2c80dc55764b50819a8 F src/os_win.c 03d27be3a20048ef52a648d5f0a15f5edda9f2a3 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c +F src/pager.c 5283581c8ce8950ff483a0b3a3cab9cb4d25a21e F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 F src/parse.y c4e0387bc88c8e21e5ba653e2578959a1f3cdbc7 F src/pcache.c 10539fb959849ad6efff80050541cab3d25089d4 F src/pcache.h b44658c9c932d203510279439d891a2a83e12ba8 F src/pcache1.c 69d137620a305f814398bd29a0c998038c0695e9 -F src/pragma.c 2a81f312cdb78bf0672a0484478ca3c1083028e9 +F src/pragma.c c1f4d012ea9f6b1ce52d341b2cd0ad72d560afd7 F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f F src/prepare.c 1fffbdcd6f8a0173a8f70d71f22528f4c0e1e3d3 F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f @@ -231,7 +231,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 53486a98c17b7ae09b8c2b398013e973ce4c1aae F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 361dfc32244656bbe3f0e53d8ed791b3ec0c4be8 -F src/shell.c 28b3e1174a7fc00155d7d00880a33589a88508c9 +F src/shell.c 78eabce4c16c45e36fea2368f95118116399ba8a F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d @@ -239,7 +239,7 @@ F src/sqliteInt.h af228df2a02bf1a608d678b312d46aa480470b3c F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179 F src/table.c e7a09215315a978057fb42c640f890160dbcc45e -F src/tclsqlite.c fa72a7c5278662357c105ba7925c1d0972506ff9 +F src/tclsqlite.c 14f1992dd6100bfeb1a3dec7e7f449e1c814b8ee F src/test1.c 90fbedce75330d48d99eadb7d5f4223e86969585 F src/test2.c 577961fe48961b2f2e5c8b56ee50c3f459d3359d F src/test3.c 64d2afdd68feac1bb5e2ffb8226c8c639f798622 @@ -265,12 +265,12 @@ F src/test_intarray.c 6c610a21ab8edde85a3a2c7f2b069244ecf4d834 F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202 F src/test_journal.c 5360fbe1d1e4416ca36290562fd5a2e3f70f32aa F src/test_loadext.c a5251f956ab6af21e138dc1f9c0399394a510cb4 -F src/test_malloc.c b9495384e74923aefde8311de974bf9b0f5ba570 -F src/test_multiplex.c 97813565daa7ee480abcc5dd1e9984ed1f71eb8c +F src/test_malloc.c 208f09a4e21defa496bc1094fcfadea19385a112 +F src/test_multiplex.c 4dfb159e5c280c0ebdbf8b5ab9d95bf2765061f9 F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3 F src/test_mutex.c 293042d623ebba969160f471a82aa1551626454f -F src/test_onefile.c 0396f220561f3b4eedc450cef26d40c593c69a25 -F src/test_osinst.c 3d0340bc31a9f3d8a3547e0272373e80f78dde25 +F src/test_onefile.c 38f7cbe79d5bafe95bde683cc3a53b8ca16daf10 +F src/test_osinst.c 5423dc1d355f594371f27dd292ca54bd320b8196 F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00 F src/test_quota.c 180813f43683be5725458fc1ff13ac455d8e722d F src/test_quota.h 2a8ad1952d1d2ca9af0ce0465e56e6c023b5e15d @@ -283,7 +283,7 @@ F src/test_superlock.c 06797157176eb7085027d9dd278c0d7a105e3ec9 F src/test_syscall.c 2e21ca7f7dc54a028f1967b63f1e76155c356f9b F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c af391ec03d23486dffbcc250b7e58e073f172af9 -F src/test_vfs.c b7e6831e6fcf04c5090accff30640ec5c9630739 +F src/test_vfs.c 3b65d42e18b262805716bd96178c81da8f2d9283 F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 6bbcc9fe50c917864d48287b4792d46d6e873481 @@ -1207,7 +1207,7 @@ F tool/fuzzershell.c 9e7e273da203037154b433bb67f10b0d9772b370 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c ae5f61e3b164d35955777b20d6febcbaf0950702 +F tool/lemon.c b9109f59b57e7b6f101c4fe644c8361ba6dee969 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/logest.c eef612f8adf4d0993dafed0416064cf50d5d33c6 F tool/mkautoconfamal.sh d1a2da0e15b2ed33d60af35c7e9d483f13a8eb9f @@ -1251,7 +1251,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 ca64ef079811006f3e0526919871ffd286c3e714 -R 52d9f3383650b84247283bfd77621eab +P 977fd39c1509edec2e28cc8bac64e0994699f398 +R 482b18ff9d203ff55695e8f455ac3925 U mistachkin -Z 4ecdfe31e09fefcd24da72e520807bdb +Z 1e735d37890a7ca485ccb54b168d7937 diff --git a/manifest.uuid b/manifest.uuid index 1edabded57..ab4a139b2c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -977fd39c1509edec2e28cc8bac64e0994699f398 \ No newline at end of file +d05becd873a03a366843a34e7f4c732dd8f88c86 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index fc8895bbd6..d9916a14a6 100644 --- a/src/insert.c +++ b/src/insert.c @@ -2021,7 +2021,6 @@ static int xferOptimization( ** might change the definition of a collation sequence and then run ** a VACUUM command. In that case keys may not be written in strictly ** sorted order. */ - int i; for(i=0; inColumn; i++){ char *zColl = pSrcIdx->azColl[i]; assert( zColl!=0 ); diff --git a/src/pager.c b/src/pager.c index 2230174e5c..9ee2ecab5a 100644 --- a/src/pager.c +++ b/src/pager.c @@ -3044,9 +3044,7 @@ static int pagerWalFrames( ){ int rc; /* Return code */ int nList; /* Number of pages in pList */ -#if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES) PgHdr *p; /* For looping over pages */ -#endif assert( pPager->pWal ); assert( pList ); @@ -3063,7 +3061,6 @@ static int pagerWalFrames( ** any pages with page numbers greater than nTruncate into the WAL file. ** They will never be read by any client. So remove them from the pDirty ** list here. */ - PgHdr *p; PgHdr **ppNext = &pList; nList = 0; for(p=pList; (*ppNext = p)!=0; p=p->pDirty){ @@ -3083,7 +3080,6 @@ static int pagerWalFrames( pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags ); if( rc==SQLITE_OK && pPager->pBackup ){ - PgHdr *p; for(p=pList; p; p=p->pDirty){ sqlite3BackupUpdate(pPager->pBackup, p->pgno, (u8 *)p->pData); } diff --git a/src/pragma.c b/src/pragma.c index 614daa54df..1b4213844d 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -164,15 +164,15 @@ static int changeTempStorage(Parse *pParse, const char *zStorageType){ */ static void returnSingleInt(Parse *pParse, const char *zLabel, i64 value){ Vdbe *v = sqlite3GetVdbe(pParse); - int mem = ++pParse->nMem; + int nMem = ++pParse->nMem; i64 *pI64 = sqlite3DbMallocRaw(pParse->db, sizeof(value)); if( pI64 ){ memcpy(pI64, &value, sizeof(value)); } - sqlite3VdbeAddOp4(v, OP_Int64, 0, mem, 0, (char*)pI64, P4_INT64); + sqlite3VdbeAddOp4(v, OP_Int64, 0, nMem, 0, (char*)pI64, P4_INT64); sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC); - sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1); + sqlite3VdbeAddOp2(v, OP_ResultRow, nMem, 1); } @@ -337,11 +337,11 @@ void sqlite3Pragma( rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl); if( rc==SQLITE_OK ){ if( aFcntl[0] ){ - int mem = ++pParse->nMem; - sqlite3VdbeAddOp4(v, OP_String8, 0, mem, 0, aFcntl[0], 0); + int nMem = ++pParse->nMem; + sqlite3VdbeAddOp4(v, OP_String8, 0, nMem, 0, aFcntl[0], 0); sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "result", SQLITE_STATIC); - sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1); + sqlite3VdbeAddOp2(v, OP_ResultRow, nMem, 1); sqlite3_free(aFcntl[0]); } goto pragma_out; diff --git a/src/shell.c b/src/shell.c index 0d83084741..830deb29a3 100644 --- a/src/shell.c +++ b/src/shell.c @@ -336,7 +336,7 @@ static int stdin_is_interactive = 1; ** to this database a static variable so that it can be accessed ** by the SIGINT handler to interrupt database processing. */ -static sqlite3 *db = 0; +static sqlite3 *globalDb = 0; /* ** True if an interrupt (Control-C) has been received. @@ -805,7 +805,7 @@ static void interrupt_handler(int NotUsed){ UNUSED_PARAMETER(NotUsed); seenInterrupt++; if( seenInterrupt>2 ) exit(1); - if( db ) sqlite3_interrupt(db); + if( globalDb ) sqlite3_interrupt(globalDb); } #endif @@ -1909,23 +1909,23 @@ static void open_db(ShellState *p, int keepAlive){ if( p->db==0 ){ sqlite3_initialize(); sqlite3_open(p->zDbFilename, &p->db); - db = p->db; - if( db && sqlite3_errcode(db)==SQLITE_OK ){ - sqlite3_create_function(db, "shellstatic", 0, SQLITE_UTF8, 0, + globalDb = p->db; + if( p->db && sqlite3_errcode(p->db)==SQLITE_OK ){ + sqlite3_create_function(p->db, "shellstatic", 0, SQLITE_UTF8, 0, shellstaticFunc, 0, 0); } - if( db==0 || SQLITE_OK!=sqlite3_errcode(db) ){ + if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){ fprintf(stderr,"Error: unable to open database \"%s\": %s\n", - p->zDbFilename, sqlite3_errmsg(db)); + p->zDbFilename, sqlite3_errmsg(p->db)); if( keepAlive ) return; exit(1); } #ifndef SQLITE_OMIT_LOAD_EXTENSION sqlite3_enable_load_extension(p->db, 1); #endif - sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0, + sqlite3_create_function(p->db, "readfile", 1, SQLITE_UTF8, 0, readfileFunc, 0, 0); - sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0, + sqlite3_create_function(p->db, "writefile", 2, SQLITE_UTF8, 0, writefileFunc, 0, 0); } } @@ -2586,7 +2586,7 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){ ** Return 1 on error, 2 to exit, and 0 otherwise. */ static int do_meta_command(char *zLine, ShellState *p){ - int i = 1; + int h = 1; int nArg = 0; int n, c; int rc = 0; @@ -2594,24 +2594,24 @@ static int do_meta_command(char *zLine, ShellState *p){ /* Parse the input line into tokens. */ - while( zLine[i] && nArgdb, zSql, -1, &pStmt, 0); import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */ - if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){ + if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){ char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable); char cSep = '('; while( xRead(&sCtx) ){ @@ -3007,7 +3007,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_free(zCreate); if( rc ){ fprintf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable, - sqlite3_errmsg(db)); + sqlite3_errmsg(p->db)); sqlite3_free(sCtx.z); xCloser(sCtx.in); return 1; @@ -3017,7 +3017,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_free(zSql); if( rc ){ if (pStmt) sqlite3_finalize(pStmt); - fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db)); + fprintf(stderr,"Error: %s\n", sqlite3_errmsg(p->db)); xCloser(sCtx.in); return 1; } @@ -3042,13 +3042,13 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); if( rc ){ - fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db)); + fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); if (pStmt) sqlite3_finalize(pStmt); xCloser(sCtx.in); return 1; } - needCommit = sqlite3_get_autocommit(db); - if( needCommit ) sqlite3_exec(db, "BEGIN", 0, 0, 0); + needCommit = sqlite3_get_autocommit(p->db); + if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0); do{ int startLine = sCtx.nLine; for(i=0; idb)); } } }while( sCtx.cTerm!=EOF ); @@ -3095,7 +3095,7 @@ static int do_meta_command(char *zLine, ShellState *p){ xCloser(sCtx.in); sqlite3_free(sCtx.z); sqlite3_finalize(pStmt); - if( needCommit ) sqlite3_exec(db, "COMMIT", 0, 0, 0); + if( needCommit ) sqlite3_exec(p->db, "COMMIT", 0, 0, 0); }else if( c=='i' && (strncmp(azArg[0], "indices", n)==0 @@ -3649,13 +3649,13 @@ static int do_meta_command(char *zLine, ShellState *p){ while( sqlite3_step(pStmt)==SQLITE_ROW ){ if( nRow>=nAlloc ){ char **azNew; - int n = nAlloc*2 + 10; - azNew = sqlite3_realloc(azResult, sizeof(azResult[0])*n); + int n2 = nAlloc*2 + 10; + azNew = sqlite3_realloc(azResult, sizeof(azResult[0])*n2); if( azNew==0 ){ fprintf(stderr, "Error: out of memory\n"); break; } - nAlloc = n; + nAlloc = n2; azResult = azNew; } azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0)); @@ -3708,15 +3708,15 @@ static int do_meta_command(char *zLine, ShellState *p){ { "imposter", SQLITE_TESTCTRL_IMPOSTER }, }; int testctrl = -1; - int rc = 0; - int i, n; + int rc2 = 0; + int i, n2; open_db(p, 0); /* convert testctrl text option to value. allow any unique prefix ** of the option name, or a numerical value. */ - n = strlen30(azArg[1]); + n2 = strlen30(azArg[1]); for(i=0; i<(int)(sizeof(aCtrl)/sizeof(aCtrl[0])); i++){ - if( strncmp(azArg[1], aCtrl[i].zCtrlName, n)==0 ){ + if( strncmp(azArg[1], aCtrl[i].zCtrlName, n2)==0 ){ if( testctrl<0 ){ testctrl = aCtrl[i].ctrlCode; }else{ @@ -3737,8 +3737,8 @@ static int do_meta_command(char *zLine, ShellState *p){ case SQLITE_TESTCTRL_RESERVE: if( nArg==3 ){ int opt = (int)strtol(azArg[2], 0, 0); - rc = sqlite3_test_control(testctrl, p->db, opt); - fprintf(p->out, "%d (0x%08x)\n", rc, rc); + rc2 = sqlite3_test_control(testctrl, p->db, opt); + fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { fprintf(stderr,"Error: testctrl %s takes a single int option\n", azArg[1]); @@ -3751,8 +3751,8 @@ static int do_meta_command(char *zLine, ShellState *p){ case SQLITE_TESTCTRL_PRNG_RESET: case SQLITE_TESTCTRL_BYTEORDER: if( nArg==2 ){ - rc = sqlite3_test_control(testctrl); - fprintf(p->out, "%d (0x%08x)\n", rc, rc); + rc2 = sqlite3_test_control(testctrl); + fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { fprintf(stderr,"Error: testctrl %s takes no options\n", azArg[1]); } @@ -3762,8 +3762,8 @@ static int do_meta_command(char *zLine, ShellState *p){ case SQLITE_TESTCTRL_PENDING_BYTE: if( nArg==3 ){ unsigned int opt = (unsigned int)integerValue(azArg[2]); - rc = sqlite3_test_control(testctrl, opt); - fprintf(p->out, "%d (0x%08x)\n", rc, rc); + rc2 = sqlite3_test_control(testctrl, opt); + fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { fprintf(stderr,"Error: testctrl %s takes a single unsigned" " int option\n", azArg[1]); @@ -3776,8 +3776,8 @@ static int do_meta_command(char *zLine, ShellState *p){ case SQLITE_TESTCTRL_NEVER_CORRUPT: if( nArg==3 ){ int opt = booleanValue(azArg[2]); - rc = sqlite3_test_control(testctrl, opt); - fprintf(p->out, "%d (0x%08x)\n", rc, rc); + rc2 = sqlite3_test_control(testctrl, opt); + fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { fprintf(stderr,"Error: testctrl %s takes a single int option\n", azArg[1]); @@ -3789,8 +3789,8 @@ static int do_meta_command(char *zLine, ShellState *p){ case SQLITE_TESTCTRL_ISKEYWORD: if( nArg==3 ){ const char *opt = azArg[2]; - rc = sqlite3_test_control(testctrl, opt); - fprintf(p->out, "%d (0x%08x)\n", rc, rc); + rc2 = sqlite3_test_control(testctrl, opt); + fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { fprintf(stderr,"Error: testctrl %s takes a single char * option\n", azArg[1]); @@ -3800,11 +3800,11 @@ static int do_meta_command(char *zLine, ShellState *p){ case SQLITE_TESTCTRL_IMPOSTER: if( nArg==5 ){ - rc = sqlite3_test_control(testctrl, p->db, + rc2 = sqlite3_test_control(testctrl, p->db, azArg[2], integerValue(azArg[3]), integerValue(azArg[4])); - fprintf(p->out, "%d (0x%08x)\n", rc, rc); + fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); }else{ fprintf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n"); } diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 710084b89e..e38c1dd083 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -1191,7 +1191,7 @@ static int dbPrepareAndBind( int n; u8 *data; const char *zType = (pVar->typePtr ? pVar->typePtr->name : ""); - char c = zType[0]; + c = zType[0]; if( zVar[0]=='@' || (c=='b' && strcmp(zType,"bytearray")==0 && pVar->bytes==0) ){ /* Load a BLOB type if the Tcl variable is a bytearray and @@ -2298,7 +2298,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } Tcl_DecrRefCount(pRet); }else{ - ClientData cd[2]; + ClientData cd2[2]; DbEvalContext *p; Tcl_Obj *pArray = 0; Tcl_Obj *pScript; @@ -2312,9 +2312,9 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ p = (DbEvalContext *)Tcl_Alloc(sizeof(DbEvalContext)); dbEvalInit(p, pDb, objv[2], pArray); - cd[0] = (void *)p; - cd[1] = (void *)pScript; - rc = DbEvalNextCmd(cd, interp, TCL_OK); + cd2[0] = (void *)p; + cd2[1] = (void *)pScript; + rc = DbEvalNextCmd(cd2, interp, TCL_OK); } break; } diff --git a/src/test_malloc.c b/src/test_malloc.c index 1ea4de5063..94a2282923 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -211,15 +211,15 @@ static int faultsimInstall(int install){ faultsimBeginBenign, faultsimEndBenign ); }else{ - sqlite3_mem_methods m; + sqlite3_mem_methods m2; assert(memfault.m.xMalloc); /* One should be able to reset the default memory allocator by storing ** a zeroed allocator then calling GETMALLOC. */ - memset(&m, 0, sizeof(m)); - sqlite3_config(SQLITE_CONFIG_MALLOC, &m); - sqlite3_config(SQLITE_CONFIG_GETMALLOC, &m); - assert( memcmp(&m, &memfault.m, sizeof(m))==0 ); + memset(&m2, 0, sizeof(m2)); + sqlite3_config(SQLITE_CONFIG_MALLOC, &m2); + sqlite3_config(SQLITE_CONFIG_GETMALLOC, &m2); + assert( memcmp(&m2, &memfault.m, sizeof(m2))==0 ); rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &memfault.m); sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, 0, 0); diff --git a/src/test_multiplex.c b/src/test_multiplex.c index cd379f18f6..c1077fbee3 100644 --- a/src/test_multiplex.c +++ b/src/test_multiplex.c @@ -568,15 +568,15 @@ static int multiplexOpen( if( pSubOpen==0 && rc==SQLITE_OK ) rc = SQLITE_CANTOPEN; } if( rc==SQLITE_OK ){ - sqlite3_int64 sz; + sqlite3_int64 sz64; - rc = pSubOpen->pMethods->xFileSize(pSubOpen, &sz); + rc = pSubOpen->pMethods->xFileSize(pSubOpen, &sz64); if( rc==SQLITE_OK && zName ){ int bExists; if( flags & SQLITE_OPEN_MASTER_JOURNAL ){ pGroup->bEnabled = 0; }else - if( sz==0 ){ + if( sz64==0 ){ if( flags & SQLITE_OPEN_MAIN_JOURNAL ){ /* If opening a main journal file and the first chunk is zero ** bytes in size, delete any subsequent chunks from the @@ -607,10 +607,10 @@ static int multiplexOpen( rc = pOrigVfs->xAccess(pOrigVfs, pGroup->aReal[1].z, SQLITE_ACCESS_EXISTS, &bExists); bExists = multiplexSubSize(pGroup, 1, &rc)>0; - if( rc==SQLITE_OK && bExists && sz==(sz&0xffff0000) && sz>0 - && sz!=pGroup->szChunk ){ - pGroup->szChunk = (int)sz; - }else if( rc==SQLITE_OK && !bExists && sz>pGroup->szChunk ){ + if( rc==SQLITE_OK && bExists && sz64==(sz64&0xffff0000) && sz64>0 + && sz64!=pGroup->szChunk ){ + pGroup->szChunk = (int)sz64; + }else if( rc==SQLITE_OK && !bExists && sz64>pGroup->szChunk ){ pGroup->bEnabled = 0; } } diff --git a/src/test_onefile.c b/src/test_onefile.c index 69867441b8..122be700e6 100644 --- a/src/test_onefile.c +++ b/src/test_onefile.c @@ -595,9 +595,9 @@ static int fsOpen( int rc = SQLITE_OK; if( 0==(flags&(SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_MAIN_JOURNAL)) ){ - tmp_file *p = (tmp_file *)pFile; - memset(p, 0, sizeof(*p)); - p->base.pMethods = &tmp_io_methods; + tmp_file *p2 = (tmp_file *)pFile; + memset(p2, 0, sizeof(*p2)); + p2->base.pMethods = &tmp_io_methods; return SQLITE_OK; } diff --git a/src/test_osinst.c b/src/test_osinst.c index 1701def159..4ae23a87c6 100644 --- a/src/test_osinst.c +++ b/src/test_osinst.c @@ -1131,7 +1131,6 @@ static int test_vfslog( switch( (enum VL_enum)iSub ){ case VL_ANNOTATE: { - int rc; char *zVfs; char *zMsg; if( objc!=4 ){ @@ -1148,7 +1147,6 @@ static int test_vfslog( break; } case VL_FINALIZE: { - int rc; char *zVfs; if( objc!=3 ){ Tcl_WrongNumArgs(interp, 2, objv, "VFS"); @@ -1164,7 +1162,6 @@ static int test_vfslog( }; case VL_NEW: { - int rc; char *zVfs; char *zParent; char *zLog; diff --git a/src/test_vfs.c b/src/test_vfs.c index 2277cf7eb5..a8c6ae7bf5 100644 --- a/src/test_vfs.c +++ b/src/test_vfs.c @@ -1080,7 +1080,7 @@ static int testvfs_obj_cmd( switch( aSubcmd[i].eCmd ){ case CMD_SHM: { Tcl_Obj *pObj; - int i, rc; + int rc; TestvfsBuffer *pBuffer; char *zName; if( objc!=3 && objc!=4 ){ @@ -1160,7 +1160,6 @@ static int testvfs_obj_cmd( }; Tcl_Obj **apElem = 0; int nElem = 0; - int i; int mask = 0; if( objc!=3 ){ Tcl_WrongNumArgs(interp, 2, objv, "LIST"); diff --git a/tool/lemon.c b/tool/lemon.c index cc3066bec0..89d992c37e 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -1114,7 +1114,6 @@ void FindActions(struct lemon *lemp) /* Resolve conflicts */ for(i=0; instate; i++){ struct action *ap, *nap; - struct state *stp; stp = lemp->sorted[i]; /* assert( stp->ap ); */ stp->ap = Action_sort(stp->ap); @@ -3748,9 +3747,9 @@ void ReportTable( /* Generate the include code, if any */ tplt_print(out,lemp,lemp->include,&lineno); if( mhflag ){ - char *name = file_makename(lemp, ".h"); - fprintf(out,"#include \"%s\"\n", name); lineno++; - free(name); + char *incName = file_makename(lemp, ".h"); + fprintf(out,"#include \"%s\"\n", incName); lineno++; + free(incName); } tplt_xfer(lemp->name,in,out,&lineno); @@ -3791,7 +3790,6 @@ void ReportTable( } name = lemp->name ? lemp->name : "Parse"; if( lemp->arg && lemp->arg[0] ){ - int i; i = lemonStrlen(lemp->arg); while( i>=1 && isspace(lemp->arg[i-1]) ) i--; while( i>=1 && (isalnum(lemp->arg[i-1]) || lemp->arg[i-1]=='_') ) i--; @@ -4479,18 +4477,18 @@ int Strsafe_insert(const char *data) } if( x1a->count>=x1a->size ){ /* Need to make the hash table bigger */ - int i,size; + int i,arrSize; struct s_x1 array; - array.size = size = x1a->size*2; + array.size = arrSize = x1a->size*2; array.count = x1a->count; - array.tbl = (x1node*)calloc(size, sizeof(x1node) + sizeof(x1node*)); + array.tbl = (x1node*)calloc(arrSize, sizeof(x1node) + sizeof(x1node*)); if( array.tbl==0 ) return 0; /* Fail due to malloc failure */ - array.ht = (x1node**)&(array.tbl[size]); - for(i=0; icount; i++){ x1node *oldnp, *newnp; oldnp = &(x1a->tbl[i]); - h = strhash(oldnp->data) & (size-1); + h = strhash(oldnp->data) & (arrSize-1); newnp = &(array.tbl[i]); if( array.ht[h] ) array.ht[h]->from = &(newnp->next); newnp->next = array.ht[h]; @@ -4646,18 +4644,18 @@ int Symbol_insert(struct symbol *data, const char *key) } if( x2a->count>=x2a->size ){ /* Need to make the hash table bigger */ - int i,size; + int i,arrSize; struct s_x2 array; - array.size = size = x2a->size*2; + array.size = arrSize = x2a->size*2; array.count = x2a->count; - array.tbl = (x2node*)calloc(size, sizeof(x2node) + sizeof(x2node*)); + array.tbl = (x2node*)calloc(arrSize, sizeof(x2node) + sizeof(x2node*)); if( array.tbl==0 ) return 0; /* Fail due to malloc failure */ - array.ht = (x2node**)&(array.tbl[size]); - for(i=0; icount; i++){ x2node *oldnp, *newnp; oldnp = &(x2a->tbl[i]); - h = strhash(oldnp->key) & (size-1); + h = strhash(oldnp->key) & (arrSize-1); newnp = &(array.tbl[i]); if( array.ht[h] ) array.ht[h]->from = &(newnp->next); newnp->next = array.ht[h]; @@ -4722,12 +4720,12 @@ int Symbol_count() struct symbol **Symbol_arrayof() { struct symbol **array; - int i,size; + int i,arrSize; if( x2a==0 ) return 0; - size = x2a->count; - array = (struct symbol **)calloc(size, sizeof(struct symbol *)); + arrSize = x2a->count; + array = (struct symbol **)calloc(arrSize, sizeof(struct symbol *)); if( array ){ - for(i=0; itbl[i].data; + for(i=0; itbl[i].data; } return array; } @@ -4843,18 +4841,18 @@ int State_insert(struct state *data, struct config *key) } if( x3a->count>=x3a->size ){ /* Need to make the hash table bigger */ - int i,size; + int i,arrSize; struct s_x3 array; - array.size = size = x3a->size*2; + array.size = arrSize = x3a->size*2; array.count = x3a->count; - array.tbl = (x3node*)calloc(size, sizeof(x3node) + sizeof(x3node*)); + array.tbl = (x3node*)calloc(arrSize, sizeof(x3node) + sizeof(x3node*)); if( array.tbl==0 ) return 0; /* Fail due to malloc failure */ - array.ht = (x3node**)&(array.tbl[size]); - for(i=0; icount; i++){ x3node *oldnp, *newnp; oldnp = &(x3a->tbl[i]); - h = statehash(oldnp->key) & (size-1); + h = statehash(oldnp->key) & (arrSize-1); newnp = &(array.tbl[i]); if( array.ht[h] ) array.ht[h]->from = &(newnp->next); newnp->next = array.ht[h]; @@ -4901,12 +4899,12 @@ struct state *State_find(struct config *key) struct state **State_arrayof() { struct state **array; - int i,size; + int i,arrSize; if( x3a==0 ) return 0; - size = x3a->count; - array = (struct state **)calloc(size, sizeof(struct state *)); + arrSize = x3a->count; + array = (struct state **)calloc(arrSize, sizeof(struct state *)); if( array ){ - for(i=0; itbl[i].data; + for(i=0; itbl[i].data; } return array; } @@ -4983,18 +4981,18 @@ int Configtable_insert(struct config *data) } if( x4a->count>=x4a->size ){ /* Need to make the hash table bigger */ - int i,size; + int i,arrSize; struct s_x4 array; - array.size = size = x4a->size*2; + array.size = arrSize = x4a->size*2; array.count = x4a->count; - array.tbl = (x4node*)calloc(size, sizeof(x4node) + sizeof(x4node*)); + array.tbl = (x4node*)calloc(arrSize, sizeof(x4node) + sizeof(x4node*)); if( array.tbl==0 ) return 0; /* Fail due to malloc failure */ - array.ht = (x4node**)&(array.tbl[size]); - for(i=0; icount; i++){ x4node *oldnp, *newnp; oldnp = &(x4a->tbl[i]); - h = confighash(oldnp->data) & (size-1); + h = confighash(oldnp->data) & (arrSize-1); newnp = &(array.tbl[i]); if( array.ht[h] ) array.ht[h]->from = &(newnp->next); newnp->next = array.ht[h]; From 5f1d2fa4d2f75470dcac0b85ba60e3495cce0e88 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 19 Apr 2015 21:59:19 +0000 Subject: [PATCH 47/74] Fix another assert() that is not true if the database schema is corrupt. FossilOrigin-Name: bc97cec6338b16a4e9b1a9457d01bb7fe462934d --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/build.c | 3 ++- test/misc1.test | 11 +++++++++++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 45fb2ca55d..afcf92746e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sfaulty\sassert\sin\sthe\sschema\sparsing\slogic. -D 2015-04-19T20:39:17.335 +C Fix\sanother\sassert()\sthat\sis\snot\strue\sif\sthe\sdatabase\sschema\sis\scorrupt. +D 2015-04-19T21:59:19.589 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -176,7 +176,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 127aceb71ba93f59bc9c6ba810e992a04299e98a F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4 -F src/build.c bc3a513a57b0962aa98b38ab9c850f3987457885 +F src/build.c 2e46e275a9104bbebdaf04bccae3fe47c95d57b2 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 @@ -743,7 +743,7 @@ F test/minmax.test 42fbad0e81afaa6e0de41c960329f2b2c3526efd F test/minmax2.test b44bae787fc7b227597b01b0ca5575c7cb54d3bc F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 F test/minmax4.test 936941484ebdceb8adec7c86b6cd9b6e5e897c1f -F test/misc1.test e908edf5c6e02dcc7453c1519e59625c67cc099e +F test/misc1.test 783ba75743b2cf71e0f646bf540a6cef57264811 F test/misc2.test 00d7de54eda90e237fc9a38b9e5ccc769ebf6d4d F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6 @@ -1251,7 +1251,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 dc61b292d8eaf422ca8a2b18f1caccef1a5389fd -R cfb6006d4eb96e8b001f7f44f28a3f5a +P b1ed949584a2526c04952b98c3aa283427f45e10 +R 7eb252d844c06f104bb11959e0f1c997 U drh -Z 30562fcecce8e59f5b0c8b52be03b8fe +Z 149b8d57c1b56c76702cf167c619275e diff --git a/manifest.uuid b/manifest.uuid index 496f912ba1..a0dbc177c1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b1ed949584a2526c04952b98c3aa283427f45e10 \ No newline at end of file +bc97cec6338b16a4e9b1a9457d01bb7fe462934d \ No newline at end of file diff --git a/src/build.c b/src/build.c index 52f4e27e32..19783ecee3 100644 --- a/src/build.c +++ b/src/build.c @@ -1216,7 +1216,8 @@ void sqlite3AddColumnType(Parse *pParse, Token *pType){ p = pParse->pNewTable; if( p==0 || NEVER(p->nCol<1) ) return; pCol = &p->aCol[p->nCol-1]; - assert( pCol->zType==0 ); + assert( pCol->zType==0 || CORRUPT_DB ); + sqlite3DbFree(pParse->db, pCol->zType); pCol->zType = sqlite3NameFromToken(pParse->db, pType); pCol->affinity = sqlite3AffinityType(pCol->zType, &pCol->szEst); } diff --git a/test/misc1.test b/test/misc1.test index 0dc4d81347..7ae50e4fe0 100644 --- a/test/misc1.test +++ b/test/misc1.test @@ -672,5 +672,16 @@ do_catchsql_test misc1-23.2 { ROLLBACK; DROP TABLE F; } {1 {no such table: F}} +db close +sqlite3 db :memory: +do_catchsql_test misc1-23.3 { + CREATE TABLE t1(x UNIQUE); + PRAGMA writable_schema=ON; + UPDATE sqlite_master SET sql='CREATE table y(a TEXT, a TEXT)'; + BEGIN; + CREATE TABLE t2(y); + ROLLBACK; + DROP TABLE IF EXISTS t; +} {0 {}} finish_test From 752099696505db3abc1a841028c2ca6d3713d3e3 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 19 Apr 2015 22:31:45 +0000 Subject: [PATCH 48/74] Silently ignore parser stack overflow when parsing a malformed schema in PRAGMA writable_schema mode. FossilOrigin-Name: 2cb37b959c66b5ae3535ab81ba14a4ebf9732df7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/build.c | 1 + test/misc5.test | 18 ++++++++++++++++++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index afcf92746e..6f897f3bcf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sanother\sassert()\sthat\sis\snot\strue\sif\sthe\sdatabase\sschema\sis\scorrupt. -D 2015-04-19T21:59:19.589 +C Silently\signore\sparser\sstack\soverflow\swhen\sparsing\sa\smalformed\sschema\sin\nPRAGMA\swritable_schema\smode. +D 2015-04-19T22:31:45.600 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -176,7 +176,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 127aceb71ba93f59bc9c6ba810e992a04299e98a F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4 -F src/build.c 2e46e275a9104bbebdaf04bccae3fe47c95d57b2 +F src/build.c e246c2cea69c8f6fc825a156ea2de9dd4a17f18b F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 @@ -747,7 +747,7 @@ F test/misc1.test 783ba75743b2cf71e0f646bf540a6cef57264811 F test/misc2.test 00d7de54eda90e237fc9a38b9e5ccc769ebf6d4d F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6 -F test/misc5.test 528468b26d03303b1f047146e5eefc941b9069f5 +F test/misc5.test f96428ea95b3820aafc6f1c50cf48a09e4597ee1 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 F test/misc7.test edd0b63e2ee29a256900b0514f6fff27e19e9bb2 F test/misc8.test fc2754d38892f7dac30c22db3616c2764f117d66 @@ -1251,7 +1251,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 b1ed949584a2526c04952b98c3aa283427f45e10 -R 7eb252d844c06f104bb11959e0f1c997 +P bc97cec6338b16a4e9b1a9457d01bb7fe462934d +R 01f9eeee512ab8c1eb8c49d658fe5ba3 U drh -Z 149b8d57c1b56c76702cf167c619275e +Z 025d0c7f7a9e2517785c78c21f380610 diff --git a/manifest.uuid b/manifest.uuid index a0dbc177c1..09db9c0876 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bc97cec6338b16a4e9b1a9457d01bb7fe462934d \ No newline at end of file +2cb37b959c66b5ae3535ab81ba14a4ebf9732df7 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 19783ecee3..11f0b39245 100644 --- a/src/build.c +++ b/src/build.c @@ -2451,6 +2451,7 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){ } assert( pParse->nErr==0 ); assert( pName->nSrc==1 ); + if( sqlite3ReadSchema(pParse) ) goto exit_drop_table; if( noErr ) db->suppressErr++; pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]); if( noErr ) db->suppressErr--; diff --git a/test/misc5.test b/test/misc5.test index 14ba44ead0..30176b8082 100644 --- a/test/misc5.test +++ b/test/misc5.test @@ -583,6 +583,24 @@ do_test misc5-7.1 { catchsql $sql } {1 {parser stack overflow}} +# Parser stack overflow is silently ignored when it occurs while parsing the +# schema and PRAGMA writable_schema is turned on. +# +do_test misc5-7.2 { + sqlite3 db2 :memory: + catchsql { + CREATE TABLE t1(x UNIQUE); + PRAGMA writable_schema=ON; + UPDATE sqlite_master SET sql='CREATE table t(o CHECK(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((;VALUES(o)'; + BEGIN; + CREATE TABLE t2(y); + ROLLBACK; + DROP TABLE IF EXISTS D; + } db2 +} {0 {}} +db2 close + + # Ticket #1911 # ifcapable compound { From 992590be1c72af9d6d5c09b4a5793b16d0cd90af Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 19 Apr 2015 22:41:22 +0000 Subject: [PATCH 49/74] Fix a broken assert() and comparison for INSERT INTO ... SELECT when the SELECT uses an unknown collating sequence. FossilOrigin-Name: e73ac0cbac257d2d2b28e51423e30d7449b6c7b5 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/insert.c | 3 +-- test/insert4.test | 5 +++++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 6f897f3bcf..806b4e4f19 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Silently\signore\sparser\sstack\soverflow\swhen\sparsing\sa\smalformed\sschema\sin\nPRAGMA\swritable_schema\smode. -D 2015-04-19T22:31:45.600 +C Fix\sa\sbroken\sassert()\sand\scomparison\sfor\sINSERT\sINTO\s...\sSELECT\swhen\sthe\nSELECT\suses\san\sunknown\scollating\ssequence. +D 2015-04-19T22:41:22.682 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -190,7 +190,7 @@ F src/global.c 4f77cadbc5427d00139ba43d0f3979804cbb700e F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c 9f5f25a9d645089973d2f451711b7402bfde6ab5 +F src/insert.c b152e71457c40a3967ceafa9e7cbbb52e9ead2c1 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770 @@ -666,7 +666,7 @@ F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 F test/insert.test 38742b5e9601c8f8d76e9b7555f7270288c2d371 F test/insert2.test 4f3a04d168c728ed5ec2c88842e772606c7ce435 F test/insert3.test 1b7db95a03ad9c5013fdf7d6722b6cd66ee55e30 -F test/insert4.test 4791662c50518bdd37d394cae9a7a8014e845bb3 +F test/insert4.test a20432f1c0fbbcff8f11d0e6ab4acb8c9db58023 F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6 F test/instr.test 737bbf80685232033f3abedc6ae92f75860b5dd2 F test/intarray.test 066b7d7ac38d25bf96f87f1b017bfc687551cdd4 @@ -1251,7 +1251,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 bc97cec6338b16a4e9b1a9457d01bb7fe462934d -R 01f9eeee512ab8c1eb8c49d658fe5ba3 +P 2cb37b959c66b5ae3535ab81ba14a4ebf9732df7 +R e2cf191d4292c134d8577e2e34e33df7 U drh -Z 025d0c7f7a9e2517785c78c21f380610 +Z 7931b9be35191227870d2d70e1da695e diff --git a/manifest.uuid b/manifest.uuid index 09db9c0876..aa056fdc0a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2cb37b959c66b5ae3535ab81ba14a4ebf9732df7 \ No newline at end of file +e73ac0cbac257d2d2b28e51423e30d7449b6c7b5 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 73c550b832..f8f37666a1 100644 --- a/src/insert.c +++ b/src/insert.c @@ -649,8 +649,7 @@ void sqlite3Insert( dest.nSdst = pTab->nCol; rc = sqlite3Select(pParse, pSelect, &dest); regFromSelect = dest.iSdst; - assert( pParse->nErr==0 || rc ); - if( rc || db->mallocFailed ) goto insert_cleanup; + if( rc || db->mallocFailed || pParse->nErr ) goto insert_cleanup; sqlite3VdbeAddOp1(v, OP_EndCoroutine, regYield); sqlite3VdbeJumpHere(v, addrTop - 1); /* label B: */ assert( pSelect->pEList ); diff --git a/test/insert4.test b/test/insert4.test index 889d5e7807..3eece87e5f 100644 --- a/test/insert4.test +++ b/test/insert4.test @@ -560,5 +560,10 @@ do_test insert4-8.25 { } } {1 3} +do_catchsql_test insert4-9.1 { + DROP TABLE IF EXISTS t1; + CREATE TABLE t1(x); + INSERT INTO t1(x) VALUES(5 COLLATE xyzzy) UNION SELECT 0; +} {1 {no such collation sequence: xyzzy}} finish_test From 542a176d5e6fb2446265bdda5c0db79448a4be63 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 19 Apr 2015 23:11:10 +0000 Subject: [PATCH 50/74] Fix an off-by-one assert() in the virtual table argument tokenizer. FossilOrigin-Name: c83052e48bbae0f45db2a44155b4e5482ee4a901 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vtab.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 806b4e4f19..340322d8fa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbroken\sassert()\sand\scomparison\sfor\sINSERT\sINTO\s...\sSELECT\swhen\sthe\nSELECT\suses\san\sunknown\scollating\ssequence. -D 2015-04-19T22:41:22.682 +C Fix\san\soff-by-one\sassert()\sin\sthe\svirtual\stable\sargument\stokenizer. +D 2015-04-19T23:11:10.399 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -302,7 +302,7 @@ F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90 F src/vdbemem.c c0dc81285b7571b0a31c40f17846fe2397ec1cd9 F src/vdbesort.c 2e7f683464fd5db3be4beaa1ff2d39e24fcb64b8 F src/vdbetrace.c f95c2dff9041fcf07f871789c22ebb0648ea0b7c -F src/vtab.c 4feb365e2688dd02474e671e37f27e35784d2cff +F src/vtab.c 5f81f8a59c1f5ddb94c918f25ed5d83578fcc633 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 753995db83247f20361a8e8a874990b21a75abd9 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 @@ -1251,7 +1251,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 2cb37b959c66b5ae3535ab81ba14a4ebf9732df7 -R e2cf191d4292c134d8577e2e34e33df7 +P e73ac0cbac257d2d2b28e51423e30d7449b6c7b5 +R 70d28450bd13a75aeed954614a2f2b46 U drh -Z 7931b9be35191227870d2d70e1da695e +Z 2b960b7774bbbdaf4d5bf53bdfe32951 diff --git a/manifest.uuid b/manifest.uuid index aa056fdc0a..a3ebe5f013 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e73ac0cbac257d2d2b28e51423e30d7449b6c7b5 \ No newline at end of file +c83052e48bbae0f45db2a44155b4e5482ee4a901 \ No newline at end of file diff --git a/src/vtab.c b/src/vtab.c index ad65cdf7f4..2c6d106794 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -472,7 +472,7 @@ void sqlite3VtabArgExtend(Parse *pParse, Token *p){ pArg->z = p->z; pArg->n = p->n; }else{ - assert(pArg->z < p->z); + assert(pArg->z <= p->z); pArg->n = (int)(&p->z[p->n] - pArg->z); } } From f659cf48e848cbb7946815a2ec65e3eb622355ae Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sun, 19 Apr 2015 23:39:05 +0000 Subject: [PATCH 51/74] Modify the 'mkvsix' tool itself to support the Visual Studio 2015 CTP. FossilOrigin-Name: e0b7a191f3c22d9eacf645c58be59e0fdcb8860d --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/mkvsix.tcl | 52 ++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index a250a05f62..dbfe67b412 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC\s2015. -D 2015-04-19T21:43:16.561 +C Modify\sthe\s'mkvsix'\stool\sitself\sto\ssupport\sthe\sVisual\sStudio\s2015\sCTP. +D 2015-04-19T23:39:05.488 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1219,7 +1219,7 @@ F tool/mksqlite3c-noext.tcl 69bae8ce4aa52d2ff82d4a8a856bf283ec035b2e F tool/mksqlite3c.tcl 52a3352f7aa15f1db851e45ac3a5e2173d6fe93c F tool/mksqlite3h.tcl 44730d586c9031638cdd2eb443b801c0d2dbd9f8 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b -F tool/mkvsix.tcl 52a4c613707ac34ae9c226e5ccc69cb948556105 +F tool/mkvsix.tcl 3b58b9398f91c7dbf18d49eb87cefeee9efdbce1 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 34d7ac01fe4fd18e3637f64abe12c40eca0f6b97 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c @@ -1251,7 +1251,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 977fd39c1509edec2e28cc8bac64e0994699f398 -R 482b18ff9d203ff55695e8f455ac3925 +P d05becd873a03a366843a34e7f4c732dd8f88c86 +R bb1f1e19d70e43199cc9b8784e79ff68 U mistachkin -Z 1e735d37890a7ca485ccb54b168d7937 +Z 8dda7ece1b23ed740b28f121d2c5d713 diff --git a/manifest.uuid b/manifest.uuid index ab4a139b2c..19e522ec1e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d05becd873a03a366843a34e7f4c732dd8f88c86 \ No newline at end of file +e0b7a191f3c22d9eacf645c58be59e0fdcb8860d \ No newline at end of file diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl index 208ce2b142..15ae2b0d3a 100644 --- a/tool/mkvsix.tcl +++ b/tool/mkvsix.tcl @@ -174,6 +174,9 @@ proc writeFile { fileName data } { return "" } +# +# TODO: Modify this procedure when a new version of Visual Studio is released. +# proc getMinVsVersionXmlChunk { vsVersion } { switch -exact $vsVersion { 2012 { @@ -184,17 +187,26 @@ proc getMinVsVersionXmlChunk { vsVersion } { return [appendArgs \ "\r\n " {MinVSVersion="12.0"}] } + 2015 { + return [appendArgs \ + "\r\n " {MinVSVersion="14.0"}] + } default { return "" } } } +# +# TODO: Modify this procedure when a new version of Visual Studio is released. +# proc getMaxPlatformVersionXmlChunk { packageFlavor vsVersion } { # - # NOTE: Only Visual Studio 2013 supports this SDK manifest attribute. + # NOTE: Only Visual Studio 2013 and later support this attribute within the + # SDK manifest. # - if {![string equal $vsVersion 2013]} then { + if {![string equal $vsVersion 2013] && \ + ![string equal $vsVersion 2015]} then { return "" } @@ -221,6 +233,9 @@ proc getMaxPlatformVersionXmlChunk { packageFlavor vsVersion } { } } +# +# TODO: Modify this procedure when a new version of Visual Studio is released. +# proc getExtraFileListXmlChunk { packageFlavor vsVersion } { # # NOTE: Windows Phone 8.0 does not require any extra attributes in its VSIX @@ -245,6 +260,14 @@ proc getExtraFileListXmlChunk { packageFlavor vsVersion } { "\r\n " AppliesTo=\" $appliesTo \" \ "\r\n " {DependsOn="Microsoft.VCLibs, version=12.0"}] } + 2015 { + # + # TODO: Is the ".AppLocal" suffix always needed here? + # + return [appendArgs \ + "\r\n " AppliesTo=\" $appliesTo \" \ + "\r\n " {DependsOn="Microsoft.VCLibs.AppLocal, version=14.0"}] + } default { return "" } @@ -354,10 +377,11 @@ if {[string length $vsVersion] == 0} then { fail "invalid Visual Studio version" } -if {![string equal $vsVersion 2012] && ![string equal $vsVersion 2013]} then { +if {![string equal $vsVersion 2012] && ![string equal $vsVersion 2013] && \ + ![string equal $vsVersion 2015]} then { fail [appendArgs \ "unsupported Visual Studio version, must be one of: " \ - [list 2012 2013]] + [list 2012 2013 2015]] } set shortNames(WinRT,2012) SQLite.WinRT @@ -368,6 +392,7 @@ set shortNames(WP80,2013) SQLite.WP80.2013 set shortNames(WP81,2013) SQLite.WP81 set shortNames(Win32,2012) SQLite.Win32 set shortNames(Win32,2013) SQLite.Win32.2013 +set shortNames(UAP,2015) SQLite.UAP.2015 set displayNames(WinRT,2012) "SQLite for Windows Runtime" set displayNames(WinRT,2013) "SQLite for Windows Runtime" @@ -377,6 +402,7 @@ set displayNames(WP80,2013) "SQLite for Windows Phone" set displayNames(WP81,2013) "SQLite for Windows Phone 8.1" set displayNames(Win32,2012) "SQLite for Windows" set displayNames(Win32,2013) "SQLite for Windows" +set displayNames(UAP,2015) "SQLite for Universal App Platform" if {[string equal $packageFlavor WinRT]} then { set shortName $shortNames($packageFlavor,$vsVersion) @@ -432,6 +458,22 @@ if {[string equal $packageFlavor WinRT]} then { set extraSdkPath "\\..\\$targetPlatformIdentifier" set extraFileListAttributes \ [getExtraFileListXmlChunk $packageFlavor $vsVersion] +} elseif {[string equal $packageFlavor UAP]} then { + if {$vsVersion ne "2015"} then { + fail [appendArgs \ + "unsupported combination, package flavor " $packageFlavor \ + " is only supported with Visual Studio 2015"] + } + set shortName $shortNames($packageFlavor,$vsVersion) + set displayName $displayNames($packageFlavor,$vsVersion) + set targetPlatformIdentifier UAP + set targetPlatformVersion v0.8.0.0 + set minVsVersion [getMinVsVersionXmlChunk $vsVersion] + set maxPlatformVersion \ + [getMaxPlatformVersionXmlChunk $packageFlavor $vsVersion] + set extraSdkPath "\\..\\$targetPlatformIdentifier" + set extraFileListAttributes \ + [getExtraFileListXmlChunk $packageFlavor $vsVersion] } elseif {[string equal $packageFlavor Win32]} then { set shortName $shortNames($packageFlavor,$vsVersion) set displayName $displayNames($packageFlavor,$vsVersion) @@ -446,7 +488,7 @@ if {[string equal $packageFlavor WinRT]} then { } else { fail [appendArgs \ "unsupported package flavor, must be one of: " \ - [list WinRT WinRT81 WP80 WP81 Win32]] + [list WinRT WinRT81 WP80 WP81 UAP Win32]] } ############################################################################### From 19b887e4ecce4bbcc0b175337712121b6deb15da Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sun, 19 Apr 2015 23:48:10 +0000 Subject: [PATCH 52/74] Fix another harmless compiler warning. FossilOrigin-Name: 5ae853aaebaee76c9265061984185f74c10c4c8b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index d47bc01416..911f609b4e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\supdates\sfrom\strunk. -D 2015-04-19T23:40:55.108 +C Fix\sanother\sharmless\scompiler\swarning. +D 2015-04-19T23:48:10.023 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -307,7 +307,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 753995db83247f20361a8e8a874990b21a75abd9 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 -F src/where.c 8ba8ff31dc9bf1b69fe771d35d8764d5a1efd310 +F src/where.c 723b4f614cd60b7198f5f1cc053362f8a28b0bed F src/whereInt.h cbe4aa57326998d89e7698ca65bb7c28541d483c F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1251,7 +1251,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 e0b7a191f3c22d9eacf645c58be59e0fdcb8860d c83052e48bbae0f45db2a44155b4e5482ee4a901 -R 82b5a61054e21833b8d835777835ac1a +P 59d1a3bb6050a812c4eb0d25ac53327081b9efed +R c62ac4459285512471f07359006f6839 U mistachkin -Z eb6e9bb0494d4ea430c53bed9c33a7ce +Z 8e5b7cac312056ae4f94ac4a6cc605a8 diff --git a/manifest.uuid b/manifest.uuid index 74e4f4e1c0..f36e0dbd24 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -59d1a3bb6050a812c4eb0d25ac53327081b9efed \ No newline at end of file +5ae853aaebaee76c9265061984185f74c10c4c8b \ No newline at end of file diff --git a/src/where.c b/src/where.c index 3467a68626..1b97ebf98f 100644 --- a/src/where.c +++ b/src/where.c @@ -6646,7 +6646,6 @@ WhereInfo *sqlite3WhereBegin( } #ifdef WHERETRACE_ENABLED /* !=0 */ if( sqlite3WhereTrace ){ - int ii; sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut); if( pWInfo->nOBSat>0 ){ sqlite3DebugPrintf(" ORDERBY=%d,0x%llx", pWInfo->nOBSat, pWInfo->revMask); From b496a8f547853a12c02d16cd4cfb100a3ee5ba70 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 20 Apr 2015 01:13:33 +0000 Subject: [PATCH 53/74] Add an ALWAYS() around a new branch that was made unreachable by an even newer change. FossilOrigin-Name: 592c010478fba7410424f011a62e019c826f1ac3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/expr.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 340322d8fa..98ea026575 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\soff-by-one\sassert()\sin\sthe\svirtual\stable\sargument\stokenizer. -D 2015-04-19T23:11:10.399 +C Add\san\sALWAYS()\saround\sa\snew\sbranch\sthat\swas\smade\sunreachable\sby\san\seven\nnewer\schange. +D 2015-04-20T01:13:33.830 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -182,7 +182,7 @@ F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e -F src/expr.c 25a732f30ba391dfb00bbdc9ec079056c2fbced5 +F src/expr.c 5555f768c05d7d4a7840c6c2e72ad7aecbe0fe54 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 3343d551a8d810782257244fb33f2ce191493c39 F src/func.c 1414c24c873c48796ad45942257a179a423ba42f @@ -1251,7 +1251,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 e73ac0cbac257d2d2b28e51423e30d7449b6c7b5 -R 70d28450bd13a75aeed954614a2f2b46 +P c83052e48bbae0f45db2a44155b4e5482ee4a901 +R 952a9e0aae8c56d03933920a47e90909 U drh -Z 2b960b7774bbbdaf4d5bf53bdfe32951 +Z b000b63de0ad5ddbe40a2bc087fe2878 diff --git a/manifest.uuid b/manifest.uuid index a3ebe5f013..0e878dee1e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c83052e48bbae0f45db2a44155b4e5482ee4a901 \ No newline at end of file +592c010478fba7410424f011a62e019c826f1ac3 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 660fbff7b6..3f8bd942ef 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1252,7 +1252,7 @@ u32 sqlite3ExprListFlags(const ExprList *pList){ if( pList ){ for(i=0; inExpr; i++){ Expr *pExpr = pList->a[i].pExpr; - if( pExpr ) m |= pList->a[i].pExpr->flags; + if( ALWAYS(pExpr) ) m |= pList->a[i].pExpr->flags; } } return m; From f34e9aabd8af209fa849eea0141ba9e0302e4a93 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 20 Apr 2015 12:50:13 +0000 Subject: [PATCH 54/74] Enhance fuzzershell to support multiple blocks of SQL, each run in its own private in-memory database. FossilOrigin-Name: ab0a96ca73cfe92d5a837c71c148e8361f42acc3 --- manifest | 12 ++--- manifest.uuid | 2 +- tool/fuzzershell.c | 122 ++++++++++++++++++++++++++++++++------------- 3 files changed, 95 insertions(+), 41 deletions(-) diff --git a/manifest b/manifest index 98ea026575..6d6a24c20d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\sALWAYS()\saround\sa\snew\sbranch\sthat\swas\smade\sunreachable\sby\san\seven\nnewer\schange. -D 2015-04-20T01:13:33.830 +C Enhance\sfuzzershell\sto\ssupport\smultiple\sblocks\sof\sSQL,\seach\srun\sin\sits\sown\nprivate\sin-memory\sdatabase. +D 2015-04-20T12:50:13.942 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1203,7 +1203,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 -F tool/fuzzershell.c 9e7e273da203037154b433bb67f10b0d9772b370 +F tool/fuzzershell.c d6f9206395645668499aa5b097cbcda5ef67d457 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce @@ -1251,7 +1251,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 c83052e48bbae0f45db2a44155b4e5482ee4a901 -R 952a9e0aae8c56d03933920a47e90909 +P 592c010478fba7410424f011a62e019c826f1ac3 +R 55f62d08aa055d79c5fb00626b830397 U drh -Z b000b63de0ad5ddbe40a2bc087fe2878 +Z 4938f7ca9f322011187311f0d5e05712 diff --git a/manifest.uuid b/manifest.uuid index 0e878dee1e..2ad27925f2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -592c010478fba7410424f011a62e019c826f1ac3 \ No newline at end of file +ab0a96ca73cfe92d5a837c71c148e8361f42acc3 \ No newline at end of file diff --git a/tool/fuzzershell.c b/tool/fuzzershell.c index a44a722505..6f841e220c 100644 --- a/tool/fuzzershell.c +++ b/tool/fuzzershell.c @@ -31,6 +31,29 @@ ** ** (4) The eval() SQL function is added, allowing the fuzzer to do ** interesting recursive operations. +** +** 2015-04-20: The input text can be divided into separate SQL chunks using +** lines of the form: +** +** |****<...>****| +** +** where the "..." is arbitrary text, except the "|" should really be "/". +** ("|" is used here to avoid compiler warnings about nested comments.) +** Each such SQL comment is printed as it is encountered. A separate +** in-memory SQLite database is created to run each chunk of SQL. This +** feature allows the "queue" of AFL to be captured into a single big +** file using a command like this: +** +** (for i in id:*; do echo '|****<'$i'>****|'; cat $i; done) >~/all-queue.txt +** +** (Once again, change the "|" to "/") Then all elements of the AFL queue +** can be run in a single go (for regression testing, for example, by typing: +** +** fuzzershell -f ~/all-queue.txt >out.txt +** +** After running each chunk of SQL, the database connection is closed. The +** program aborts if the close fails or if there is any unfreed memory after +** the close. */ #include #include @@ -218,8 +241,9 @@ int main(int argc, char **argv){ FILE *in = stdin; /* Where to read SQL text from */ int rc = SQLITE_OK; /* Result codes from API functions */ int i; /* Loop counter */ + int iNext; /* Next block of SQL */ sqlite3 *db; /* Open database */ - sqlite3 *dbInit; /* On-disk database used to initialize the in-memory db */ + sqlite3 *dbInit = 0; /* On-disk database used to initialize the in-memory db */ const char *zInitDb = 0;/* Name of the initialization database file */ char *zErrMsg = 0; /* Error message returned from sqlite3_exec() */ @@ -250,45 +274,75 @@ int main(int argc, char **argv){ } } sqlite3_config(SQLITE_CONFIG_LOG, shellLog, 0); - rc = sqlite3_open_v2( - "main.db", &db, - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY, - 0); - if( rc!=SQLITE_OK ){ - abendError("Unable to open the in-memory database"); - } - if( zInitDb ){ - sqlite3_backup *pBackup; - rc = sqlite3_open_v2(zInitDb, &dbInit, SQLITE_OPEN_READONLY, 0); - if( rc!=SQLITE_OK ){ - abendError("unable to open initialization database \"%s\"", zInitDb); - } - pBackup = sqlite3_backup_init(db, "main", dbInit, "main"); - rc = sqlite3_backup_step(pBackup, -1); - if( rc!=SQLITE_DONE ){ - abendError("attempt to initialize the in-memory database failed (rc=%d)",rc); - } - sqlite3_backup_finish(pBackup); - sqlite3_close(dbInit); - } - sqlite3_trace(db, traceCallback, 0); - sqlite3_create_function(db, "eval", 1, SQLITE_UTF8, 0, sqlEvalFunc, 0, 0); - sqlite3_create_function(db, "eval", 2, SQLITE_UTF8, 0, sqlEvalFunc, 0, 0); while( !feof(in) ){ - nAlloc += 1000; - zIn = sqlite3_realloc(zIn, nAlloc); + nAlloc += nAlloc+1000; + zIn = realloc(zIn, nAlloc); if( zIn==0 ) fatalError("out of memory"); got = fread(zIn+nIn, 1, nAlloc-nIn-1, in); nIn += (int)got; zIn[nIn] = 0; if( got==0 ) break; } - printf("INPUT (%d bytes): [%s]\n", nIn, zIn); - rc = sqlite3_exec(db, zIn, execCallback, 0, &zErrMsg); - printf("RESULT-CODE: %d\n", rc); - if( zErrMsg ){ - printf("ERROR-MSG: [%s]\n", zErrMsg); - sqlite3_free(zErrMsg); + if( zInitDb ){ + rc = sqlite3_open_v2(zInitDb, &dbInit, SQLITE_OPEN_READONLY, 0); + if( rc!=SQLITE_OK ){ + abendError("unable to open initialization database \"%s\"", zInitDb); + } } - return rc!=SQLITE_OK; + for(i=0; i****/"); + if( z ){ + z += 6; + printf("%.*s\n", (int)(z-&zIn[i]), &zIn[i]); + i += (int)(z-&zIn[i]); + } + } + for(iNext=i; iNext0 ){ + abendError("memory in use after close: %lld bytes", sqlite3_memory_used()); + } + } + free(zIn); + return 0; } From cef258433592d83aff6441338fbcf3d52a121fc2 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 20 Apr 2015 13:59:18 +0000 Subject: [PATCH 55/74] Fix an obscure memory leak in sqlite3Stat4ProbeFree() FossilOrigin-Name: c72abbe2c1735f3d563c6672616b2918b6209922 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbemem.c | 2 +- test/analyze3.test | 13 +++++++++++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 6d6a24c20d..e5d22be389 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sfuzzershell\sto\ssupport\smultiple\sblocks\sof\sSQL,\seach\srun\sin\sits\sown\nprivate\sin-memory\sdatabase. -D 2015-04-20T12:50:13.942 +C Fix\san\sobscure\smemory\sleak\sin\ssqlite3Stat4ProbeFree() +D 2015-04-20T13:59:18.103 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -299,7 +299,7 @@ F src/vdbeInt.h 9cbaa84f53ddd2d09a0cf61a94337a3a035d08a0 F src/vdbeapi.c 583d56b129dd27f12bed518270de9ebe521e6a75 F src/vdbeaux.c 03591cca98ec50e1493043f0ff7abbece0b9c83d F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90 -F src/vdbemem.c c0dc81285b7571b0a31c40f17846fe2397ec1cd9 +F src/vdbemem.c b5256445b318b0f2b3bc429028469cfbb08f19a5 F src/vdbesort.c 2e7f683464fd5db3be4beaa1ff2d39e24fcb64b8 F src/vdbetrace.c f95c2dff9041fcf07f871789c22ebb0648ea0b7c F src/vtab.c 5f81f8a59c1f5ddb94c918f25ed5d83578fcc633 @@ -321,7 +321,7 @@ F test/alter4.test c461150723ac957f3b2214aa0b11552cd72023ec F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f F test/analyze.test 3eb35a4af972f98422e5dc0586501b17d103d321 -F test/analyze3.test 75b9e42ea1e4edc919250450dc5762186965d4e6 +F test/analyze3.test c2c07285e1012315e561132fcfa8fd43be66ec8c F test/analyze4.test eff2df19b8dd84529966420f29ea52edc6b56213 F test/analyze5.test 765c4e284aa69ca172772aa940946f55629bc8c4 F test/analyze6.test f1c552ce39cca4ec922a7e4e0e5d0203d6b3281f @@ -1251,7 +1251,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 592c010478fba7410424f011a62e019c826f1ac3 -R 55f62d08aa055d79c5fb00626b830397 +P ab0a96ca73cfe92d5a837c71c148e8361f42acc3 +R 3caac82026514fa2d10894c0463eb30d U drh -Z 4938f7ca9f322011187311f0d5e05712 +Z 942c4169ecb37cfefc1570a95881cae9 diff --git a/manifest.uuid b/manifest.uuid index 2ad27925f2..07bc7a50d8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ab0a96ca73cfe92d5a837c71c148e8361f42acc3 \ No newline at end of file +c72abbe2c1735f3d563c6672616b2918b6209922 \ No newline at end of file diff --git a/src/vdbemem.c b/src/vdbemem.c index 76147442ab..7c9a2d919b 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1647,7 +1647,7 @@ void sqlite3Stat4ProbeFree(UnpackedRecord *pRec){ Mem *aMem = pRec->aMem; sqlite3 *db = aMem[0].db; for(i=0; ipKeyInfo); sqlite3DbFree(db, pRec); diff --git a/test/analyze3.test b/test/analyze3.test index d22387dcc3..75a2cc4f7e 100644 --- a/test/analyze3.test +++ b/test/analyze3.test @@ -662,4 +662,17 @@ do_eqp_test analyze3-6-2 { SELECT * FROM t1 WHERE a = 5 AND b > 'w' AND c = 13; } {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (c=?)}} +#----------------------------------------------------------------------------- +# 2015-04-20. +# Memory leak in sqlite3Stat4ProbeFree(). (Discovered while fuzzing.) +# +do_execsql_test analyze-7.1 { + DROP TABLE IF EXISTS t1; + CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); + INSERT INTO t1 VALUES(1,1,'0000'); + CREATE INDEX t0b ON t1(b); + ANALYZE; + SELECT c FROM t1 WHERE b=3 AND a BETWEEN 30 AND hex(1); +} {} + finish_test From 4eed05347c7ab6444c95e805c117e5aafac8aa76 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 20 Apr 2015 15:13:08 +0000 Subject: [PATCH 56/74] Fix a memory leak caused by duplicate entries in the sqlite_stat1 table. FossilOrigin-Name: 2f58c8c9722fffc486610f9e6b08178d53a56b64 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/analyze.c | 15 +++++++++------ test/analyze3.test | 17 +++++++++++++++++ 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index e5d22be389..985903506a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sobscure\smemory\sleak\sin\ssqlite3Stat4ProbeFree() -D 2015-04-20T13:59:18.103 +C Fix\sa\smemory\sleak\scaused\sby\sduplicate\sentries\sin\sthe\ssqlite_stat1\stable. +D 2015-04-20T15:13:08.018 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c d23d6b6991f66b383934f137fd4384d93fb98c81 -F src/analyze.c 91540f835163d5369ccbae78e2e6c74d0dd53c1d +F src/analyze.c d23790787f80ebed58df7774744b4cf96401498b F src/attach.c c38ac5a520a231d5d0308fd7f2ad95191c867bae F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c ff743689c4d6c5cb55ad42ed9d174b2b3e71f1e3 @@ -321,7 +321,7 @@ F test/alter4.test c461150723ac957f3b2214aa0b11552cd72023ec F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f F test/analyze.test 3eb35a4af972f98422e5dc0586501b17d103d321 -F test/analyze3.test c2c07285e1012315e561132fcfa8fd43be66ec8c +F test/analyze3.test 0f0ee6135b293a0e5af471a8423b80b688469d71 F test/analyze4.test eff2df19b8dd84529966420f29ea52edc6b56213 F test/analyze5.test 765c4e284aa69ca172772aa940946f55629bc8c4 F test/analyze6.test f1c552ce39cca4ec922a7e4e0e5d0203d6b3281f @@ -1251,7 +1251,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 ab0a96ca73cfe92d5a837c71c148e8361f42acc3 -R 3caac82026514fa2d10894c0463eb30d -U drh -Z 942c4169ecb37cfefc1570a95881cae9 +P c72abbe2c1735f3d563c6672616b2918b6209922 +R 1099b0a7b8aeb7ed253f854d69b78f1d +U dan +Z 6ab446cc76a19cef515e242940078110 diff --git a/manifest.uuid b/manifest.uuid index 07bc7a50d8..0affbc1e57 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c72abbe2c1735f3d563c6672616b2918b6209922 \ No newline at end of file +2f58c8c9722fffc486610f9e6b08178d53a56b64 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index fec2bdb39d..2a0d6d2fb7 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -1519,14 +1519,17 @@ static int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){ z = argv[2]; if( pIndex ){ + tRowcnt *aiRowEst = 0; int nCol = pIndex->nKeyCol+1; #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 - tRowcnt * const aiRowEst = pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero( - sizeof(tRowcnt) * nCol - ); - if( aiRowEst==0 ) pInfo->db->mallocFailed = 1; -#else - tRowcnt * const aiRowEst = 0; + /* Index.aiRowEst may already be set here if there are duplicate + ** sqlite_stat1 entries for this index. In that case just clobber + ** the old data with the new instead of allocating a new array. */ + if( pIndex->aiRowEst==0 ){ + pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero(sizeof(tRowcnt) * nCol); + if( pIndex->aiRowEst==0 ) pInfo->db->mallocFailed = 1; + } + aiRowEst = pIndex->aiRowEst; #endif pIndex->bUnordered = 0; decodeIntArray((char*)z, nCol, aiRowEst, pIndex->aiRowLogEst, pIndex); diff --git a/test/analyze3.test b/test/analyze3.test index 75a2cc4f7e..d61d21a947 100644 --- a/test/analyze3.test +++ b/test/analyze3.test @@ -16,6 +16,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix analyze3 ifcapable !stat4&&!stat3 { finish_test @@ -46,6 +47,9 @@ ifcapable !stat4&&!stat3 { # # analyze3-6.*: Test that the problem fixed by commit [127a5b776d] is fixed. # +# analyze3-7.*: Test that some memory leaks discovered by fuzz testing +# have been fixed. +# proc getvar {varname} { uplevel #0 set $varname } db function var getvar @@ -675,4 +679,17 @@ do_execsql_test analyze-7.1 { SELECT c FROM t1 WHERE b=3 AND a BETWEEN 30 AND hex(1); } {} +# At one point duplicate stat1 entries were causing a memory leak. +# +reset_db +do_execsql_test 7.2 { + CREATE TABLE t1(a,b,c); + CREATE INDEX t1a ON t1(a); + ANALYZE; + SELECT * FROM sqlite_stat1; + INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1a','12000'); + INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1a','12000'); + ANALYZE sqlite_master; +} + finish_test From 4a74d076e3d184383a5550a16d0ceebfc37abdcb Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 20 Apr 2015 18:58:38 +0000 Subject: [PATCH 57/74] Many new configuration options for fuzzershell. FossilOrigin-Name: 41c954391690833bf2ece4ea14457ee4bdd74e90 --- manifest | 14 ++-- manifest.uuid | 2 +- tool/fuzzershell.c | 179 +++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 182 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 985903506a..53525fbdbb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smemory\sleak\scaused\sby\sduplicate\sentries\sin\sthe\ssqlite_stat1\stable. -D 2015-04-20T15:13:08.018 +C Many\snew\sconfiguration\soptions\sfor\sfuzzershell. +D 2015-04-20T18:58:38.348 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1203,7 +1203,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 -F tool/fuzzershell.c d6f9206395645668499aa5b097cbcda5ef67d457 +F tool/fuzzershell.c a25ae00de7ec929723981bc5d0c8c484ea1e6a9c F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce @@ -1251,7 +1251,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 c72abbe2c1735f3d563c6672616b2918b6209922 -R 1099b0a7b8aeb7ed253f854d69b78f1d -U dan -Z 6ab446cc76a19cef515e242940078110 +P 2f58c8c9722fffc486610f9e6b08178d53a56b64 +R 3fade4dfead5d7d8a2c7049fe386ecdf +U drh +Z 1d6c6c4ef178b17fd0f9732ebc91d908 diff --git a/manifest.uuid b/manifest.uuid index 0affbc1e57..564fc7fe47 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f58c8c9722fffc486610f9e6b08178d53a56b64 \ No newline at end of file +41c954391690833bf2ece4ea14457ee4bdd74e90 \ No newline at end of file diff --git a/tool/fuzzershell.c b/tool/fuzzershell.c index 6f841e220c..e412e59b38 100644 --- a/tool/fuzzershell.c +++ b/tool/fuzzershell.c @@ -47,7 +47,7 @@ ** (for i in id:*; do echo '|****<'$i'>****|'; cat $i; done) >~/all-queue.txt ** ** (Once again, change the "|" to "/") Then all elements of the AFL queue -** can be run in a single go (for regression testing, for example, by typing: +** can be run in a single go (for regression testing, for example) by typing: ** ** fuzzershell -f ~/all-queue.txt >out.txt ** @@ -59,6 +59,7 @@ #include #include #include +#include #include "sqlite3.h" /* @@ -97,6 +98,22 @@ static void fatalError(const char *zFormat, ...){ exit(1); } +/* +** Evaluate some SQL. Abort if unable. +*/ +static void sqlexec(sqlite3 *db, const char *zFormat, ...){ + va_list ap; + char *zSql; + char *zErrMsg = 0; + int rc; + va_start(ap, zFormat); + zSql = sqlite3_vmprintf(zFormat, ap); + va_end(ap); + rc = sqlite3_exec(db, zSql, 0, 0, &zErrMsg); + if( rc ) abendError("failed sql [%s]: %s", zSql, zErrMsg); + sqlite3_free(zSql); +} + /* ** This callback is invoked by sqlite3_log(). */ @@ -226,12 +243,78 @@ static void showHelp(void){ printf( "Read SQL text from standard input and evaluate it.\n" "Options:\n" +" --autovacuum Enable AUTOVACUUM mode\n" " -f FILE Read SQL text from FILE instead of standard input\n" +" --heap SZ MIN Memory allocator uses SZ bytes & min allocation MIN\n" " --help Show this help text\n" " --initdb DBFILE Initialize the in-memory database using template DBFILE\n" +" --lookaside N SZ Configure lookaside for N slots of SZ bytes each\n" +" --pagesize N Set the page size to N\n" +" --pcache N SZ Configure N pages of pagecache each of size SZ bytes\n" +" --scratch N SZ Configure scratch memory for N slots of SZ bytes each\n" +" --utf16be Set text encoding to UTF-16BE\n" +" --utf16le Set text encoding to UTF-16LE\n" ); } +/* +** Return the value of a hexadecimal digit. Return -1 if the input +** is not a hex digit. +*/ +static int hexDigitValue(char c){ + if( c>='0' && c<='9' ) return c - '0'; + if( c>='a' && c<='f' ) return c - 'a' + 10; + if( c>='A' && c<='F' ) return c - 'A' + 10; + return -1; +} + +/* +** Interpret zArg as an integer value, possibly with suffixes. +*/ +static int integerValue(const char *zArg){ + sqlite3_int64 v = 0; + static const struct { char *zSuffix; int iMult; } aMult[] = { + { "KiB", 1024 }, + { "MiB", 1024*1024 }, + { "GiB", 1024*1024*1024 }, + { "KB", 1000 }, + { "MB", 1000000 }, + { "GB", 1000000000 }, + { "K", 1000 }, + { "M", 1000000 }, + { "G", 1000000000 }, + }; + int i; + int isNeg = 0; + if( zArg[0]=='-' ){ + isNeg = 1; + zArg++; + }else if( zArg[0]=='+' ){ + zArg++; + } + if( zArg[0]=='0' && zArg[1]=='x' ){ + int x; + zArg += 2; + while( (x = hexDigitValue(zArg[0]))>=0 ){ + v = (v<<4) + x; + zArg++; + } + }else{ + while( isdigit(zArg[0]) ){ + v = v*10 + zArg[0] - '0'; + zArg++; + } + } + for(i=0; i0x7fffffff ) abendError("parameter too large - max 2147483648"); + return (int)(isNeg? -v : v); +} + int main(int argc, char **argv){ char *zIn = 0; /* Input text */ @@ -246,6 +329,18 @@ int main(int argc, char **argv){ sqlite3 *dbInit = 0; /* On-disk database used to initialize the in-memory db */ const char *zInitDb = 0;/* Name of the initialization database file */ char *zErrMsg = 0; /* Error message returned from sqlite3_exec() */ + const char *zEncoding = 0; /* --utf16be or --utf16le */ + int nHeap = 0, mnHeap = 0; /* Heap size from --heap */ + int nLook = 0, szLook = 0; /* --lookaside configuration */ + int nPCache = 0, szPCache = 0;/* --pcache configuration */ + int nScratch = 0, szScratch=0;/* --scratch configuration */ + int pageSize = 0; /* Desired page size. 0 means default */ + void *pHeap = 0; /* Allocated heap space */ + void *pLook = 0; /* Allocated lookaside space */ + void *pPCache = 0; /* Allocated storage for pcache */ + void *pScratch = 0; /* Allocated storage for scratch */ + int doAutovac = 0; /* True for --autovacuum */ + g.zArgv0 = argv[0]; for(i=1; i=argc-2 ) abendError("missing arguments on %s\n", argv[i]); + nHeap = integerValue(argv[i+1]); + mnHeap = integerValue(argv[i+2]); + i += 2; + }else + if( strcmp(z,"help")==0 ){ + showHelp(); + return 0; + }else if( strcmp(z, "initdb")==0 && i+1=argc-2 ) abendError("missing arguments on %s", argv[i]); + nLook = integerValue(argv[i+1]); + szLook = integerValue(argv[i+2]); + i += 2; + }else + if( strcmp(z,"pagesize")==0 ){ + if( i>=argc-1 ) abendError("missing argument on %s", argv[i]); + pageSize = integerValue(argv[++i]); + }else + if( strcmp(z,"pcache")==0 ){ + if( i>=argc-2 ) abendError("missing arguments on %s", argv[i]); + nPCache = integerValue(argv[i+1]); + szPCache = integerValue(argv[i+2]); + i += 2; + }else + if( strcmp(z,"scratch")==0 ){ + if( i>=argc-2 ) abendError("missing arguments on %s", argv[i]); + nScratch = integerValue(argv[i+1]); + szScratch = integerValue(argv[i+2]); + i += 2; + }else + if( strcmp(z,"utf16le")==0 ){ + zEncoding = "utf16le"; + }else + if( strcmp(z,"utf16be")==0 ){ + zEncoding = "utf16be"; + }else { abendError("unknown option: %s", argv[i]); } @@ -274,6 +406,33 @@ int main(int argc, char **argv){ } } sqlite3_config(SQLITE_CONFIG_LOG, shellLog, 0); + if( nHeap>0 ){ + pHeap = malloc( nHeap ); + if( pHeap==0 ) fatalError("cannot allocate %d-byte heap\n", nHeap); + rc = sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nHeap, mnHeap); + if( rc ) abendError("heap configuration failed: %d\n", rc); + } + if( nLook>0 ){ + sqlite3_config(SQLITE_CONFIG_LOOKASIDE, 0, 0); + if( szLook>0 ){ + pLook = malloc( nLook*szLook ); + if( pLook==0 ) fatalError("out of memory"); + } + } + if( nScratch>0 && szScratch>0 ){ + pScratch = malloc( nScratch*(sqlite3_int64)szScratch ); + if( pScratch==0 ) fatalError("cannot allocate %lld-byte scratch", + nScratch*(sqlite3_int64)szScratch); + rc = sqlite3_config(SQLITE_CONFIG_SCRATCH, pScratch, szScratch, nScratch); + if( rc ) abendError("scratch configuration failed: %d\n", rc); + } + if( nPCache>0 && szPCache>0 ){ + pPCache = malloc( nPCache*(sqlite3_int64)szPCache ); + if( pPCache==0 ) fatalError("cannot allocate %lld-byte pcache", + nPCache*(sqlite3_int64)szPCache); + rc = sqlite3_config(SQLITE_CONFIG_PAGECACHE, pPCache, szPCache, nPCache); + if( rc ) abendError("pcache configuration failed: %d", rc); + } while( !feof(in) ){ nAlloc += nAlloc+1000; zIn = realloc(zIn, nAlloc); @@ -308,6 +467,10 @@ int main(int argc, char **argv){ if( rc!=SQLITE_OK ){ abendError("Unable to open the in-memory database"); } + if( pLook ){ + rc = sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE, pLook, szLook, nLook); + if( rc!=SQLITE_OK ) abendError("lookaside configuration filed: %d", rc); + } if( zInitDb ){ sqlite3_backup *pBackup; pBackup = sqlite3_backup_init(db, "main", dbInit, "main"); @@ -322,7 +485,9 @@ int main(int argc, char **argv){ sqlite3_create_function(db, "eval", 1, SQLITE_UTF8, 0, sqlEvalFunc, 0, 0); sqlite3_create_function(db, "eval", 2, SQLITE_UTF8, 0, sqlEvalFunc, 0, 0); sqlite3_limit(db, SQLITE_LIMIT_LENGTH, 1000000); - + if( zEncoding ) sqlexec(db, "PRAGMA encoding=%s", zEncoding); + if( pageSize ) sqlexec(db, "PRAGMA pagesize=%d", pageSize); + if( doAutovac ) sqlexec(db, "PRAGMA auto_vacuum=FULL"); cSaved = zIn[iNext]; zIn[iNext] = 0; printf("INPUT (offset: %d, size: %d): [%s]\n", @@ -344,5 +509,9 @@ int main(int argc, char **argv){ } } free(zIn); + free(pHeap); + free(pLook); + free(pScratch); + free(pPCache); return 0; } From 9985dabbacc878e7c11c4e3b79aecb43d6ec836c Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 20 Apr 2015 22:36:49 +0000 Subject: [PATCH 58/74] Add the --mode option to fuzzershell. FossilOrigin-Name: b940b0fa6cf68fef58344d269ad5d39468ffe72f --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/fuzzershell.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 53525fbdbb..68707be4d4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Many\snew\sconfiguration\soptions\sfor\sfuzzershell. -D 2015-04-20T18:58:38.348 +C Add\sthe\s--mode\soption\sto\sfuzzershell. +D 2015-04-20T22:36:49.631 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1203,7 +1203,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 -F tool/fuzzershell.c a25ae00de7ec929723981bc5d0c8c484ea1e6a9c +F tool/fuzzershell.c 00c12b1e95095f43980ae3cafb51938eda577fe2 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce @@ -1251,7 +1251,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 2f58c8c9722fffc486610f9e6b08178d53a56b64 -R 3fade4dfead5d7d8a2c7049fe386ecdf +P 41c954391690833bf2ece4ea14457ee4bdd74e90 +R 18124f1b8c247e9f547c30e618d3a441 U drh -Z 1d6c6c4ef178b17fd0f9732ebc91d908 +Z d312afa4cd0d932d0a233db0b53736ad diff --git a/manifest.uuid b/manifest.uuid index 564fc7fe47..dfe61ad96a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -41c954391690833bf2ece4ea14457ee4bdd74e90 \ No newline at end of file +b940b0fa6cf68fef58344d269ad5d39468ffe72f \ No newline at end of file diff --git a/tool/fuzzershell.c b/tool/fuzzershell.c index e412e59b38..abdfd3ff00 100644 --- a/tool/fuzzershell.c +++ b/tool/fuzzershell.c @@ -315,6 +315,14 @@ static int integerValue(const char *zArg){ return (int)(isNeg? -v : v); } +/* +** Various operating modes +*/ +#define FZMODE_Generic 1 +#define FZMODE_Strftime 2 +#define FZMODE_Printf 3 +#define FZMODE_Glob 4 + int main(int argc, char **argv){ char *zIn = 0; /* Input text */ @@ -340,6 +348,9 @@ int main(int argc, char **argv){ void *pPCache = 0; /* Allocated storage for pcache */ void *pScratch = 0; /* Allocated storage for scratch */ int doAutovac = 0; /* True for --autovacuum */ + char *zSql; /* SQL to run */ + char *zToFree = 0; /* Call sqlite3_free() on this afte running zSql */ + int iMode = FZMODE_Generic; /* Operating mode */ g.zArgv0 = argv[0]; @@ -376,6 +387,21 @@ int main(int argc, char **argv){ szLook = integerValue(argv[i+2]); i += 2; }else + if( strcmp(z,"mode")==0 ){ + if( i>=argc-1 ) abendError("missing argument on %s", argv[i]); + z = argv[++i]; + if( strcmp(z,"generic")==0 ){ + iMode = FZMODE_Printf; + }else if( strcmp(z, "glob")==0 ){ + iMode = FZMODE_Glob; + }else if( strcmp(z, "printf")==0 ){ + iMode = FZMODE_Printf; + }else if( strcmp(z, "strftime")==0 ){ + iMode = FZMODE_Strftime; + }else{ + abendError("unknown --mode: %s", z); + } + }else if( strcmp(z,"pagesize")==0 ){ if( i>=argc-1 ) abendError("missing argument on %s", argv[i]); pageSize = integerValue(argv[++i]); @@ -492,7 +518,23 @@ int main(int argc, char **argv){ zIn[iNext] = 0; printf("INPUT (offset: %d, size: %d): [%s]\n", i, (int)strlen(&zIn[i]), &zIn[i]); - rc = sqlite3_exec(db, &zIn[i], execCallback, 0, &zErrMsg); + zSql = &zIn[i]; + switch( iMode ){ + case FZMODE_Glob: + zSql = zToFree = sqlite3_mprintf("SELECT glob(%s);", zSql); + break; + case FZMODE_Printf: + zSql = zToFree = sqlite3_mprintf("SELECT printf(%s);", zSql); + break; + case FZMODE_Strftime: + zSql = zToFree = sqlite3_mprintf("SELECT strftime(%s);", zSql); + break; + } + rc = sqlite3_exec(db, zSql, execCallback, 0, &zErrMsg); + if( zToFree ){ + sqlite3_free(zToFree); + zToFree = 0; + } zIn[iNext] = cSaved; printf("RESULT-CODE: %d\n", rc); From 0f517ea8d4400858233e1c8c2368eaa22661771e Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Apr 2015 02:12:13 +0000 Subject: [PATCH 59/74] Make sure the whereSplit() routine in the query planner is not confused by the likely() operator. FossilOrigin-Name: 588db14ffb4b0e8e76d511b7b1541db3ec78836a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 9 +++++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index c16ea75772..722a49165b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enable\scompilation\sand\sVSIX\spackage\screation\swith\sthe\sVisual\sStudio\s2015\sCTP. -D 2015-04-21T00:23:38.259 +C Make\ssure\sthe\swhereSplit()\sroutine\sin\sthe\squery\splanner\sis\snot\sconfused\nby\sthe\slikely()\soperator. +D 2015-04-21T02:12:13.667 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -307,7 +307,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 753995db83247f20361a8e8a874990b21a75abd9 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 -F src/where.c 723b4f614cd60b7198f5f1cc053362f8a28b0bed +F src/where.c 32fe265e3dc74ef3b27deb9e6eb5fc3c71409612 F src/whereInt.h cbe4aa57326998d89e7698ca65bb7c28541d483c F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1251,7 +1251,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 b940b0fa6cf68fef58344d269ad5d39468ffe72f 5ae853aaebaee76c9265061984185f74c10c4c8b -R 9804529a8e22c5281a0b002dbd15342c -U mistachkin -Z 2ec7897fcafe697e2540c7ecf3cbf657 +P 03b725a768290e3c7b31f1ba3310532fd7dc05cd +R 1a86c7004bf5b29df45cd677c642d5c4 +U drh +Z 973efc28f5c5e0de1e0d5148069074b3 diff --git a/manifest.uuid b/manifest.uuid index 39b81f4f27..e1164a819a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -03b725a768290e3c7b31f1ba3310532fd7dc05cd \ No newline at end of file +588db14ffb4b0e8e76d511b7b1541db3ec78836a \ No newline at end of file diff --git a/src/where.c b/src/where.c index 1b97ebf98f..25d20c8808 100644 --- a/src/where.c +++ b/src/where.c @@ -255,13 +255,14 @@ static int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){ ** all terms of the WHERE clause. */ static void whereSplit(WhereClause *pWC, Expr *pExpr, u8 op){ + Expr *pE2 = sqlite3ExprSkipCollate(pExpr); pWC->op = op; - if( pExpr==0 ) return; - if( pExpr->op!=op ){ + if( pE2==0 ) return; + if( pE2->op!=op ){ whereClauseInsert(pWC, pExpr, 0); }else{ - whereSplit(pWC, pExpr->pLeft, op); - whereSplit(pWC, pExpr->pRight, op); + whereSplit(pWC, pE2->pLeft, op); + whereSplit(pWC, pE2->pRight, op); } } From 60f4e0918d0aeb74fc92ae1fe7e329abda1fb0b2 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Apr 2015 02:17:30 +0000 Subject: [PATCH 60/74] Test case for the previous check-in. FossilOrigin-Name: a526f58bc96c0fdead51b6bd9aafea7b48bf398e --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/select4.test | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 722a49165b..52f60dcf18 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthe\swhereSplit()\sroutine\sin\sthe\squery\splanner\sis\snot\sconfused\nby\sthe\slikely()\soperator. -D 2015-04-21T02:12:13.667 +C Test\scase\sfor\sthe\sprevious\scheck-in. +D 2015-04-21T02:17:30.839 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -839,7 +839,7 @@ F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5 F test/select1.test be62204d2bd9a5a8a149e9974cfddce893d8f686 F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054 -F test/select4.test a3201fa921fdfc1397cc629e78c7a976e198a40d +F test/select4.test 48e14766d98b744b2202cca6d4679bf7ef3784c8 F test/select5.test e758b8ef94f69b111df4cb819008856655dcd535 F test/select6.test 39eac4a5c03650b2b473c532882273283ee8b7a0 F test/select7.test 7fd2ef598cfabb6b9ff6ac13973b91d0527df49d @@ -1251,7 +1251,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 03b725a768290e3c7b31f1ba3310532fd7dc05cd -R 1a86c7004bf5b29df45cd677c642d5c4 +P 588db14ffb4b0e8e76d511b7b1541db3ec78836a +R 0379e03a168715422bfe2697c2af7c68 U drh -Z 973efc28f5c5e0de1e0d5148069074b3 +Z ee4991a8fe0a3ae557d83e10280b0c68 diff --git a/manifest.uuid b/manifest.uuid index e1164a819a..82b2d7e2ea 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -588db14ffb4b0e8e76d511b7b1541db3ec78836a \ No newline at end of file +a526f58bc96c0fdead51b6bd9aafea7b48bf398e \ No newline at end of file diff --git a/test/select4.test b/test/select4.test index ce7e7e7b0d..42c61d92ad 100644 --- a/test/select4.test +++ b/test/select4.test @@ -893,5 +893,8 @@ do_execsql_test select4-14.13 { do_execsql_test select4-14.14 { VALUES(1),(2),(3) EXCEPT VALUES(1),(3); } {2} +do_execsql_test select4-14.15 { + SELECT * FROM (SELECT 123), (SELECT 456) ON likely(0 OR 1) OR 0; +} {123 456} finish_test From b6b676ea7c5361112130fbb0e7d471e9c610f7d4 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Apr 2015 03:13:47 +0000 Subject: [PATCH 61/74] Fix some identifier name de-quoting issues in the foreign key and trigger logic. FossilOrigin-Name: 59e92bd9521f1e8315a9a7e7fd3d63b0c75eaf0e --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/fkey.c | 18 +++++++++--------- src/trigger.c | 4 +++- test/fkey1.test | 30 ++++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 52f60dcf18..59e1c9e13d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Test\scase\sfor\sthe\sprevious\scheck-in. -D 2015-04-21T02:17:30.839 +C Fix\ssome\sidentifier\sname\sde-quoting\sissues\sin\sthe\sforeign\skey\sand\strigger\slogic. +D 2015-04-21T03:13:47.283 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -184,7 +184,7 @@ F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e F src/expr.c 5555f768c05d7d4a7840c6c2e72ad7aecbe0fe54 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb -F src/fkey.c 3343d551a8d810782257244fb33f2ce191493c39 +F src/fkey.c 6040cf888922273171f30b8d6e0726aeae4ec82d F src/func.c 1414c24c873c48796ad45942257a179a423ba42f F src/global.c 4f77cadbc5427d00139ba43d0f3979804cbb700e F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 @@ -288,7 +288,7 @@ F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 6bbcc9fe50c917864d48287b4792d46d6e873481 F src/tokenize.c b7fb584c2be5ec39b6fdf04b185e7c6f33f8dc15 -F src/trigger.c bc647c712454c9b209fac082bb82870b5fd6fa54 +F src/trigger.c 45db6f59c6a945e1fe1acbdc77263c5c414d4c65 F src/update.c 3c4ecc282accf12d39edb8d524cf089645e55a13 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c a6431c92803b975b7322724a7b433e538d243539 @@ -504,7 +504,7 @@ F test/extension01.test 00d13cec817f331a687a243e0e5a2d87b0e358c9 F test/fallocate.test 3e979af17dfa7e5e9dda5eba1a696c04fa9d47f7 F test/filectrl.test 14fa712e42c4cb791e09dfd58a6a03efb47ef13a F test/filefmt.test cb34663f126cbc2d358af552dcaf5c72769b0146 -F test/fkey1.test e1d1fa84cde579185ea01358436839703e415a5b +F test/fkey1.test de5b287f6a480b36bd51e8debcf48168e26e4ed2 F test/fkey2.test f3d27ecba480a348c328965d154214719bb158a9 F test/fkey3.test 76d475c80b84ee7a5d062e56ccb6ea68882e2b49 F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d @@ -1251,7 +1251,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 588db14ffb4b0e8e76d511b7b1541db3ec78836a -R 0379e03a168715422bfe2697c2af7c68 +P a526f58bc96c0fdead51b6bd9aafea7b48bf398e +R 6263ca10bc3a41fc51b68112322cb0ff U drh -Z ee4991a8fe0a3ae557d83e10280b0c68 +Z 0f5648b8f58dd956d25b7cd57819a2e5 diff --git a/manifest.uuid b/manifest.uuid index 82b2d7e2ea..0549accf50 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a526f58bc96c0fdead51b6bd9aafea7b48bf398e \ No newline at end of file +59e92bd9521f1e8315a9a7e7fd3d63b0c75eaf0e \ No newline at end of file diff --git a/src/fkey.c b/src/fkey.c index 3e4b752e86..e85ec6156c 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -1197,10 +1197,10 @@ static Trigger *fkActionTrigger( ** parent table are used for the comparison. */ pEq = sqlite3PExpr(pParse, TK_EQ, sqlite3PExpr(pParse, TK_DOT, - sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld), - sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol) + sqlite3ExprAlloc(db, TK_ID, &tOld, 0), + sqlite3ExprAlloc(db, TK_ID, &tToCol, 0) , 0), - sqlite3PExpr(pParse, TK_ID, 0, 0, &tFromCol) + sqlite3ExprAlloc(db, TK_ID, &tFromCol, 0) , 0); pWhere = sqlite3ExprAnd(db, pWhere, pEq); @@ -1212,12 +1212,12 @@ static Trigger *fkActionTrigger( if( pChanges ){ pEq = sqlite3PExpr(pParse, TK_IS, sqlite3PExpr(pParse, TK_DOT, - sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld), - sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol), + sqlite3ExprAlloc(db, TK_ID, &tOld, 0), + sqlite3ExprAlloc(db, TK_ID, &tToCol, 0), 0), sqlite3PExpr(pParse, TK_DOT, - sqlite3PExpr(pParse, TK_ID, 0, 0, &tNew), - sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol), + sqlite3ExprAlloc(db, TK_ID, &tNew, 0), + sqlite3ExprAlloc(db, TK_ID, &tToCol, 0), 0), 0); pWhen = sqlite3ExprAnd(db, pWhen, pEq); @@ -1227,8 +1227,8 @@ static Trigger *fkActionTrigger( Expr *pNew; if( action==OE_Cascade ){ pNew = sqlite3PExpr(pParse, TK_DOT, - sqlite3PExpr(pParse, TK_ID, 0, 0, &tNew), - sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol) + sqlite3ExprAlloc(db, TK_ID, &tNew, 0), + sqlite3ExprAlloc(db, TK_ID, &tToCol, 0) , 0); }else if( action==OE_SetDflt ){ Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt; diff --git a/src/trigger.c b/src/trigger.c index 1bc232727f..3a8e006f27 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -676,9 +676,11 @@ static SrcList *targetSrcList( int iDb; /* Index of the database to use */ SrcList *pSrc; /* SrcList to be returned */ - pSrc = sqlite3SrcListAppend(pParse->db, 0, &pStep->target, 0); + pSrc = sqlite3SrcListAppend(pParse->db, 0, 0, 0); if( pSrc ){ assert( pSrc->nSrc>0 ); + pSrc->a[pSrc->nSrc-1].zName = + sqlite3DbStrNDup(pParse->db, pStep->target.z, pStep->target.n); iDb = sqlite3SchemaToIndex(pParse->db, pStep->pTrig->pSchema); if( iDb==0 || iDb>=2 ){ sqlite3 *db = pParse->db; diff --git a/test/fkey1.test b/test/fkey1.test index 90a4c44409..0bd4939eb5 100644 --- a/test/fkey1.test +++ b/test/fkey1.test @@ -121,4 +121,34 @@ do_test fkey1-3.5 { sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0 } {0 0 0} +# Stress the dequoting logic. The first test is not so bad. +do_execsql_test fkey1-4.0 { + PRAGMA foreign_keys=ON; + CREATE TABLE "xx1"("xx2" TEXT PRIMARY KEY, "xx3" TEXT); + INSERT INTO "xx1"("xx2","xx3") VALUES('abc','def'); + CREATE TABLE "xx4"("xx5" TEXT REFERENCES "xx1" ON DELETE CASCADE); + INSERT INTO "xx4"("xx5") VALUES('abc'); + INSERT INTO "xx1"("xx2","xx3") VALUES('uvw','xyz'); + SELECT 1, "xx5" FROM "xx4"; + DELETE FROM "xx1"; + SELECT 2, "xx5" FROM "xx4"; +} {1 abc} + +# This case is identical to the previous except the "xx" in each name +# is changed to a single escaped double-quote character. +do_execsql_test fkey1-4.1 { + PRAGMA foreign_keys=ON; + CREATE TABLE """1"("""2" TEXT PRIMARY KEY, """3" TEXT); + INSERT INTO """1"("""2","""3") VALUES('abc','def'); + CREATE TABLE """4"("""5" TEXT REFERENCES """1" ON DELETE CASCADE); + INSERT INTO """4"("""5") VALUES('abc'); + INSERT INTO """1"("""2","""3") VALUES('uvw','xyz'); + SELECT 1, """5" FROM """4"; + DELETE FROM """1"; + SELECT 2, """5" FROM """4"; +} {1 abc} +do_execsql_test fkey1-4.2 { + PRAGMA table_info="""1"; +} {0 {"2} TEXT 0 {} 1 1 {"3} TEXT 0 {} 0} + finish_test From 3c9a0737232d1800155bc42c9b7158487069a42a Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 Apr 2015 12:06:53 +0000 Subject: [PATCH 62/74] Fix an fts4 problem to do with the handling of phrases that contain zero tokens. FossilOrigin-Name: caba5be0b2bdaf4eb4af9af267c0c22dfbd3dba5 --- ext/fts3/fts3.c | 10 ++++++---- manifest | 15 +++++++------- manifest.uuid | 2 +- test/fts3expr5.test | 48 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 test/fts3expr5.test diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 3037719e9d..41c93daaeb 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4617,12 +4617,14 @@ static void fts3EvalStartReaders( ){ if( pExpr && SQLITE_OK==*pRc ){ if( pExpr->eType==FTSQUERY_PHRASE ){ - int i; int nToken = pExpr->pPhrase->nToken; - for(i=0; ipPhrase->aToken[i].pDeferred==0 ) break; + if( nToken ){ + int i; + for(i=0; ipPhrase->aToken[i].pDeferred==0 ) break; + } + pExpr->bDeferred = (i==nToken); } - pExpr->bDeferred = (i==nToken); *pRc = fts3EvalPhraseStart(pCsr, 1, pExpr->pPhrase); }else{ fts3EvalStartReaders(pCsr, pExpr->pLeft, pRc); diff --git a/manifest b/manifest index 59e1c9e13d..f4075fa3d3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssome\sidentifier\sname\sde-quoting\sissues\sin\sthe\sforeign\skey\sand\strigger\slogic. -D 2015-04-21T03:13:47.283 +C Fix\san\sfts4\sproblem\sto\sdo\swith\sthe\shandling\sof\sphrases\sthat\scontain\szero\stokens. +D 2015-04-21T12:06:53.262 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 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 29300a76fabbbb8fc30bb261c27d421df9f40c76 +F ext/fts3/fts3.c 1b198ddb76cd706722dacbbaeb17a2fde6fca2cc F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 3626655d6ba903a3919bb44e1c38e5f0f9d6be82 F ext/fts3/fts3_aux.c 5c211e17a64885faeb16b9ba7772f9d5445c2365 @@ -587,6 +587,7 @@ F test/fts3expr.test 3401d47b229c4504424caf362cc4ff704cad4162 F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a F test/fts3expr3.test 9e91b8edbcb197bf2e92161aa7696446d96dce5f F test/fts3expr4.test e1be1248566f43c252d4404d52914f1fc4bfa065 +F test/fts3expr5.test f9abfffbf5e53d48a33e12a1e8f8ba2c551c9b49 F test/fts3fault.test cb72dccb0a3b9f730f16c5240f3fcb9303eb1660 F test/fts3fault2.test f953bb3cf903988172270a9a0aafd5a890b0f98f F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641 @@ -1251,7 +1252,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 a526f58bc96c0fdead51b6bd9aafea7b48bf398e -R 6263ca10bc3a41fc51b68112322cb0ff -U drh -Z 0f5648b8f58dd956d25b7cd57819a2e5 +P 59e92bd9521f1e8315a9a7e7fd3d63b0c75eaf0e +R e9b5552434d39d6b3276df99138ae1dc +U dan +Z 403ed60a8d3b410bd6a0e0c95de6325c diff --git a/manifest.uuid b/manifest.uuid index 0549accf50..8b3d6459df 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -59e92bd9521f1e8315a9a7e7fd3d63b0c75eaf0e \ No newline at end of file +caba5be0b2bdaf4eb4af9af267c0c22dfbd3dba5 \ No newline at end of file diff --git a/test/fts3expr5.test b/test/fts3expr5.test new file mode 100644 index 0000000000..1e0985108e --- /dev/null +++ b/test/fts3expr5.test @@ -0,0 +1,48 @@ +# 2006 September 9 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# This file implements regression tests for SQLite library. The +# focus of this script is testing the FTS3 module. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix fts3expr5 + +# If SQLITE_ENABLE_FTS3 is defined, omit this file. +ifcapable !fts3 { + finish_test + return +} + +#------------------------------------------------------------------------- +# Various forms of empty phrase expressions. +# +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t0 USING fts3(x); + SELECT rowid FROM t0 WHERE x MATCH ''; +} {} +do_execsql_test 1.1 { + SELECT rowid FROM t0 WHERE x MATCH '""'; +} {} +do_execsql_test 1.2 { + SELECT rowid FROM t0 WHERE x MATCH '"" ""'; +} {} +do_execsql_test 1.3 { + SELECT rowid FROM t0 WHERE x MATCH '"" OR ""'; +} {} +do_execsql_test 1.4 { + SELECT rowid FROM t0 WHERE x MATCH '"" NOT ""'; +} {} +do_execsql_test 1.5 { + SELECT rowid FROM t0 WHERE x MATCH '""""'; +} {} + +finish_test From 7c052da54dd6b7f6182f36650333b09e691346d1 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Apr 2015 15:16:48 +0000 Subject: [PATCH 63/74] Change an assert() in the aggregate query code generator into a testcase(). FossilOrigin-Name: d1e6bc918b0c8e0701f5e15afb91b84a9004231b --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/select.c | 3 ++- test/count.test | 5 +++++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index f4075fa3d3..269786e967 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sfts4\sproblem\sto\sdo\swith\sthe\shandling\sof\sphrases\sthat\scontain\szero\stokens. -D 2015-04-21T12:06:53.262 +C Change\san\sassert()\sin\sthe\saggregate\squery\scode\sgenerator\sinto\sa\stestcase(). +D 2015-04-21T15:16:48.720 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +230,7 @@ F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 53486a98c17b7ae09b8c2b398013e973ce4c1aae F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c 361dfc32244656bbe3f0e53d8ed791b3ec0c4be8 +F src/select.c d87c64b394293f00e85c95d729c8663b74d560ea F src/shell.c 78eabce4c16c45e36fea2368f95118116399ba8a F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -435,7 +435,7 @@ F test/corruptH.test 5dd4fa98c6c1ed33b178f9e8a48c4fdd3cfc9067 F test/corruptI.test 221ad8b7f0a9ac6b80fc577e73b5ad8cdea31243 F test/corruptJ.test 9e29e7a81ee3b6ac50f77ea7a9e2f3fa03f32d91 F test/cost.test 19d314526616ce4473eb4e4e450fcb94499ce318 -F test/count.test 42a251178e32f617eda33f76236a7f79825a50b5 +F test/count.test cb2e0f934c6eb33670044520748d2ecccd46259c F test/coveridxscan.test cdb47d01acc4a634a34fd25abe85189e0d0f1e62 F test/crash.test fb9dc4a02dcba30d4aa5c2c226f98b220b2b959f F test/crash2.test 5b14d4eb58b880e231361d3b609b216acda86651 @@ -1252,7 +1252,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 59e92bd9521f1e8315a9a7e7fd3d63b0c75eaf0e -R e9b5552434d39d6b3276df99138ae1dc -U dan -Z 403ed60a8d3b410bd6a0e0c95de6325c +P caba5be0b2bdaf4eb4af9af267c0c22dfbd3dba5 +R a42d4b42e1e0eeb130dc235a2eaf2ef6 +U drh +Z f1234d42aa2af13247e7d70d40d070fb diff --git a/manifest.uuid b/manifest.uuid index 8b3d6459df..f0aa771194 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -caba5be0b2bdaf4eb4af9af267c0c22dfbd3dba5 \ No newline at end of file +d1e6bc918b0c8e0701f5e15afb91b84a9004231b \ No newline at end of file diff --git a/src/select.c b/src/select.c index c49f327893..a72db2c0f9 100644 --- a/src/select.c +++ b/src/select.c @@ -4608,7 +4608,8 @@ static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){ } if( pF->iDistinct>=0 ){ addrNext = sqlite3VdbeMakeLabel(v); - assert( nArg==1 ); + testcase( nArg==0 ); /* Error condition */ + testcase( nArg>1 ); /* Also an error */ codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg); } if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ diff --git a/test/count.test b/test/count.test index 3461e49c1d..862b62ab17 100644 --- a/test/count.test +++ b/test/count.test @@ -191,4 +191,9 @@ do_execsql_test count-5.1 { SELECT count(*) FROM t5; } {1} +do_catchsql_test count-6.1 { + CREATE TABLE t6(x); + SELECT count(DISTINCT) FROM t6 GROUP BY x; +} {1 {DISTINCT aggregates must have exactly one argument}} + finish_test From 4b79bde7a222380946c54e8158f746767a9d30b0 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 Apr 2015 15:49:04 +0000 Subject: [PATCH 64/74] Fix an obscure problem with "INSERT INTO tbl(cols) SELECT" statements where the SELECT is a compound with an ORDER BY and "cols" is a strict subset of tbl's columns. FossilOrigin-Name: 718d5d0eab045a874107e078a857226a80ab912d --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/select.c | 2 +- test/insert2.test | 20 ++++++++++++++++++++ 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 269786e967..6f4fc284aa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\san\sassert()\sin\sthe\saggregate\squery\scode\sgenerator\sinto\sa\stestcase(). -D 2015-04-21T15:16:48.720 +C Fix\san\sobscure\sproblem\swith\s"INSERT\sINTO\stbl(cols)\sSELECT"\sstatements\swhere\sthe\sSELECT\sis\sa\scompound\swith\san\sORDER\sBY\sand\s"cols"\sis\sa\sstrict\ssubset\sof\stbl's\scolumns. +D 2015-04-21T15:49:04.252 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +230,7 @@ F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 53486a98c17b7ae09b8c2b398013e973ce4c1aae F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c d87c64b394293f00e85c95d729c8663b74d560ea +F src/select.c b14a9e1ee035166df10f8f5c9379ac697ef43f62 F src/shell.c 78eabce4c16c45e36fea2368f95118116399ba8a F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -665,7 +665,7 @@ F test/indexedby.test 5f527a78bae74c61b8046ae3037f9dfb0bf0c353 F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 F test/insert.test 38742b5e9601c8f8d76e9b7555f7270288c2d371 -F test/insert2.test 4f3a04d168c728ed5ec2c88842e772606c7ce435 +F test/insert2.test 4d14b8f1b810a41995f6286b64a6943215d52208 F test/insert3.test 1b7db95a03ad9c5013fdf7d6722b6cd66ee55e30 F test/insert4.test a20432f1c0fbbcff8f11d0e6ab4acb8c9db58023 F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6 @@ -1252,7 +1252,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 caba5be0b2bdaf4eb4af9af267c0c22dfbd3dba5 -R a42d4b42e1e0eeb130dc235a2eaf2ef6 -U drh -Z f1234d42aa2af13247e7d70d40d070fb +P d1e6bc918b0c8e0701f5e15afb91b84a9004231b +R 7ccd1057167111672b7d4496a5645687 +U dan +Z 692b69290119d874ac81343f57f21abd diff --git a/manifest.uuid b/manifest.uuid index f0aa771194..90ab0db88f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d1e6bc918b0c8e0701f5e15afb91b84a9004231b \ No newline at end of file +718d5d0eab045a874107e078a857226a80ab912d \ No newline at end of file diff --git a/src/select.c b/src/select.c index a72db2c0f9..09186668a4 100644 --- a/src/select.c +++ b/src/select.c @@ -2642,7 +2642,7 @@ static int generateOutputSubroutine( pDest->iSdst = sqlite3GetTempRange(pParse, pIn->nSdst); pDest->nSdst = pIn->nSdst; } - sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pDest->nSdst); + sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pIn->nSdst); sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm); break; } diff --git a/test/insert2.test b/test/insert2.test index 6876d538ae..977fbc584a 100644 --- a/test/insert2.test +++ b/test/insert2.test @@ -16,6 +16,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix insert2 # Create some tables with data that we can select against # @@ -275,4 +276,23 @@ ifcapable subquery { } {1 2 1 3 1 4} } +do_execsql_test 6.0 { + CREATE TABLE t5(a, b, c DEFAULT 'c', d); +} +do_execsql_test 6.1 { + INSERT INTO t5(a) SELECT 456 UNION ALL SELECT 123 ORDER BY 1; + SELECT * FROM t5 ORDER BY rowid; +} {123 {} c {} 456 {} c {}} + +ifcapable fts3 { + do_execsql_test 6.2 { + CREATE VIRTUAL TABLE t0 USING fts4(a); + } + do_execsql_test 6.3 { + INSERT INTO t0 SELECT 0 UNION SELECT 0 AS 'x' ORDER BY x; + SELECT * FROM t0; + } {0} +} + + finish_test From be360e1ed1d1519a8702abef8a5f761ad06f9cd5 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Apr 2015 16:09:07 +0000 Subject: [PATCH 65/74] Fix a memory leak in the SELECT code generator tracing logic (code that is omitted in non-debugging builds). FossilOrigin-Name: b623ebd859dcb1d99398aa9953f6b113bad26304 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 6f4fc284aa..11361b4b2a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sobscure\sproblem\swith\s"INSERT\sINTO\stbl(cols)\sSELECT"\sstatements\swhere\sthe\sSELECT\sis\sa\scompound\swith\san\sORDER\sBY\sand\s"cols"\sis\sa\sstrict\ssubset\sof\stbl's\scolumns. -D 2015-04-21T15:49:04.252 +C Fix\sa\smemory\sleak\sin\sthe\sSELECT\scode\sgenerator\stracing\slogic\s(code\sthat\sis\nomitted\sin\snon-debugging\sbuilds). +D 2015-04-21T16:09:07.623 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +230,7 @@ F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 53486a98c17b7ae09b8c2b398013e973ce4c1aae F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c b14a9e1ee035166df10f8f5c9379ac697ef43f62 +F src/select.c 3b64da1c1130a9c82a9b5d3afe1d44ab8a31f25a F src/shell.c 78eabce4c16c45e36fea2368f95118116399ba8a F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -1252,7 +1252,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 d1e6bc918b0c8e0701f5e15afb91b84a9004231b -R 7ccd1057167111672b7d4496a5645687 -U dan -Z 692b69290119d874ac81343f57f21abd +P 718d5d0eab045a874107e078a857226a80ab912d +R 7e6bc612737dab76da35e37065b9b922 +U drh +Z ba983635f4ecc26ab029799e1b9c58b7 diff --git a/manifest.uuid b/manifest.uuid index 90ab0db88f..e6e16b709b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -718d5d0eab045a874107e078a857226a80ab912d \ No newline at end of file +b623ebd859dcb1d99398aa9953f6b113bad26304 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 09186668a4..6a18ff4599 100644 --- a/src/select.c +++ b/src/select.c @@ -5538,6 +5538,7 @@ void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){ StrAccum x; char zLine[100]; sqlite3StrAccumInit(&x, zLine, sizeof(zLine), 0); + x.useMalloc = 0; sqlite3XPrintf(&x, 0, "{%d,*}", pItem->iCursor); if( pItem->zDatabase ){ sqlite3XPrintf(&x, 0, " %s.%s", pItem->zDatabase, pItem->zName); From 464083544eae55666b8b75d3b801235b3fe4b983 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 Apr 2015 16:38:49 +0000 Subject: [PATCH 66/74] Ensure that tables names are dequoted exactly once by the trigger logic. FossilOrigin-Name: 9d887b92f8086961e045f8acb9ee7a443796d411 --- manifest | 20 +++++++++---------- manifest.uuid | 2 +- src/fkey.c | 7 +++---- src/sqliteInt.h | 10 +++++----- src/trigger.c | 19 +++++++++--------- test/triggerC.test | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 77 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index 11361b4b2a..72aeca55c3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smemory\sleak\sin\sthe\sSELECT\scode\sgenerator\stracing\slogic\s(code\sthat\sis\nomitted\sin\snon-debugging\sbuilds). -D 2015-04-21T16:09:07.623 +C Ensure\sthat\stables\snames\sare\sdequoted\sexactly\sonce\sby\sthe\strigger\slogic. +D 2015-04-21T16:38:49.045 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -184,7 +184,7 @@ F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e F src/expr.c 5555f768c05d7d4a7840c6c2e72ad7aecbe0fe54 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb -F src/fkey.c 6040cf888922273171f30b8d6e0726aeae4ec82d +F src/fkey.c c9b63a217d86582c22121699a47f22f524608869 F src/func.c 1414c24c873c48796ad45942257a179a423ba42f F src/global.c 4f77cadbc5427d00139ba43d0f3979804cbb700e F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 @@ -235,7 +235,7 @@ F src/shell.c 78eabce4c16c45e36fea2368f95118116399ba8a F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d -F src/sqliteInt.h 3a1fccc2bb62ab16750730b6f6f24305e686a0ce +F src/sqliteInt.h 8abcea1295138f10ef8f7ed38db5f1b573b93ece F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179 F src/table.c e7a09215315a978057fb42c640f890160dbcc45e @@ -288,7 +288,7 @@ F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 6bbcc9fe50c917864d48287b4792d46d6e873481 F src/tokenize.c b7fb584c2be5ec39b6fdf04b185e7c6f33f8dc15 -F src/trigger.c 45db6f59c6a945e1fe1acbdc77263c5c414d4c65 +F src/trigger.c 322f23aad694e8f31d384dcfa386d52a48d3c52f F src/update.c 3c4ecc282accf12d39edb8d524cf089645e55a13 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c a6431c92803b975b7322724a7b433e538d243539 @@ -1088,7 +1088,7 @@ F test/trigger8.test 30cb0530bd7c4728055420e3f739aa00412eafa4 F test/trigger9.test 2226ec795a33b0460ab5cf8891e9054cc7edef41 F test/triggerA.test fe5597f47ee21bacb4936dc827994ed94161e332 F test/triggerB.test 56780c031b454abac2340dbb3b71ac5c56c3d7fe -F test/triggerC.test a68980c5955d62ee24be6f97129d824f199f9a4c +F test/triggerC.test 302d8995f5ffe63bbc15053abb3ef7a39cf5a092 F test/triggerD.test 8e7f3921a92a5797d472732108109e44575fa650 F test/triggerE.test 355e9c5cbaed5cd039a60baad1fb2197caeb8e52 F test/tt3_checkpoint.c 9e75cf7c1c364f52e1c47fd0f14c4340a9db0fe1 @@ -1252,7 +1252,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 718d5d0eab045a874107e078a857226a80ab912d -R 7e6bc612737dab76da35e37065b9b922 -U drh -Z ba983635f4ecc26ab029799e1b9c58b7 +P b623ebd859dcb1d99398aa9953f6b113bad26304 +R 1545a9c9d59837055bc5d4ecbd66cac7 +U dan +Z a1ff940bb9d58b1311bd4296ffd3ef6a diff --git a/manifest.uuid b/manifest.uuid index e6e16b709b..73ad47817c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b623ebd859dcb1d99398aa9953f6b113bad26304 \ No newline at end of file +9d887b92f8086961e045f8acb9ee7a443796d411 \ No newline at end of file diff --git a/src/fkey.c b/src/fkey.c index e85ec6156c..09513e4620 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -1275,13 +1275,12 @@ static Trigger *fkActionTrigger( pTrigger = (Trigger *)sqlite3DbMallocZero(db, sizeof(Trigger) + /* struct Trigger */ sizeof(TriggerStep) + /* Single step in trigger program */ - nFrom + 1 /* Space for pStep->target.z */ + nFrom + 1 /* Space for pStep->zTarget */ ); if( pTrigger ){ pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1]; - pStep->target.z = (char *)&pStep[1]; - pStep->target.n = nFrom; - memcpy((char *)pStep->target.z, zFrom, nFrom); + pStep->zTarget = (char *)&pStep[1]; + memcpy((char *)pStep->zTarget, zFrom, nFrom); pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE); pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index deab70fc48..f34645fa8d 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2776,7 +2776,7 @@ struct Trigger { * orconf -> stores the ON CONFLICT algorithm * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then * this stores a pointer to the SELECT statement. Otherwise NULL. - * target -> A token holding the quoted name of the table to insert into. + * zTarget -> Dequoted name of the table to insert into. * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then * this stores values to be inserted. Otherwise NULL. * pIdList -> If this is an INSERT INTO ... () VALUES ... @@ -2784,12 +2784,12 @@ struct Trigger { * inserted into. * * (op == TK_DELETE) - * target -> A token holding the quoted name of the table to delete from. + * zTarget -> Dequoted name of the table to delete from. * pWhere -> The WHERE clause of the DELETE statement if one is specified. * Otherwise NULL. * * (op == TK_UPDATE) - * target -> A token holding the quoted name of the table to update rows of. + * zTarget -> Dequoted name of the table to update. * pWhere -> The WHERE clause of the UPDATE statement if one is specified. * Otherwise NULL. * pExprList -> A list of the columns to update and the expressions to update @@ -2801,8 +2801,8 @@ struct TriggerStep { u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */ u8 orconf; /* OE_Rollback etc. */ Trigger *pTrig; /* The trigger that this step is a part of */ - Select *pSelect; /* SELECT statment or RHS of INSERT INTO .. SELECT ... */ - Token target; /* Target table for DELETE, UPDATE, INSERT */ + Select *pSelect; /* SELECT statement or RHS of INSERT INTO SELECT ... */ + char *zTarget; /* Target table for DELETE, UPDATE, INSERT */ Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */ ExprList *pExprList; /* SET clause for UPDATE. */ IdList *pIdList; /* Column names for INSERT */ diff --git a/src/trigger.c b/src/trigger.c index 3a8e006f27..2eba0cf92c 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -372,12 +372,12 @@ static TriggerStep *triggerStepAllocate( ){ TriggerStep *pTriggerStep; - pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n); + pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1); if( pTriggerStep ){ char *z = (char*)&pTriggerStep[1]; memcpy(z, pName->z, pName->n); - pTriggerStep->target.z = z; - pTriggerStep->target.n = pName->n; + sqlite3Dequote(z); + pTriggerStep->zTarget = z; pTriggerStep->op = op; } return pTriggerStep; @@ -660,7 +660,7 @@ Trigger *sqlite3TriggersExist( } /* -** Convert the pStep->target token into a SrcList and return a pointer +** Convert the pStep->zTarget string into a SrcList and return a pointer ** to that SrcList. ** ** This routine adds a specific database name, if needed, to the target when @@ -673,18 +673,17 @@ static SrcList *targetSrcList( Parse *pParse, /* The parsing context */ TriggerStep *pStep /* The trigger containing the target token */ ){ + sqlite3 *db = pParse->db; int iDb; /* Index of the database to use */ SrcList *pSrc; /* SrcList to be returned */ - pSrc = sqlite3SrcListAppend(pParse->db, 0, 0, 0); + pSrc = sqlite3SrcListAppend(db, 0, 0, 0); if( pSrc ){ assert( pSrc->nSrc>0 ); - pSrc->a[pSrc->nSrc-1].zName = - sqlite3DbStrNDup(pParse->db, pStep->target.z, pStep->target.n); - iDb = sqlite3SchemaToIndex(pParse->db, pStep->pTrig->pSchema); + pSrc->a[pSrc->nSrc-1].zName = sqlite3DbStrDup(db, pStep->zTarget); + iDb = sqlite3SchemaToIndex(db, pStep->pTrig->pSchema); if( iDb==0 || iDb>=2 ){ - sqlite3 *db = pParse->db; - assert( iDbdb->nDb ); + assert( iDbnDb ); pSrc->a[pSrc->nSrc-1].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zName); } } diff --git a/test/triggerC.test b/test/triggerC.test index 14cc0f01dd..3e47521fd1 100644 --- a/test/triggerC.test +++ b/test/triggerC.test @@ -12,6 +12,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix triggerC ifcapable {!trigger} { finish_test return @@ -993,4 +994,52 @@ reset_db optimization_control db factor-constants 0 do_execsql_test triggerC-14.2 $SQL {1 2 3} +#------------------------------------------------------------------------- +# Check that table names used by trigger programs are dequoted exactly +# once. +# +do_execsql_test 15.1.1 { + PRAGMA recursive_triggers = 1; + CREATE TABLE node( + id int not null primary key, + pid int not null default 0 references node, + key varchar not null, + path varchar default '', + unique(pid, key) + ); + CREATE TRIGGER node_delete_referencing AFTER DELETE ON "node" + BEGIN + DELETE FROM "node" WHERE pid = old."id"; + END; +} +do_execsql_test 15.1.2 { + INSERT INTO node(id, pid, key) VALUES(9, 0, 'test'); + INSERT INTO node(id, pid, key) VALUES(90, 9, 'test1'); + INSERT INTO node(id, pid, key) VALUES(900, 90, 'test2'); + DELETE FROM node WHERE id=9; + SELECT * FROM node; +} + +do_execsql_test 15.2.1 { + CREATE TABLE x1 (x); + + CREATE TABLE x2 (a, b); + CREATE TABLE '"x2"'(a, b); + + INSERT INTO x2 VALUES(1, 2); + INSERT INTO x2 VALUES(3, 4); + INSERT INTO '"x2"' SELECT * FROM x2; + + CREATE TRIGGER x1ai AFTER INSERT ON x1 BEGIN + INSERT INTO """x2""" VALUES('x', 'y'); + DELETE FROM """x2""" WHERE a=1; + UPDATE """x2""" SET b = 11 WHERE a = 3; + END; + + INSERT INTO x1 VALUES('go!'); +} + +do_execsql_test 15.2.2 { SELECT * FROM x2; } {1 2 3 4} +do_execsql_test 15.2.3 { SELECT * FROM """x2"""; } {3 11 x y} + finish_test From dfb5e1cbc629287038ed72d7498aacf812c7a437 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Apr 2015 17:07:01 +0000 Subject: [PATCH 67/74] Make sure the datatype and collating sequence of transients tables are not initialized more than once. Otherwise a memory leak results. FossilOrigin-Name: 9e6beda2c8d879e438ee933e658f860d6eb42a20 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/select.c | 2 ++ test/subquery.test | 10 ++++++++++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 72aeca55c3..7762cd732f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\stables\snames\sare\sdequoted\sexactly\sonce\sby\sthe\strigger\slogic. -D 2015-04-21T16:38:49.045 +C Make\ssure\sthe\sdatatype\sand\scollating\ssequence\sof\stransients\stables\sare\nnot\sinitialized\smore\sthan\sonce.\s\sOtherwise\sa\smemory\sleak\sresults. +D 2015-04-21T17:07:01.179 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +230,7 @@ F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 53486a98c17b7ae09b8c2b398013e973ce4c1aae F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c 3b64da1c1130a9c82a9b5d3afe1d44ab8a31f25a +F src/select.c 01c386a3fda06bf3a1fee5391f103390480937bb F src/shell.c 78eabce4c16c45e36fea2368f95118116399ba8a F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -901,7 +901,7 @@ F test/spellfix.test 24f676831acddd2f4056a598fd731a72c6311f49 F test/sqllimits1.test e05786eaed7950ff6a2d00031d001d8a26131e68 F test/stat.test 76fd746b85459e812a0193410fb599f0531f22de F test/stmt.test 25d64e3dbf9a3ce89558667d7f39d966fe2a71b9 -F test/subquery.test 666fdecceac258f5fd84bed09a64e49d9f37edd9 +F test/subquery.test d7268d193dd33d5505df965399d3a594e76ae13f F test/subquery2.test 438f8a7da1457277b22e4176510f7659b286995f F test/subselect.test d24fd8757daf97dafd2e889c73ea4c4272dcf4e4 F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a @@ -1252,7 +1252,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 b623ebd859dcb1d99398aa9953f6b113bad26304 -R 1545a9c9d59837055bc5d4ecbd66cac7 -U dan -Z a1ff940bb9d58b1311bd4296ffd3ef6a +P 9d887b92f8086961e045f8acb9ee7a443796d411 +R 3636eb5c943e6a1ccf08bc5de8e48684 +U drh +Z d704b3d64babe71da7ea3a63e7e599d3 diff --git a/manifest.uuid b/manifest.uuid index 73ad47817c..ac07ad5039 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9d887b92f8086961e045f8acb9ee7a443796d411 \ No newline at end of file +9e6beda2c8d879e438ee933e658f860d6eb42a20 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 6a18ff4599..20d39440cb 100644 --- a/src/select.c +++ b/src/select.c @@ -1700,6 +1700,8 @@ static void selectAddColumnTypeAndCollation( a = pSelect->pEList->a; for(i=0, pCol=pTab->aCol; inCol; i++, pCol++){ p = a[i].pExpr; + if( pCol->zType ) break; + if( pCol->zColl ) break; pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p,0,0,0, &pCol->szEst)); szAll += pCol->szEst; pCol->affinity = sqlite3ExprAffinity(p); diff --git a/test/subquery.test b/test/subquery.test index 93c3f28ddb..06facbbae0 100644 --- a/test/subquery.test +++ b/test/subquery.test @@ -584,4 +584,14 @@ do_test subquery-7.11 { } {30303} } ;############# Disabled +# 2015-04-21. +# Verify that a memory leak in the table column type and collation analysis +# is plugged. +# +do_execsql_test subquery-8.1 { + CREATE TABLE t8(a TEXT, b INT); + SELECT (SELECT 0 FROM (SELECT * FROM t1)) AS x WHERE x; + SELECT (SELECT 0 FROM (SELECT * FROM (SELECT 0))) AS x WHERE x; +} {} + finish_test From 1cb50c880e02a469bbb3cb02112e89ba3a5c6857 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Apr 2015 17:17:47 +0000 Subject: [PATCH 68/74] Alternative fix for the double-initialization of type and collating sequence problem that leaves the estimated table size intact. FossilOrigin-Name: 623ddbdbf48d26dac58c593bcb9e7b184334ddfc --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/select.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 7762cd732f..e1382b4f62 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthe\sdatatype\sand\scollating\ssequence\sof\stransients\stables\sare\nnot\sinitialized\smore\sthan\sonce.\s\sOtherwise\sa\smemory\sleak\sresults. -D 2015-04-21T17:07:01.179 +C Alternative\sfix\sfor\sthe\sdouble-initialization\sof\stype\sand\scollating\ssequence\nproblem\sthat\sleaves\sthe\sestimated\stable\ssize\sintact. +D 2015-04-21T17:17:47.197 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +230,7 @@ F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 53486a98c17b7ae09b8c2b398013e973ce4c1aae F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c 01c386a3fda06bf3a1fee5391f103390480937bb +F src/select.c 35433ea8894ac42594ddc31eb0165a6d6401cfe5 F src/shell.c 78eabce4c16c45e36fea2368f95118116399ba8a F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -1252,7 +1252,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 9d887b92f8086961e045f8acb9ee7a443796d411 -R 3636eb5c943e6a1ccf08bc5de8e48684 +P 9e6beda2c8d879e438ee933e658f860d6eb42a20 +R e945ee9cd5bcd63adee2f8cd77bbfeb7 U drh -Z d704b3d64babe71da7ea3a63e7e599d3 +Z a3d2a31d5a72cc2f0da62ee0f93b8c64 diff --git a/manifest.uuid b/manifest.uuid index ac07ad5039..bfbccd2f06 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9e6beda2c8d879e438ee933e658f860d6eb42a20 \ No newline at end of file +623ddbdbf48d26dac58c593bcb9e7b184334ddfc \ No newline at end of file diff --git a/src/select.c b/src/select.c index 20d39440cb..7797804c18 100644 --- a/src/select.c +++ b/src/select.c @@ -1700,14 +1700,14 @@ static void selectAddColumnTypeAndCollation( a = pSelect->pEList->a; for(i=0, pCol=pTab->aCol; inCol; i++, pCol++){ p = a[i].pExpr; - if( pCol->zType ) break; - if( pCol->zColl ) break; - pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p,0,0,0, &pCol->szEst)); + if( pCol->zType==0 ){ + pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p,0,0,0, &pCol->szEst)); + } szAll += pCol->szEst; pCol->affinity = sqlite3ExprAffinity(p); if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_NONE; pColl = sqlite3ExprCollSeq(pParse, p); - if( pColl ){ + if( pColl && pCol->zColl==0 ){ pCol->zColl = sqlite3DbStrDup(db, pColl->zName); } } From 318d38cf7e16d0f47dc982c33e80792e06a6fff6 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 22 Apr 2015 01:33:53 +0000 Subject: [PATCH 69/74] When compiling for UAP, link against the new minimal MSVC runtime. FossilOrigin-Name: 2cb945116e7a5b78741b19839899826b539d5868 --- Makefile.msc | 20 +++++++++++++++++++- manifest | 16 ++++++++-------- manifest.uuid | 2 +- tool/build-all-msvc.bat | 15 +++++++++++++++ 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index bf290d0040..382f2b7dc0 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -115,6 +115,14 @@ USE_RC = 1 FOR_WINRT = 0 !ENDIF +# Set this non-0 to compile binaries suitable for the UAP environment. +# This setting does not apply to any binaries that require Tcl to operate +# properly (i.e. the text fixture, etc). +# +!IFNDEF FOR_UAP +FOR_UAP = 0 +!ENDIF + # Set this non-0 to skip attempting to look for and/or link with the Tcl # runtime library. # @@ -713,7 +721,7 @@ LTLIBOPTS = /NOLOGO # !IF $(FOR_WINRT)!=0 LTLINKOPTS = $(LTLINKOPTS) /APPCONTAINER -!IF "$(VISUALSTUDIOVERSION)"=="12.0" +!IF "$(VISUALSTUDIOVERSION)"=="12.0" || "$(VISUALSTUDIOVERSION)"=="14.0" !IFNDEF STORELIBPATH !IF "$(PLATFORM)"=="x86" STORELIBPATH = $(CRTLIBPATH)\store @@ -757,6 +765,16 @@ LTLINKOPTS = $(LTLINKOPTS) WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelH LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:ole32.lib !ENDIF +# When compiling for UAP, some extra linker options are also required. +# +!IF $(FOR_UAP)!=0 +LTLINKOPTS = $(LTLINKOPTS) /DYNAMICBASE /NODEFAULTLIB:kernel32.lib +LTLINKOPTS = $(LTLINKOPTS) mincore.lib +!IFDEF PSDKLIBPATH +LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(PSDKLIBPATH)" +!ENDIF +!ENDIF + # If either debugging or symbols are enabled, enable PDBs. # !IF $(DEBUG)>1 || $(SYMBOLS)!=0 diff --git a/manifest b/manifest index e1382b4f62..f62c283903 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Alternative\sfix\sfor\sthe\sdouble-initialization\sof\stype\sand\scollating\ssequence\nproblem\sthat\sleaves\sthe\sestimated\stable\ssize\sintact. -D 2015-04-21T17:17:47.197 +C When\scompiling\sfor\sUAP,\slink\sagainst\sthe\snew\sminimal\sMSVC\sruntime. +D 2015-04-22T01:33:53.959 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 513abdaff333b04ef68775ec25ceb6053b4ecafd +F Makefile.msc 32d8fe89ac5c130f9f14293fb4a59b120895c943 F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 F VERSION 2e244662b71e6e68a5c29b014ebc5b7564f4cc5a @@ -1197,7 +1197,7 @@ F test/without_rowid6.test db0dbf03c49030aa3c1ba5f618620334bd2baf5f F test/wordcount.c 9915e06cb33d8ca8109b8700791afe80d305afda F test/zeroblob.test fb3c0e4ab172d386954deda24c03f500e121d80d F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac -F tool/build-all-msvc.bat 19be654f72b0b0ed4d2451a998c603a4eb65a60f x +F tool/build-all-msvc.bat 9058bd90a3c078a3d8c17d40e853aaa0f47885f4 x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b @@ -1252,7 +1252,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 9e6beda2c8d879e438ee933e658f860d6eb42a20 -R e945ee9cd5bcd63adee2f8cd77bbfeb7 -U drh -Z a3d2a31d5a72cc2f0da62ee0f93b8c64 +P 623ddbdbf48d26dac58c593bcb9e7b184334ddfc +R 647b9c5f348c3c64b56250400a815823 +U mistachkin +Z 2676785d203eabdaf7fb118930189562 diff --git a/manifest.uuid b/manifest.uuid index bfbccd2f06..9362726267 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -623ddbdbf48d26dac58c593bcb9e7b184334ddfc \ No newline at end of file +2cb945116e7a5b78741b19839899826b539d5868 \ No newline at end of file diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index 534ea75be6..9f5176db9d 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -483,6 +483,8 @@ FOR %%P IN (%PLATFORMS%) DO ( REM IF DEFINED USE_WINV100_NSDKLIBPATH ( CALL :fn_AppendVariable NSDKLIBPATH \..\10\lib\10.0.10030.0\um\x86 + CALL :fn_CopyVariable UniversalCRTSdkDir PSDKLIBPATH + CALL :fn_AppendVariable PSDKLIBPATH Lib\10.0.10030.0\um\%%D ) ELSE IF DEFINED USE_WINV63_NSDKLIBPATH ( CALL :fn_AppendVariable NSDKLIBPATH \lib\winv6.3\um\x86 ) ELSE IF "%VisualStudioVersion%" == "12.0" ( @@ -666,6 +668,19 @@ REM NOTE: If we get to this point, we have succeeded. REM GOTO no_errors +:fn_ShowVariable + SETLOCAL + SET __ECHO_CMD=ECHO %%%2%% + FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO ( + IF NOT "%%V" == "" ( + IF NOT "%%V" == "%%%2%%" ( + %_VECHO% %1 = '%%V' + ) + ) + ) + ENDLOCAL + GOTO :EOF + :fn_ResetErrorLevel VERIFY > NUL GOTO :EOF From 3fb2cc1173bba37a35bff408de125056e2244e95 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 22 Apr 2015 11:16:34 +0000 Subject: [PATCH 70/74] Change the printf, strftime, and glob modes of fuzzershell so that they reject all inputs that do not start with a string literal followed by a comma. This helps the fuzzer focus in on the kinds of behavior those modes are intended to test. FossilOrigin-Name: 1cceefa7c6585bca786fe9f7118f7beb829ad709 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/fuzzershell.c | 9 ++++++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index f62c283903..92e2149ed4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\scompiling\sfor\sUAP,\slink\sagainst\sthe\snew\sminimal\sMSVC\sruntime. -D 2015-04-22T01:33:53.959 +C Change\sthe\sprintf,\sstrftime,\sand\sglob\smodes\sof\sfuzzershell\sso\sthat\sthey\nreject\sall\sinputs\sthat\sdo\snot\sstart\swith\sa\sstring\sliteral\sfollowed\sby\sa\ncomma.\s\sThis\shelps\sthe\sfuzzer\sfocus\sin\son\sthe\skinds\sof\sbehavior\sthose\smodes\nare\sintended\sto\stest. +D 2015-04-22T11:16:34.611 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1204,7 +1204,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 -F tool/fuzzershell.c 00c12b1e95095f43980ae3cafb51938eda577fe2 +F tool/fuzzershell.c f9aa24371ce48b3a1c215eb0a9668936a7b64896 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce @@ -1252,7 +1252,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 623ddbdbf48d26dac58c593bcb9e7b184334ddfc -R 647b9c5f348c3c64b56250400a815823 -U mistachkin -Z 2676785d203eabdaf7fb118930189562 +P 2cb945116e7a5b78741b19839899826b539d5868 +R 71e4a500a938155e198d8a588c679f56 +U drh +Z e9086986aed5a59c4a7252a09fff7a6a diff --git a/manifest.uuid b/manifest.uuid index 9362726267..d86acf85ff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2cb945116e7a5b78741b19839899826b539d5868 \ No newline at end of file +1cceefa7c6585bca786fe9f7118f7beb829ad709 \ No newline at end of file diff --git a/tool/fuzzershell.c b/tool/fuzzershell.c index abdfd3ff00..c142a32c65 100644 --- a/tool/fuzzershell.c +++ b/tool/fuzzershell.c @@ -485,7 +485,12 @@ int main(int argc, char **argv){ } } for(iNext=i; iNext Date: Wed, 22 Apr 2015 13:16:46 +0000 Subject: [PATCH 71/74] Improved filtering of input for fuzzershell for modes other than generic. FossilOrigin-Name: 025e8370dde2918b66683f8d7fa9c7d23d03c9b4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/fuzzershell.c | 7 ++++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 92e2149ed4..bd800e86c1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sprintf,\sstrftime,\sand\sglob\smodes\sof\sfuzzershell\sso\sthat\sthey\nreject\sall\sinputs\sthat\sdo\snot\sstart\swith\sa\sstring\sliteral\sfollowed\sby\sa\ncomma.\s\sThis\shelps\sthe\sfuzzer\sfocus\sin\son\sthe\skinds\sof\sbehavior\sthose\smodes\nare\sintended\sto\stest. -D 2015-04-22T11:16:34.611 +C Improved\sfiltering\sof\sinput\sfor\sfuzzershell\sfor\smodes\sother\sthan\sgeneric. +D 2015-04-22T13:16:46.644 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1204,7 +1204,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 -F tool/fuzzershell.c f9aa24371ce48b3a1c215eb0a9668936a7b64896 +F tool/fuzzershell.c bcdca60b54654c8fc25fd215953d9b6bb55fd7d4 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce @@ -1252,7 +1252,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 2cb945116e7a5b78741b19839899826b539d5868 -R 71e4a500a938155e198d8a588c679f56 +P 1cceefa7c6585bca786fe9f7118f7beb829ad709 +R cbbdf393d38b0307d153eda6dc2aba63 U drh -Z e9086986aed5a59c4a7252a09fff7a6a +Z 11145234dd05700bee32abe646d63f11 diff --git a/manifest.uuid b/manifest.uuid index d86acf85ff..7dd9717246 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1cceefa7c6585bca786fe9f7118f7beb829ad709 \ No newline at end of file +025e8370dde2918b66683f8d7fa9c7d23d03c9b4 \ No newline at end of file diff --git a/tool/fuzzershell.c b/tool/fuzzershell.c index c142a32c65..c130460509 100644 --- a/tool/fuzzershell.c +++ b/tool/fuzzershell.c @@ -351,6 +351,7 @@ int main(int argc, char **argv){ char *zSql; /* SQL to run */ char *zToFree = 0; /* Call sqlite3_free() on this afte running zSql */ int iMode = FZMODE_Generic; /* Operating mode */ + const char *zCkGlob = 0; /* Inputs must match this glob */ g.zArgv0 = argv[0]; @@ -392,12 +393,16 @@ int main(int argc, char **argv){ z = argv[++i]; if( strcmp(z,"generic")==0 ){ iMode = FZMODE_Printf; + zCkGlob = 0; }else if( strcmp(z, "glob")==0 ){ iMode = FZMODE_Glob; + zCkGlob = "'*','*'"; }else if( strcmp(z, "printf")==0 ){ iMode = FZMODE_Printf; + zCkGlob = "'*',*"; }else if( strcmp(z, "strftime")==0 ){ iMode = FZMODE_Strftime; + zCkGlob = "'*',*"; }else{ abendError("unknown --mode: %s", z); } @@ -487,7 +492,7 @@ int main(int argc, char **argv){ for(iNext=i; iNext Date: Thu, 23 Apr 2015 11:52:04 +0000 Subject: [PATCH 72/74] Fix a problem causing the fts3 integrity-check to fail if run inside a transaction. FossilOrigin-Name: 3b925189a75eae875da256b6e54999cad3cef1eb --- ext/fts3/fts3.c | 2 +- ext/fts3/fts3_write.c | 13 +++++++------ manifest | 20 ++++++++++---------- manifest.uuid | 2 +- test/fts4check.test | 30 ++++++++++++++++++++++++++++++ test/trace2.test | 2 +- 6 files changed, 50 insertions(+), 19 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 41c93daaeb..6ab05230be 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -2810,7 +2810,7 @@ static int fts3SegReaderCursor( ** calls out here. */ if( iLevel<0 && p->aIndex ){ Fts3SegReader *pSeg = 0; - rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix, &pSeg); + rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix||isScan, &pSeg); if( rc==SQLITE_OK && pSeg ){ rc = fts3SegReaderCursorAppend(pCsr, pSeg); } diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index a16070766f..4cd2aebf6a 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -326,7 +326,7 @@ static int fts3SqlStmt( /* 25 */ "", /* 26 */ "DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?", -/* 27 */ "SELECT DISTINCT level / (1024 * ?) FROM %Q.'%q_segdir'", +/* 27 */ "SELECT ? UNION SELECT level / (1024 * ?) FROM %Q.'%q_segdir'", /* This statement is used to determine which level to read the input from ** when performing an incremental merge. It returns the absolute level number @@ -3444,7 +3444,8 @@ static int fts3DoOptimize(Fts3Table *p, int bReturnDone){ rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0); if( rc==SQLITE_OK ){ int rc2; - sqlite3_bind_int(pAllLangid, 1, p->nIndex); + sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid); + sqlite3_bind_int(pAllLangid, 2, p->nIndex); while( sqlite3_step(pAllLangid)==SQLITE_ROW ){ int i; int iLangid = sqlite3_column_int(pAllLangid, 0); @@ -4776,7 +4777,7 @@ static int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){ pHint->n = i; i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel); i += fts3GetVarint32(&pHint->a[i], pnInput); - if( i!=nHint ) return SQLITE_CORRUPT_VTAB; + if( i!=nHint ) return FTS_CORRUPT_VTAB; return SQLITE_OK; } @@ -5144,7 +5145,8 @@ static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){ rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0); if( rc==SQLITE_OK ){ int rc2; - sqlite3_bind_int(pAllLangid, 1, p->nIndex); + sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid); + sqlite3_bind_int(pAllLangid, 2, p->nIndex); while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){ int iLangid = sqlite3_column_int(pAllLangid, 0); int i; @@ -5157,7 +5159,6 @@ static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){ } /* This block calculates the checksum according to the %_content table */ - rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0); if( rc==SQLITE_OK ){ sqlite3_tokenizer_module const *pModule = p->pTokenizer->pModule; sqlite3_stmt *pStmt = 0; @@ -5254,7 +5255,7 @@ static int fts3DoIntegrityCheck( int rc; int bOk = 0; rc = fts3IntegrityCheck(p, &bOk); - if( rc==SQLITE_OK && bOk==0 ) rc = SQLITE_CORRUPT_VTAB; + if( rc==SQLITE_OK && bOk==0 ) rc = FTS_CORRUPT_VTAB; return rc; } diff --git a/manifest b/manifest index bd800e86c1..f353bf1198 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\sfiltering\sof\sinput\sfor\sfuzzershell\sfor\smodes\sother\sthan\sgeneric. -D 2015-04-22T13:16:46.644 +C Fix\sa\sproblem\scausing\sthe\sfts3\sintegrity-check\sto\sfail\sif\srun\sinside\sa\stransaction. +D 2015-04-23T11:52:04.753 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 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 1b198ddb76cd706722dacbbaeb17a2fde6fca2cc +F ext/fts3/fts3.c 81f9ed55ad58614828ad9d8b1e0525ad78fede1b F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 3626655d6ba903a3919bb44e1c38e5f0f9d6be82 F ext/fts3/fts3_aux.c 5c211e17a64885faeb16b9ba7772f9d5445c2365 @@ -96,7 +96,7 @@ F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 F ext/fts3/fts3_unicode.c a93f5edc0aff44ef8b06d7cb55b52026541ca145 F ext/fts3/fts3_unicode2.c c3d01968d497bd7001e7dc774ba75b372738c057 -F ext/fts3/fts3_write.c 7104ec015474ee61a8a570349b925f35c6b0a294 +F ext/fts3/fts3_write.c 4f005f78592a1447ca96c8475ef5342ab7dbe02a F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/fts3/tool/fts3view.c 8e53d0190a7b3443764bbd32ad47be2bd852026d @@ -606,7 +606,7 @@ F test/fts3tok1.test 178c050199af8c05299b1ad572514ce1c54b7827 F test/fts3tok_err.test 52273cd193b9036282f7bacb43da78c6be87418d F test/fts3varint.test 752c08ed5d32c5d7dc211b056f4ed68a76b7e36e F test/fts4aa.test 10aac8e9d62c7357590acfabe3fad01e9a9ce1cb -F test/fts4check.test 74d77f6cdb768ac49df5afda575cef14ae3d239a +F test/fts4check.test 9d9e818fd6cb29c0e007cd6d00447739d4fde430 F test/fts4content.test abb0c77bc3da3df64fec72e00844d2257a90025d F test/fts4docid.test e33c383cfbdff0284685604d256f347a18fdbf01 F test/fts4growth.test df10fde9f47cf5c71861e63fd8efcd573c4f7e53 @@ -1072,7 +1072,7 @@ F test/tkt4018.test 7c2c9ba4df489c676a0a7a0e809a1fb9b2185bd1 F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/tpch01.test 04adbf8d8300fa60a222f28d901abd76e7be6dd4 F test/trace.test 73a5508100f7fccfbc3f8018d5f6963ed478eea0 -F test/trace2.test 93b47ca6996c66b47f57224cfb146f34e07df382 +F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 @@ -1252,7 +1252,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 1cceefa7c6585bca786fe9f7118f7beb829ad709 -R cbbdf393d38b0307d153eda6dc2aba63 -U drh -Z 11145234dd05700bee32abe646d63f11 +P 025e8370dde2918b66683f8d7fa9c7d23d03c9b4 +R 0493843e21c0418553e48f04134edffd +U dan +Z f0b3e3cb42b414d1c0d4ee7ec6a01960 diff --git a/manifest.uuid b/manifest.uuid index 7dd9717246..53450bf693 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -025e8370dde2918b66683f8d7fa9c7d23d03c9b4 \ No newline at end of file +3b925189a75eae875da256b6e54999cad3cef1eb \ No newline at end of file diff --git a/test/fts4check.test b/test/fts4check.test index c98886cccc..4ded053871 100644 --- a/test/fts4check.test +++ b/test/fts4check.test @@ -179,5 +179,35 @@ do_test 4.2 { } {1 {database disk image is malformed}} reset_db +#-------------------------------------------------------------------------- +# Test case 5.* +# +# Test that the integrity-check works if there is uncommitted data. +# +do_execsql_test 5.0 { + BEGIN; + CREATE VIRTUAL TABLE t5 USING fts4(a, prefix="1,2,3"); + INSERT INTO t5 VALUES('And down by Kosiosko, where the reed-banks sweep'); + INSERT INTO t5 VALUES('and sway, and the rolling plains are wide, the'); + INSERT INTO t5 VALUES('man from snowy river is a household name today,'); + INSERT INTO t5 VALUES('and the stockmen tell the story of his ride'); +} + +do_execsql_test 5.1 { + INSERT INTO t5(t5) VALUES('integrity-check'); +} {} + +do_catchsql_test 5.2 { + INSERT INTO t5_content VALUES(5, 'his hardy mountain pony'); + INSERT INTO t5(t5) VALUES('integrity-check'); +} {1 {database disk image is malformed}} + +do_execsql_test 5.3 ROLLBACK + +do_execsql_test 5.4 { + CREATE VIRTUAL TABLE t5 USING fts4(a, prefix="1,2,3"); + INSERT INTO t5(t5) VALUES('integrity-check'); +} {} + finish_test diff --git a/test/trace2.test b/test/trace2.test index 562c70c538..a3f0aeb878 100644 --- a/test/trace2.test +++ b/test/trace2.test @@ -143,7 +143,7 @@ ifcapable fts3 { INSERT INTO x1(x1) VALUES('optimize'); } { "INSERT INTO x1(x1) VALUES('optimize');" - "-- SELECT DISTINCT level / (1024 * ?) FROM 'main'.'x1_segdir'" + "-- SELECT ? UNION SELECT level / (1024 * ?) FROM 'main'.'x1_segdir'" "-- SELECT idx, start_block, leaves_end_block, end_block, root FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?ORDER BY level DESC, idx ASC" "-- SELECT max(level) FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?" "-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)" From 00808deed0fa19953cded0d5d76076e451f2db7e Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 23 Apr 2015 13:00:42 +0000 Subject: [PATCH 73/74] Improvement to "ID" formatting on the ".selecttrace 0x1ff" debugging function. FossilOrigin-Name: 01c50cee37bfaddfecdda014728c35a1be1d991a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/expr.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index f353bf1198..3a81a72bab 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\scausing\sthe\sfts3\sintegrity-check\sto\sfail\sif\srun\sinside\sa\stransaction. -D 2015-04-23T11:52:04.753 +C Improvement\sto\s"ID"\sformatting\son\sthe\s".selecttrace\s0x1ff"\sdebugging\sfunction. +D 2015-04-23T13:00:42.419 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -182,7 +182,7 @@ F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e -F src/expr.c 5555f768c05d7d4a7840c6c2e72ad7aecbe0fe54 +F src/expr.c 4c05a28eebe63b288fda1db0e8de556a82ca2ec6 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c c9b63a217d86582c22121699a47f22f524608869 F src/func.c 1414c24c873c48796ad45942257a179a423ba42f @@ -1252,7 +1252,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 025e8370dde2918b66683f8d7fa9c7d23d03c9b4 -R 0493843e21c0418553e48f04134edffd -U dan -Z f0b3e3cb42b414d1c0d4ee7ec6a01960 +P 3b925189a75eae875da256b6e54999cad3cef1eb +R 91b21b2647bc9d8855495606fbb1f5a3 +U drh +Z 7838074221fad9e070444c0a40a76b3b diff --git a/manifest.uuid b/manifest.uuid index 53450bf693..9c82b5e536 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3b925189a75eae875da256b6e54999cad3cef1eb \ No newline at end of file +01c50cee37bfaddfecdda014728c35a1be1d991a \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 3f8bd942ef..115af20596 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3383,7 +3383,7 @@ void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){ break; } case TK_ID: { - sqlite3TreeViewLine(pView,"ID %Q", pExpr->u.zToken); + sqlite3TreeViewLine(pView,"ID \"%w\"", pExpr->u.zToken); break; } #ifndef SQLITE_OMIT_CAST From 41148f83c47b0d196f9d11aaad89d3528ecb4830 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 23 Apr 2015 13:37:05 +0000 Subject: [PATCH 74/74] Fix a faulty assert() in the "AS" alias resolution logic of the parser. FossilOrigin-Name: b5e43602833249aa4b73337bf85b7f308450dab6 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/resolve.c | 4 ++-- test/resolver01.test | 10 +++++++++- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 3a81a72bab..d1717e9040 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvement\sto\s"ID"\sformatting\son\sthe\s".selecttrace\s0x1ff"\sdebugging\sfunction. -D 2015-04-23T13:00:42.419 +C Fix\sa\sfaulty\sassert()\sin\sthe\s"AS"\salias\sresolution\slogic\sof\sthe\sparser. +D 2015-04-23T13:37:05.307 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -228,7 +228,7 @@ F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f F src/prepare.c 1fffbdcd6f8a0173a8f70d71f22528f4c0e1e3d3 F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 -F src/resolve.c 53486a98c17b7ae09b8c2b398013e973ce4c1aae +F src/resolve.c 13109bc3b5ab404446296efa17039640de5bc35d F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 35433ea8894ac42594ddc31eb0165a6d6401cfe5 F src/shell.c 78eabce4c16c45e36fea2368f95118116399ba8a @@ -814,7 +814,7 @@ F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 F test/releasetest.tcl a37cd82092c8be438255d65804b5951d6e3ecdae -F test/resolver01.test 33abf37ff8335e6bf98f2b45a0af3e06996ccd9a +F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea F test/rollback2.test fc14cf6d1a2b250d2735ef16124b971bce152f14 F test/rollbackfault.test 6a004f71087cc399296cffbb5429ea6da655ae65 @@ -1252,7 +1252,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 3b925189a75eae875da256b6e54999cad3cef1eb -R 91b21b2647bc9d8855495606fbb1f5a3 +P 01c50cee37bfaddfecdda014728c35a1be1d991a +R b16870d1654f6de484a72bbc7fa9d1f0 U drh -Z 7838074221fad9e070444c0a40a76b3b +Z cee60c918913e56f32da2a16c41282ec diff --git a/manifest.uuid b/manifest.uuid index 9c82b5e536..77658405b1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -01c50cee37bfaddfecdda014728c35a1be1d991a \ No newline at end of file +b5e43602833249aa4b73337bf85b7f308450dab6 \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index 32e0a98fd7..b75db42ef6 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -79,7 +79,7 @@ static void incrAggFunctionDepth(Expr *pExpr, int N){ ** SELECT a+b, c+d FROM t1 ORDER BY (a+b) COLLATE nocase; ** ** The nSubquery parameter specifies how many levels of subquery the -** alias is removed from the original expression. The usually value is +** alias is removed from the original expression. The usual value is ** zero but it might be more if the alias is contained within a subquery ** of the original expression. The Expr.op2 field of TK_AGG_FUNCTION ** structures must be increased by the nSubquery amount. @@ -99,7 +99,7 @@ static void resolveAlias( assert( iCol>=0 && iColnExpr ); pOrig = pEList->a[iCol].pExpr; assert( pOrig!=0 ); - assert( pOrig->flags & EP_Resolved ); + assert( (pOrig->flags & EP_Resolved)!=0 || zType[0]==0 ); db = pParse->db; pDup = sqlite3ExprDup(db, pOrig, 0); if( pDup==0 ) return; diff --git a/test/resolver01.test b/test/resolver01.test index 7d95a2132a..59bb3c021a 100644 --- a/test/resolver01.test +++ b/test/resolver01.test @@ -11,10 +11,12 @@ # # This file tests features of the name resolver (the component that # figures out what identifiers in the SQL statement refer to) that -# were fixed by ticket [2500cdb9be] +# were fixed by ticket [2500cdb9be]. # # See also tickets [1c69be2daf] and [f617ea3125] from 2013-08-14. # +# Also a fuzzer-discovered problem on 2015-04-23. +# set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -201,6 +203,12 @@ do_execsql_test resolver01-6.3 { GROUP BY lower(name); } {1 {} 1 {}} +do_execsql_test resolver01-7.1 { + SELECT 2 AS x WHERE (SELECT x AS y WHERE 3>y); +} {2} +do_execsql_test resolver01-7.2 { + SELECT 2 AS x WHERE (SELECT x AS y WHERE 1>y); +} {}