From 5402710b0b4a7903f62a3a0ceec928ff045e67cd Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 6 Aug 2014 14:36:53 +0000 Subject: [PATCH 01/28] Fix harmless compiler warnings. In the command-line shell, report if the ".system" command returns a non-zero result. FossilOrigin-Name: 1202e9771f6d699dbf5268368108a3527d06d799 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/main.c | 2 +- src/shell.c | 5 +++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index f2683e69ef..bdbb4d649d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sobsolete\scomment\sin\sthe\sfunc.c\ssource\sfile.\s\sNo\schanges\sto\scode. -D 2014-08-06T11:58:40.249 +C Fix\sharmless\scompiler\swarnings.\s\sIn\sthe\scommand-line\sshell,\sreport\sif\sthe\n".system"\scommand\sreturns\sa\snon-zero\sresult. +D 2014-08-06T14:36:53.910 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -189,7 +189,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303 -F src/main.c bbf7f993843fc3fc496089747f6849272d77e824 +F src/main.c 6bc7cd1b896a47f2803f69a56737191abf76918a F src/malloc.c 0203ebce9152c6a0e5de520140b8ba65187350be F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c0c990fcaddff810ea277b4fb5d9138603dd5d4b @@ -223,7 +223,7 @@ F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece F src/resolve.c 5fc110baeacf120a73fe34e103f052632ff11a02 F src/rowset.c a9c9aae3234b44a6d7c6f5a3cadf90dce1e627be F src/select.c 1529c49075464c5a95fde77314073612b1b8d595 -F src/shell.c 191129c3f7a9cf241aea90ff6a6be3e74d3767f0 +F src/shell.c 4af71e7f25af6da6debda87dcbd6be37da710916 F src/sqlite.h.in 9bbc5815c73b0e77e68b5275481a5e3e7814a804 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc @@ -1185,8 +1185,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 ab1a751e1304749bef5bc5c833f9abed8950f7d0 -Q +7a145c9409e70b92946534eb44c2e205f7309897 -R c5d9492d210d0878e8d4fad26b1bb9f1 +P 5c6bb57d90bad32785d6d9cdf110a825bbc5ec73 +R 70e92229f0d1d2ca5063839c778d94a2 U drh -Z c0ef6bc5c4f2711fca6f4933f6dbf08d +Z 832222a1addbce429c4a8001874a3f39 diff --git a/manifest.uuid b/manifest.uuid index 89b8c4d9e9..3b487cbb12 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5c6bb57d90bad32785d6d9cdf110a825bbc5ec73 \ No newline at end of file +1202e9771f6d699dbf5268368108a3527d06d799 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 990e62e6e4..a95200641f 100644 --- a/src/main.c +++ b/src/main.c @@ -1056,7 +1056,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) || defined(SQLITE_TEST) +#if (defined(SQLITE_DEBUG) && SQLITE_OS_WIN) || defined(SQLITE_TEST) const char *sqlite3ErrName(int rc){ const char *zName = 0; int i, origRc = rc; diff --git a/src/shell.c b/src/shell.c index 371efa024e..e9ecf194b6 100644 --- a/src/shell.c +++ b/src/shell.c @@ -3126,7 +3126,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ && (strncmp(azArg[0], "shell", n)==0 || strncmp(azArg[0],"system",n)==0) ){ char *zCmd; - int i; + int i, x; if( nArg<2 ){ fprintf(stderr, "Usage: .system COMMAND\n"); rc = 1; @@ -3137,8 +3137,9 @@ static int do_meta_command(char *zLine, struct callback_data *p){ zCmd = sqlite3_mprintf(strchr(azArg[i],' ')==0?"%z %s":"%z \"%s\"", zCmd, azArg[i]); } - (void)system(zCmd); + x = system(zCmd); sqlite3_free(zCmd); + if( x ) fprintf(stderr, "System command returns %d\n", x); }else if( c=='s' && strncmp(azArg[0], "show", n)==0 ){ From e8f2c9dc71c9c3d7b08552a8db5fbd4ab5b5fb86 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 6 Aug 2014 17:49:13 +0000 Subject: [PATCH 02/28] Fix two more harmless compiler warnings. Make sure the fts3_unicode2.c file is in sync with mkunicode.tcl. FossilOrigin-Name: a2a60307ea68a3230952a56cb65369ba0a208967 --- ext/fts3/fts3_unicode2.c | 2 +- ext/fts3/unicode/mkunicode.tcl | 6 +++--- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/vdbe.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ext/fts3/fts3_unicode2.c b/ext/fts3/fts3_unicode2.c index 4837dbd272..a2ca622c6e 100644 --- a/ext/fts3/fts3_unicode2.c +++ b/ext/fts3/fts3_unicode2.c @@ -39,7 +39,7 @@ int sqlite3FtsUnicodeIsalnum(int c){ ** C. It is not possible to represent a range larger than 1023 codepoints ** using this format. */ - const static unsigned int aEntry[] = { + static const unsigned int aEntry[] = { 0x00000030, 0x0000E807, 0x00016C06, 0x0001EC2F, 0x0002AC07, 0x0002D001, 0x0002D803, 0x0002EC01, 0x0002FC01, 0x00035C01, 0x0003DC01, 0x000B0804, 0x000B480E, 0x000B9407, 0x000BB401, diff --git a/ext/fts3/unicode/mkunicode.tcl b/ext/fts3/unicode/mkunicode.tcl index 2da17c51a5..66698bb055 100644 --- a/ext/fts3/unicode/mkunicode.tcl +++ b/ext/fts3/unicode/mkunicode.tcl @@ -298,7 +298,7 @@ proc an_print_range_array {lRange} { ** using this format. */ }] - puts -nonewline " const static unsigned int aEntry\[\] = \{" + puts -nonewline " static const unsigned int aEntry\[\] = \{" set i 0 foreach range $lRange { foreach {iFirst nRange} $range {} @@ -732,7 +732,7 @@ proc print_fileheader {} { */ }] puts "" - puts "#if defined(SQLITE_ENABLE_FTS4_UNICODE61)" + puts "#ifndef SQLITE_DISABLE_FTS3_UNICODE" puts "#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)" puts "" puts "#include " @@ -808,4 +808,4 @@ if {$::generate_test_code} { } puts "#endif /* defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) */" -puts "#endif /* !defined(SQLITE_ENABLE_FTS4_UNICODE61) */" +puts "#endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */" diff --git a/manifest b/manifest index bdbb4d649d..4f407ebf1a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings.\s\sIn\sthe\scommand-line\sshell,\sreport\sif\sthe\n".system"\scommand\sreturns\sa\snon-zero\sresult. -D 2014-08-06T14:36:53.910 +C Fix\stwo\smore\sharmless\scompiler\swarnings.\s\sMake\ssure\sthe\sfts3_unicode2.c\sfile\nis\sin\ssync\swith\smkunicode.tcl. +D 2014-08-06T17:49:13.360 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -95,14 +95,14 @@ F ext/fts3/fts3_tokenizer.c bbdc731bc91338050675c6d1da9ab82147391e16 F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 F ext/fts3/fts3_unicode.c e80eef8a11f2020dc9c1eb95c5b405b9012f2fbe -F ext/fts3/fts3_unicode2.c c8adda75aad0c6c252ef3dd555f811f437485044 +F ext/fts3/fts3_unicode2.c b81e5f0f7991e5f706544f7f7a9931c491f8ac07 F ext/fts3/fts3_write.c 8260388626516a7005d06a9dce94f9e55c6c2a41 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/fts3/tool/fts3view.c 3986531f2fc0ceca0c89c31ec7d0589b6adb19d6 F ext/fts3/unicode/CaseFolding.txt 8c678ca52ecc95e16bc7afc2dbf6fc9ffa05db8c F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 -F ext/fts3/unicode/mkunicode.tcl dc6f268eb526710e2c6e496c372471d773d0c368 +F ext/fts3/unicode/mkunicode.tcl ddeb6629fbcd5eb9b55f8999dbad5e4c63e5dd5a F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 F ext/icu/icu.c d415ccf984defeb9df2c0e1afcfaa2f6dc05eacb F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 @@ -283,7 +283,7 @@ F src/update.c ea336ce7b8b3fc5e316ba8f082e6445babf81059 F src/utf.c a0314e637768a030e6e84a957d0c4f6ba910cc05 F src/util.c 3076bdd51cdbf60a6e2e57fada745be37133c73e F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179 -F src/vdbe.c 2db817cf7c51fa775ecc68160352aefc3d9870f7 +F src/vdbe.c cd8d7e3ecd3e0e0684f6bf48469966335c666883 F src/vdbe.h c63fad052c9e7388d551e556e119c0bcf6bebdf8 F src/vdbeInt.h f5513f2b5ac1e2c5128996c7ea23add256a301df F src/vdbeapi.c 24e40422382beb774daab11fe9fe9d37e8a04949 @@ -1185,7 +1185,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 5c6bb57d90bad32785d6d9cdf110a825bbc5ec73 -R 70e92229f0d1d2ca5063839c778d94a2 +P 1202e9771f6d699dbf5268368108a3527d06d799 +R d4b78aa6bcc5216879daa10572b102f7 U drh -Z 832222a1addbce429c4a8001874a3f39 +Z 6c4725b3b555727ccd6e011265bbf365 diff --git a/manifest.uuid b/manifest.uuid index 3b487cbb12..7c82aa8be9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1202e9771f6d699dbf5268368108a3527d06d799 \ No newline at end of file +a2a60307ea68a3230952a56cb65369ba0a208967 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 6c46d76569..10b81a7992 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -3266,7 +3266,7 @@ case OP_ReopenIdx: { assert( pOp->p5==0 ); assert( pOp->p4type==P4_KEYINFO ); pCur = p->apCsr[pOp->p1]; - if( pCur && pCur->pgnoRoot==pOp->p2 ){ + if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){ assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */ break; } From 858b638d1f76b0bb1a7f47f3eab72ca69a3a587e Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 6 Aug 2014 18:50:51 +0000 Subject: [PATCH 03/28] A couple more harmless compiler warnings eliminated. FossilOrigin-Name: bcf6d775f90f4d1ba018a1b965f2f710df130f01 --- ext/fts3/fts3_unicode2.c | 4 ++-- ext/fts3/unicode/mkunicode.tcl | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ext/fts3/fts3_unicode2.c b/ext/fts3/fts3_unicode2.c index a2ca622c6e..20b7a25dbf 100644 --- a/ext/fts3/fts3_unicode2.c +++ b/ext/fts3/fts3_unicode2.c @@ -131,7 +131,7 @@ int sqlite3FtsUnicodeIsalnum(int c){ return ( (aAscii[c >> 5] & (1 << (c & 0x001F)))==0 ); }else if( c<(1<<22) ){ unsigned int key = (((unsigned int)c)<<10) | 0x000003FF; - int iRes; + int iRes = 0; int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1; int iLo = 0; while( iHi>=iLo ){ @@ -202,7 +202,7 @@ static int remove_diacritic(int c){ } assert( key>=aDia[iRes] ); return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]); -}; +} /* diff --git a/ext/fts3/unicode/mkunicode.tcl b/ext/fts3/unicode/mkunicode.tcl index 66698bb055..c3083ee368 100644 --- a/ext/fts3/unicode/mkunicode.tcl +++ b/ext/fts3/unicode/mkunicode.tcl @@ -160,7 +160,7 @@ proc print_rd {map} { } assert( key>=aDia[iRes] ); return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);} - puts "\};" + puts "\}" } proc print_isdiacritic {zFunc map} { @@ -349,7 +349,7 @@ proc print_isalnum {zFunc lRange} { return ( (aAscii[c >> 5] & (1 << (c & 0x001F)))==0 ); }else if( c<(1<<22) ){ unsigned int key = (((unsigned int)c)<<10) | 0x000003FF; - int iRes; + int iRes = 0; int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1; int iLo = 0; while( iHi>=iLo ){ diff --git a/manifest b/manifest index 4f407ebf1a..e0d03aef40 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stwo\smore\sharmless\scompiler\swarnings.\s\sMake\ssure\sthe\sfts3_unicode2.c\sfile\nis\sin\ssync\swith\smkunicode.tcl. -D 2014-08-06T17:49:13.360 +C A\scouple\smore\sharmless\scompiler\swarnings\seliminated. +D 2014-08-06T18:50:51.299 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -95,14 +95,14 @@ F ext/fts3/fts3_tokenizer.c bbdc731bc91338050675c6d1da9ab82147391e16 F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 F ext/fts3/fts3_unicode.c e80eef8a11f2020dc9c1eb95c5b405b9012f2fbe -F ext/fts3/fts3_unicode2.c b81e5f0f7991e5f706544f7f7a9931c491f8ac07 +F ext/fts3/fts3_unicode2.c c3d01968d497bd7001e7dc774ba75b372738c057 F ext/fts3/fts3_write.c 8260388626516a7005d06a9dce94f9e55c6c2a41 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/fts3/tool/fts3view.c 3986531f2fc0ceca0c89c31ec7d0589b6adb19d6 F ext/fts3/unicode/CaseFolding.txt 8c678ca52ecc95e16bc7afc2dbf6fc9ffa05db8c F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 -F ext/fts3/unicode/mkunicode.tcl ddeb6629fbcd5eb9b55f8999dbad5e4c63e5dd5a +F ext/fts3/unicode/mkunicode.tcl a2567f9d6ad6779879a2e394c120ad8718557e65 F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 F ext/icu/icu.c d415ccf984defeb9df2c0e1afcfaa2f6dc05eacb F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 @@ -1185,7 +1185,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 1202e9771f6d699dbf5268368108a3527d06d799 -R d4b78aa6bcc5216879daa10572b102f7 +P a2a60307ea68a3230952a56cb65369ba0a208967 +R 1442001d079992194e2cf55642b869fa U drh -Z 6c4725b3b555727ccd6e011265bbf365 +Z bb5786216c21ae2a69b537cdb50bf939 diff --git a/manifest.uuid b/manifest.uuid index 7c82aa8be9..ff8a700478 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a2a60307ea68a3230952a56cb65369ba0a208967 \ No newline at end of file +bcf6d775f90f4d1ba018a1b965f2f710df130f01 \ No newline at end of file From ddef5dc044de3ec73c9223359d45f1a6a55a792d Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 Aug 2014 16:50:00 +0000 Subject: [PATCH 04/28] When the estimated cost to do a sort overwhelms the estimated cost to do individual table lookups, make sure that the table lookup costs are still taken into consideration when selecting the lookup algorithm. FossilOrigin-Name: ec5d84ba69c100d9565425ed74040a49e410ea03 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 37 ++++++++++++++++++++++++++++++------- test/whereJ.test | 46 +++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 83 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index e0d03aef40..1e4aea7641 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C A\scouple\smore\sharmless\scompiler\swarnings\seliminated. -D 2014-08-06T18:50:51.299 +C When\sthe\sestimated\scost\sto\sdo\sa\ssort\soverwhelms\sthe\sestimated\scost\sto\sdo\nindividual\stable\slookups,\smake\ssure\sthat\sthe\stable\slookup\scosts\sare\sstill\ntaken\sinto\sconsideration\swhen\sselecting\sthe\slookup\salgorithm. +D 2014-08-07T16:50:00.581 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -296,7 +296,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c ce1b9a3a2573033cd15e0882719db7f211f21cdd +F src/where.c 5a099c6d2a1bfbf46bc64979e89330dee3a1f3b9 F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1117,7 +1117,7 @@ F test/whereF.test 5b2ba0dbe8074aa13e416b37c753991f0a2492d7 F test/whereG.test 69f5ec4b15760a8c860f80e2d55525669390aab3 F test/whereH.test e4b07f7a3c2f5d31195cd33710054c78667573b2 F test/whereI.test 1d89199697919d4930be05a71e7fe620f114e622 -F test/whereJ.test 7dde28284d20f358b559ca592e294db03e1d7103 +F test/whereJ.test 35a40a50d0e13aa6b0de7cc5d4b204e5f9f9669f F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31 F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c F test/win32heap.test ea19770974795cff26e11575e12d422dbd16893c @@ -1185,7 +1185,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 a2a60307ea68a3230952a56cb65369ba0a208967 -R 1442001d079992194e2cf55642b869fa +P bcf6d775f90f4d1ba018a1b965f2f710df130f01 +R da285ec7c1bbef437389fa691998cee0 U drh -Z bb5786216c21ae2a69b537cdb50bf939 +Z 083887f7ebac8cb5fec0c6d1cdc7c751 diff --git a/manifest.uuid b/manifest.uuid index ff8a700478..04f61bd019 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bcf6d775f90f4d1ba018a1b965f2f710df130f01 \ No newline at end of file +ec5d84ba69c100d9565425ed74040a49e410ea03 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 20823046f7..ff65cc3b36 100644 --- a/src/where.c +++ b/src/where.c @@ -5424,6 +5424,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ LogEst rCost; /* Cost of a path */ LogEst nOut; /* Number of outputs */ LogEst mxCost = 0; /* Maximum cost of a set of paths */ + LogEst mxOut = 0; /* nOut value for maximum cost path */ int nTo, nFrom; /* Number of valid entries in aTo[] and aFrom[] */ WherePath *aFrom; /* All nFrom paths at the previous level */ WherePath *aTo; /* The nTo best paths at the current level */ @@ -5441,7 +5442,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** For joins of 3 or more tables, track the 10 best paths */ mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 10); assert( nLoop<=pWInfo->pTabList->nSrc ); - WHERETRACE(0x002, ("---- begin solver\n")); + WHERETRACE(0x002, ("---- begin solver. (nRowEst=%d)\n", nRowEst)); /* Allocate and initialize space for aTo and aFrom */ ii = (sizeof(WherePath)+sizeof(WhereLoop*)*nLoop)*mxChoice*2; @@ -5529,7 +5530,13 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ }else{ revMask = pFrom->revLoop; } - /* Check to see if pWLoop should be added to the mxChoice best so far */ + /* Check to see if pWLoop should be added to the set of + ** mxChoice best-so-far paths. + ** + ** First look for an existing path among best-so-far paths + ** that covers the same set of loops and has the same isOrdered + ** setting as the current path candidate. + */ for(jj=0, pTo=aTo; jjmaskLoop==maskNew && ((pTo->isOrdered^isOrdered)&80)==0 @@ -5539,7 +5546,14 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ } } if( jj>=nTo ){ - if( nTo>=mxChoice && rCost>=mxCost ){ + /* None of the existing best-so-far paths match the candidate. */ +if( nTo>=mxChoice && rCost==mxCost ) printf("nOut=%d mxOut=%d\n", nOut, mxOut); + if( nTo>=mxChoice + && (rCost>mxCost || (rCost==mxCost && nOut>=mxOut)) + ){ + /* The current candidate is no better than any of the mxChoice + ** paths currently in the best-so-far buffer. So discard + ** this candidate as not viable. */ #ifdef WHERETRACE_ENABLED /* 0x4 */ if( sqlite3WhereTrace&0x4 ){ sqlite3DebugPrintf("Skip %s cost=%-3d,%3d order=%c\n", @@ -5549,7 +5563,8 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ #endif continue; } - /* Add a new Path to the aTo[] set */ + /* If we reach this points it means that the new candidate path + ** needs to be added to the set of best-so-far paths. */ if( nTorCost<=rCost ){ + /* Control reaches here if best-so-far path pTo=aTo[jj] covers the + ** same set of loops and has the sam isOrdered setting as the + ** candidate path. Check to see if the candidate should replace + ** pTo or if the candidate should be skipped */ + if( pTo->rCostrCost==rCost && pTo->nRow<=nOut) ){ #ifdef WHERETRACE_ENABLED /* 0x4 */ if( sqlite3WhereTrace&0x4 ){ sqlite3DebugPrintf( @@ -5578,11 +5597,13 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?'); } #endif + /* Discard the candidate path from further consideration */ testcase( pTo->rCost==rCost ); continue; } testcase( pTo->rCost==rCost+1 ); - /* A new and better score for a previously created equivalent path */ + /* Control reaches here if the candidate path is better than the + ** pTo path. Replace pTo with the candidate. */ #ifdef WHERETRACE_ENABLED /* 0x4 */ if( sqlite3WhereTrace&0x4 ){ sqlite3DebugPrintf( @@ -5606,9 +5627,11 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ if( nTo>=mxChoice ){ mxI = 0; mxCost = aTo[0].rCost; + mxOut = aTo[0].nRow; for(jj=1, pTo=&aTo[1]; jjrCost>mxCost ){ + if( pTo->rCost>mxCost || (pTo->rCost==mxCost && pTo->nRow>mxOut) ){ mxCost = pTo->rCost; + mxOut = pTo->nRow; mxI = jj; } } diff --git a/test/whereJ.test b/test/whereJ.test index 3cdeae890b..5209f16193 100644 --- a/test/whereJ.test +++ b/test/whereJ.test @@ -9,7 +9,7 @@ # #*********************************************************************** # -# This file implements a single regression test for a complex +# This file implements regression tests for a complex # query planning case. # @@ -328,4 +328,48 @@ do_execsql_test whereJ-1.4 { GROUP BY aid; } {/B-TREE/} +############################################################################ +# Ensure that the sorting cost does not swamp the loop costs and cause +# distinctions between individual loop costs to get lost, and hence for +# sub-optimal loops to be chosen. +# +do_execsql_test whereJ-2.1 { + CREATE TABLE tab( + id INTEGER PRIMARY KEY, + minChild INTEGER REFERENCES t1, + maxChild INTEGER REFERENCES t1, + x INTEGER + ); + EXPLAIN QUERY PLAN + SELECT t4.x + FROM tab AS t0, tab AS t1, tab AS t2, tab AS t3, tab AS t4 + WHERE t0.id=0 + AND t1.id BETWEEN t0.minChild AND t0.maxChild + AND t2.id BETWEEN t1.minChild AND t1.maxChild + AND t3.id BETWEEN t2.minChild AND t2.maxChild + AND t4.id BETWEEN t3.minChild AND t3.maxChild + ORDER BY t4.x; +} {~/SCAN/} +do_execsql_test whereJ-2.2 { + EXPLAIN QUERY PLAN + SELECT t4.x + FROM tab AS t0a, tab AS t0b, + tab AS t1a, tab AS t1b, + tab AS t2a, tab AS t2b, + tab AS t3a, tab AS t3b, + tab AS t4 + WHERE 1 + AND t0a.id=1 + AND t1a.id BETWEEN t0a.minChild AND t0a.maxChild + AND t2a.id BETWEEN t1a.minChild AND t1a.maxChild + AND t3a.id BETWEEN t2a.minChild AND t2a.maxChild + AND t0b.id=2 + AND t1b.id BETWEEN t0b.minChild AND t0b.maxChild + AND t2b.id BETWEEN t1b.minChild AND t1b.maxChild + AND t3b.id BETWEEN t2b.minChild AND t2b.maxChild + AND t4.id BETWEEN t3a.minChild AND t3b.maxChild + ORDER BY t4.x; +} {~/SCAN/} + + finish_test From b28ce65f45ef4fabef86e0fc1dc55a211ca8d191 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 Aug 2014 20:25:37 +0000 Subject: [PATCH 05/28] Remove the extraneous debugging printf() from the previous check-in. FossilOrigin-Name: 8f04d2c0084afa6381e78847c9aa296498d448cb --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1e4aea7641..833fa0e284 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sthe\sestimated\scost\sto\sdo\sa\ssort\soverwhelms\sthe\sestimated\scost\sto\sdo\nindividual\stable\slookups,\smake\ssure\sthat\sthe\stable\slookup\scosts\sare\sstill\ntaken\sinto\sconsideration\swhen\sselecting\sthe\slookup\salgorithm. -D 2014-08-07T16:50:00.581 +C Remove\sthe\sextraneous\sdebugging\sprintf()\sfrom\sthe\sprevious\scheck-in. +D 2014-08-07T20:25:37.284 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -296,7 +296,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c 5a099c6d2a1bfbf46bc64979e89330dee3a1f3b9 +F src/where.c 5e4fe929798e75f9d5c6b5b9c545fbc006966c33 F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1185,7 +1185,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 bcf6d775f90f4d1ba018a1b965f2f710df130f01 -R da285ec7c1bbef437389fa691998cee0 +P ec5d84ba69c100d9565425ed74040a49e410ea03 +R 85fb26fb0f7344228780016c4074b483 U drh -Z 083887f7ebac8cb5fec0c6d1cdc7c751 +Z 218dd74820a0f9854df8a36e666b7aca diff --git a/manifest.uuid b/manifest.uuid index 04f61bd019..4e34981ca6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ec5d84ba69c100d9565425ed74040a49e410ea03 \ No newline at end of file +8f04d2c0084afa6381e78847c9aa296498d448cb \ No newline at end of file diff --git a/src/where.c b/src/where.c index ff65cc3b36..ff50f52b45 100644 --- a/src/where.c +++ b/src/where.c @@ -5547,7 +5547,6 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ } if( jj>=nTo ){ /* None of the existing best-so-far paths match the candidate. */ -if( nTo>=mxChoice && rCost==mxCost ) printf("nOut=%d mxOut=%d\n", nOut, mxOut); if( nTo>=mxChoice && (rCost>mxCost || (rCost==mxCost && nOut>=mxOut)) ){ From f2a90306cacfab863d3561024287bcdb88245bcc Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 Aug 2014 20:37:01 +0000 Subject: [PATCH 06/28] Clarify the computation of compatible isOrdered by in the plan solver of the query planner. FossilOrigin-Name: b5e8fd575a80334160de0aac8084ed5cd28816a5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 6 +++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 833fa0e284..a3788a8b47 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sextraneous\sdebugging\sprintf()\sfrom\sthe\sprevious\scheck-in. -D 2014-08-07T20:25:37.284 +C Clarify\sthe\scomputation\sof\scompatible\sisOrdered\sby\sin\sthe\splan\ssolver\sof\nthe\squery\splanner. +D 2014-08-07T20:37:01.008 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -296,7 +296,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c 5e4fe929798e75f9d5c6b5b9c545fbc006966c33 +F src/where.c 4cd4b3622caa81b71ebce8fea8f7811ae052d664 F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1185,7 +1185,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 ec5d84ba69c100d9565425ed74040a49e410ea03 -R 85fb26fb0f7344228780016c4074b483 +P 8f04d2c0084afa6381e78847c9aa296498d448cb +R 444666601d1d38c7f4902aa29891f8d2 U drh -Z 218dd74820a0f9854df8a36e666b7aca +Z fa58944021488910925d31a2d03bf4a8 diff --git a/manifest.uuid b/manifest.uuid index 4e34981ca6..42afde34f7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8f04d2c0084afa6381e78847c9aa296498d448cb \ No newline at end of file +b5e8fd575a80334160de0aac8084ed5cd28816a5 \ No newline at end of file diff --git a/src/where.c b/src/where.c index ff50f52b45..4dd6579e2f 100644 --- a/src/where.c +++ b/src/where.c @@ -5536,10 +5536,14 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** First look for an existing path among best-so-far paths ** that covers the same set of loops and has the same isOrdered ** setting as the current path candidate. + ** + ** The term "((pTo->isOrdered^isOrdered)&0x80)==0" is equivalent + ** to (pTo->isOrdered==(-1))==(isOrdered==(-1))" for the range + ** of legal values for isOrdered, -1..64. */ for(jj=0, pTo=aTo; jjmaskLoop==maskNew - && ((pTo->isOrdered^isOrdered)&80)==0 + && ((pTo->isOrdered^isOrdered)&0x80)==0 ){ testcase( jj==nTo-1 ); break; From 1d8ba02445b68bb2f66a7cffffe52aed3f7508ae Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 8 Aug 2014 12:51:42 +0000 Subject: [PATCH 07/28] Reworking the documentation on integer result codes. This is a comment and documentation change only. There are no changes to code. FossilOrigin-Name: 54f1df7b63166f14b2f0d5955c546820e5cbdec9 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 36 ++++++++++++++---------------------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index be7f215708..71ec5214cd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sthe\sestimated\ssorting\scost\soverwhelms\sthe\sestimated\slookup\scost,\sensure\nthat\slookup\scosts\sare\sstill\staken\sinto\saccount\swhen\sselecting\sa\slookup\nalgorithm. -D 2014-08-07T20:42:33.655 +C Reworking\sthe\sdocumentation\son\sinteger\sresult\scodes.\s\sThis\sis\sa\scomment\nand\sdocumentation\schange\sonly.\s\sThere\sare\sno\schanges\sto\scode. +D 2014-08-08T12:51:42.280 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -224,7 +224,7 @@ F src/resolve.c 5fc110baeacf120a73fe34e103f052632ff11a02 F src/rowset.c a9c9aae3234b44a6d7c6f5a3cadf90dce1e627be F src/select.c 1529c49075464c5a95fde77314073612b1b8d595 F src/shell.c 4af71e7f25af6da6debda87dcbd6be37da710916 -F src/sqlite.h.in 9bbc5815c73b0e77e68b5275481a5e3e7814a804 +F src/sqlite.h.in c9c7328b51a94633c229b435eda8092fcd4e1ea3 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc F src/sqliteInt.h 641f8fbb65ca2084c8df95b525f6f82c7a1e91ae @@ -1185,8 +1185,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 bcf6d775f90f4d1ba018a1b965f2f710df130f01 b5e8fd575a80334160de0aac8084ed5cd28816a5 -R 444666601d1d38c7f4902aa29891f8d2 -T +closed b5e8fd575a80334160de0aac8084ed5cd28816a5 +P 2af630c5720a4d71f22a952af29346a09bd8dfd0 +R b6800f247d253d726e2d1b70eaab6208 U drh -Z f100e3a960f67faf0129a27666ad7927 +Z 92cc627e0fe24841ecb93d0e5157435c diff --git a/manifest.uuid b/manifest.uuid index 421b35294d..3d8e83ed97 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2af630c5720a4d71f22a952af29346a09bd8dfd0 \ No newline at end of file +54f1df7b63166f14b2f0d5955c546820e5cbdec9 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 8470d9e8c0..e3287071b2 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -264,7 +264,7 @@ typedef sqlite_uint64 sqlite3_uint64; ** ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors ** for the [sqlite3] object. -** ^Calls to sqlite3_close() and sqlite3_close_v2() return SQLITE_OK if +** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if ** the [sqlite3] object is successfully destroyed and all associated ** resources are deallocated. ** @@ -285,7 +285,7 @@ typedef sqlite_uint64 sqlite3_uint64; ** with the [sqlite3] object prior to attempting to close the object. ^If ** sqlite3_close_v2() is called on a [database connection] that still has ** outstanding [prepared statements], [BLOB handles], and/or -** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation +** [sqlite3_backup] objects then it returns [SQLITE_OK] but the deallocation ** of resources is deferred until all [prepared statements], [BLOB handles], ** and [sqlite3_backup] objects are also destroyed. ** @@ -381,16 +381,14 @@ int sqlite3_exec( /* ** CAPI3REF: Result Codes -** KEYWORDS: SQLITE_OK {error code} {error codes} -** KEYWORDS: {result code} {result codes} +** KEYWORDS: {result code definitions} ** ** Many SQLite functions return an integer result code from the set shown ** here in order to indicate success or failure. ** ** New error codes may be added in future versions of SQLite. ** -** See also: [SQLITE_IOERR_READ | extended result codes], -** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes]. +** See also: [extended result code definitions] */ #define SQLITE_OK 0 /* Successful result */ /* beginning-of-error-codes */ @@ -428,26 +426,19 @@ int sqlite3_exec( /* ** CAPI3REF: Extended Result Codes -** KEYWORDS: {extended error code} {extended error codes} -** KEYWORDS: {extended result code} {extended result codes} +** KEYWORDS: {extended result code definitions} ** -** In its default configuration, SQLite API routines return one of 26 integer -** [SQLITE_OK | result codes]. However, experience has shown that many of +** In its default configuration, SQLite API routines return one of 30 integer +** [result codes]. However, experience has shown that many of ** these result codes are too coarse-grained. They do not provide as ** much information about problems as programmers might like. In an effort to ** address this, newer versions of SQLite (version 3.3.8 and later) include ** support for additional result codes that provide more detailed information -** about errors. The extended result codes are enabled or disabled +** about errors. These [extended result codes] are enabled or disabled ** on a per database connection basis using the -** [sqlite3_extended_result_codes()] API. -** -** Some of the available extended result codes are listed here. -** One may expect the number of extended result codes will increase -** over time. Software that uses extended result codes should expect -** to see new result codes in future releases of SQLite. -** -** The SQLITE_OK result code will never be extended. It will always -** be exactly zero. +** [sqlite3_extended_result_codes()] API. Or, the extended code for +** the most recent error can be obtained using +** [sqlite3_extended_errcode()]. */ #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) @@ -2523,8 +2514,8 @@ int sqlite3_set_authorizer( ** [sqlite3_set_authorizer | authorizer documentation] for additional ** information. ** -** Note that SQLITE_IGNORE is also used as a [SQLITE_ROLLBACK | return code] -** from the [sqlite3_vtab_on_conflict()] interface. +** Note that SQLITE_IGNORE is also used as a [conflict resolution mode] +** returned from the [sqlite3_vtab_on_conflict()] interface. */ #define SQLITE_DENY 1 /* Abort the SQL statement with an error */ #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ @@ -7364,6 +7355,7 @@ int sqlite3_vtab_on_conflict(sqlite3 *); /* ** CAPI3REF: Conflict resolution modes +** KEYWORDS: {conflict resolution mode} ** ** These constants are returned by [sqlite3_vtab_on_conflict()] to ** inform a [virtual table] implementation what the [ON CONFLICT] mode From 3c19bbea0abf6fa092f5a6a4eeb3a45655b0c5e5 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 8 Aug 2014 15:38:11 +0000 Subject: [PATCH 08/28] The SQLITE_IOERR_BLOCKED extended error code is not longer used, so remove assert() statements and documentation for that error code. Also make other documentation improvements. FossilOrigin-Name: 36b7c5cefcad6bad044806092593c84876fee8bc --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/main.c | 1 - src/os_unix.c | 10 ---------- src/sqlite.h.in | 26 ++++++-------------------- src/vdbeaux.c | 1 - 6 files changed, 16 insertions(+), 42 deletions(-) diff --git a/manifest b/manifest index 71ec5214cd..e81ad39217 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reworking\sthe\sdocumentation\son\sinteger\sresult\scodes.\s\sThis\sis\sa\scomment\nand\sdocumentation\schange\sonly.\s\sThere\sare\sno\schanges\sto\scode. -D 2014-08-08T12:51:42.280 +C The\sSQLITE_IOERR_BLOCKED\sextended\serror\scode\sis\snot\slonger\sused,\sso\sremove\nassert()\sstatements\sand\sdocumentation\sfor\sthat\serror\scode.\s\sAlso\smake\sother\ndocumentation\simprovements. +D 2014-08-08T15:38:11.174 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -189,7 +189,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303 -F src/main.c 6bc7cd1b896a47f2803f69a56737191abf76918a +F src/main.c 5cd4d5037e07af703d12035fdfdaf802abf2b7f8 F src/malloc.c 0203ebce9152c6a0e5de520140b8ba65187350be F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c0c990fcaddff810ea277b4fb5d9138603dd5d4b @@ -207,7 +207,7 @@ F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace F src/os.h 60d419395e32a8029fa380a80a3da2e9030f635e F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c a7baf1b30f3c58ba20b813e01aab23b18ae44f85 +F src/os_unix.c f0a58d439d58b207c06f4a25463113dcba7bd9da F src/os_win.c 3fca1bfdf78338705bf536059a407d0fb04016d5 F src/os_win.h 057344a6720b4c8405d9bd98f58cb37a6ee46c25 F src/pager.c f6bb1fa6cdf2062f2d8aec3e64db302bca519ab8 @@ -224,7 +224,7 @@ F src/resolve.c 5fc110baeacf120a73fe34e103f052632ff11a02 F src/rowset.c a9c9aae3234b44a6d7c6f5a3cadf90dce1e627be F src/select.c 1529c49075464c5a95fde77314073612b1b8d595 F src/shell.c 4af71e7f25af6da6debda87dcbd6be37da710916 -F src/sqlite.h.in c9c7328b51a94633c229b435eda8092fcd4e1ea3 +F src/sqlite.h.in 66a923e0d8a3a771a7050f292cc8028b8c711652 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc F src/sqliteInt.h 641f8fbb65ca2084c8df95b525f6f82c7a1e91ae @@ -287,7 +287,7 @@ F src/vdbe.c cd8d7e3ecd3e0e0684f6bf48469966335c666883 F src/vdbe.h c63fad052c9e7388d551e556e119c0bcf6bebdf8 F src/vdbeInt.h f5513f2b5ac1e2c5128996c7ea23add256a301df F src/vdbeapi.c 24e40422382beb774daab11fe9fe9d37e8a04949 -F src/vdbeaux.c ac063f36c929f88bf6cecdbcc413000e272265bb +F src/vdbeaux.c bbe934b0d472c98f57433829db91fc052e90fa17 F src/vdbeblob.c 9205ce9d3b064d9600f8418a897fc88b5687d9ac F src/vdbemem.c d90a1e8acf8b63dc9d14cbbea12bfec6cec31394 F src/vdbesort.c f7f5563bf7d4695ca8f3203f3bf9de96d04ed0b3 @@ -1185,7 +1185,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 2af630c5720a4d71f22a952af29346a09bd8dfd0 -R b6800f247d253d726e2d1b70eaab6208 +P 54f1df7b63166f14b2f0d5955c546820e5cbdec9 +R 7baa54a57d0f22faa98f7b7348dc4b71 U drh -Z 92cc627e0fe24841ecb93d0e5157435c +Z 8357d07b76c5300f8dd47c47cbfcc4a1 diff --git a/manifest.uuid b/manifest.uuid index 3d8e83ed97..dcae5f47f8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -54f1df7b63166f14b2f0d5955c546820e5cbdec9 \ No newline at end of file +36b7c5cefcad6bad044806092593c84876fee8bc \ No newline at end of file diff --git a/src/main.c b/src/main.c index a95200641f..bf5c38a47e 100644 --- a/src/main.c +++ b/src/main.c @@ -1091,7 +1091,6 @@ const char *sqlite3ErrName(int rc){ case SQLITE_IOERR_UNLOCK: zName = "SQLITE_IOERR_UNLOCK"; break; case SQLITE_IOERR_RDLOCK: zName = "SQLITE_IOERR_RDLOCK"; break; case SQLITE_IOERR_DELETE: zName = "SQLITE_IOERR_DELETE"; break; - case SQLITE_IOERR_BLOCKED: zName = "SQLITE_IOERR_BLOCKED"; break; case SQLITE_IOERR_NOMEM: zName = "SQLITE_IOERR_NOMEM"; break; case SQLITE_IOERR_ACCESS: zName = "SQLITE_IOERR_ACCESS"; break; case SQLITE_IOERR_CHECKRESERVEDLOCK: diff --git a/src/os_unix.c b/src/os_unix.c index 347e82220c..28feb1182c 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -761,16 +761,6 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) { case EPERM: return SQLITE_PERM; - /* EDEADLK is only possible if a call to fcntl(F_SETLKW) is made. And - ** this module never makes such a call. And the code in SQLite itself - ** asserts that SQLITE_IOERR_BLOCKED is never returned. For these reasons - ** this case is also commented out. If the system does set errno to EDEADLK, - ** the default SQLITE_IOERR_XXX code will be returned. */ -#if 0 - case EDEADLK: - return SQLITE_IOERR_BLOCKED; -#endif - #if EOPNOTSUPP!=ENOTSUP case EOPNOTSUPP: /* something went terribly awry, unless during file system support diff --git a/src/sqlite.h.in b/src/sqlite.h.in index e3287071b2..c89cbc1f17 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -671,7 +671,7 @@ struct sqlite3_file { ** locking strategy (for example to use dot-file locks), to inquire ** about the status of a lock, or to break stale locks. The SQLite ** core reserves all opcodes less than 100 for its own use. -** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available. +** A [file control opcodes | list of opcodes] less than 100 is available. ** Applications that define a custom xFileControl method should use opcodes ** greater than 100 to avoid conflicts. VFS implementations should ** return [SQLITE_NOTFOUND] for file control opcodes that they do not @@ -744,6 +744,7 @@ struct sqlite3_io_methods { /* ** CAPI3REF: Standard File Control Opcodes +** KEYWORDS: {file control opcodes} {file control opcode} ** ** These integer constants are opcodes for the xFileControl method ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] @@ -2031,7 +2032,7 @@ int sqlite3_complete16(const void *sql); ** The sqlite3_busy_handler() interface is used to implement ** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout]. ** -** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] +** ^If the busy callback is NULL, then [SQLITE_BUSY] ** is returned immediately upon encountering the lock. ^If the busy callback ** is not NULL, then the callback might be invoked with two arguments. ** @@ -2040,7 +2041,7 @@ int sqlite3_complete16(const void *sql); ** the busy handler callback is the number of times that the busy handler has ** been invoked for the same locking event. ^If the ** busy callback returns 0, then no additional attempts are made to -** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned +** access the database and [SQLITE_BUSY] is returned ** to the application. ** ^If the callback returns non-zero, then another attempt ** is made to access the database and the cycle repeats. @@ -2048,7 +2049,7 @@ int sqlite3_complete16(const void *sql); ** The presence of a busy handler does not guarantee that it will be invoked ** when there is lock contention. ^If SQLite determines that invoking the busy ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] -** or [SQLITE_IOERR_BLOCKED] to the application instead of invoking the +** to the application instead of invoking the ** busy handler. ** Consider a scenario where one process is holding a read lock that ** it is trying to promote to a reserved lock and @@ -2063,21 +2064,6 @@ int sqlite3_complete16(const void *sql); ** ** ^The default busy callback is NULL. ** -** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] -** when SQLite is in the middle of a large transaction where all the -** changes will not fit into the in-memory cache. SQLite will -** already hold a RESERVED lock on the database file, but it needs -** to promote this lock to EXCLUSIVE so that it can spill cache -** pages into the database file without harm to concurrent -** readers. ^If it is unable to promote the lock, then the in-memory -** cache will be left in an inconsistent state and so the error -** code is promoted from the relatively benign [SQLITE_BUSY] to -** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion -** forces an automatic rollback of the changes. See the -** -** CorruptionFollowingBusyError wiki page for a discussion of why -** this is important. -** ** ^(There can only be a single busy handler defined for each ** [database connection]. Setting a new busy handler clears any ** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] @@ -2102,7 +2088,7 @@ int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); ** will sleep multiple times until at least "ms" milliseconds of sleeping ** have accumulated. ^After at least "ms" milliseconds of sleeping, ** the handler returns 0 which causes [sqlite3_step()] to return -** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. +** [SQLITE_BUSY]. ** ** ^Calling this routine with an argument less than or equal to zero ** turns off all busy handlers. diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 240085bfbf..dba11eed67 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -2301,7 +2301,6 @@ int sqlite3VdbeHalt(Vdbe *p){ /* Check for one of the special errors */ mrc = p->rc & 0xff; - assert( p->rc!=SQLITE_IOERR_BLOCKED ); /* This error no longer exists */ isSpecialError = mrc==SQLITE_NOMEM || mrc==SQLITE_IOERR || mrc==SQLITE_INTERRUPT || mrc==SQLITE_FULL; if( isSpecialError ){ From 50ae31e6f678b476a8473df2b707c341029ce6cc Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 8 Aug 2014 16:52:28 +0000 Subject: [PATCH 09/28] Because SQLite internally calculates query plan costs using a logarithmic scale, very large estimated sorting costs can cause all other estimated costs to be rounded down to zero. In these cases break ties between plans with the same total cost by comparing the costs with sorting excluded. This is an alternative fix for the same problem as addressed by [2af630c572]. FossilOrigin-Name: 299b9570279ded7158d22349ef93384286a5c755 --- manifest | 19 +++--- manifest.uuid | 2 +- src/where.c | 158 ++++++++++++++++++++++++++++++++----------------- src/whereInt.h | 1 + 4 files changed, 118 insertions(+), 62 deletions(-) diff --git a/manifest b/manifest index e81ad39217..fe79529289 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sSQLITE_IOERR_BLOCKED\sextended\serror\scode\sis\snot\slonger\sused,\sso\sremove\nassert()\sstatements\sand\sdocumentation\sfor\sthat\serror\scode.\s\sAlso\smake\sother\ndocumentation\simprovements. -D 2014-08-08T15:38:11.174 +C Because\sSQLite\sinternally\scalculates\squery\splan\scosts\susing\sa\slogarithmic\sscale,\svery\slarge\sestimated\ssorting\scosts\scan\scause\sall\sother\sestimated\scosts\sto\sbe\srounded\sdown\sto\szero.\sIn\sthese\scases\sbreak\sties\sbetween\splans\swith\sthe\ssame\stotal\scost\sby\scomparing\sthe\scosts\swith\ssorting\sexcluded.\sThis\sis\san\salternative\sfix\sfor\sthe\ssame\sproblem\sas\saddressed\sby\s[2af630c572]. +D 2014-08-08T16:52:28.259 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -296,8 +296,8 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c 4cd4b3622caa81b71ebce8fea8f7811ae052d664 -F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6 +F src/where.c 012ef65af2ae3e1061aa42bbe4eb549b409ee7e7 +F src/whereInt.h 923820bee9726033a501a08d2fc69b9c1ee4feb3 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6 @@ -1185,7 +1185,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 54f1df7b63166f14b2f0d5955c546820e5cbdec9 -R 7baa54a57d0f22faa98f7b7348dc4b71 -U drh -Z 8357d07b76c5300f8dd47c47cbfcc4a1 +P 36b7c5cefcad6bad044806092593c84876fee8bc +R 97e5eb0484c42f8168a99aaa07e49072 +T *branch * query-planner-fix +T *sym-query-planner-fix * +T -sym-trunk * +U dan +Z 10210eb3192fa621adfca2044e28b578 diff --git a/manifest.uuid b/manifest.uuid index dcae5f47f8..2b491ab1ab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -36b7c5cefcad6bad044806092593c84876fee8bc \ No newline at end of file +299b9570279ded7158d22349ef93384286a5c755 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 4dd6579e2f..ece31542b7 100644 --- a/src/where.c +++ b/src/where.c @@ -5400,6 +5400,45 @@ static const char *wherePathName(WherePath *pPath, int nLoop, WhereLoop *pLast){ } #endif +/* +** Return the cost of sorting nRow rows, assuming that the keys have +** nOrderby columns and that the first nSorted columns are already in +** order. +*/ +static LogEst whereSortingCost( + WhereInfo *pWInfo, + LogEst nRow, + int nOrderBy, + int nSorted +){ + /* TUNING: Estimated cost of a full external sort, where N is + ** the number of rows to sort is: + ** + ** cost = (3.0 * N * log(N)). + ** + ** Or, if the order-by clause has X terms but only the last Y + ** terms are out of order, then block-sorting will reduce the + ** sorting cost to: + ** + ** cost = (3.0 * N * log(N)) * (Y/X) + ** + ** The (Y/X) term is implemented using stack variable rScale + ** below. */ + LogEst rScale, rSortCost; + assert( nOrderBy>0 && 66==sqlite3LogEst(100) ); + rScale = sqlite3LogEst((nOrderBy-nSorted)*100/nOrderBy) - 66; + rSortCost = nRow + estLog(nRow) + rScale + 16; + + /* TUNING: The cost of implementing DISTINCT using a B-TREE is + ** similar but with a larger constant of proportionality. + ** Multiply by an additional factor of 3.0. */ + if( pWInfo->wctrlFlags & WHERE_WANT_DISTINCT ){ + rSortCost += 16; + } + + return rSortCost; +} + /* ** Given the list of WhereLoop objects at pWInfo->pLoops, this routine ** attempts to find the lowest cost path that visits each WhereLoop @@ -5421,10 +5460,8 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ int ii, jj; /* Loop counters */ int mxI = 0; /* Index of next entry to replace */ int nOrderBy; /* Number of ORDER BY clause terms */ - LogEst rCost; /* Cost of a path */ - LogEst nOut; /* Number of outputs */ LogEst mxCost = 0; /* Maximum cost of a set of paths */ - LogEst mxOut = 0; /* nOut value for maximum cost path */ + LogEst mxUnsorted = 0; /* Maximum unsorted cost of a set of path */ int nTo, nFrom; /* Number of valid entries in aTo[] and aFrom[] */ WherePath *aFrom; /* All nFrom paths at the previous level */ WherePath *aTo; /* The nTo best paths at the current level */ @@ -5432,6 +5469,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ WherePath *pTo; /* An element of aTo[] that we are working on */ WhereLoop *pWLoop; /* One of the WhereLoop objects */ WhereLoop **pX; /* Used to divy up the pSpace memory */ + LogEst *aSortCost = 0; /* Sorting and partial sorting costs */ char *pSpace; /* Temporary memory used by this routine */ pParse = pWInfo->pParse; @@ -5444,8 +5482,20 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ assert( nLoop<=pWInfo->pTabList->nSrc ); WHERETRACE(0x002, ("---- begin solver. (nRowEst=%d)\n", nRowEst)); - /* Allocate and initialize space for aTo and aFrom */ + /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this + ** case the purpose of this call is to estimate the number of rows returned + ** by the overall query. Once this estimate has been obtained, the caller + ** will invoke this function a second time, passing the estimate as the + ** nRowEst parameter. */ + if( pWInfo->pOrderBy==0 || nRowEst==0 ){ + nOrderBy = 0; + }else{ + nOrderBy = pWInfo->pOrderBy->nExpr; + } + + /* Allocate and initialize space for aTo, aFrom and aSortCost[] */ ii = (sizeof(WherePath)+sizeof(WhereLoop*)*nLoop)*mxChoice*2; + ii += sizeof(LogEst) * nOrderBy; pSpace = sqlite3DbMallocRaw(db, ii); if( pSpace==0 ) return SQLITE_NOMEM; aTo = (WherePath*)pSpace; @@ -5455,6 +5505,16 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ for(ii=mxChoice*2, pFrom=aTo; ii>0; ii--, pFrom++, pX += nLoop){ pFrom->aLoop = pX; } + if( nOrderBy ){ + /* If there is an ORDER BY clause and it is not being ignored, set up + ** space for the aSortCost[] array. Each element of the aSortCost array + ** is either zero - meaning it has not yet been initialized - or the + ** cost of sorting nRowEst rows of data where the first X terms of + ** the ORDER BY clause are already in order, where X is the array + ** index. */ + aSortCost = (LogEst*)pX; + memset(aSortCost, 0, sizeof(LogEst) * (nOrderBy+1)); + } /* Seed the search with a single WherePath containing zero WhereLoops. ** @@ -5463,15 +5523,15 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** rows, then do not use the automatic index. */ aFrom[0].nRow = MIN(pParse->nQueryLoop, 46); assert( 46==sqlite3LogEst(25) ); nFrom = 1; - - /* Precompute the cost of sorting the final result set, if the caller - ** to sqlite3WhereBegin() was concerned about sorting */ - if( pWInfo->pOrderBy==0 || nRowEst==0 ){ - aFrom[0].isOrdered = 0; - nOrderBy = 0; - }else{ - aFrom[0].isOrdered = nLoop>0 ? -1 : 1; - nOrderBy = pWInfo->pOrderBy->nExpr; + assert( aFrom[0].isOrdered==0 ); + if( nOrderBy ){ + /* If nLoop is zero, then there are no FROM terms in the query. Since + ** in this case the query may return a maximum of one row, the results + ** are already in the requested order. Set isOrdered to nOrderBy to + ** indicate this. Or, if nLoop is greater than zero, set isOrdered to + ** -1, indicating that the result set may or may not be ordered, + ** depending on the loops added to the current plan. */ + aFrom[0].isOrdered = nLoop>0 ? -1 : nOrderBy; } /* Compute successively longer WherePaths using the previous generation @@ -5481,55 +5541,44 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ nTo = 0; for(ii=0, pFrom=aFrom; iipLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ - Bitmask maskNew; - Bitmask revMask = 0; - i8 isOrdered = pFrom->isOrdered; + LogEst nOut; /* Rows visited by (pFrom+pWLoop) */ + LogEst rCost; /* Cost of path (pFrom+pWLoop) */ + LogEst rUnsorted; /* Unsorted cost of (pFrom+pWLoop) */ + i8 isOrdered = pFrom->isOrdered; /* isOrdered for (pFrom+pWLoop) */ + Bitmask maskNew; /* Mask of src visited by (..) */ + Bitmask revMask = 0; /* Mask of rev-order loops for (..) */ + if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue; if( (pWLoop->maskSelf & pFrom->maskLoop)!=0 ) continue; /* At this point, pWLoop is a candidate to be the next loop. ** Compute its cost */ - rCost = sqlite3LogEstAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow); - rCost = sqlite3LogEstAdd(rCost, pFrom->rCost); + rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow); + rUnsorted = sqlite3LogEstAdd(rUnsorted, pFrom->rUnsorted); nOut = pFrom->nRow + pWLoop->nOut; maskNew = pFrom->maskLoop | pWLoop->maskSelf; if( isOrdered<0 ){ isOrdered = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom, pWInfo->wctrlFlags, iLoop, pWLoop, &revMask); - if( isOrdered>=0 && isOrdered0 && 66==sqlite3LogEst(100) ); - rScale = sqlite3LogEst((nOrderBy-isOrdered)*100/nOrderBy) - 66; - rSortCost = nRowEst + estLog(nRowEst) + rScale + 16; - - /* TUNING: The cost of implementing DISTINCT using a B-TREE is - ** similar but with a larger constant of proportionality. - ** Multiply by an additional factor of 3.0. */ - if( pWInfo->wctrlFlags & WHERE_WANT_DISTINCT ){ - rSortCost += 16; - } - WHERETRACE(0x002, - ("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n", - rSortCost, (nOrderBy-isOrdered), nOrderBy, rCost, - sqlite3LogEstAdd(rCost,rSortCost))); - rCost = sqlite3LogEstAdd(rCost, rSortCost); - } }else{ revMask = pFrom->revLoop; } + if( isOrdered>=0 && isOrdered=nTo ){ /* None of the existing best-so-far paths match the candidate. */ if( nTo>=mxChoice - && (rCost>mxCost || (rCost==mxCost && nOut>=mxOut)) + && (rCost>mxCost || (rCost==mxCost && rUnsorted>=mxUnsorted)) ){ /* The current candidate is no better than any of the mxChoice ** paths currently in the best-so-far buffer. So discard @@ -5624,17 +5673,20 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ pTo->revLoop = revMask; pTo->nRow = nOut; pTo->rCost = rCost; + pTo->rUnsorted = rUnsorted; pTo->isOrdered = isOrdered; memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop); pTo->aLoop[iLoop] = pWLoop; if( nTo>=mxChoice ){ mxI = 0; mxCost = aTo[0].rCost; - mxOut = aTo[0].nRow; + mxUnsorted = aTo[0].nRow; for(jj=1, pTo=&aTo[1]; jjrCost>mxCost || (pTo->rCost==mxCost && pTo->nRow>mxOut) ){ + if( pTo->rCost>mxCost + || (pTo->rCost==mxCost && pTo->rUnsorted>mxUnsorted) + ){ mxCost = pTo->rCost; - mxOut = pTo->nRow; + mxUnsorted = pTo->rUnsorted; mxI = jj; } } diff --git a/src/whereInt.h b/src/whereInt.h index 72e7530db9..81f4a03667 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -183,6 +183,7 @@ struct WherePath { Bitmask revLoop; /* aLoop[]s that should be reversed for ORDER BY */ LogEst nRow; /* Estimated number of rows generated by this path */ LogEst rCost; /* Total cost of this path */ + LogEst rUnsorted; /* Total cost of this path ignoring sorting costs */ i8 isOrdered; /* No. of ORDER BY terms satisfied. -1 for unknown */ WhereLoop **aLoop; /* Array of WhereLoop objects implementing this path */ }; From e2c278513d56f27725b0b9118c19aef2fc77e695 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 8 Aug 2014 17:25:33 +0000 Subject: [PATCH 10/28] Fix a buffer overrun in the previous commit. FossilOrigin-Name: 43c59c85436dc8001c81f4aac7f5231b13d741cb --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/where.c | 11 +++++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index fe79529289..3634881a4d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Because\sSQLite\sinternally\scalculates\squery\splan\scosts\susing\sa\slogarithmic\sscale,\svery\slarge\sestimated\ssorting\scosts\scan\scause\sall\sother\sestimated\scosts\sto\sbe\srounded\sdown\sto\szero.\sIn\sthese\scases\sbreak\sties\sbetween\splans\swith\sthe\ssame\stotal\scost\sby\scomparing\sthe\scosts\swith\ssorting\sexcluded.\sThis\sis\san\salternative\sfix\sfor\sthe\ssame\sproblem\sas\saddressed\sby\s[2af630c572]. -D 2014-08-08T16:52:28.259 +C Fix\sa\sbuffer\soverrun\sin\sthe\sprevious\scommit. +D 2014-08-08T17:25:33.967 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -296,7 +296,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c 012ef65af2ae3e1061aa42bbe4eb549b409ee7e7 +F src/where.c ab20f9c24a422ee8900831b343c3d1e5e7aca87b F src/whereInt.h 923820bee9726033a501a08d2fc69b9c1ee4feb3 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1185,10 +1185,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 36b7c5cefcad6bad044806092593c84876fee8bc -R 97e5eb0484c42f8168a99aaa07e49072 -T *branch * query-planner-fix -T *sym-query-planner-fix * -T -sym-trunk * +P 299b9570279ded7158d22349ef93384286a5c755 +R 1f8265817308d29fd5a420f3d8d1525f U dan -Z 10210eb3192fa621adfca2044e28b578 +Z 2535cee87377895ac3ecbfed51081b0b diff --git a/manifest.uuid b/manifest.uuid index 2b491ab1ab..b3ea543e1e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -299b9570279ded7158d22349ef93384286a5c755 \ No newline at end of file +43c59c85436dc8001c81f4aac7f5231b13d741cb \ No newline at end of file diff --git a/src/where.c b/src/where.c index ece31542b7..9c30136e87 100644 --- a/src/where.c +++ b/src/where.c @@ -5471,6 +5471,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ WhereLoop **pX; /* Used to divy up the pSpace memory */ LogEst *aSortCost = 0; /* Sorting and partial sorting costs */ char *pSpace; /* Temporary memory used by this routine */ + int nSpace; /* Bytes of space allocated at pSpace */ pParse = pWInfo->pParse; db = pParse->db; @@ -5494,9 +5495,9 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ } /* Allocate and initialize space for aTo, aFrom and aSortCost[] */ - ii = (sizeof(WherePath)+sizeof(WhereLoop*)*nLoop)*mxChoice*2; - ii += sizeof(LogEst) * nOrderBy; - pSpace = sqlite3DbMallocRaw(db, ii); + nSpace = (sizeof(WherePath)+sizeof(WhereLoop*)*nLoop)*mxChoice*2; + nSpace += sizeof(LogEst) * nOrderBy; + pSpace = sqlite3DbMallocRaw(db, nSpace); if( pSpace==0 ) return SQLITE_NOMEM; aTo = (WherePath*)pSpace; aFrom = aTo+mxChoice; @@ -5513,8 +5514,10 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** the ORDER BY clause are already in order, where X is the array ** index. */ aSortCost = (LogEst*)pX; - memset(aSortCost, 0, sizeof(LogEst) * (nOrderBy+1)); + memset(aSortCost, 0, sizeof(LogEst) * nOrderBy); } + assert( aSortCost==0 || &pSpace[nSpace]==(char*)&aSortCost[nOrderBy] ); + assert( aSortCost!=0 || &pSpace[nSpace]==(char*)pX ); /* Seed the search with a single WherePath containing zero WhereLoops. ** From e8a537eea7a57ad1b42bb75cd7d7a4ee29d7653c Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 8 Aug 2014 18:26:20 +0000 Subject: [PATCH 11/28] Update requirements marks. No changes to code. FossilOrigin-Name: 7556bd9aa5db1b9cd92d0e48effcda9fe96f3128 --- manifest | 17 ++++++++--------- manifest.uuid | 2 +- src/resolve.c | 2 +- test/e_createtable.test | 6 +++--- test/e_expr.test | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index e2bfea2510..61a8d036f4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\sway\sthe\squery\splanner\shandles\ssorting\scosts,\sso\sthat\nvery\slarge\ssorting\scosts\sdo\snot\soverwhelm\sthe\sloop\scosts. -D 2014-08-08T17:49:55.898 +C Update\srequirements\smarks.\s\sNo\schanges\sto\scode. +D 2014-08-08T18:26:20.575 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -220,7 +220,7 @@ F src/pragma.c d10ef67c4de79f78188b965b4b7988aff1d66f2e F src/prepare.c 677521ab7132615a8a26107a1d1c3132f44ae337 F src/printf.c af06f66927919730f03479fed6ae9854f73419f4 F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece -F src/resolve.c 5fc110baeacf120a73fe34e103f052632ff11a02 +F src/resolve.c 44e2e434deaef2b41d4410ede695d867deb89886 F src/rowset.c a9c9aae3234b44a6d7c6f5a3cadf90dce1e627be F src/select.c 1529c49075464c5a95fde77314073612b1b8d595 F src/shell.c 4af71e7f25af6da6debda87dcbd6be37da710916 @@ -442,11 +442,11 @@ F test/descidx3.test 09ddbe3f5295f482d2f8b687cf6db8bad7acd9a2 F test/diskfull.test 106391384780753ea6896b7b4f005d10e9866b6e F test/distinct.test 086e70c765f172e8974e9f83b9ac5ca03c154e77 F test/distinctagg.test 1a6ef9c87a58669438fc771450d7a72577417376 -F test/e_createtable.test ed82efcedc4b3656b27a5fcd12335cdb7e20eeee +F test/e_createtable.test 181653f6f45e3adde73f8686600ce5ad7515466b F test/e_delete.test d5186e2f5478b659f16a2c8b66c09892823e542a F test/e_droptrigger.test 3cd080807622c13e5bbb61fc9a57bd7754da2412 F test/e_dropview.test 0c9f7f60989164a70a67a9d9c26d1083bc808306 -F test/e_expr.test 5c71d183fbf519a4769fd2e2124afdc70b5b1f42 +F test/e_expr.test 5f4528f3dea1c3c401d19ab1d543ec7959e67464 F test/e_fkey.test a1783fe1f759e1990e6a11adfcf0702dac4d0707 F test/e_fts3.test 5c02288842e4f941896fd44afdef564dd5fc1459 F test/e_insert.test 7b2fa9cd1456f83474d6c5d27db3abaeb8be2023 @@ -1185,8 +1185,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 36b7c5cefcad6bad044806092593c84876fee8bc 43c59c85436dc8001c81f4aac7f5231b13d741cb -R 1f8265817308d29fd5a420f3d8d1525f -T +closed 43c59c85436dc8001c81f4aac7f5231b13d741cb +P bdaa6947371a60a31b6a13267b0ba6e46df2a8ce +R 72bdb7fa5001d300e89054929fd995d2 U drh -Z 45c189f6c18b0be836f726dcb23b5c12 +Z 671dba8d2ee0bfa11f311df8108f5873 diff --git a/manifest.uuid b/manifest.uuid index c94e49bd0f..4ea12bd8df 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bdaa6947371a60a31b6a13267b0ba6e46df2a8ce \ No newline at end of file +7556bd9aa5db1b9cd92d0e48effcda9fe96f3128 \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index ce26f00c66..0226d06462 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -354,7 +354,7 @@ static int lookupName( } } if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && HasRowid(pTab) ){ - /* IMP: R-24309-18625 */ + /* IMP: R-51414-32910 */ /* IMP: R-44911-55124 */ iCol = -1; } diff --git a/test/e_createtable.test b/test/e_createtable.test index 42fc017e2a..08f606f65b 100644 --- a/test/e_createtable.test +++ b/test/e_createtable.test @@ -1175,9 +1175,9 @@ do_createtable_tests 4.2 -repair { # EVIDENCE-OF: R-59124-61339 Each row in a table with a primary key must # have a unique combination of values in its primary key columns. # -# EVIDENCE-OF: R-39102-06737 If an INSERT or UPDATE statement attempts -# to modify the table content so that two or more rows feature identical -# primary key values, it is a constraint violation. +# EVIDENCE-OF: R-06471-16287 If an INSERT or UPDATE statement attempts +# to modify the table content so that two or more rows have identical +# primary key values, that is a constraint violation. # drop_all_tables do_execsql_test 4.3.0 { diff --git a/test/e_expr.test b/test/e_expr.test index a743c0c390..60e345441a 100644 --- a/test/e_expr.test +++ b/test/e_expr.test @@ -450,7 +450,7 @@ do_execsql_test e_expr-10.3.4 { SELECT typeof('isn''t') } {text} # containing hexadecimal data and preceded by a single "x" or "X" # character. # -# EVIDENCE-OF: R-39344-59787 For example: X'53514C697465' +# EVIDENCE-OF: R-19836-11244 Example: X'53514C697465' # do_execsql_test e_expr-10.4.1 { SELECT typeof(X'0123456789ABCDEF') } blob do_execsql_test e_expr-10.4.2 { SELECT typeof(x'0123456789ABCDEF') } blob From 91be7dc32078819a51ef024ba548024d55484179 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Aug 2014 13:53:30 +0000 Subject: [PATCH 12/28] Changes that will perhaps enable SQLite to work better on VxWorks. FossilOrigin-Name: de27c742c0dcda20b51339598bf6094a8dcf5fb9 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 19 ++++++++++++------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 61a8d036f4..8b2db457d5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\srequirements\smarks.\s\sNo\schanges\sto\scode. -D 2014-08-08T18:26:20.575 +C Changes\sthat\swill\sperhaps\senable\sSQLite\sto\swork\sbetter\son\sVxWorks. +D 2014-08-11T13:53:30.969 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -207,7 +207,7 @@ F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace F src/os.h 60d419395e32a8029fa380a80a3da2e9030f635e F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c f0a58d439d58b207c06f4a25463113dcba7bd9da +F src/os_unix.c 17e7ab0f9160a78c964d615b15b1658ab2090d42 F src/os_win.c 3fca1bfdf78338705bf536059a407d0fb04016d5 F src/os_win.h 057344a6720b4c8405d9bd98f58cb37a6ee46c25 F src/pager.c f6bb1fa6cdf2062f2d8aec3e64db302bca519ab8 @@ -1185,7 +1185,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 bdaa6947371a60a31b6a13267b0ba6e46df2a8ce -R 72bdb7fa5001d300e89054929fd995d2 +P 7556bd9aa5db1b9cd92d0e48effcda9fe96f3128 +R 07fe7ef4c70cea44dc683244e34b47a2 U drh -Z 671dba8d2ee0bfa11f311df8108f5873 +Z c5b6316215c9354c3470fdb843673338 diff --git a/manifest.uuid b/manifest.uuid index 4ea12bd8df..b1e2fcea2d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7556bd9aa5db1b9cd92d0e48effcda9fe96f3128 \ No newline at end of file +de27c742c0dcda20b51339598bf6094a8dcf5fb9 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 28feb1182c..feb9314167 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -94,11 +94,10 @@ #include #include #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 -#include +# include #endif - -#if SQLITE_ENABLE_LOCKING_STYLE +#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS # include # if OS_VXWORKS # include @@ -318,7 +317,11 @@ static int posixOpen(const char *zFile, int flags, int mode){ ** we are not running as root. */ static int posixFchown(int fd, uid_t uid, gid_t gid){ +#if OS_VXWORKS + return 0; +#else return geteuid() ? 0 : fchown(fd,uid,gid); +#endif } /* Forward reference */ @@ -374,7 +377,7 @@ static struct unix_syscall { { "read", (sqlite3_syscall_ptr)read, 0 }, #define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent) -#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE +#if defined(USE_PREAD) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS) { "pread", (sqlite3_syscall_ptr)pread, 0 }, #else { "pread", (sqlite3_syscall_ptr)0, 0 }, @@ -391,7 +394,7 @@ static struct unix_syscall { { "write", (sqlite3_syscall_ptr)write, 0 }, #define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent) -#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE +#if defined(USE_PREAD) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS) { "pwrite", (sqlite3_syscall_ptr)pwrite, 0 }, #else { "pwrite", (sqlite3_syscall_ptr)0, 0 }, @@ -1295,7 +1298,11 @@ static int findInodeInfo( static int fileHasMoved(unixFile *pFile){ struct stat buf; return pFile->pInode!=0 && +#if OS_VXWORKS + pFile->pId!=pFile->pInode->fileId.Pid; +#else (osStat(pFile->zPath, &buf)!=0 || buf.st_ino!=pFile->pInode->fileId.ino); +#endif } @@ -2438,7 +2445,6 @@ static int semCheckReservedLock(sqlite3_file *id, int *pResOut) { /* Otherwise see if some other process holds it. */ if( !reserved ){ sem_t *pSem = pFile->pInode->pSem; - struct stat statBuf; if( sem_trywait(pSem)==-1 ){ int tErrno = errno; @@ -2491,7 +2497,6 @@ static int semCheckReservedLock(sqlite3_file *id, int *pResOut) { */ static int semLock(sqlite3_file *id, int eFileLock) { unixFile *pFile = (unixFile*)id; - int fd; sem_t *pSem = pFile->pInode->pSem; int rc = SQLITE_OK; From 490fe86f1a74ca24703b7b63a656915d49180b72 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Aug 2014 14:21:32 +0000 Subject: [PATCH 13/28] Fix harmless compiler warnings. FossilOrigin-Name: 52b03f045edf6fc29f9ba9a5cac53a59f0feb0eb --- ext/fts3/fts3_unicode.c | 2 +- ext/misc/fileio.c | 5 +---- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/shell.c | 5 +---- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/ext/fts3/fts3_unicode.c b/ext/fts3/fts3_unicode.c index 57e7a4d3c9..94fc27b5b4 100644 --- a/ext/fts3/fts3_unicode.c +++ b/ext/fts3/fts3_unicode.c @@ -318,7 +318,7 @@ static int unicodeNext( ){ unicode_cursor *pCsr = (unicode_cursor *)pC; unicode_tokenizer *p = ((unicode_tokenizer *)pCsr->base.pTokenizer); - int iCode; + int iCode = 0; char *zOut; const unsigned char *z = &pCsr->aInput[pCsr->iOff]; const unsigned char *zStart = z; diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index f80949bff2..fbe2d030c0 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -61,7 +61,6 @@ static void writefileFunc( ){ FILE *out; const char *z; - int n; sqlite3_int64 rc; const char *zFile; @@ -71,11 +70,9 @@ static void writefileFunc( if( out==0 ) return; z = (const char*)sqlite3_value_blob(argv[1]); if( z==0 ){ - n = 0; rc = 0; }else{ - n = sqlite3_value_bytes(argv[1]); - rc = fwrite(z, 1, n, out); + rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out); } fclose(out); sqlite3_result_int64(context, rc); diff --git a/manifest b/manifest index 8b2db457d5..0039113b6b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sthat\swill\sperhaps\senable\sSQLite\sto\swork\sbetter\son\sVxWorks. -D 2014-08-11T13:53:30.969 +C Fix\sharmless\scompiler\swarnings. +D 2014-08-11T14:21:32.900 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -94,7 +94,7 @@ F ext/fts3/fts3_tokenize_vtab.c 011170fe9eba5ff062f1a31d3188e00267716706 F ext/fts3/fts3_tokenizer.c bbdc731bc91338050675c6d1da9ab82147391e16 F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 -F ext/fts3/fts3_unicode.c e80eef8a11f2020dc9c1eb95c5b405b9012f2fbe +F ext/fts3/fts3_unicode.c a93f5edc0aff44ef8b06d7cb55b52026541ca145 F ext/fts3/fts3_unicode2.c c3d01968d497bd7001e7dc774ba75b372738c057 F ext/fts3/fts3_write.c 8260388626516a7005d06a9dce94f9e55c6c2a41 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 @@ -109,7 +109,7 @@ F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 678056a4bfcd83c4e82dea81d37543cd1d6dbee1 F ext/misc/closure.c 636024302cde41b2bf0c542f81c40c624cfb7012 F ext/misc/compress.c 76e45655f4046e756064ab10c62e18f2eb846b9f -F ext/misc/fileio.c beea82bb5055b6590cffe2d2e6d922905894f691 +F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 136533c53cfce0957f0b48fa11dba27e21c5c01d F ext/misc/ieee754.c b0362167289170627659e84173f5d2e8fee8566e F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 @@ -223,7 +223,7 @@ F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece F src/resolve.c 44e2e434deaef2b41d4410ede695d867deb89886 F src/rowset.c a9c9aae3234b44a6d7c6f5a3cadf90dce1e627be F src/select.c 1529c49075464c5a95fde77314073612b1b8d595 -F src/shell.c 4af71e7f25af6da6debda87dcbd6be37da710916 +F src/shell.c 75bb7bd2c80bb44861598f322a417c4bafe98fd7 F src/sqlite.h.in 66a923e0d8a3a771a7050f292cc8028b8c711652 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc @@ -1185,7 +1185,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 7556bd9aa5db1b9cd92d0e48effcda9fe96f3128 -R 07fe7ef4c70cea44dc683244e34b47a2 +P de27c742c0dcda20b51339598bf6094a8dcf5fb9 +R b22e48d145e96418fb870a5b38049ca4 U drh -Z c5b6316215c9354c3470fdb843673338 +Z 67a30f4afb77c4b424be11cabe826966 diff --git a/manifest.uuid b/manifest.uuid index b1e2fcea2d..832743ad81 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -de27c742c0dcda20b51339598bf6094a8dcf5fb9 \ No newline at end of file +52b03f045edf6fc29f9ba9a5cac53a59f0feb0eb \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index e9ecf194b6..a74dcdb85d 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1694,7 +1694,6 @@ static void writefileFunc( ){ FILE *out; const char *z; - int n; sqlite3_int64 rc; const char *zFile; @@ -1704,11 +1703,9 @@ static void writefileFunc( if( out==0 ) return; z = (const char*)sqlite3_value_blob(argv[1]); if( z==0 ){ - n = 0; rc = 0; }else{ - n = sqlite3_value_bytes(argv[1]); - rc = fwrite(z, 1, n, out); + rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out); } fclose(out); sqlite3_result_int64(context, rc); From ddb17cae386ce5a4ccb920419e9065e7efd65324 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Aug 2014 15:54:11 +0000 Subject: [PATCH 14/28] Updates to evidence marks and requirements. No changes to code. FossilOrigin-Name: 62d38308b519a5362f559b296a0cf1acccf8f673 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/legacy.c | 3 +++ src/main.c | 2 ++ src/resolve.c | 6 +++++- src/sqlite.h.in | 4 ++-- test/func3.test | 24 +++++++++++++++++------- 7 files changed, 40 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 0039113b6b..0781e2b0bb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings. -D 2014-08-11T14:21:32.900 +C Updates\sto\sevidence\smarks\sand\srequirements.\s\sNo\schanges\sto\scode. +D 2014-08-11T15:54:11.189 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -186,10 +186,10 @@ F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/insert.c 991e4964e9295da3993e2c0f81c7faf642371848 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d -F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12 +F src/legacy.c febc2a9e7ad6c1a6191c7b5b9170b325d263f343 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303 -F src/main.c 5cd4d5037e07af703d12035fdfdaf802abf2b7f8 +F src/main.c f86a887bf46a3df0058eae1af991a12f59e5d1ef F src/malloc.c 0203ebce9152c6a0e5de520140b8ba65187350be F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c0c990fcaddff810ea277b4fb5d9138603dd5d4b @@ -220,11 +220,11 @@ F src/pragma.c d10ef67c4de79f78188b965b4b7988aff1d66f2e F src/prepare.c 677521ab7132615a8a26107a1d1c3132f44ae337 F src/printf.c af06f66927919730f03479fed6ae9854f73419f4 F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece -F src/resolve.c 44e2e434deaef2b41d4410ede695d867deb89886 +F src/resolve.c 0ea356d32a5e884add23d1b9b4e8736681dd5697 F src/rowset.c a9c9aae3234b44a6d7c6f5a3cadf90dce1e627be F src/select.c 1529c49075464c5a95fde77314073612b1b8d595 F src/shell.c 75bb7bd2c80bb44861598f322a417c4bafe98fd7 -F src/sqlite.h.in 66a923e0d8a3a771a7050f292cc8028b8c711652 +F src/sqlite.h.in ed9d35990c61f0388ca6405706455c4095310553 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc F src/sqliteInt.h 641f8fbb65ca2084c8df95b525f6f82c7a1e91ae @@ -589,7 +589,7 @@ F test/fts4unicode.test 01ec3fe2a7c3cfff3b4c0581b83caa11b33efa36 F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test ae97561957aba6ca9e3a7b8a13aac41830d701ef F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f -F test/func3.test e82d16b13739f1a0c5efb20048583c79b767b625 +F test/func3.test d202a7606d23f90988a664e88e268aed1087c11c F test/func4.test 6beacdfcb0e18c358e6c2dcacf1b65d1fa80955f F test/func5.test cdd224400bc3e48d891827cc913a57051a426fa4 F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 @@ -1185,7 +1185,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 de27c742c0dcda20b51339598bf6094a8dcf5fb9 -R b22e48d145e96418fb870a5b38049ca4 +P 52b03f045edf6fc29f9ba9a5cac53a59f0feb0eb +R 8606a5b0f380536d0eae822aaf63b02e U drh -Z 67a30f4afb77c4b424be11cabe826966 +Z 15a1264271dfbd20eedca74e84319e8d diff --git a/manifest.uuid b/manifest.uuid index 832743ad81..a43bc55fab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -52b03f045edf6fc29f9ba9a5cac53a59f0feb0eb \ No newline at end of file +62d38308b519a5362f559b296a0cf1acccf8f673 \ No newline at end of file diff --git a/src/legacy.c b/src/legacy.c index 94649ae705..1913f0b5af 100644 --- a/src/legacy.c +++ b/src/legacy.c @@ -96,6 +96,9 @@ int sqlite3_exec( } } if( xCallback(pArg, nCol, azVals, azCols) ){ + /* EVIDENCE-OF: R-38229-40159 If the callback function to + ** sqlite3_exec() returns non-zero, then sqlite3_exec() will + ** return SQLITE_ABORT. */ rc = SQLITE_ABORT; sqlite3VdbeFinalize((Vdbe *)pStmt); pStmt = 0; diff --git a/src/main.c b/src/main.c index bf5c38a47e..d945106d73 100644 --- a/src/main.c +++ b/src/main.c @@ -827,6 +827,8 @@ static int connectionIsBusy(sqlite3 *db){ */ static int sqlite3Close(sqlite3 *db, int forceZombie){ if( !db ){ + /* EVIDENCE-OF: R-63257-11740 Calling sqlite3_close() or + ** sqlite3_close_v2() with a NULL pointer argument is a harmless no-op. */ return SQLITE_OK; } if( !sqlite3SafetyCheckSickOrOk(db) ){ diff --git a/src/resolve.c b/src/resolve.c index 0226d06462..935d311346 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -710,7 +710,11 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to ** likelihood(X, 0.0625). ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is short-hand for - ** likelihood(X,0.0625). */ + ** likelihood(X,0.0625). + ** EVIDENCE-OF: R-36850-34127 The likely(X) function is short-hand for + ** likelihood(X,0.9375). + ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent to + ** likelihood(X,0.9375). */ /* TUNING: unlikely() probability is 0.0625. likely() is 0.9375 */ pExpr->iTable = pDef->zName[0]=='u' ? 62 : 938; } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index c89cbc1f17..230f8d4028 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -272,7 +272,7 @@ typedef sqlite_uint64 sqlite3_uint64; ** statements or unfinished sqlite3_backup objects then sqlite3_close() ** will leave the database connection open and return [SQLITE_BUSY]. ** ^If sqlite3_close_v2() is called with unfinalized prepared statements -** and unfinished sqlite3_backups, then the database connection becomes +** and/or unfinished sqlite3_backups, then the database connection becomes ** an unusable "zombie" which will automatically be deallocated when the ** last prepared statement is finalized or the last sqlite3_backup is ** finished. The sqlite3_close_v2() interface is intended for use with @@ -285,7 +285,7 @@ typedef sqlite_uint64 sqlite3_uint64; ** with the [sqlite3] object prior to attempting to close the object. ^If ** sqlite3_close_v2() is called on a [database connection] that still has ** outstanding [prepared statements], [BLOB handles], and/or -** [sqlite3_backup] objects then it returns [SQLITE_OK] but the deallocation +** [sqlite3_backup] objects then it returns [SQLITE_OK] and the deallocation ** of resources is deferred until all [prepared statements], [BLOB handles], ** and [sqlite3_backup] objects are also destroyed. ** diff --git a/test/func3.test b/test/func3.test index b5a082a4ca..3b1613b56c 100644 --- a/test/func3.test +++ b/test/func3.test @@ -153,28 +153,38 @@ do_test func3-5.39 { db eval {EXPLAIN SELECT unlikely(min(1.0+'2.0',4*11))} } [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}] -do_execsql_test func3-5.40 { + +# EVIDENCE-OF: R-23735-03107 The likely(X) function returns the argument +# X unchanged. +# +do_execsql_test func3-5.50 { SELECT likely(9223372036854775807); } {9223372036854775807} -do_execsql_test func3-5.41 { +do_execsql_test func3-5.51 { SELECT likely(-9223372036854775808); } {-9223372036854775808} -do_execsql_test func3-5.42 { +do_execsql_test func3-5.52 { SELECT likely(14.125); } {14.125} -do_execsql_test func3-5.43 { +do_execsql_test func3-5.53 { SELECT likely(NULL); } {{}} -do_execsql_test func3-5.44 { +do_execsql_test func3-5.54 { SELECT likely('test-string'); } {test-string} -do_execsql_test func3-5.45 { +do_execsql_test func3-5.55 { SELECT quote(likely(x'010203000405')); } {X'010203000405'} -do_test func3-5.49 { + +# EVIDENCE-OF: R-43464-09689 The likely(X) function is a no-op that the +# code generator optimizes away so that it consumes no CPU cycles at +# run-time (that is, during calls to sqlite3_step()). +# +do_test func3-5.59 { db eval {EXPLAIN SELECT likely(min(1.0+'2.0',4*11))} } [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}] + finish_test From 9f959b07de5fcc58f5e9e470d3b741d3c9c9f2c2 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Aug 2014 17:37:27 +0000 Subject: [PATCH 15/28] Add a few more requirements tests. FossilOrigin-Name: b5652439d5d770f0edeb80c8f55fa7cc515482e3 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/main.c | 2 +- test/e_expr.test | 7 +++++++ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 0781e2b0bb..f7cef7e70f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Updates\sto\sevidence\smarks\sand\srequirements.\s\sNo\schanges\sto\scode. -D 2014-08-11T15:54:11.189 +C Add\sa\sfew\smore\srequirements\stests. +D 2014-08-11T17:37:27.183 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -189,7 +189,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c febc2a9e7ad6c1a6191c7b5b9170b325d263f343 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303 -F src/main.c f86a887bf46a3df0058eae1af991a12f59e5d1ef +F src/main.c 1cf92c5c6468f2b6ed99b638706781ccc9c60b42 F src/malloc.c 0203ebce9152c6a0e5de520140b8ba65187350be F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c0c990fcaddff810ea277b4fb5d9138603dd5d4b @@ -446,7 +446,7 @@ F test/e_createtable.test 181653f6f45e3adde73f8686600ce5ad7515466b F test/e_delete.test d5186e2f5478b659f16a2c8b66c09892823e542a F test/e_droptrigger.test 3cd080807622c13e5bbb61fc9a57bd7754da2412 F test/e_dropview.test 0c9f7f60989164a70a67a9d9c26d1083bc808306 -F test/e_expr.test 5f4528f3dea1c3c401d19ab1d543ec7959e67464 +F test/e_expr.test 8f5fdd7261e2d746813b0c6a1c0e34824ad3c5ad F test/e_fkey.test a1783fe1f759e1990e6a11adfcf0702dac4d0707 F test/e_fts3.test 5c02288842e4f941896fd44afdef564dd5fc1459 F test/e_insert.test 7b2fa9cd1456f83474d6c5d27db3abaeb8be2023 @@ -1185,7 +1185,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 52b03f045edf6fc29f9ba9a5cac53a59f0feb0eb -R 8606a5b0f380536d0eae822aaf63b02e +P 62d38308b519a5362f559b296a0cf1acccf8f673 +R 02be8e57f1690f8a6be367e01ea8228e U drh -Z 15a1264271dfbd20eedca74e84319e8d +Z 0a8f19538bd793702427af9b3a2d2400 diff --git a/manifest.uuid b/manifest.uuid index a43bc55fab..f63115401a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -62d38308b519a5362f559b296a0cf1acccf8f673 \ No newline at end of file +b5652439d5d770f0edeb80c8f55fa7cc515482e3 \ No newline at end of file diff --git a/src/main.c b/src/main.c index d945106d73..cea72829df 100644 --- a/src/main.c +++ b/src/main.c @@ -2077,7 +2077,7 @@ static const int aHardLimit[] = { SQLITE_MAX_FUNCTION_ARG, SQLITE_MAX_ATTACHED, SQLITE_MAX_LIKE_PATTERN_LENGTH, - SQLITE_MAX_VARIABLE_NUMBER, + SQLITE_MAX_VARIABLE_NUMBER, /* IMP: R-38091-32352 */ SQLITE_MAX_TRIGGER_DEPTH, }; diff --git a/test/e_expr.test b/test/e_expr.test index 60e345441a..271635f944 100644 --- a/test/e_expr.test +++ b/test/e_expr.test @@ -1596,6 +1596,13 @@ do_expr_test e_expr-30.4.1 { CAST('' AS INTEGER) } integer 0 do_expr_test e_expr-30.4.2 { CAST('not a number' AS INTEGER) } integer 0 do_expr_test e_expr-30.4.3 { CAST('XXI' AS INTEGER) } integer 0 +# EVIDENCE-OF: R-08980-53124 The CAST operator understands decimal +# integers only — conversion of hexadecimal integers stops at +# the "x" in the "0x" prefix of the hexadecimal integer string and thus +# result of the CAST is always zero. +do_expr_test e_expr-30.5.1 { CAST('0x1234' AS INTEGER) } integer 0 +do_expr_test e_expr-30.5.2 { CAST('0X1234' AS INTEGER) } integer 0 + # EVIDENCE-OF: R-02752-50091 A cast of a REAL value into an INTEGER # results in the integer between the REAL value and zero that is closest # to the REAL value. From 91d1249748846897684d285466c809a602ca57dc Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 11 Aug 2014 17:38:38 +0000 Subject: [PATCH 16/28] Fix for #ifdef issue with GetVersionEx in the Win32 VFS. FossilOrigin-Name: 1a0d466dd48163c86de4774035fe4a30c1c55311 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 22 ++++++++++++++++++---- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index f7cef7e70f..8aa852cdf5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\sfew\smore\srequirements\stests. -D 2014-08-11T17:37:27.183 +C Fix\sfor\s#ifdef\sissue\swith\sGetVersionEx\sin\sthe\sWin32\sVFS. +D 2014-08-11T17:38:38.381 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -208,7 +208,7 @@ F src/os.h 60d419395e32a8029fa380a80a3da2e9030f635e F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 17e7ab0f9160a78c964d615b15b1658ab2090d42 -F src/os_win.c 3fca1bfdf78338705bf536059a407d0fb04016d5 +F src/os_win.c d37c3e70e85f9c9bfb2e0dad1b1d8714077fbf8d F src/os_win.h 057344a6720b4c8405d9bd98f58cb37a6ee46c25 F src/pager.c f6bb1fa6cdf2062f2d8aec3e64db302bca519ab8 F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428 @@ -1185,7 +1185,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 62d38308b519a5362f559b296a0cf1acccf8f673 -R 02be8e57f1690f8a6be367e01ea8228e -U drh -Z 0a8f19538bd793702427af9b3a2d2400 +P b5652439d5d770f0edeb80c8f55fa7cc515482e3 +R da55da95544cc788a74ff6acfb8e9051 +U mistachkin +Z 276e7597dfac53b7c7af380d74f891b3 diff --git a/manifest.uuid b/manifest.uuid index f63115401a..2da18ac2ad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b5652439d5d770f0edeb80c8f55fa7cc515482e3 \ No newline at end of file +1a0d466dd48163c86de4774035fe4a30c1c55311 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 5f1d84a3fb..0f391f9521 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -155,7 +155,7 @@ ** [sometimes] not used by the code (e.g. via conditional compilation). */ #ifndef UNUSED_VARIABLE_VALUE -# define UNUSED_VARIABLE_VALUE(x) (void)(x) +# define UNUSED_VARIABLE_VALUE(x) (void)(x) #endif /* @@ -1052,7 +1052,16 @@ static struct win_syscall { ** is really just a macro that uses a compiler intrinsic (e.g. x64). ** So do not try to make this is into a redefinable interface. */ +#if defined(InterlockedCompareExchange) + { "InterlockedCompareExchange", (SYSCALL)0, 0 }, + #define osInterlockedCompareExchange InterlockedCompareExchange +#else + { "InterlockedCompareExchange", (SYSCALL)InterlockedCompareExchange, 0 }, + +#define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG volatile*, \ + LONG,LONG))aSyscall[76].pCurrent) +#endif /* defined(InterlockedCompareExchange) */ }; /* End of the overrideable system calls */ @@ -1312,12 +1321,14 @@ void sqlite3_win32_sleep(DWORD milliseconds){ ** based on the NT kernel. */ int sqlite3_win32_is_nt(void){ +#if defined(SQLITE_WIN32_GETVERSIONEX) && SQLITE_WIN32_GETVERSIONEX if( osInterlockedCompareExchange(&sqlite3_os_type, 0, 0)==0 ){ -#if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WIN8 +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \ + defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WIN8 OSVERSIONINFOW sInfo; sInfo.dwOSVersionInfoSize = sizeof(sInfo); osGetVersionExW(&sInfo); -#else +#elif defined(SQLITE_WIN32_HAS_ANSI) OSVERSIONINFOA sInfo; sInfo.dwOSVersionInfoSize = sizeof(sInfo); osGetVersionExA(&sInfo); @@ -1326,6 +1337,9 @@ int sqlite3_win32_is_nt(void){ (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0); } return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2; +#else + return 1; +#endif } #ifdef SQLITE_WIN32_MALLOC @@ -5482,7 +5496,7 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==76 ); + assert( ArraySize(aSyscall)==77 ); /* get memory map allocation granularity */ memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); From c96c7e3c15195d6bd532a31215a7075db3601b0f Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Aug 2014 17:40:30 +0000 Subject: [PATCH 17/28] Clarify the comment explaining the meaning of the SQLITE_WIN32_GETVERSIONEX macro in the Windows VFS. FossilOrigin-Name: 69714287dbbdbf4ef2a2c5e99ed740ae7d27e051 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 12 ++++-------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 8aa852cdf5..ab513ec919 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sfor\s#ifdef\sissue\swith\sGetVersionEx\sin\sthe\sWin32\sVFS. -D 2014-08-11T17:38:38.381 +C Clarify\sthe\scomment\sexplaining\sthe\smeaning\sof\sthe\sSQLITE_WIN32_GETVERSIONEX\nmacro\sin\sthe\sWindows\sVFS. +D 2014-08-11T17:40:30.234 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -208,7 +208,7 @@ F src/os.h 60d419395e32a8029fa380a80a3da2e9030f635e F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 17e7ab0f9160a78c964d615b15b1658ab2090d42 -F src/os_win.c d37c3e70e85f9c9bfb2e0dad1b1d8714077fbf8d +F src/os_win.c f8affe82a8b28990879a564c84d78c51aab4fa90 F src/os_win.h 057344a6720b4c8405d9bd98f58cb37a6ee46c25 F src/pager.c f6bb1fa6cdf2062f2d8aec3e64db302bca519ab8 F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428 @@ -1185,7 +1185,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 b5652439d5d770f0edeb80c8f55fa7cc515482e3 -R da55da95544cc788a74ff6acfb8e9051 -U mistachkin -Z 276e7597dfac53b7c7af380d74f891b3 +P 1a0d466dd48163c86de4774035fe4a30c1c55311 +R 1a63d8cf8de05d642fa8f087d8e134e9 +U drh +Z 62728ef38d819e244d119f9b4cea00bc diff --git a/manifest.uuid b/manifest.uuid index 2da18ac2ad..c5ea92e575 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1a0d466dd48163c86de4774035fe4a30c1c55311 \ No newline at end of file +69714287dbbdbf4ef2a2c5e99ed740ae7d27e051 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 0f391f9521..0ad87006bf 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -72,18 +72,14 @@ #endif /* -** Check if the GetVersionEx[AW] functions should be considered deprecated -** and avoid using them in that case. It should be noted here that if the -** value of the SQLITE_WIN32_GETVERSIONEX pre-processor macro is zero -** (whether via this block or via being manually specified), that implies -** the underlying operating system will always be based on the Windows NT -** Kernel. +** Check to see if the GetVersionEx[AW] functions are deprecated on the +** target. GetVersionEx[AW] were first deprecated in Win8.1. The */ #ifndef SQLITE_WIN32_GETVERSIONEX # if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WINBLUE -# define SQLITE_WIN32_GETVERSIONEX 0 +# define SQLITE_WIN32_GETVERSIONEX 0 /* GetVersionEx() is deprecated */ # else -# define SQLITE_WIN32_GETVERSIONEX 1 +# define SQLITE_WIN32_GETVERSIONEX 1 /* GetVersionEx() is current */ # endif #endif From e5e20d354d4b07cfcdf3fcc6e7c9eb19dc09a160 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Aug 2014 17:41:53 +0000 Subject: [PATCH 18/28] Further clarification and typo fixes for the previous comment change. FossilOrigin-Name: 87ef9e2f293afd89901fed6be45b0f0052df6846 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ab513ec919..b027033737 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clarify\sthe\scomment\sexplaining\sthe\smeaning\sof\sthe\sSQLITE_WIN32_GETVERSIONEX\nmacro\sin\sthe\sWindows\sVFS. -D 2014-08-11T17:40:30.234 +C Further\sclarification\sand\stypo\sfixes\sfor\sthe\sprevious\scomment\schange. +D 2014-08-11T17:41:53.298 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -208,7 +208,7 @@ F src/os.h 60d419395e32a8029fa380a80a3da2e9030f635e F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 17e7ab0f9160a78c964d615b15b1658ab2090d42 -F src/os_win.c f8affe82a8b28990879a564c84d78c51aab4fa90 +F src/os_win.c 80e4b93cd46b6c4c6375c68faf61ef5cbb0a251a F src/os_win.h 057344a6720b4c8405d9bd98f58cb37a6ee46c25 F src/pager.c f6bb1fa6cdf2062f2d8aec3e64db302bca519ab8 F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428 @@ -1185,7 +1185,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 1a0d466dd48163c86de4774035fe4a30c1c55311 -R 1a63d8cf8de05d642fa8f087d8e134e9 +P 69714287dbbdbf4ef2a2c5e99ed740ae7d27e051 +R b95f2777181460436236a8c0d3ecfe02 U drh -Z 62728ef38d819e244d119f9b4cea00bc +Z 9211ee242443aa3aa6c7a0b0186317b6 diff --git a/manifest.uuid b/manifest.uuid index c5ea92e575..7c1d97ec7a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -69714287dbbdbf4ef2a2c5e99ed740ae7d27e051 \ No newline at end of file +87ef9e2f293afd89901fed6be45b0f0052df6846 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 0ad87006bf..72ffa746d2 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -73,7 +73,7 @@ /* ** Check to see if the GetVersionEx[AW] functions are deprecated on the -** target. GetVersionEx[AW] were first deprecated in Win8.1. The +** target system. GetVersionEx was first deprecated in Win8.1. */ #ifndef SQLITE_WIN32_GETVERSIONEX # if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WINBLUE From f0740a947d44f585ddfdf5e1fc9e0b91eed7e0df Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 11 Aug 2014 17:51:23 +0000 Subject: [PATCH 19/28] Modify GetVersionEx Win32 VFS fix for use with the test suite. FossilOrigin-Name: fd2221768b45d9006bbb2919a4977cf2791826d6 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index b027033737..49af3799cd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\sclarification\sand\stypo\sfixes\sfor\sthe\sprevious\scomment\schange. -D 2014-08-11T17:41:53.298 +C Modify\sGetVersionEx\sWin32\sVFS\sfix\sfor\suse\swith\sthe\stest\ssuite. +D 2014-08-11T17:51:23.396 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -208,7 +208,7 @@ F src/os.h 60d419395e32a8029fa380a80a3da2e9030f635e F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 17e7ab0f9160a78c964d615b15b1658ab2090d42 -F src/os_win.c 80e4b93cd46b6c4c6375c68faf61ef5cbb0a251a +F src/os_win.c e0260a7ba735b4a30b5eccf1a3ace9d6b9718204 F src/os_win.h 057344a6720b4c8405d9bd98f58cb37a6ee46c25 F src/pager.c f6bb1fa6cdf2062f2d8aec3e64db302bca519ab8 F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428 @@ -1185,7 +1185,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 69714287dbbdbf4ef2a2c5e99ed740ae7d27e051 -R b95f2777181460436236a8c0d3ecfe02 -U drh -Z 9211ee242443aa3aa6c7a0b0186317b6 +P 87ef9e2f293afd89901fed6be45b0f0052df6846 +R e0e522e37a27751d028bda9decd5982c +U mistachkin +Z eaad92a848e90bf0dd1d823726bec5b2 diff --git a/manifest.uuid b/manifest.uuid index 7c1d97ec7a..903be479d6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -87ef9e2f293afd89901fed6be45b0f0052df6846 \ No newline at end of file +fd2221768b45d9006bbb2919a4977cf2791826d6 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 72ffa746d2..7d98490ab3 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1333,6 +1333,8 @@ int sqlite3_win32_is_nt(void){ (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0); } return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2; +#elif SQLITE_TEST + return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2; #else return 1; #endif From fcf2a7757e9c95b62783dd231c814723b1e9f73c Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 12 Aug 2014 01:23:07 +0000 Subject: [PATCH 20/28] Fix an assert() statement in the SELECT code generator that was incorrect following an OOM error. FossilOrigin-Name: a179e41e40dba4c19a488985f77777acd27b689d --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 49af3799cd..7a1fd203a6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sGetVersionEx\sWin32\sVFS\sfix\sfor\suse\swith\sthe\stest\ssuite. -D 2014-08-11T17:51:23.396 +C Fix\san\sassert()\sstatement\sin\sthe\sSELECT\scode\sgenerator\sthat\swas\nincorrect\sfollowing\san\sOOM\serror. +D 2014-08-12T01:23:07.241 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -222,7 +222,7 @@ F src/printf.c af06f66927919730f03479fed6ae9854f73419f4 F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece F src/resolve.c 0ea356d32a5e884add23d1b9b4e8736681dd5697 F src/rowset.c a9c9aae3234b44a6d7c6f5a3cadf90dce1e627be -F src/select.c 1529c49075464c5a95fde77314073612b1b8d595 +F src/select.c ea48e891406ccdf748f3eb02893e056d134a0fea F src/shell.c 75bb7bd2c80bb44861598f322a417c4bafe98fd7 F src/sqlite.h.in ed9d35990c61f0388ca6405706455c4095310553 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e @@ -1185,7 +1185,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 87ef9e2f293afd89901fed6be45b0f0052df6846 -R e0e522e37a27751d028bda9decd5982c -U mistachkin -Z eaad92a848e90bf0dd1d823726bec5b2 +P fd2221768b45d9006bbb2919a4977cf2791826d6 +R b6cc4377208f7ed66435f59cee05c5c1 +U drh +Z b6d2068c4cafb891d688b19239264b19 diff --git a/manifest.uuid b/manifest.uuid index 903be479d6..c78b961e4d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fd2221768b45d9006bbb2919a4977cf2791826d6 \ No newline at end of file +a179e41e40dba4c19a488985f77777acd27b689d \ No newline at end of file diff --git a/src/select.c b/src/select.c index f5456c893d..932874d8fe 100644 --- a/src/select.c +++ b/src/select.c @@ -706,7 +706,7 @@ static void selectInnerLoop( sqlite3VdbeChangeP4(v, -1, (const char *)pColl, P4_COLLSEQ); sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); } - assert( sqlite3VdbeCurrentAddr(v)==iJump ); + assert( sqlite3VdbeCurrentAddr(v)==iJump || pParse->db->mallocFailed ); sqlite3VdbeAddOp3(v, OP_Copy, regResult, regPrev, nResultCol-1); break; } From 793bd861fe53ab1e4d6ec105b268ec8bc2d9cae1 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 12 Aug 2014 09:36:08 +0000 Subject: [PATCH 21/28] Add a test to ensure that the problem fixed by [a179e41e40] does not recur. FossilOrigin-Name: 31356f2cae26278660e6bd360ad35e57261d977c --- manifest | 13 +++++++------ manifest.uuid | 2 +- test/mallocL.test | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 test/mallocL.test diff --git a/manifest b/manifest index 7a1fd203a6..ecafc92b44 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sassert()\sstatement\sin\sthe\sSELECT\scode\sgenerator\sthat\swas\nincorrect\sfollowing\san\sOOM\serror. -D 2014-08-12T01:23:07.241 +C Add\sa\stest\sto\sensure\sthat\sthe\sproblem\sfixed\sby\s[a179e41e40]\sdoes\snot\srecur. +D 2014-08-12T09:36:08.939 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -696,6 +696,7 @@ F test/mallocH.test 79b65aed612c9b3ed2dcdaa727c85895fd1bfbdb F test/mallocI.test a88c2b9627c8506bf4703d8397420043a786cdb6 F test/mallocJ.test b5d1839da331d96223e5f458856f8ffe1366f62e F test/mallocK.test 3cff7c0f64735f6883bacdd294e45a6ed5714817 +F test/mallocL.test 252ddc7eb4fbf75364eab17b938816085ff1fc17 F test/malloc_common.tcl 58e54229c4132ef882a11fab6419ec4cd3073589 F test/manydb.test 28385ae2087967aa05c38624cec7d96ec74feb3e F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f @@ -1185,7 +1186,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 fd2221768b45d9006bbb2919a4977cf2791826d6 -R b6cc4377208f7ed66435f59cee05c5c1 -U drh -Z b6d2068c4cafb891d688b19239264b19 +P a179e41e40dba4c19a488985f77777acd27b689d +R fc85cc8ab2d6ab6a18c32ae79fed8287 +U dan +Z 3ae13b57bd03139bdf57f8a227f614c2 diff --git a/manifest.uuid b/manifest.uuid index c78b961e4d..7def0f461f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a179e41e40dba4c19a488985f77777acd27b689d \ No newline at end of file +31356f2cae26278660e6bd360ad35e57261d977c \ No newline at end of file diff --git a/test/mallocL.test b/test/mallocL.test new file mode 100644 index 0000000000..6532ca5e14 --- /dev/null +++ b/test/mallocL.test @@ -0,0 +1,43 @@ +# 2014 August 12 +# +# 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 test script is designed to show that the assert() fix at +# [f1cb48f412] really is required. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +source $testdir/malloc_common.tcl +set testprefix mallocL + +do_test 1.0 { + for {set i 0} {$i < 40} {incr i} { + lappend cols "c$i" + lappend vals $i + } + + execsql "CREATE TABLE t1([join $cols ,])" + execsql "CREATE INDEX i1 ON t1([join $cols ,])" + execsql "INSERT INTO t1 VALUES([join $vals ,])" +} {} + +for {set j 1} {$j < 40} {incr j} { + set ::sql "SELECT DISTINCT [join [lrange $cols 0 $j] ,] FROM t1" + do_faultsim_test 1.$j -faults oom* -body { + execsql $::sql + } -test { + faultsim_test_result [list 0 [lrange $::vals 0 $::j]] + } +} + + +finish_test + From 61ffea549087e3489eb59a80bc152ed6c9c65804 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 12 Aug 2014 12:19:25 +0000 Subject: [PATCH 22/28] Fix typos in the VxWorks code of os_unix.c. FossilOrigin-Name: 19682e8fdc4a3b7884dba3e4387763e435ec16e6 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index ecafc92b44..8868264630 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\sto\sensure\sthat\sthe\sproblem\sfixed\sby\s[a179e41e40]\sdoes\snot\srecur. -D 2014-08-12T09:36:08.939 +C Fix\stypos\sin\sthe\sVxWorks\scode\sof\sos_unix.c. +D 2014-08-12T12:19:25.484 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -207,7 +207,7 @@ F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace F src/os.h 60d419395e32a8029fa380a80a3da2e9030f635e F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 17e7ab0f9160a78c964d615b15b1658ab2090d42 +F src/os_unix.c 119f4f1fb94e74373d53e4946d33e4bc31e91b26 F src/os_win.c e0260a7ba735b4a30b5eccf1a3ace9d6b9718204 F src/os_win.h 057344a6720b4c8405d9bd98f58cb37a6ee46c25 F src/pager.c f6bb1fa6cdf2062f2d8aec3e64db302bca519ab8 @@ -1186,7 +1186,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 a179e41e40dba4c19a488985f77777acd27b689d -R fc85cc8ab2d6ab6a18c32ae79fed8287 -U dan -Z 3ae13b57bd03139bdf57f8a227f614c2 +P 31356f2cae26278660e6bd360ad35e57261d977c +R 3b3addf1401dd2b7481a8053af2cf7fe +U drh +Z 2e7aab7a2b3236c3b8e957ada63bd33e diff --git a/manifest.uuid b/manifest.uuid index 7def0f461f..fda807ffed 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -31356f2cae26278660e6bd360ad35e57261d977c \ No newline at end of file +19682e8fdc4a3b7884dba3e4387763e435ec16e6 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index feb9314167..d8b5db7680 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1296,12 +1296,12 @@ static int findInodeInfo( ** Return TRUE if pFile has been renamed or unlinked since it was first opened. */ static int fileHasMoved(unixFile *pFile){ +#if OS_VXWORKS + return pFile->pInode!=0 && pFile->pId!=pFile->pInode->fileId.pId; +#else struct stat buf; return pFile->pInode!=0 && -#if OS_VXWORKS - pFile->pId!=pFile->pInode->fileId.Pid; -#else - (osStat(pFile->zPath, &buf)!=0 || buf.st_ino!=pFile->pInode->fileId.ino); + (osStat(pFile->zPath, &buf)!=0 || buf.st_ino!=pFile->pInode->fileId.ino); #endif } From 76ccd89d13590fad2c34922753c75efe120c3491 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 12 Aug 2014 13:38:52 +0000 Subject: [PATCH 23/28] If SQLITE_TEST_REALLOC_STRESS is defined, extend the op-code array used by virtual-machine programs by one element at a time, instead of doubling its size with each realloc(). FossilOrigin-Name: 4c291827224b84487a38e7ccba2edabc0f15b5ba --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/vdbeaux.c | 26 +++++++++++++++++++------- test/incrblob_err.test | 1 + test/malloc.test | 1 + test/malloc_common.tcl | 1 + 6 files changed, 33 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 8868264630..60d54fa586 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypos\sin\sthe\sVxWorks\scode\sof\sos_unix.c. -D 2014-08-12T12:19:25.484 +C If\sSQLITE_TEST_REALLOC_STRESS\sis\sdefined,\sextend\sthe\sop-code\sarray\sused\sby\svirtual-machine\sprograms\sby\sone\selement\sat\sa\stime,\sinstead\sof\sdoubling\sits\ssize\swith\seach\srealloc(). +D 2014-08-12T13:38:52.837 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -287,7 +287,7 @@ F src/vdbe.c cd8d7e3ecd3e0e0684f6bf48469966335c666883 F src/vdbe.h c63fad052c9e7388d551e556e119c0bcf6bebdf8 F src/vdbeInt.h f5513f2b5ac1e2c5128996c7ea23add256a301df F src/vdbeapi.c 24e40422382beb774daab11fe9fe9d37e8a04949 -F src/vdbeaux.c bbe934b0d472c98f57433829db91fc052e90fa17 +F src/vdbeaux.c d83ca171e5df5fdea95e61b6e935d78c02b9d982 F src/vdbeblob.c 9205ce9d3b064d9600f8418a897fc88b5687d9ac F src/vdbemem.c d90a1e8acf8b63dc9d14cbbea12bfec6cec31394 F src/vdbesort.c f7f5563bf7d4695ca8f3203f3bf9de96d04ed0b3 @@ -613,7 +613,7 @@ F test/incrblob.test e81846d214f3637622620fbde7cd526781cfe328 F test/incrblob2.test bf4d549aa4a466d7fbe3e3a3693d3861263d5600 F test/incrblob3.test d8d036fde015d4a159cd3cbae9d29003b37227a4 F test/incrblob4.test f26502a5697893e5acea268c910f16478c2f0fab -F test/incrblob_err.test d2562d2771ebffd4b3af89ef64c140dd44371597 +F test/incrblob_err.test af1f12ba60d220c9752073ff2bda2ad59e88960d F test/incrblobfault.test 280474078f6da9e732cd2a215d3d854969014b6e F test/incrvacuum.test d2a6ddf5e429720b5fe502766af747915ccf6c32 F test/incrvacuum2.test 379eeb8740b0ef60c372c439ad4cbea20b34bb9b @@ -676,7 +676,7 @@ F test/lock_common.tcl 0c270b121d40959fa2f3add382200c27045b3d95 F test/lookaside.test 93f07bac140c5bb1d49f3892d2684decafdc7af2 F test/main.test 39c4bb8a157f57298ed1659d6df89d9f35aaf2c8 F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9 -F test/malloc.test fd368e31fe98d4779ed80442f311ed9f03bcd1f7 +F test/malloc.test 4eb83876dfe4915766c179b687b8640437f14abf F test/malloc3.test e3b32c724b5a124b57cb0ed177f675249ad0c66a F test/malloc4.test 957337613002b7058a85116493a262f679f3a261 F test/malloc5.test fafce0aa9157060445cd1a56ad50fc79d82f28c3 @@ -697,7 +697,7 @@ F test/mallocI.test a88c2b9627c8506bf4703d8397420043a786cdb6 F test/mallocJ.test b5d1839da331d96223e5f458856f8ffe1366f62e F test/mallocK.test 3cff7c0f64735f6883bacdd294e45a6ed5714817 F test/mallocL.test 252ddc7eb4fbf75364eab17b938816085ff1fc17 -F test/malloc_common.tcl 58e54229c4132ef882a11fab6419ec4cd3073589 +F test/malloc_common.tcl 3663f9001ce3e29bbaa9677ffe15cd468e3ec7e3 F test/manydb.test 28385ae2087967aa05c38624cec7d96ec74feb3e F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f F test/memdb.test fcb5297b321b562084fc79d64d5a12a1cd2b639b @@ -1186,7 +1186,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 31356f2cae26278660e6bd360ad35e57261d977c -R 3b3addf1401dd2b7481a8053af2cf7fe -U drh -Z 2e7aab7a2b3236c3b8e957ada63bd33e +P 19682e8fdc4a3b7884dba3e4387763e435ec16e6 +R c6c0e18a93e2092b23f216934f9dfe20 +U dan +Z 311715db7c795982c324ba776d8b3111 diff --git a/manifest.uuid b/manifest.uuid index fda807ffed..4788e494de 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -19682e8fdc4a3b7884dba3e4387763e435ec16e6 \ No newline at end of file +4c291827224b84487a38e7ccba2edabc0f15b5ba \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index dba11eed67..62bde7da84 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -84,18 +84,30 @@ void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){ } /* -** Resize the Vdbe.aOp array so that it is at least one op larger than -** it was. +** Resize the Vdbe.aOp array so that it is at least nOp elements larger +** its current size. nOp is guaranteed to be less than or equal to 1024. ** ** If an out-of-memory error occurs while resizing the array, return -** SQLITE_NOMEM. In this case Vdbe.aOp and Vdbe.nOpAlloc remain +** SQLITE_NOMEM. In this case Vdbe.aOp and Parse.nOpAlloc remain ** unchanged (this is so that any opcodes already allocated can be ** correctly deallocated along with the rest of the Vdbe). */ -static int growOpArray(Vdbe *v){ +static int growOpArray(Vdbe *v, int nOp){ VdbeOp *pNew; Parse *p = v->pParse; + + /* If SQLITE_TEST_REALLOC_STRESS is defined and the current op array is + ** less than 512 entries in size, grow the op array by the minimum amount + ** required. Otherwise, allocate either double the current size of the + ** array or 1KB of space, whichever is smaller. */ +#ifdef SQLITE_TEST_REALLOC_STRESS + int nNew = (p->nOpAlloc>=512 ? p->nOpAlloc*2 : p->nOpAlloc+nOp); +#else int nNew = (p->nOpAlloc ? p->nOpAlloc*2 : (int)(1024/sizeof(Op))); + UNUSED_PARAMETER(nOp); +#endif + + assert( nNew>=(p->nOpAlloc+nOp) ); pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op)); if( pNew ){ p->nOpAlloc = sqlite3DbMallocSize(p->db, pNew)/sizeof(Op); @@ -139,7 +151,7 @@ int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){ assert( p->magic==VDBE_MAGIC_INIT ); assert( op>0 && op<0xff ); if( p->pParse->nOpAlloc<=i ){ - if( growOpArray(p) ){ + if( growOpArray(p, 1) ){ return 1; } } @@ -541,7 +553,7 @@ VdbeOp *sqlite3VdbeTakeOpArray(Vdbe *p, int *pnOp, int *pnMaxArg){ int sqlite3VdbeAddOpList(Vdbe *p, int nOp, VdbeOpList const *aOp, int iLineno){ int addr; assert( p->magic==VDBE_MAGIC_INIT ); - if( p->nOp + nOp > p->pParse->nOpAlloc && growOpArray(p) ){ + if( p->nOp + nOp > p->pParse->nOpAlloc && growOpArray(p, nOp) ){ return 0; } addr = p->nOp; @@ -726,7 +738,7 @@ void sqlite3VdbeLinkSubProgram(Vdbe *pVdbe, SubProgram *p){ ** Change the opcode at addr into OP_Noop */ void sqlite3VdbeChangeToNoop(Vdbe *p, int addr){ - if( p->aOp ){ + if( addrnOp ){ VdbeOp *pOp = &p->aOp[addr]; sqlite3 *db = p->db; freeP4(db, pOp->p4type, pOp->p4.p); diff --git a/test/incrblob_err.test b/test/incrblob_err.test index 35d37fee92..a08bea3e4e 100644 --- a/test/incrblob_err.test +++ b/test/incrblob_err.test @@ -14,6 +14,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set ::testprefix incrblob_err ifcapable {!incrblob || !memdebug || !tclvar} { finish_test diff --git a/test/malloc.test b/test/malloc.test index 5d03aa8fe8..4276b58bba 100644 --- a/test/malloc.test +++ b/test/malloc.test @@ -20,6 +20,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set ::testprefix malloc # Only run these tests if memory debugging is turned on. diff --git a/test/malloc_common.tcl b/test/malloc_common.tcl index 160897057a..b586c88d1f 100644 --- a/test/malloc_common.tcl +++ b/test/malloc_common.tcl @@ -409,6 +409,7 @@ proc do_malloc_test {tn args} { if {[string is integer $tn]} { set tn malloc-$tn + catch { set tn $::testprefix-$tn } } if {[info exists ::mallocopts(-start)]} { set start $::mallocopts(-start) From d79d27aedade556f73c98daa1b91b098fa2e1899 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 12 Aug 2014 14:06:13 +0000 Subject: [PATCH 24/28] Run a test with TEST_REALLOC_STRESS and OMIT_LOOKASIDE defined as part of releasetest.tcl on Linux/x86-64. FossilOrigin-Name: a1baf3a7b177728cdfcd6d9345a0d6bf0a8887c0 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/releasetest.tcl | 7 +++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 60d54fa586..90eaca8c90 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sSQLITE_TEST_REALLOC_STRESS\sis\sdefined,\sextend\sthe\sop-code\sarray\sused\sby\svirtual-machine\sprograms\sby\sone\selement\sat\sa\stime,\sinstead\sof\sdoubling\sits\ssize\swith\seach\srealloc(). -D 2014-08-12T13:38:52.837 +C Run\sa\stest\swith\sTEST_REALLOC_STRESS\sand\sOMIT_LOOKASIDE\sdefined\sas\spart\sof\sreleasetest.tcl\son\sLinux/x86-64. +D 2014-08-12T14:06:13.039 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -773,7 +773,7 @@ F test/rdonly.test dd30a4858d8e0fbad2304c2bd74a33d4df36412a F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 F test/releasetest.mk 2eced2f9ae701fd0a29e714a241760503ccba25a -F test/releasetest.tcl 06d289d8255794073a58d2850742f627924545ce +F test/releasetest.tcl a0df0dfc5e3ee83ade87b9cc96db41b52d590b9e F test/resolver01.test 33abf37ff8335e6bf98f2b45a0af3e06996ccd9a F test/rollback.test e9504a009a202c3ed711da2e6879ff60c5a4669c F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 @@ -1186,7 +1186,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 19682e8fdc4a3b7884dba3e4387763e435ec16e6 -R c6c0e18a93e2092b23f216934f9dfe20 +P 4c291827224b84487a38e7ccba2edabc0f15b5ba +R 1284079e980f8822b336e39d17ba6126 U dan -Z 311715db7c795982c324ba776d8b3111 +Z b89cd6a3a53bd57f0d4f91bd2d9a8d6b diff --git a/manifest.uuid b/manifest.uuid index 4788e494de..e3d0ee73b5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4c291827224b84487a38e7ccba2edabc0f15b5ba \ No newline at end of file +a1baf3a7b177728cdfcd6d9345a0d6bf0a8887c0 \ No newline at end of file diff --git a/test/releasetest.tcl b/test/releasetest.tcl index b635061c55..eb2e440013 100644 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -176,6 +176,12 @@ array set ::Configs { -DSQLITE_DISABLE_FTS4_DEFERRED -DSQLITE_ENABLE_RTREE } + + "No-lookaside" { + -DSQLITE_TEST_REALLOC_STRESS=1 + -DSQLITE_OMIT_LOOKASIDE=1 + -DHAVE_USLEEP=1 + } } array set ::Platforms { @@ -188,6 +194,7 @@ array set ::Platforms { "Extra-Robustness" test "Device-Two" test "Ftrapv" test + "No-lookaside" test "Default" "threadtest test" "Device-One" fulltest } From 81e069eee5bd94f57c8756cb4195deebd74763b2 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 12 Aug 2014 14:29:20 +0000 Subject: [PATCH 25/28] Improve the comments associated with SQLITE_TEST_REALLOC_STRESS and add an extra assert() to prove an assumption. FossilOrigin-Name: 35c454616321d480ecbc4efdf6869bbcdf0d3aa2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 15 ++++++++++----- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 90eaca8c90..04ef69ea7d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Run\sa\stest\swith\sTEST_REALLOC_STRESS\sand\sOMIT_LOOKASIDE\sdefined\sas\spart\sof\sreleasetest.tcl\son\sLinux/x86-64. -D 2014-08-12T14:06:13.039 +C Improve\sthe\scomments\sassociated\swith\sSQLITE_TEST_REALLOC_STRESS\sand\sadd\nan\sextra\sassert()\sto\sprove\san\sassumption. +D 2014-08-12T14:29:20.012 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -287,7 +287,7 @@ F src/vdbe.c cd8d7e3ecd3e0e0684f6bf48469966335c666883 F src/vdbe.h c63fad052c9e7388d551e556e119c0bcf6bebdf8 F src/vdbeInt.h f5513f2b5ac1e2c5128996c7ea23add256a301df F src/vdbeapi.c 24e40422382beb774daab11fe9fe9d37e8a04949 -F src/vdbeaux.c d83ca171e5df5fdea95e61b6e935d78c02b9d982 +F src/vdbeaux.c 25d62ef82cf1be2a1255eacac636fa0d943d8b3d F src/vdbeblob.c 9205ce9d3b064d9600f8418a897fc88b5687d9ac F src/vdbemem.c d90a1e8acf8b63dc9d14cbbea12bfec6cec31394 F src/vdbesort.c f7f5563bf7d4695ca8f3203f3bf9de96d04ed0b3 @@ -1186,7 +1186,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 4c291827224b84487a38e7ccba2edabc0f15b5ba -R 1284079e980f8822b336e39d17ba6126 -U dan -Z b89cd6a3a53bd57f0d4f91bd2d9a8d6b +P a1baf3a7b177728cdfcd6d9345a0d6bf0a8887c0 +R f180a595651acb4f056167092db3a8a0 +U drh +Z 0f6249f5f46f843c4c724ed2717337d8 diff --git a/manifest.uuid b/manifest.uuid index e3d0ee73b5..7672239134 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a1baf3a7b177728cdfcd6d9345a0d6bf0a8887c0 \ No newline at end of file +35c454616321d480ecbc4efdf6869bbcdf0d3aa2 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 62bde7da84..fb3f7c3a8c 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -85,7 +85,8 @@ void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){ /* ** Resize the Vdbe.aOp array so that it is at least nOp elements larger -** its current size. nOp is guaranteed to be less than or equal to 1024. +** than its current size. nOp is guaranteed to be less than or equal +** to 1024/sizeof(Op). ** ** If an out-of-memory error occurs while resizing the array, return ** SQLITE_NOMEM. In this case Vdbe.aOp and Parse.nOpAlloc remain @@ -96,10 +97,13 @@ static int growOpArray(Vdbe *v, int nOp){ VdbeOp *pNew; Parse *p = v->pParse; - /* If SQLITE_TEST_REALLOC_STRESS is defined and the current op array is - ** less than 512 entries in size, grow the op array by the minimum amount - ** required. Otherwise, allocate either double the current size of the - ** array or 1KB of space, whichever is smaller. */ + /* The SQLITE_TEST_REALLOC_STRESS compile-time option is designed to force + ** more frequent reallocs and hence provide more opportunities for + ** simulated OOM faults. SQLITE_TEST_REALLOC_STRESS is generally used + ** during testing only. With SQLITE_TEST_REALLOC_STRESS grow the op array + ** by the minimum* amount required until the size reaches 512. Normal + ** operation (without SQLITE_TEST_REALLOC_STRESS) is to double the current + ** size of the op array or add 1KB of space, whichever is smaller. */ #ifdef SQLITE_TEST_REALLOC_STRESS int nNew = (p->nOpAlloc>=512 ? p->nOpAlloc*2 : p->nOpAlloc+nOp); #else @@ -107,6 +111,7 @@ static int growOpArray(Vdbe *v, int nOp){ UNUSED_PARAMETER(nOp); #endif + assert( nOp<=(1024/sizeof(Op)) ); assert( nNew>=(p->nOpAlloc+nOp) ); pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op)); if( pNew ){ From 4eb4fefe2dd2c451b7f6ec8e73cf06ba73a83407 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 12 Aug 2014 16:13:37 +0000 Subject: [PATCH 26/28] Fix compilation issue in the Win32 VFS when manually defining SQLITE_WIN32_NO_ANSI. FossilOrigin-Name: 6715991296886c2a02b9a285a1e61189ad1f79c0 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 04ef69ea7d..353ccbf28d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sthe\scomments\sassociated\swith\sSQLITE_TEST_REALLOC_STRESS\sand\sadd\nan\sextra\sassert()\sto\sprove\san\sassumption. -D 2014-08-12T14:29:20.012 +C Fix\scompilation\sissue\sin\sthe\sWin32\sVFS\swhen\smanually\sdefining\sSQLITE_WIN32_NO_ANSI. +D 2014-08-12T16:13:37.205 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -208,7 +208,7 @@ F src/os.h 60d419395e32a8029fa380a80a3da2e9030f635e F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 119f4f1fb94e74373d53e4946d33e4bc31e91b26 -F src/os_win.c e0260a7ba735b4a30b5eccf1a3ace9d6b9718204 +F src/os_win.c 1c936c7b0659d0eb12b868e2cd710a570e78873e F src/os_win.h 057344a6720b4c8405d9bd98f58cb37a6ee46c25 F src/pager.c f6bb1fa6cdf2062f2d8aec3e64db302bca519ab8 F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428 @@ -1186,7 +1186,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 a1baf3a7b177728cdfcd6d9345a0d6bf0a8887c0 -R f180a595651acb4f056167092db3a8a0 -U drh -Z 0f6249f5f46f843c4c724ed2717337d8 +P 35c454616321d480ecbc4efdf6869bbcdf0d3aa2 +R b496e5fc455ad86aa746ec5d2b99190f +U mistachkin +Z fae056f6598b8171729329dfe1ec3668 diff --git a/manifest.uuid b/manifest.uuid index 7672239134..47dd9e4073 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -35c454616321d480ecbc4efdf6869bbcdf0d3aa2 \ No newline at end of file +6715991296886c2a02b9a285a1e61189ad1f79c0 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 7d98490ab3..f479de3a1b 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1324,13 +1324,15 @@ int sqlite3_win32_is_nt(void){ OSVERSIONINFOW sInfo; sInfo.dwOSVersionInfoSize = sizeof(sInfo); osGetVersionExW(&sInfo); + osInterlockedCompareExchange(&sqlite3_os_type, + (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0); #elif defined(SQLITE_WIN32_HAS_ANSI) OSVERSIONINFOA sInfo; sInfo.dwOSVersionInfoSize = sizeof(sInfo); osGetVersionExA(&sInfo); -#endif osInterlockedCompareExchange(&sqlite3_os_type, (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0); +#endif } return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2; #elif SQLITE_TEST From 299b24688aa73b1921ae09e03d88ad54f6bf86f2 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 12 Aug 2014 20:13:22 +0000 Subject: [PATCH 27/28] Fix where9.test so that it works with the "no_optimization" permutation. FossilOrigin-Name: d46adf9d8f741838b9c30f915231d6a3986c3591 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/where9.test | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 353ccbf28d..8f0418df43 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompilation\sissue\sin\sthe\sWin32\sVFS\swhen\smanually\sdefining\sSQLITE_WIN32_NO_ANSI. -D 2014-08-12T16:13:37.205 +C Fix\swhere9.test\sso\sthat\sit\sworks\swith\sthe\s"no_optimization"\spermutation. +D 2014-08-12T20:13:22.252 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1108,7 +1108,7 @@ F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b F test/where7.test 5a4b0abc207d71da4deecd734ad8579e8dd40aa8 F test/where8.test 806f1dcec4088be2b826b33f757fe6e17c3236a1 F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739 -F test/where9.test 4f3eab951353a3ae164befc521c777dfa903e46c +F test/where9.test 729c3ba9b47e8f9f1aab96bae7dad2a524f1d1a2 F test/whereA.test 4d253178d135ec46d1671e440cd8f2b916aa6e6b F test/whereB.test 0def95db3bdec220a731c7e4bec5930327c1d8c5 F test/whereC.test d6f4ecd4fa2d9429681a5b22a25d2bda8e86ab8a @@ -1186,7 +1186,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 35c454616321d480ecbc4efdf6869bbcdf0d3aa2 -R b496e5fc455ad86aa746ec5d2b99190f -U mistachkin -Z fae056f6598b8171729329dfe1ec3668 +P 6715991296886c2a02b9a285a1e61189ad1f79c0 +R 710d8f15d7faf7079d5cbb8c78df8572 +U dan +Z 37c0d23955a964bca892f819d09ecb97 diff --git a/manifest.uuid b/manifest.uuid index 47dd9e4073..e6ce5cc412 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6715991296886c2a02b9a285a1e61189ad1f79c0 \ No newline at end of file +d46adf9d8f741838b9c30f915231d6a3986c3591 \ No newline at end of file diff --git a/test/where9.test b/test/where9.test index 1c32ff82f7..d073074d43 100644 --- a/test/where9.test +++ b/test/where9.test @@ -781,7 +781,12 @@ do_test where9-6.8.2 { OR (b NOT NULL AND c NOT NULL AND d IS NULL) } } {1 {no query solution}} + +set solution_possible 0 ifcapable stat4||stat3 { + if {[permutation] != "no_optimization"} { set solution_possible 1 } +} +if $solution_possible { # When STAT3 is enabled, the "b NOT NULL" terms get translated # into b>NULL, which can be satified by the index t1b. It is a very # expensive way to do the query, but it works, and so a solution is possible. From bd9455457a5d752399c288f203439f8ce3105c13 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 Aug 2014 11:39:42 +0000 Subject: [PATCH 28/28] Minor change to unixDelete for VxWorks with a DOS filesystem. FossilOrigin-Name: f01d42cc8b00d2b7c4f14defcb05fdc493cf1bfd --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 6 +++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 8f0418df43..2718e0bc1a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\swhere9.test\sso\sthat\sit\sworks\swith\sthe\s"no_optimization"\spermutation. -D 2014-08-12T20:13:22.252 +C Minor\schange\sto\sunixDelete\sfor\sVxWorks\swith\sa\sDOS\sfilesystem. +D 2014-08-13T11:39:42.875 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -207,7 +207,7 @@ F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace F src/os.h 60d419395e32a8029fa380a80a3da2e9030f635e F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 119f4f1fb94e74373d53e4946d33e4bc31e91b26 +F src/os_unix.c bd7df3094a60915c148517504c76df4fca24e542 F src/os_win.c 1c936c7b0659d0eb12b868e2cd710a570e78873e F src/os_win.h 057344a6720b4c8405d9bd98f58cb37a6ee46c25 F src/pager.c f6bb1fa6cdf2062f2d8aec3e64db302bca519ab8 @@ -1186,7 +1186,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 6715991296886c2a02b9a285a1e61189ad1f79c0 -R 710d8f15d7faf7079d5cbb8c78df8572 -U dan -Z 37c0d23955a964bca892f819d09ecb97 +P d46adf9d8f741838b9c30f915231d6a3986c3591 +R 0bcddbf637a1ae28dd56c0df43bdd1a6 +U drh +Z a0023172094bb1f589643de5ae500c6e diff --git a/manifest.uuid b/manifest.uuid index e6ce5cc412..12fc1aa48f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d46adf9d8f741838b9c30f915231d6a3986c3591 \ No newline at end of file +f01d42cc8b00d2b7c4f14defcb05fdc493cf1bfd \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index d8b5db7680..b1a0bedcff 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5883,7 +5883,11 @@ static int unixDelete( UNUSED_PARAMETER(NotUsed); SimulateIOError(return SQLITE_IOERR_DELETE); if( osUnlink(zPath)==(-1) ){ - if( errno==ENOENT ){ + if( errno==ENOENT +#if OS_VXWORKS + || errno==0x380003 +#endif + ){ rc = SQLITE_IOERR_DELETE_NOENT; }else{ rc = unixLogError(SQLITE_IOERR_DELETE, "unlink", zPath);