From f932f7145ede311a79a15197841c2706af5bc71c Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 12 Apr 2015 17:35:27 +0000 Subject: [PATCH 01/28] Fix a problem with a stale Select.pWith pointer when a CTE is used together with a compound query and an ORDER BY clause. FossilOrigin-Name: 9a453f52a2b30595891604ede7d4acf61c2736a1 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 1 + test/with1.test | 6 ++++++ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 7967b35884..5478452884 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sproblems\swhen\sa\squery\shas\sa\sGROUP\sBY\sand\san\sORDER\sBY\sbut\sno\sFROM\sclause. -D 2015-04-12T01:22:04.580 +C Fix\sa\sproblem\swith\sa\sstale\sSelect.pWith\spointer\swhen\sa\sCTE\sis\sused\stogether\nwith\sa\scompound\squery\sand\san\sORDER\sBY\sclause. +D 2015-04-12T17:35:27.113 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +230,7 @@ F src/printf.c 8ae1fa9d30c1200a9268a390ba9e9cea9197b27a F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 41aa91af56d960e9414ce1d7c17cfb68e0d1c6cb F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c c28c52e353287434fac8473e56ee4be848d12c9d +F src/select.c 117e0f9ac9254a6f7472fac5144eba21ba0b2ec1 F src/shell.c 84a1593bd86aaa14f4da8a8f9b16fbc239d262aa F src/sqlite.h.in 278602140d49575e8708e643161f4263e428a02a F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -1184,7 +1184,7 @@ F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c F test/win32heap.test ea19770974795cff26e11575e12d422dbd16893c F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972 F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d -F test/with1.test 9df5cd8a62148b3d9ef8597aea563e3863018bcd +F test/with1.test a86bf7f9288ba759a25ee57221d3bffaca36032a F test/with2.test ee227a663586aa09771cafd4fa269c5217eaf775 F test/withM.test e97f2a8c506ab3ea9eab94e6f6072f6cc924c991 F test/without_rowid1.test 7862e605753c8d25329f665fa09072e842183151 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 79326d6eece926fd1c148b29f0b726208d8b44c0 -R b8a99417c5276ad65ad7b525e5ae16a3 +P e527d96a1e098ade4e9d124b630a8c2ea2ac9b36 +R f469da7981f7e5a80ef00c68d565b4fb U drh -Z ba0a0070ee213de4cf49a8279f3da0ad +Z 637f476e29fbab1d809f7d30402eeba5 diff --git a/manifest.uuid b/manifest.uuid index df7dea6773..cdf3e1131c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e527d96a1e098ade4e9d124b630a8c2ea2ac9b36 \ No newline at end of file +9a453f52a2b30595891604ede7d4acf61c2736a1 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 90aaa842a6..930a099e80 100644 --- a/src/select.c +++ b/src/select.c @@ -3883,6 +3883,7 @@ static int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){ pNew->pOrderBy = 0; p->pPrior = 0; p->pNext = 0; + p->pWith = 0; p->selFlags &= ~SF_Compound; assert( (p->selFlags & SF_Converted)==0 ); p->selFlags |= SF_Converted; diff --git a/test/with1.test b/test/with1.test index ad88a67c22..80892d2642 100644 --- a/test/with1.test +++ b/test/with1.test @@ -843,4 +843,10 @@ do_catchsql_test 13.3 { SELECT i FROM c; } {1 {table c has 1 values for 2 columns}} +# 2015-04-12 +# +do_execsql_test 14.1 { + WITH x AS (SELECT * FROM t) SELECT 0 EXCEPT SELECT 0 ORDER BY 1 COLLATE binary; +} {} + finish_test From 9dc225ef1c4ad4db3e518b1ba6a2ce4480865f98 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 12 Apr 2015 21:28:50 +0000 Subject: [PATCH 02/28] Update the version number to 3.8.10 because of the new sort optimizations from check-in [79326d6eec]. FossilOrigin-Name: bd2cfa1d72368db91064bace298df3d77d9963e6 --- VERSION | 2 +- configure | 18 +++++++++--------- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/VERSION b/VERSION index 203e6d5c9a..d20cc2bf02 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.8.9 +3.8.10 diff --git a/configure b/configure index d259324bdd..9a3d102a8a 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.62 for sqlite 3.8.9. +# Generated by GNU Autoconf 2.62 for sqlite 3.8.10. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. @@ -743,8 +743,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.8.9' -PACKAGE_STRING='sqlite 3.8.9' +PACKAGE_VERSION='3.8.10' +PACKAGE_STRING='sqlite 3.8.10' PACKAGE_BUGREPORT='' # Factoring default headers for most tests. @@ -1481,7 +1481,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.8.9 to adapt to many kinds of systems. +\`configure' configures sqlite 3.8.10 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1546,7 +1546,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.8.9:";; + short | recursive ) echo "Configuration of sqlite 3.8.10:";; esac cat <<\_ACEOF @@ -1660,7 +1660,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.8.9 +sqlite configure 3.8.10 generated by GNU Autoconf 2.62 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1674,7 +1674,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.8.9, which was +It was created by sqlite $as_me 3.8.10, which was generated by GNU Autoconf 2.62. Invocation command line was $ $0 $@ @@ -13953,7 +13953,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.8.9, which was +This file was extended by sqlite $as_me 3.8.10, which was generated by GNU Autoconf 2.62. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14006,7 +14006,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -sqlite config.status 3.8.9 +sqlite config.status 3.8.10 configured by $0, generated by GNU Autoconf 2.62, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/manifest b/manifest index 5478452884..4a1c19474e 100644 --- a/manifest +++ b/manifest @@ -1,12 +1,12 @@ -C Fix\sa\sproblem\swith\sa\sstale\sSelect.pWith\spointer\swhen\sa\sCTE\sis\sused\stogether\nwith\sa\scompound\squery\sand\san\sORDER\sBY\sclause. -D 2015-04-12T17:35:27.113 +C Update\sthe\sversion\snumber\sto\s3.8.10\sbecause\sof\sthe\snew\ssort\soptimizations\sfrom\scheck-in\s[79326d6eec]. +D 2015-04-12T21:28:50.540 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.msc 0078f5781538e07ea38683439f38d5f5ab79ab6e F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866 -F VERSION 319eb1ced4b4d17a67730f2b7b85f15c1346cb60 +F VERSION 2e244662b71e6e68a5c29b014ebc5b7564f4cc5a F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F addopcodes.awk 9eb448a552d5c0185cf62c463f9c173cedae3811 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 @@ -38,7 +38,7 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 42b71ad3fe21c9e88fa59e8458ca1a6bc72eb0c0 F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 8b18c2378805a1d8aaca85d293671f450dd3c723 x +F configure 2ea5f5b58dd106da449ab598ab6e515339d7fa2a x F configure.ac 0b775d383c536bbaafc1e46dd3cbb81a7ea11aeb F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html 334dbf6621b8fb8790297ec1abf3cfa4621709d1 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e527d96a1e098ade4e9d124b630a8c2ea2ac9b36 -R f469da7981f7e5a80ef00c68d565b4fb +P 9a453f52a2b30595891604ede7d4acf61c2736a1 +R 4a2a023e9382e5658a5d290bebd20330 U drh -Z 637f476e29fbab1d809f7d30402eeba5 +Z 3fe3cb8d2199de920836663cd4df5373 diff --git a/manifest.uuid b/manifest.uuid index cdf3e1131c..d0ccf9d2b0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9a453f52a2b30595891604ede7d4acf61c2736a1 \ No newline at end of file +bd2cfa1d72368db91064bace298df3d77d9963e6 \ No newline at end of file From 4a614e9013478d98c1bfe1014f8d7a978c3c378d Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 13 Apr 2015 12:45:58 +0000 Subject: [PATCH 03/28] Remove an unreachable branch from the vdbeSorterCompareInt() routine. FossilOrigin-Name: f666ef06869f4fb655c43daacf5034c17575d951 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbesort.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4a1c19474e..40ccc22361 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sversion\snumber\sto\s3.8.10\sbecause\sof\sthe\snew\ssort\soptimizations\sfrom\scheck-in\s[79326d6eec]. -D 2015-04-12T21:28:50.540 +C Remove\san\sunreachable\sbranch\sfrom\sthe\svdbeSorterCompareInt()\sroutine. +D 2015-04-13T12:45:58.929 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -300,7 +300,7 @@ F src/vdbeapi.c 583d56b129dd27f12bed518270de9ebe521e6a75 F src/vdbeaux.c a20504ae52392459fa08402fda3f195f19d7c79d F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90 F src/vdbemem.c c0dc81285b7571b0a31c40f17846fe2397ec1cd9 -F src/vdbesort.c 5a729a15fb46b1759e13be49a10441172628e593 +F src/vdbesort.c 2e7f683464fd5db3be4beaa1ff2d39e24fcb64b8 F src/vdbetrace.c 7e4222955e07dd707a2f360c0eb73452be1cb010 F src/vtab.c 9ca557215e8591ceb66e0b7c0a579c6df1e54b2d F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9a453f52a2b30595891604ede7d4acf61c2736a1 -R 4a2a023e9382e5658a5d290bebd20330 +P bd2cfa1d72368db91064bace298df3d77d9963e6 +R b8f08800d49097dd7ac4eb07d7ead02a U drh -Z 3fe3cb8d2199de920836663cd4df5373 +Z b7397c89c618aad1f80f88c7af5c800c diff --git a/manifest.uuid b/manifest.uuid index d0ccf9d2b0..660e0945e6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bd2cfa1d72368db91064bace298df3d77d9963e6 \ No newline at end of file +f666ef06869f4fb655c43daacf5034c17575d951 \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index 14803c0b3e..4d9ef90cdc 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -882,10 +882,11 @@ static int vdbeSorterCompareInt( }else{ res = s1 - s2; } + assert( res!=0 ); if( res>0 ){ if( *v1 & 0x80 ) res = -1; - }else if( res<0 ){ + }else{ if( *v2 & 0x80 ) res = +1; } } From ab06b0e5be8377fc510fcde3c2d1de773a97942d Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 13 Apr 2015 14:03:54 +0000 Subject: [PATCH 04/28] Remove an unreachable branch from the VACUUM logic. FossilOrigin-Name: 65ace4b062d9454a296c5a1aa7ea7316b1507ad4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/insert.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 40ccc22361..cf166dc945 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunreachable\sbranch\sfrom\sthe\svdbeSorterCompareInt()\sroutine. -D 2015-04-13T12:45:58.929 +C Remove\san\sunreachable\sbranch\sfrom\sthe\sVACUUM\slogic. +D 2015-04-13T14:03:54.116 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -190,7 +190,7 @@ F src/global.c 4f77cadbc5427d00139ba43d0f3979804cbb700e F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c 1cc9dc4e939b5dd4a74ac4a3222b89e66b074210 +F src/insert.c 305dd3f9539d0affa4bf1c14cc7dffb34867e040 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P bd2cfa1d72368db91064bace298df3d77d9963e6 -R b8f08800d49097dd7ac4eb07d7ead02a +P f666ef06869f4fb655c43daacf5034c17575d951 +R 13ae6f8a2a03926d32aaccc1e7fe4f0a U drh -Z b7397c89c618aad1f80f88c7af5c800c +Z 18a3bd532998a4429c86c5536067680b diff --git a/manifest.uuid b/manifest.uuid index 660e0945e6..c6033ca289 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f666ef06869f4fb655c43daacf5034c17575d951 \ No newline at end of file +65ace4b062d9454a296c5a1aa7ea7316b1507ad4 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index f8ae4d7d3c..fc8895bbd6 100644 --- a/src/insert.c +++ b/src/insert.c @@ -2024,7 +2024,8 @@ static int xferOptimization( int i; for(i=0; inColumn; i++){ char *zColl = pSrcIdx->azColl[i]; - if( zColl && sqlite3_stricmp("BINARY", zColl) ) break; + assert( zColl!=0 ); + if( sqlite3_stricmp("BINARY", zColl) ) break; } if( i==pSrcIdx->nColumn ){ useSeekResult = OPFLAG_USESEEKRESULT; From 481ecd95d0e4386094e1eaa2d1512998d6d7fbdd Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 13 Apr 2015 14:08:27 +0000 Subject: [PATCH 05/28] Test that if the definition of a collation sequence is changed and VACUUM run, the new database contains records sorted in the (new) correct order. FossilOrigin-Name: ce6eaac10a190b26b87bfe75918e2ef58fd7a3f9 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/vacuum2.test | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index cf166dc945..1207568ae7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunreachable\sbranch\sfrom\sthe\sVACUUM\slogic. -D 2015-04-13T14:03:54.116 +C Test\sthat\sif\sthe\sdefinition\sof\sa\scollation\ssequence\sis\schanged\sand\sVACUUM\srun,\sthe\snew\sdatabase\scontains\srecords\ssorted\sin\sthe\s(new)\scorrect\sorder. +D 2015-04-13T14:08:27.490 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1107,7 +1107,7 @@ F test/uri.test 23662b7b61958b0f0e47082de7d06341ccf85d5b F test/userauth01.test e740a2697a7b40d7c5003a7d7edaee16acd349a9 F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d -F test/vacuum2.test af432e6e3bfc0ea20a80cb86a03c7d9876d38324 +F test/vacuum2.test aa048abee196c16c9ba308465494009057b79f9b F test/vacuum3.test 77ecdd54592b45a0bcb133339f99f1ae0ae94d0d F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f666ef06869f4fb655c43daacf5034c17575d951 -R 13ae6f8a2a03926d32aaccc1e7fe4f0a -U drh -Z 18a3bd532998a4429c86c5536067680b +P 65ace4b062d9454a296c5a1aa7ea7316b1507ad4 +R 10297fb20a52d4dc7c571adcebaddc36 +U dan +Z 0a6c3062817beaba9c93ab9bd5dcc5e3 diff --git a/manifest.uuid b/manifest.uuid index c6033ca289..fcea990f8f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -65ace4b062d9454a296c5a1aa7ea7316b1507ad4 \ No newline at end of file +ce6eaac10a190b26b87bfe75918e2ef58fd7a3f9 \ No newline at end of file diff --git a/test/vacuum2.test b/test/vacuum2.test index b3bfab3022..0350c8ec42 100644 --- a/test/vacuum2.test +++ b/test/vacuum2.test @@ -15,6 +15,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix vacuum2 # Do not use a codec for tests in this file, as the database file is # manipulated directly using tcl scripts (using the [hexio_write] command). @@ -227,5 +228,24 @@ do_test vacuum2-5.4 { lappend res2 $res } {1 2 3 4 5 6 7 8 9 10 {1 {cannot VACUUM - SQL statements in progress}}} +#------------------------------------------------------------------------- +# Check that if the definition of a collation sequence is changed and +# VACUUM run, records are store in the (new) correct order following the +# VACUUM. Even if the modified collation is attached to a PK of a WITHOUT +# ROWID table. + +proc cmp {lhs rhs} { string compare $lhs $rhs } +db collate cmp cmp +do_execsql_test 6.0 { + CREATE TABLE t6(x PRIMARY KEY COLLATE cmp, y) WITHOUT ROWID; + CREATE INDEX t6y ON t6(y); + INSERT INTO t6 VALUES('i', 'one'); + INSERT INTO t6 VALUES('ii', 'one'); + INSERT INTO t6 VALUES('iii', 'one'); +} +integrity_check 6.1 +proc cmp {lhs rhs} { string compare $rhs $lhs } +do_execsql_test 6.2 VACUUM +integrity_check 6.3 finish_test From c01501a3861944d8027a5e620e420238db9bcc2c Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 13 Apr 2015 14:44:01 +0000 Subject: [PATCH 06/28] Remove a faulty assert() from the btree balancing logic. FossilOrigin-Name: d06669d968c8f6af8799fbfeabadaab68b9b8db8 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/btree.c | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 1207568ae7..bddc4cadc4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Test\sthat\sif\sthe\sdefinition\sof\sa\scollation\ssequence\sis\schanged\sand\sVACUUM\srun,\sthe\snew\sdatabase\scontains\srecords\ssorted\sin\sthe\s(new)\scorrect\sorder. -D 2015-04-13T14:08:27.490 +C Remove\sa\sfaulty\sassert()\sfrom\sthe\sbtree\sbalancing\slogic. +D 2015-04-13T14:44:01.870 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -173,7 +173,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c ff743689c4d6c5cb55ad42ed9d174b2b3e71f1e3 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c 2caf598165f3608fde8abac2b243826616ce54b7 +F src/btree.c 67648f6532c2da79d3b3fb6853aa1a0c3ba0e1ad F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4 F src/build.c fa4795bc795077388aa4e746e1b25ef97bc10489 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 65ace4b062d9454a296c5a1aa7ea7316b1507ad4 -R 10297fb20a52d4dc7c571adcebaddc36 -U dan -Z 0a6c3062817beaba9c93ab9bd5dcc5e3 +P ce6eaac10a190b26b87bfe75918e2ef58fd7a3f9 +R bac46adba95b910001781f1715fe4531 +U drh +Z 344080508147bb8eb54111c6b1e074c7 diff --git a/manifest.uuid b/manifest.uuid index fcea990f8f..3daf8bbf88 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ce6eaac10a190b26b87bfe75918e2ef58fd7a3f9 \ No newline at end of file +d06669d968c8f6af8799fbfeabadaab68b9b8db8 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 789796d55a..9faf624235 100644 --- a/src/btree.c +++ b/src/btree.c @@ -6735,7 +6735,6 @@ static int balance_nonroot( }else if( iParentIdx==i ){ nxDiv = i-2+bBulk; }else{ - assert( bBulk==0 ); nxDiv = iParentIdx-1; } i = 2-bBulk; From 1fe0af200db60257a744104e7f264e8fd29729ac Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 13 Apr 2015 17:43:43 +0000 Subject: [PATCH 07/28] Add a comment to wal.c to explain why a race condition is safe. FossilOrigin-Name: bc33af866403c23d548dd4705675315810d52d7f --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/wal.c | 8 ++++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index bddc4cadc4..12b1e15e95 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sa\sfaulty\sassert()\sfrom\sthe\sbtree\sbalancing\slogic. -D 2015-04-13T14:44:01.870 +C Add\sa\scomment\sto\swal.c\sto\sexplain\swhy\sa\srace\scondition\sis\ssafe. +D 2015-04-13T17:43:43.335 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -304,7 +304,7 @@ F src/vdbesort.c 2e7f683464fd5db3be4beaa1ff2d39e24fcb64b8 F src/vdbetrace.c 7e4222955e07dd707a2f360c0eb73452be1cb010 F src/vtab.c 9ca557215e8591ceb66e0b7c0a579c6df1e54b2d F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 878c8e1a51cb2ec45c395d26b7d5cd9e1a098e4a +F src/wal.c 753995db83247f20361a8e8a874990b21a75abd9 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 F src/where.c 9952e4749f481707595692f2f13d3ce3b64ffdc8 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ce6eaac10a190b26b87bfe75918e2ef58fd7a3f9 -R bac46adba95b910001781f1715fe4531 -U drh -Z 344080508147bb8eb54111c6b1e074c7 +P d06669d968c8f6af8799fbfeabadaab68b9b8db8 +R 90c9a3885d268edb8b0fe9dee7687f08 +U dan +Z a7fde54970dc241049366741c468ca23 diff --git a/manifest.uuid b/manifest.uuid index 3daf8bbf88..c0be3fa5e7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d06669d968c8f6af8799fbfeabadaab68b9b8db8 \ No newline at end of file +bc33af866403c23d548dd4705675315810d52d7f \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index 558adbcad2..df3c8cb94e 100644 --- a/src/wal.c +++ b/src/wal.c @@ -1730,6 +1730,14 @@ static int walCheckpoint( mxSafeFrame = pWal->hdr.mxFrame; mxPage = pWal->hdr.nPage; for(i=1; iaReadMark[i]; if( mxSafeFrame>y ){ assert( y<=pWal->hdr.mxFrame ); From 27a348c7a0f26ea3037d0e8256f73a62dab84d31 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 13 Apr 2015 19:14:06 +0000 Subject: [PATCH 08/28] Remove the out2-prerelease VDBE opcode property and its associated code, for a 0.5% performance improvement. FossilOrigin-Name: e29c7f2c910dac07f0f92dfef5e0e743141954eb --- manifest | 16 ++++----- manifest.uuid | 2 +- mkopcodeh.awk | 27 ++++++-------- src/vdbe.c | 97 +++++++++++++++++++++++++++++++-------------------- 4 files changed, 79 insertions(+), 63 deletions(-) diff --git a/manifest b/manifest index 12b1e15e95..acc5ea4f99 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\scomment\sto\swal.c\sto\sexplain\swhy\sa\srace\scondition\sis\ssafe. -D 2015-04-13T17:43:43.335 +C Remove\sthe\sout2-prerelease\sVDBE\sopcode\sproperty\sand\sits\sassociated\scode,\nfor\sa\s0.5%\sperformance\simprovement. +D 2015-04-13T19:14:06.003 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -154,7 +154,7 @@ F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 F main.mk ddffac494a82d42772df9fe30d3a78acf4f7cb41 F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea -F mkopcodeh.awk c6b3fa301db6ef7ac916b14c60868aeaec1337b5 +F mkopcodeh.awk d5e22023b5238985bb54a72d33e0ac71fe4f8a32 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -293,7 +293,7 @@ F src/update.c 3c4ecc282accf12d39edb8d524cf089645e55a13 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c 98a7627ca48ad3265b6940915a1d08355eb3fc7e F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c c4bd96912f8837777bfe5762d310767ed628b442 +F src/vdbe.c 584abb81e4abf9dd51a9a2e71f680289bd0c019b F src/vdbe.h 7e538ecf47dccb307ea2d087c3ddc2dd8d70e79d F src/vdbeInt.h 9cbaa84f53ddd2d09a0cf61a94337a3a035d08a0 F src/vdbeapi.c 583d56b129dd27f12bed518270de9ebe521e6a75 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d06669d968c8f6af8799fbfeabadaab68b9b8db8 -R 90c9a3885d268edb8b0fe9dee7687f08 -U dan -Z a7fde54970dc241049366741c468ca23 +P bc33af866403c23d548dd4705675315810d52d7f +R 6ac0695a2f1b9d518c2805dcc9a01314 +U drh +Z 453362d5fdffab6ea02dce6dd25e18dd diff --git a/manifest.uuid b/manifest.uuid index c0be3fa5e7..5adaa0dcc9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bc33af866403c23d548dd4705675315810d52d7f \ No newline at end of file +e29c7f2c910dac07f0f92dfef5e0e743141954eb \ No newline at end of file diff --git a/mkopcodeh.awk b/mkopcodeh.awk index babfdc68d3..94db75e607 100644 --- a/mkopcodeh.awk +++ b/mkopcodeh.awk @@ -72,7 +72,6 @@ sub("\r","",name) op[name] = -1 # op[x] holds the numeric value for OP symbol x jump[name] = 0 - out2_prerelease[name] = 0 in1[name] = 0 in2[name] = 0 in3[name] = 0 @@ -92,8 +91,6 @@ sub(",","",x) if(x=="jump"){ jump[name] = 1 - }else if(x=="out2-prerelease"){ - out2_prerelease[name] = 1 }else if(x=="in1"){ in1[name] = 1 }else if(x=="in2"){ @@ -194,13 +191,12 @@ END { name = def[i] a0 = a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0 if( jump[name] ) a0 = 1; - if( out2_prerelease[name] ) a1 = 2; - if( in1[name] ) a2 = 4; - if( in2[name] ) a3 = 8; - if( in3[name] ) a4 = 16; - if( out2[name] ) a5 = 32; - if( out3[name] ) a6 = 64; - bv[i] = a0+a1+a2+a3+a4+a5+a6+a7; + if( in1[name] ) a2 = 2; + if( in2[name] ) a3 = 4; + if( in3[name] ) a4 = 8; + if( out2[name] ) a5 = 16; + if( out3[name] ) a6 = 32; + bv[i] = a0+a1+a2+a3+a4+a5+a6; } print "\n" print "/* Properties such as \"out2\" or \"jump\" that are specified in" @@ -208,12 +204,11 @@ END { print "** are encoded into bitvectors as follows:" print "*/" print "#define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */" - print "#define OPFLG_OUT2_PRERELEASE 0x0002 /* out2-prerelease: */" - print "#define OPFLG_IN1 0x0004 /* in1: P1 is an input */" - print "#define OPFLG_IN2 0x0008 /* in2: P2 is an input */" - print "#define OPFLG_IN3 0x0010 /* in3: P3 is an input */" - print "#define OPFLG_OUT2 0x0020 /* out2: P2 is an output */" - print "#define OPFLG_OUT3 0x0040 /* out3: P3 is an output */" + print "#define OPFLG_IN1 0x0002 /* in1: P1 is an input */" + print "#define OPFLG_IN2 0x0004 /* in2: P2 is an input */" + print "#define OPFLG_IN3 0x0008 /* in3: P3 is an input */" + print "#define OPFLG_OUT2 0x0010 /* out2: P2 is an output */" + print "#define OPFLG_OUT3 0x0020 /* out3: P3 is an output */" print "#define OPFLG_INITIALIZER {\\" for(i=0; i<=max; i++){ if( i%8==0 ) printf("/* %3d */",i) diff --git a/src/vdbe.c b/src/vdbe.c index 22b313756c..8492f8cc09 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -514,6 +514,21 @@ static int checkSavepointCount(sqlite3 *db){ } #endif +/* +** Return the register of pOp->p2 after first preparing it to be +** overwritten with an integer value. +*/ +static Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){ + Mem *pOut; + assert( pOp->p2>0 ); + assert( pOp->p2<=(p->nMem-p->nCursor) ); + pOut = &p->aMem[pOp->p2]; + memAboutToChange(p, pOut); + if( VdbeMemDynamic(pOut) ) sqlite3VdbeMemSetNull(pOut); + pOut->flags = MEM_Int; + return pOut; +} + /* ** Execute as much of a VDBE program as we can. @@ -633,23 +648,9 @@ int sqlite3VdbeExec( } #endif - /* On any opcode with the "out2-prerelease" tag, free any - ** external allocations out of mem[p2] and set mem[p2] to be - ** an undefined integer. Opcodes will either fill in the integer - ** value or convert mem[p2] to a different type. - */ - assert( pOp->opflags==sqlite3OpcodeProperty[pOp->opcode] ); - if( pOp->opflags & OPFLG_OUT2_PRERELEASE ){ - assert( pOp->p2>0 ); - assert( pOp->p2<=(p->nMem-p->nCursor) ); - pOut = &aMem[pOp->p2]; - memAboutToChange(p, pOut); - if( VdbeMemDynamic(pOut) ) sqlite3VdbeMemSetNull(pOut); - pOut->flags = MEM_Int; - } - /* Sanity checking on other operands */ #ifdef SQLITE_DEBUG + assert( pOp->opflags==sqlite3OpcodeProperty[pOp->opcode] ); if( (pOp->opflags & OPFLG_IN1)!=0 ){ assert( pOp->p1>0 ); assert( pOp->p1<=(p->nMem-p->nCursor) ); @@ -705,7 +706,7 @@ int sqlite3VdbeExec( ** ** Other keywords in the comment that follows each case are used to ** construct the OPFLG_INITIALIZER value that initializes opcodeProperty[]. -** Keywords include: in1, in2, in3, out2_prerelease, out2, out3. See +** Keywords include: in1, in2, in3, out2, out3. See ** the mkopcodeh.awk script for additional information. ** ** Documentation about VDBE opcodes is generated by scanning this file @@ -979,7 +980,8 @@ case OP_Halt: { ** ** The 32-bit integer value P1 is written into register P2. */ -case OP_Integer: { /* out2-prerelease */ +case OP_Integer: { /* out2 */ + pOut = out2Prerelease(p, pOp); pOut->u.i = pOp->p1; break; } @@ -990,7 +992,8 @@ case OP_Integer: { /* out2-prerelease */ ** P4 is a pointer to a 64-bit integer value. ** Write that value into register P2. */ -case OP_Int64: { /* out2-prerelease */ +case OP_Int64: { /* out2 */ + pOut = out2Prerelease(p, pOp); assert( pOp->p4.pI64!=0 ); pOut->u.i = *pOp->p4.pI64; break; @@ -1003,7 +1006,8 @@ case OP_Int64: { /* out2-prerelease */ ** P4 is a pointer to a 64-bit floating point value. ** Write that value into register P2. */ -case OP_Real: { /* same as TK_FLOAT, out2-prerelease */ +case OP_Real: { /* same as TK_FLOAT, out2 */ + pOut = out2Prerelease(p, pOp); pOut->flags = MEM_Real; assert( !sqlite3IsNaN(*pOp->p4.pReal) ); pOut->u.r = *pOp->p4.pReal; @@ -1019,8 +1023,9 @@ case OP_Real: { /* same as TK_FLOAT, out2-prerelease */ ** this transformation, the length of string P4 is computed and stored ** as the P1 parameter. */ -case OP_String8: { /* same as TK_STRING, out2-prerelease */ +case OP_String8: { /* same as TK_STRING, out2 */ assert( pOp->p4.z!=0 ); + pOut = out2Prerelease(p, pOp); pOp->opcode = OP_String; pOp->p1 = sqlite3Strlen30(pOp->p4.z); @@ -1057,8 +1062,9 @@ case OP_String8: { /* same as TK_STRING, out2-prerelease */ ** the same sequence of bytes, it is merely interpreted as a BLOB instead ** of a string, as if it had been CAST. */ -case OP_String: { /* out2-prerelease */ +case OP_String: { /* out2 */ assert( pOp->p4.z!=0 ); + pOut = out2Prerelease(p, pOp); pOut->flags = MEM_Str|MEM_Static|MEM_Term; pOut->z = pOp->p4.z; pOut->n = pOp->p1; @@ -1086,9 +1092,10 @@ case OP_String: { /* out2-prerelease */ ** NULL values will not compare equal even if SQLITE_NULLEQ is set on ** OP_Ne or OP_Eq. */ -case OP_Null: { /* out2-prerelease */ +case OP_Null: { /* out2 */ int cnt; u16 nullFlag; + pOut = out2Prerelease(p, pOp); cnt = pOp->p3-pOp->p2; assert( pOp->p3<=(p->nMem-p->nCursor) ); pOut->flags = nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null; @@ -1123,8 +1130,9 @@ case OP_SoftNull: { ** P4 points to a blob of data P1 bytes long. Store this ** blob in register P2. */ -case OP_Blob: { /* out2-prerelease */ +case OP_Blob: { /* out2 */ assert( pOp->p1 <= SQLITE_MAX_LENGTH ); + pOut = out2Prerelease(p, pOp); sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0); pOut->enc = encoding; UPDATE_MAX_BLOBSIZE(pOut); @@ -1139,7 +1147,7 @@ case OP_Blob: { /* out2-prerelease */ ** If the parameter is named, then its name appears in P4. ** The P4 value is used by sqlite3_bind_parameter_name(). */ -case OP_Variable: { /* out2-prerelease */ +case OP_Variable: { /* out2 */ Mem *pVar; /* Value being transferred */ assert( pOp->p1>0 && pOp->p1<=p->nVar ); @@ -1148,6 +1156,7 @@ case OP_Variable: { /* out2-prerelease */ if( sqlite3VdbeMemTooBig(pVar) ){ goto too_big; } + pOut = out2Prerelease(p, pOp); sqlite3VdbeMemShallowCopy(pOut, pVar, MEM_Static); UPDATE_MAX_BLOBSIZE(pOut); break; @@ -2721,7 +2730,7 @@ case OP_MakeRecord: { ** opened by cursor P1 in register P2 */ #ifndef SQLITE_OMIT_BTREECOUNT -case OP_Count: { /* out2-prerelease */ +case OP_Count: { /* out2 */ i64 nEntry; BtCursor *pCrsr; @@ -2729,6 +2738,7 @@ case OP_Count: { /* out2-prerelease */ assert( pCrsr ); nEntry = 0; /* Not needed. Only used to silence a warning. */ rc = sqlite3BtreeCount(pCrsr, &nEntry); + pOut = out2Prerelease(p, pOp); pOut->u.i = nEntry; break; } @@ -3117,7 +3127,7 @@ case OP_Transaction: { ** must be started or there must be an open cursor) before ** executing this instruction. */ -case OP_ReadCookie: { /* out2-prerelease */ +case OP_ReadCookie: { /* out2 */ int iMeta; int iDb; int iCookie; @@ -3131,6 +3141,7 @@ case OP_ReadCookie: { /* out2-prerelease */ assert( DbMaskTest(p->btreeMask, iDb) ); sqlite3BtreeGetMeta(db->aDb[iDb].pBt, iCookie, (u32 *)&iMeta); + pOut = out2Prerelease(p, pOp); pOut->u.i = iMeta; break; } @@ -3951,9 +3962,10 @@ case OP_NotExists: { /* jump, in3 */ ** The sequence number on the cursor is incremented after this ** instruction. */ -case OP_Sequence: { /* out2-prerelease */ +case OP_Sequence: { /* out2 */ assert( pOp->p1>=0 && pOp->p1nCursor ); assert( p->apCsr[pOp->p1]!=0 ); + pOut = out2Prerelease(p, pOp); pOut->u.i = p->apCsr[pOp->p1]->seqCount++; break; } @@ -3974,7 +3986,7 @@ case OP_Sequence: { /* out2-prerelease */ ** generated record number. This P3 mechanism is used to help implement the ** AUTOINCREMENT feature. */ -case OP_NewRowid: { /* out2-prerelease */ +case OP_NewRowid: { /* out2 */ i64 v; /* The new rowid */ VdbeCursor *pC; /* Cursor of table to get the new rowid */ int res; /* Result of an sqlite3BtreeLast() */ @@ -3984,6 +3996,7 @@ case OP_NewRowid: { /* out2-prerelease */ v = 0; res = 0; + pOut = out2Prerelease(p, pOp); assert( pOp->p1>=0 && pOp->p1nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); @@ -4428,12 +4441,13 @@ case OP_RowData: { ** be a separate OP_VRowid opcode for use with virtual tables, but this ** one opcode now works for both table types. */ -case OP_Rowid: { /* out2-prerelease */ +case OP_Rowid: { /* out2 */ VdbeCursor *pC; i64 v; sqlite3_vtab *pVtab; const sqlite3_module *pModule; + pOut = out2Prerelease(p, pOp); assert( pOp->p1>=0 && pOp->p1nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); @@ -4808,11 +4822,12 @@ case OP_IdxDelete: { ** ** See also: Rowid, MakeRecord. */ -case OP_IdxRowid: { /* out2-prerelease */ +case OP_IdxRowid: { /* out2 */ BtCursor *pCrsr; VdbeCursor *pC; i64 rowid; + pOut = out2Prerelease(p, pOp); assert( pOp->p1>=0 && pOp->p1nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); @@ -4951,11 +4966,12 @@ case OP_IdxGE: { /* jump */ ** ** See also: Clear */ -case OP_Destroy: { /* out2-prerelease */ +case OP_Destroy: { /* out2 */ int iMoved; int iDb; assert( p->readOnly==0 ); + pOut = out2Prerelease(p, pOp); pOut->flags = MEM_Null; if( db->nVdbeRead > db->nVDestroy+1 ){ rc = SQLITE_LOCKED; @@ -5064,12 +5080,13 @@ case OP_ResetSorter: { ** ** See documentation on OP_CreateTable for additional information. */ -case OP_CreateIndex: /* out2-prerelease */ -case OP_CreateTable: { /* out2-prerelease */ +case OP_CreateIndex: /* out2 */ +case OP_CreateTable: { /* out2 */ int pgno; int flags; Db *pDb; + pOut = out2Prerelease(p, pOp); pgno = 0; assert( pOp->p1>=0 && pOp->p1nDb ); assert( DbMaskTest(p->btreeMask, pOp->p1) ); @@ -5505,9 +5522,10 @@ case OP_Program: { /* jump */ ** the value of the P1 argument to the value of the P1 argument to the ** calling OP_Program instruction. */ -case OP_Param: { /* out2-prerelease */ +case OP_Param: { /* out2 */ VdbeFrame *pFrame; Mem *pIn; + pOut = out2Prerelease(p, pOp); pFrame = p->pFrame; pIn = &pFrame->aMem[pOp->p1 + pFrame->aOp[pFrame->pc].p1]; sqlite3VdbeMemShallowCopy(pOut, pIn, MEM_Ephem); @@ -5814,7 +5832,7 @@ case OP_Checkpoint: { ** ** Write a string containing the final journal-mode to register P2. */ -case OP_JournalMode: { /* out2-prerelease */ +case OP_JournalMode: { /* out2 */ Btree *pBt; /* Btree to change journal mode of */ Pager *pPager; /* Pager associated with pBt */ int eNew; /* New journal mode */ @@ -5823,6 +5841,7 @@ case OP_JournalMode: { /* out2-prerelease */ const char *zFilename; /* Name of database file for pPager */ #endif + pOut = out2Prerelease(p, pOp); eNew = pOp->p3; assert( eNew==PAGER_JOURNALMODE_DELETE || eNew==PAGER_JOURNALMODE_TRUNCATE @@ -6378,7 +6397,8 @@ case OP_VUpdate: { ** ** Write the current number of pages in database P1 to memory cell P2. */ -case OP_Pagecount: { /* out2-prerelease */ +case OP_Pagecount: { /* out2 */ + pOut = out2Prerelease(p, pOp); pOut->u.i = sqlite3BtreeLastPage(db->aDb[pOp->p1].pBt); break; } @@ -6394,10 +6414,11 @@ case OP_Pagecount: { /* out2-prerelease */ ** ** Store the maximum page count after the change in register P2. */ -case OP_MaxPgcnt: { /* out2-prerelease */ +case OP_MaxPgcnt: { /* out2 */ unsigned int newMax; Btree *pBt; + pOut = out2Prerelease(p, pOp); pBt = db->aDb[pOp->p1].pBt; newMax = 0; if( pOp->p3 ){ @@ -6503,7 +6524,7 @@ default: { /* This is really OP_Noop and OP_Explain */ #ifdef SQLITE_DEBUG if( db->flags & SQLITE_VdbeTrace ){ if( rc!=0 ) printf("rc=%d\n",rc); - if( pOp->opflags & (OPFLG_OUT2_PRERELEASE|OPFLG_OUT2) ){ + if( pOp->opflags & (OPFLG_OUT2) ){ registerTrace(pOp->p2, &aMem[pOp->p2]); } if( pOp->opflags & OPFLG_OUT3 ){ From f56fa4676e26c07b9ae45248e987e380743ce623 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 13 Apr 2015 21:39:54 +0000 Subject: [PATCH 09/28] Omit the "pc" or "program counter" variable from the VDBE loop for 0.6% performance increase. FossilOrigin-Name: d2f10c41a832f520de13cf8315be22e66552f8e1 --- manifest | 12 +-- manifest.uuid | 2 +- src/vdbe.c | 215 +++++++++++++++++++++++--------------------------- 3 files changed, 105 insertions(+), 124 deletions(-) diff --git a/manifest b/manifest index acc5ea4f99..9ca1e537a7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sout2-prerelease\sVDBE\sopcode\sproperty\sand\sits\sassociated\scode,\nfor\sa\s0.5%\sperformance\simprovement. -D 2015-04-13T19:14:06.003 +C Omit\sthe\s"pc"\sor\s"program\scounter"\svariable\sfrom\sthe\sVDBE\sloop\sfor\s0.6%\nperformance\sincrease. +D 2015-04-13T21:39:54.858 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -293,7 +293,7 @@ F src/update.c 3c4ecc282accf12d39edb8d524cf089645e55a13 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c 98a7627ca48ad3265b6940915a1d08355eb3fc7e F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 584abb81e4abf9dd51a9a2e71f680289bd0c019b +F src/vdbe.c 3f3afd12d4794cb51fe13dc948b1172a5eb71a94 F src/vdbe.h 7e538ecf47dccb307ea2d087c3ddc2dd8d70e79d F src/vdbeInt.h 9cbaa84f53ddd2d09a0cf61a94337a3a035d08a0 F src/vdbeapi.c 583d56b129dd27f12bed518270de9ebe521e6a75 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P bc33af866403c23d548dd4705675315810d52d7f -R 6ac0695a2f1b9d518c2805dcc9a01314 +P e29c7f2c910dac07f0f92dfef5e0e743141954eb +R 264d755a27d6975322da35a6d51f72d4 U drh -Z 453362d5fdffab6ea02dce6dd25e18dd +Z 01e6d8b5894e3dcd9945571fd6cd1cd0 diff --git a/manifest.uuid b/manifest.uuid index 5adaa0dcc9..28f820dc76 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e29c7f2c910dac07f0f92dfef5e0e743141954eb \ No newline at end of file +d2f10c41a832f520de13cf8315be22e66552f8e1 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 8492f8cc09..3bd4222c8b 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -537,9 +537,8 @@ static Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){ int sqlite3VdbeExec( Vdbe *p /* The VDBE */ ){ - int pc=0; /* The program counter */ Op *aOp = p->aOp; /* Copy of p->aOp */ - Op *pOp; /* Current operation */ + Op *pOp = aOp; /* Current operation */ int rc = SQLITE_OK; /* Value to return */ sqlite3 *db = p->db; /* The database */ u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */ @@ -615,23 +614,22 @@ int sqlite3VdbeExec( } sqlite3EndBenignMalloc(); #endif - for(pc=p->pc; rc==SQLITE_OK; pc++){ - assert( pc>=0 && pcnOp ); + for(pOp=&aOp[p->pc]; rc==SQLITE_OK; pOp++){ + assert( pOp>=aOp && pOp<&aOp[p->nOp]); if( db->mallocFailed ) goto no_mem; #ifdef VDBE_PROFILE start = sqlite3Hwtime(); #endif nVmStep++; - pOp = &aOp[pc]; #ifdef SQLITE_ENABLE_STMT_SCANSTATUS - if( p->anExec ) p->anExec[pc]++; + if( p->anExec ) p->anExec[(int)(pOp-aOp)]++; #endif /* Only allow tracing if SQLITE_DEBUG is defined. */ #ifdef SQLITE_DEBUG if( db->flags & SQLITE_VdbeTrace ){ - sqlite3VdbePrintOp(stdout, pc, pOp); + sqlite3VdbePrintOp(stdout, (int)(pOp - aOp), pOp); } #endif @@ -734,7 +732,8 @@ int sqlite3VdbeExec( ** to the current line should be indented for EXPLAIN output. */ case OP_Goto: { /* jump */ - pc = pOp->p2 - 1; +jump_to_p2_and_check_for_interrupt: + pOp = &aOp[pOp->p2 - 1]; /* Opcodes that are used as the bottom of a loop (OP_Next, OP_Prev, ** OP_VNext, OP_RowSetNext, or OP_SorterNext) all jump here upon @@ -779,9 +778,13 @@ case OP_Gosub: { /* jump */ assert( VdbeMemDynamic(pIn1)==0 ); memAboutToChange(p, pIn1); pIn1->flags = MEM_Int; - pIn1->u.i = pc; + pIn1->u.i = (int)(pOp-aOp); REGISTER_TRACE(pOp->p1, pIn1); - pc = pOp->p2 - 1; + + /* Most jump operations do a goto to this spot in order to update + ** the pOp pointer. */ +jump_to_p2: + pOp = &aOp[pOp->p2 - 1]; break; } @@ -793,7 +796,7 @@ case OP_Gosub: { /* jump */ case OP_Return: { /* in1 */ pIn1 = &aMem[pOp->p1]; assert( pIn1->flags==MEM_Int ); - pc = (int)pIn1->u.i; + pOp = &aOp[pIn1->u.i]; pIn1->flags = MEM_Undefined; break; } @@ -817,7 +820,7 @@ case OP_InitCoroutine: { /* jump */ assert( !VdbeMemDynamic(pOut) ); pOut->u.i = pOp->p3 - 1; pOut->flags = MEM_Int; - if( pOp->p2 ) pc = pOp->p2 - 1; + if( pOp->p2 ) goto jump_to_p2; break; } @@ -837,7 +840,7 @@ case OP_EndCoroutine: { /* in1 */ pCaller = &aOp[pIn1->u.i]; assert( pCaller->opcode==OP_Yield ); assert( pCaller->p2>=0 && pCaller->p2nOp ); - pc = pCaller->p2 - 1; + pOp = &aOp[pCaller->p2 - 1]; pIn1->flags = MEM_Undefined; break; } @@ -861,9 +864,9 @@ case OP_Yield: { /* in1, jump */ assert( VdbeMemDynamic(pIn1)==0 ); pIn1->flags = MEM_Int; pcDest = (int)pIn1->u.i; - pIn1->u.i = pc; + pIn1->u.i = (int)(pOp - aOp); REGISTER_TRACE(pOp->p1, pIn1); - pc = pcDest; + pOp = &aOp[pcDest]; break; } @@ -914,30 +917,34 @@ case OP_HaltIfNull: { /* in3 */ case OP_Halt: { const char *zType; const char *zLogFmt; + VdbeFrame *pFrame; + int pcx; + pcx = (int)(pOp - aOp); if( pOp->p1==SQLITE_OK && p->pFrame ){ /* Halt the sub-program. Return control to the parent frame. */ - VdbeFrame *pFrame = p->pFrame; + pFrame = p->pFrame; p->pFrame = pFrame->pParent; p->nFrame--; sqlite3VdbeSetChanges(db, p->nChange); - pc = sqlite3VdbeFrameRestore(pFrame); + pcx = sqlite3VdbeFrameRestore(pFrame); lastRowid = db->lastRowid; if( pOp->p2==OE_Ignore ){ - /* Instruction pc is the OP_Program that invoked the sub-program + /* Instruction pcx is the OP_Program that invoked the sub-program ** currently being halted. If the p2 instruction of this OP_Halt ** instruction is set to OE_Ignore, then the sub-program is throwing ** an IGNORE exception. In this case jump to the address specified ** as the p2 of the calling OP_Program. */ - pc = p->aOp[pc].p2-1; + pcx = p->aOp[pcx].p2-1; } aOp = p->aOp; aMem = p->aMem; + pOp = &aOp[pcx]; break; } p->rc = pOp->p1; p->errorAction = (u8)pOp->p2; - p->pc = pc; + p->pc = pcx; if( p->rc ){ if( pOp->p5 ){ static const char * const azType[] = { "NOT NULL", "UNIQUE", "CHECK", @@ -961,7 +968,7 @@ case OP_Halt: { }else{ sqlite3SetString(&p->zErrMsg, db, "%s constraint failed", zType); } - sqlite3_log(pOp->p1, zLogFmt, pc, p->zSql, p->zErrMsg); + sqlite3_log(pOp->p1, zLogFmt, pcx, p->zSql, p->zErrMsg); } rc = sqlite3VdbeHalt(p); assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR ); @@ -972,6 +979,7 @@ case OP_Halt: { assert( rc==SQLITE_OK || db->nDeferredCons>0 || db->nDeferredImmCons>0 ); rc = p->rc ? SQLITE_ERROR : SQLITE_DONE; } + pOp = &aOp[pcx]; goto vdbe_return; } @@ -1333,7 +1341,7 @@ case OP_ResultRow: { /* Return SQLITE_ROW */ - p->pc = pc + 1; + p->pc = (int)(pOp - aOp) + 1; rc = SQLITE_ROW; goto vdbe_return; } @@ -1579,7 +1587,7 @@ case OP_Function: { assert( pOp->p4type==P4_FUNCDEF ); ctx.pFunc = pOp->p4.pFunc; - ctx.iOp = pc; + ctx.iOp = (int)(pOp - aOp); ctx.pVdbe = p; MemSetTypeFlag(ctx.pOut, MEM_Null); ctx.fErrorOrAux = 0; @@ -1593,7 +1601,7 @@ case OP_Function: { sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(ctx.pOut)); rc = ctx.isError; } - sqlite3VdbeDeleteAuxData(p, pc, pOp->p1); + sqlite3VdbeDeleteAuxData(p, (int)(pOp - aOp), pOp->p1); } /* Copy the result of the function into register P3 */ @@ -1722,8 +1730,7 @@ case OP_MustBeInt: { /* jump, in1 */ rc = SQLITE_MISMATCH; goto abort_due_to_error; }else{ - pc = pOp->p2 - 1; - break; + goto jump_to_p2; } } } @@ -1909,7 +1916,7 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ }else{ VdbeBranchTaken(2,3); if( pOp->p5 & SQLITE_JUMPIFNULL ){ - pc = pOp->p2-1; + goto jump_to_p2; } } break; @@ -1961,6 +1968,12 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ default: res = res>=0; break; } + /* Undo any changes made by applyAffinity() to the input registers. */ + assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) ); + pIn1->flags = flags1; + assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) ); + pIn3->flags = flags3; + if( pOp->p5 & SQLITE_STOREP2 ){ pOut = &aMem[pOp->p2]; memAboutToChange(p, pOut); @@ -1970,14 +1983,9 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ }else{ VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3); if( res ){ - pc = pOp->p2-1; + goto jump_to_p2; } } - /* Undo any changes made by applyAffinity() to the input registers. */ - assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) ); - pIn1->flags = flags1; - assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) ); - pIn3->flags = flags3; break; } @@ -2072,11 +2080,11 @@ case OP_Compare: { */ case OP_Jump: { /* jump */ if( iCompare<0 ){ - pc = pOp->p1 - 1; VdbeBranchTaken(0,3); + VdbeBranchTaken(0,3); pOp = &aOp[pOp->p1 - 1]; }else if( iCompare==0 ){ - pc = pOp->p2 - 1; VdbeBranchTaken(1,3); + VdbeBranchTaken(1,3); pOp = &aOp[pOp->p2 - 1]; }else{ - pc = pOp->p3 - 1; VdbeBranchTaken(2,3); + VdbeBranchTaken(2,3); pOp = &aOp[pOp->p3 - 1]; } break; } @@ -2186,7 +2194,7 @@ case OP_Once: { /* jump */ assert( pOp->p1nOnceFlag ); VdbeBranchTaken(p->aOnceFlag[pOp->p1]!=0, 2); if( p->aOnceFlag[pOp->p1] ){ - pc = pOp->p2-1; + goto jump_to_p2; }else{ p->aOnceFlag[pOp->p1] = 1; } @@ -2221,7 +2229,7 @@ case OP_IfNot: { /* jump, in1 */ } VdbeBranchTaken(c!=0, 2); if( c ){ - pc = pOp->p2-1; + goto jump_to_p2; } break; } @@ -2235,7 +2243,7 @@ case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */ pIn1 = &aMem[pOp->p1]; VdbeBranchTaken( (pIn1->flags & MEM_Null)!=0, 2); if( (pIn1->flags & MEM_Null)!=0 ){ - pc = pOp->p2 - 1; + goto jump_to_p2; } break; } @@ -2249,7 +2257,7 @@ case OP_NotNull: { /* same as TK_NOTNULL, jump, in1 */ pIn1 = &aMem[pOp->p1]; VdbeBranchTaken( (pIn1->flags & MEM_Null)==0, 2); if( (pIn1->flags & MEM_Null)==0 ){ - pc = pOp->p2 - 1; + goto jump_to_p2; } break; } @@ -2852,7 +2860,7 @@ case OP_Savepoint: { } db->autoCommit = 1; if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){ - p->pc = pc; + p->pc = (int)(pOp - aOp); db->autoCommit = 0; p->rc = rc = SQLITE_BUSY; goto vdbe_return; @@ -2971,7 +2979,7 @@ case OP_AutoCommit: { }else{ db->autoCommit = (u8)desiredAutoCommit; if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){ - p->pc = pc; + p->pc = (int)(pOp - aOp); db->autoCommit = (u8)(1-desiredAutoCommit); p->rc = rc = SQLITE_BUSY; goto vdbe_return; @@ -3048,7 +3056,7 @@ case OP_Transaction: { if( pBt ){ rc = sqlite3BtreeBeginTrans(pBt, pOp->p2); if( rc==SQLITE_BUSY ){ - p->pc = pc; + p->pc = (int)(pOp - aOp); p->rc = rc = SQLITE_BUSY; goto vdbe_return; } @@ -3463,7 +3471,7 @@ case OP_SequenceTest: { pC = p->apCsr[pOp->p1]; assert( pC->pSorter ); if( (pC->seqCount++)==0 ){ - pc = pOp->p2 - 1; + goto jump_to_p2; } break; } @@ -3640,7 +3648,7 @@ case OP_SeekGT: { /* jump, in3 */ if( (pIn3->flags & MEM_Real)==0 ){ /* If the P3 value cannot be converted into any kind of a number, ** then the seek is not possible, so jump to P2 */ - pc = pOp->p2 - 1; VdbeBranchTaken(1,2); + VdbeBranchTaken(1,2); goto jump_to_p2; break; } @@ -3731,7 +3739,7 @@ case OP_SeekGT: { /* jump, in3 */ assert( pOp->p2>0 ); VdbeBranchTaken(res!=0,2); if( res ){ - pc = pOp->p2 - 1; + goto jump_to_p2; } break; } @@ -3825,6 +3833,7 @@ case OP_NoConflict: /* jump, in3 */ case OP_NotFound: /* jump, in3 */ case OP_Found: { /* jump, in3 */ int alreadyExists; + int takeJump; int ii; VdbeCursor *pC; int res; @@ -3847,7 +3856,7 @@ case OP_Found: { /* jump, in3 */ pIn3 = &aMem[pOp->p3]; assert( pC->pCursor!=0 ); assert( pC->isTable==0 ); - pFree = 0; /* Not needed. Only used to suppress a compiler warning. */ + pFree = 0; if( pOp->p4.i>0 ){ r.pKeyInfo = pC->pKeyInfo; r.nField = (u16)pOp->p4.i; @@ -3870,21 +3879,20 @@ case OP_Found: { /* jump, in3 */ sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey); } pIdxKey->default_rc = 0; + takeJump = 0; if( pOp->opcode==OP_NoConflict ){ /* For the OP_NoConflict opcode, take the jump if any of the ** input fields are NULL, since any key with a NULL will not ** conflict */ for(ii=0; iinField; ii++){ if( pIdxKey->aMem[ii].flags & MEM_Null ){ - pc = pOp->p2 - 1; VdbeBranchTaken(1,2); + takeJump = 1; break; } } } rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, pIdxKey, 0, 0, &res); - if( pOp->p4.i==0 ){ - sqlite3DbFree(db, pFree); - } + sqlite3DbFree(db, pFree); if( rc!=SQLITE_OK ){ break; } @@ -3895,10 +3903,10 @@ case OP_Found: { /* jump, in3 */ pC->cacheStatus = CACHE_STALE; if( pOp->opcode==OP_Found ){ VdbeBranchTaken(alreadyExists!=0,2); - if( alreadyExists ) pc = pOp->p2 - 1; + if( alreadyExists ) goto jump_to_p2; }else{ - VdbeBranchTaken(alreadyExists==0,2); - if( !alreadyExists ) pc = pOp->p2 - 1; + VdbeBranchTaken(takeJump||alreadyExists==0,2); + if( takeJump || !alreadyExists ) goto jump_to_p2; } break; } @@ -3947,10 +3955,8 @@ case OP_NotExists: { /* jump, in3 */ pC->cacheStatus = CACHE_STALE; pC->deferredMoveto = 0; VdbeBranchTaken(res!=0,2); - if( res!=0 ){ - pc = pOp->p2 - 1; - } pC->seekResult = res; + if( res!=0 ) goto jump_to_p2; break; } @@ -4310,9 +4316,7 @@ case OP_SorterCompare: { res = 0; rc = sqlite3VdbeSorterCompare(pC, pIn3, nKeyCol, &res); VdbeBranchTaken(res!=0,2); - if( res ){ - pc = pOp->p2-1; - } + if( res ) goto jump_to_p2; break; }; @@ -4533,7 +4537,7 @@ case OP_Last: { /* jump */ #endif if( pOp->p2>0 ){ VdbeBranchTaken(res!=0,2); - if( res ) pc = pOp->p2 - 1; + if( res ) goto jump_to_p2; } break; } @@ -4597,9 +4601,7 @@ case OP_Rewind: { /* jump */ pC->nullRow = (u8)res; assert( pOp->p2>0 && pOp->p2nOp ); VdbeBranchTaken(res!=0,2); - if( res ){ - pc = pOp->p2 - 1; - } + if( res ) goto jump_to_p2; break; } @@ -4710,11 +4712,11 @@ next_tail: VdbeBranchTaken(res==0,2); if( res==0 ){ pC->nullRow = 0; - pc = pOp->p2 - 1; p->aCounter[pOp->p5]++; #ifdef SQLITE_TEST sqlite3_search_count++; #endif + goto jump_to_p2_and_check_for_interrupt; }else{ pC->nullRow = 1; } @@ -4940,9 +4942,7 @@ case OP_IdxGE: { /* jump */ res++; } VdbeBranchTaken(res>0,2); - if( res>0 ){ - pc = pOp->p2 - 1 ; - } + if( res>0 ) goto jump_to_p2; break; } @@ -5312,12 +5312,12 @@ case OP_RowSetRead: { /* jump, in1, out3 */ ){ /* The boolean index is empty */ sqlite3VdbeMemSetNull(pIn1); - pc = pOp->p2 - 1; VdbeBranchTaken(1,2); + goto jump_to_p2_and_check_for_interrupt; }else{ /* A value was pulled from the index */ - sqlite3VdbeMemSetInt64(&aMem[pOp->p3], val); VdbeBranchTaken(0,2); + sqlite3VdbeMemSetInt64(&aMem[pOp->p3], val); } goto check_for_interrupt; } @@ -5368,10 +5368,7 @@ case OP_RowSetTest: { /* jump, in1, in3 */ if( iSet ){ exists = sqlite3RowSetTest(pIn1->u.pRowSet, iSet, pIn3->u.i); VdbeBranchTaken(exists!=0,2); - if( exists ){ - pc = pOp->p2 - 1; - break; - } + if( exists ) goto jump_to_p2; } if( iSet>=0 ){ sqlite3RowSetInsert(pIn1->u.pRowSet, pIn3->u.i); @@ -5460,7 +5457,7 @@ case OP_Program: { /* jump */ pFrame->v = p; pFrame->nChildMem = nMem; pFrame->nChildCsr = pProgram->nCsr; - pFrame->pc = pc; + pFrame->pc = (int)(pOp - aOp); pFrame->aMem = p->aMem; pFrame->nMem = p->nMem; pFrame->apCsr = p->apCsr; @@ -5483,7 +5480,7 @@ case OP_Program: { /* jump */ pFrame = pRt->u.pFrame; assert( pProgram->nMem+pProgram->nCsr==pFrame->nChildMem ); assert( pProgram->nCsr==pFrame->nChildCsr ); - assert( pc==pFrame->pc ); + assert( (int)(pOp - aOp)==pFrame->pc ); } p->nFrame++; @@ -5504,7 +5501,7 @@ case OP_Program: { /* jump */ #ifdef SQLITE_ENABLE_STMT_SCANSTATUS p->anExec = 0; #endif - pc = -1; + pOp = &aOp[-1]; memset(p->aOnceFlag, 0, p->nOnceFlag); break; @@ -5569,10 +5566,10 @@ case OP_FkCounter: { case OP_FkIfZero: { /* jump */ if( pOp->p1 ){ VdbeBranchTaken(db->nDeferredCons==0 && db->nDeferredImmCons==0, 2); - if( db->nDeferredCons==0 && db->nDeferredImmCons==0 ) pc = pOp->p2-1; + if( db->nDeferredCons==0 && db->nDeferredImmCons==0 ) goto jump_to_p2; }else{ VdbeBranchTaken(p->nFkConstraint==0 && db->nDeferredImmCons==0, 2); - if( p->nFkConstraint==0 && db->nDeferredImmCons==0 ) pc = pOp->p2-1; + if( p->nFkConstraint==0 && db->nDeferredImmCons==0 ) goto jump_to_p2; } break; } @@ -5623,9 +5620,7 @@ case OP_IfPos: { /* jump, in1 */ pIn1 = &aMem[pOp->p1]; assert( pIn1->flags&MEM_Int ); VdbeBranchTaken( pIn1->u.i>0, 2); - if( pIn1->u.i>0 ){ - pc = pOp->p2 - 1; - } + if( pIn1->u.i>0 ) goto jump_to_p2; break; } @@ -5640,9 +5635,7 @@ case OP_IfNeg: { /* jump, in1 */ assert( pIn1->flags&MEM_Int ); pIn1->u.i += pOp->p3; VdbeBranchTaken(pIn1->u.i<0, 2); - if( pIn1->u.i<0 ){ - pc = pOp->p2 - 1; - } + if( pIn1->u.i<0 ) goto jump_to_p2; break; } @@ -5659,7 +5652,7 @@ case OP_IfNotZero: { /* jump, in1 */ VdbeBranchTaken(pIn1->u.i<0, 2); if( pIn1->u.i ){ pIn1->u.i += pOp->p3; - pc = pOp->p2 - 1; + goto jump_to_p2; } break; } @@ -5675,9 +5668,7 @@ case OP_DecrJumpZero: { /* jump, in1 */ assert( pIn1->flags&MEM_Int ); pIn1->u.i--; VdbeBranchTaken(pIn1->u.i==0, 2); - if( pIn1->u.i==0 ){ - pc = pOp->p2 - 1; - } + if( pIn1->u.i==0 ) goto jump_to_p2; break; } @@ -5693,9 +5684,7 @@ case OP_JumpZeroIncr: { /* jump, in1 */ pIn1 = &aMem[pOp->p1]; assert( pIn1->flags&MEM_Int ); VdbeBranchTaken(pIn1->u.i==0, 2); - if( (pIn1->u.i++)==0 ){ - pc = pOp->p2 - 1; - } + if( (pIn1->u.i++)==0 ) goto jump_to_p2; break; } @@ -5737,7 +5726,7 @@ case OP_AggStep: { ctx.pOut = &t; ctx.isError = 0; ctx.pVdbe = p; - ctx.iOp = pc; + ctx.iOp = (int)(pOp - aOp); ctx.skipFlag = 0; (ctx.pFunc->xStep)(&ctx, n, apVal); /* IMP: R-24505-23230 */ if( ctx.isError ){ @@ -5958,8 +5947,8 @@ case OP_IncrVacuum: { /* jump */ rc = sqlite3BtreeIncrVacuum(pBt); VdbeBranchTaken(rc==SQLITE_DONE,2); if( rc==SQLITE_DONE ){ - pc = pOp->p2 - 1; rc = SQLITE_OK; + goto jump_to_p2; } break; } @@ -6169,25 +6158,19 @@ case OP_VFilter: { /* jump */ iQuery = (int)pQuery->u.i; /* Invoke the xFilter method */ - { - res = 0; - apArg = p->apArg; - for(i = 0; ixFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg); - sqlite3VtabImportErrmsg(p, pVtab); - if( rc==SQLITE_OK ){ - res = pModule->xEof(pVtabCursor); - } - VdbeBranchTaken(res!=0,2); - if( res ){ - pc = pOp->p2 - 1; - } + res = 0; + apArg = p->apArg; + for(i = 0; ixFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg); + sqlite3VtabImportErrmsg(p, pVtab); + if( rc==SQLITE_OK ){ + res = pModule->xEof(pVtabCursor); } pCur->nullRow = 0; - + VdbeBranchTaken(res!=0,2); + if( res ) goto jump_to_p2; break; } #endif /* SQLITE_OMIT_VIRTUALTABLE */ @@ -6274,7 +6257,7 @@ case OP_VNext: { /* jump */ VdbeBranchTaken(!res,2); if( !res ){ /* If there is data, jump to P2 */ - pc = pOp->p2 - 1; + goto jump_to_p2_and_check_for_interrupt; } goto check_for_interrupt; } @@ -6447,9 +6430,6 @@ case OP_Init: { /* jump */ char *zTrace; char *z; - if( pOp->p2 ){ - pc = pOp->p2 - 1; - } #ifndef SQLITE_OMIT_TRACE if( db->xTrace && !p->doingRerun @@ -6477,6 +6457,7 @@ case OP_Init: { /* jump */ } #endif /* SQLITE_DEBUG */ #endif /* SQLITE_OMIT_TRACE */ + if( pOp->p2 ) goto jump_to_p2; break; } @@ -6519,7 +6500,7 @@ default: { /* This is really OP_Noop and OP_Explain */ ** the evaluator loop. So we can leave it out when NDEBUG is defined. */ #ifndef NDEBUG - assert( pc>=-1 && pcnOp ); + assert( pOp>=&aOp[-1] && pOp<&aOp[p->nOp] ); #ifdef SQLITE_DEBUG if( db->flags & SQLITE_VdbeTrace ){ @@ -6543,7 +6524,7 @@ vdbe_error_halt: p->rc = rc; testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(rc, "statement aborts at %d: [%s] %s", - pc, p->zSql, p->zErrMsg); + (int)(pOp - aOp), p->zSql, p->zErrMsg); sqlite3VdbeHalt(p); if( rc==SQLITE_IOERR_NOMEM ) db->mallocFailed = 1; rc = SQLITE_ERROR; From 2647dfa2928aaa3907680d55c1df94b1d8c40eea Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 13 Apr 2015 22:26:55 +0000 Subject: [PATCH 10/28] On a DETACH statement, keep all schemas intact except fo the one that is being detached, and thus avoid unnecessary schema reparsing. FossilOrigin-Name: 661db19b34566642dd44ee4cff4ebc093cb8a552 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/attach.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 9ca1e537a7..924612731f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sthe\s"pc"\sor\s"program\scounter"\svariable\sfrom\sthe\sVDBE\sloop\sfor\s0.6%\nperformance\sincrease. -D 2015-04-13T21:39:54.858 +C On\sa\sDETACH\sstatement,\skeep\sall\sschemas\sintact\sexcept\sfo\sthe\sone\sthat\sis\nbeing\sdetached,\sand\sthus\savoid\sunnecessary\sschema\sreparsing. +D 2015-04-13T22:26:55.617 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -168,7 +168,7 @@ F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c d23d6b6991f66b383934f137fd4384d93fb98c81 F src/analyze.c 91540f835163d5369ccbae78e2e6c74d0dd53c1d -F src/attach.c 880f9b8641a829c563e52dd13c452ce457ae4dd8 +F src/attach.c 3c1053a4cf1c3ca05c8c1d74a94cb688d763cef2 F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c ff743689c4d6c5cb55ad42ed9d174b2b3e71f1e3 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e29c7f2c910dac07f0f92dfef5e0e743141954eb -R 264d755a27d6975322da35a6d51f72d4 +P d2f10c41a832f520de13cf8315be22e66552f8e1 +R 49212af07046904ea6b82f6ec3cc0926 U drh -Z 01e6d8b5894e3dcd9945571fd6cd1cd0 +Z b2d6c204725accd9dcc524641d192884 diff --git a/manifest.uuid b/manifest.uuid index 28f820dc76..c643643efb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d2f10c41a832f520de13cf8315be22e66552f8e1 \ No newline at end of file +661db19b34566642dd44ee4cff4ebc093cb8a552 \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index 7e35fa67c6..11296d02ad 100644 --- a/src/attach.c +++ b/src/attach.c @@ -298,7 +298,7 @@ static void detachFunc( sqlite3BtreeClose(pDb->pBt); pDb->pBt = 0; pDb->pSchema = 0; - sqlite3ResetAllSchemasOfConnection(db); + sqlite3CollapseDatabaseArray(db); return; detach_error: From 6bca6511666674870a081f05eec9f708ac1ce072 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 13 Apr 2015 23:05:28 +0000 Subject: [PATCH 11/28] Add #ifdef magic for HAVE_GETHOSTUUID so that the build will hopefully now work on more verions of MacOS with SQLITE_ENABLE_LOCKING_STYLE turned on. FossilOrigin-Name: 211411d02c0729c9af0e3cc7e4910db2e7e0d08e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 16 ++++++++++++++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 924612731f..148ae45ff6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C On\sa\sDETACH\sstatement,\skeep\sall\sschemas\sintact\sexcept\sfo\sthe\sone\sthat\sis\nbeing\sdetached,\sand\sthus\savoid\sunnecessary\sschema\sreparsing. -D 2015-04-13T22:26:55.617 +C Add\s#ifdef\smagic\sfor\sHAVE_GETHOSTUUID\sso\sthat\sthe\sbuild\swill\shopefully\snow\nwork\son\smore\sverions\sof\sMacOS\swith\sSQLITE_ENABLE_LOCKING_STYLE\sturned\son. +D 2015-04-13T23:05:28.978 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -214,7 +214,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 25b80a3d167da44226a2084dc9e89a6cb1f02e2e +F src/os_unix.c 5ed7e2e453c2980909a6b2c80dc55764b50819a8 F src/os_win.c 03d27be3a20048ef52a648d5f0a15f5edda9f2a3 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 4120a49ecd37697e28f5ed807f470b9c0b88410c @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d2f10c41a832f520de13cf8315be22e66552f8e1 -R 49212af07046904ea6b82f6ec3cc0926 +P 661db19b34566642dd44ee4cff4ebc093cb8a552 +R 8591357f8b00a438bdaa3b5a16ff0e3f U drh -Z b2d6c204725accd9dcc524641d192884 +Z d2025877377cf6ead9db7636c81d5974 diff --git a/manifest.uuid b/manifest.uuid index c643643efb..8657041788 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -661db19b34566642dd44ee4cff4ebc093cb8a552 \ No newline at end of file +211411d02c0729c9af0e3cc7e4910db2e7e0d08e \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 1d867d7cd8..188c025336 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -91,6 +91,17 @@ # include #endif /* SQLITE_ENABLE_LOCKING_STYLE */ +#if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \ + (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000)) +# if (!defined(TARGET_OS_EMBEDDED) || (TARGET_OS_EMBEDDED==0)) \ + && (!defined(TARGET_IPHONE_SIMULATOR) || (TARGET_IPHONE_SIMULATOR==0)) +# define HAVE_GETHOSTUUID 1 +# else +# warning "gethostuuid() is disabled." +# endif +#endif + + #if OS_VXWORKS # include # include @@ -6602,8 +6613,10 @@ int sqlite3_hostid_num = 0; #define PROXY_HOSTIDLEN 16 /* conch file host id length */ +#ifdef HAVE_GETHOSTUUID /* Not always defined in the headers as it ought to be */ extern int gethostuuid(uuid_t id, const struct timespec *wait); +#endif /* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN ** bytes of writable memory. @@ -6611,8 +6624,7 @@ extern int gethostuuid(uuid_t id, const struct timespec *wait); static int proxyGetHostID(unsigned char *pHostID, int *pError){ assert(PROXY_HOSTIDLEN == sizeof(uuid_t)); memset(pHostID, 0, PROXY_HOSTIDLEN); -# if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \ - (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000)) +#ifdef HAVE_GETHOSTUUID { struct timespec timeout = {1, 0}; /* 1 sec timeout */ if( gethostuuid(pHostID, &timeout) ){ From d9a0a9a0c6db9ac1d224ff886f89a09af720088f Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 14 Apr 2015 15:14:06 +0000 Subject: [PATCH 12/28] Update API documentation to identify many functions as methods on objects. No changes to code. FossilOrigin-Name: b549cbcee1c11f9ffedf763ca672b125eac87bfe --- manifest | 12 +++--- manifest.uuid | 2 +- src/sqlite.h.in | 100 ++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 95 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 148ae45ff6..c795bef110 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\s#ifdef\smagic\sfor\sHAVE_GETHOSTUUID\sso\sthat\sthe\sbuild\swill\shopefully\snow\nwork\son\smore\sverions\sof\sMacOS\swith\sSQLITE_ENABLE_LOCKING_STYLE\sturned\son. -D 2015-04-13T23:05:28.978 +C Update\sAPI\sdocumentation\sto\sidentify\smany\sfunctions\sas\smethods\son\sobjects.\nNo\schanges\sto\scode. +D 2015-04-14T15:14:06.177 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -232,7 +232,7 @@ F src/resolve.c 41aa91af56d960e9414ce1d7c17cfb68e0d1c6cb F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 117e0f9ac9254a6f7472fac5144eba21ba0b2ec1 F src/shell.c 84a1593bd86aaa14f4da8a8f9b16fbc239d262aa -F src/sqlite.h.in 278602140d49575e8708e643161f4263e428a02a +F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d F src/sqliteInt.h 90b7bfd89d7307cd0750663da419ba4bb81e7379 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 661db19b34566642dd44ee4cff4ebc093cb8a552 -R 8591357f8b00a438bdaa3b5a16ff0e3f +P 211411d02c0729c9af0e3cc7e4910db2e7e0d08e +R 32297e2ca295bdee2feb4a534c04bc42 U drh -Z d2025877377cf6ead9db7636c81d5974 +Z 358af9cd25fc843b833aaa97a1900951 diff --git a/manifest.uuid b/manifest.uuid index 8657041788..5721ce9565 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -211411d02c0729c9af0e3cc7e4910db2e7e0d08e \ No newline at end of file +b549cbcee1c11f9ffedf763ca672b125eac87bfe \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index acc3c51404..163bc69fe7 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -270,6 +270,7 @@ typedef sqlite_uint64 sqlite3_uint64; /* ** CAPI3REF: Closing A Database Connection +** DESTRUCTOR: sqlite3 ** ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors ** for the [sqlite3] object. @@ -321,6 +322,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**); /* ** CAPI3REF: One-Step Query Execution Interface +** METHOD: sqlite3 ** ** The sqlite3_exec() interface is a convenience wrapper around ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], @@ -1378,6 +1380,7 @@ int sqlite3_config(int, ...); /* ** CAPI3REF: Configure database connections +** METHOD: sqlite3 ** ** The sqlite3_db_config() interface is used to make configuration ** changes to a [database connection]. The interface is similar to @@ -1875,6 +1878,7 @@ struct sqlite3_mem_methods { /* ** CAPI3REF: Enable Or Disable Extended Result Codes +** METHOD: sqlite3 ** ** ^The sqlite3_extended_result_codes() routine enables or disables the ** [extended result codes] feature of SQLite. ^The extended result @@ -1884,6 +1888,7 @@ int sqlite3_extended_result_codes(sqlite3*, int onoff); /* ** CAPI3REF: Last Insert Rowid +** METHOD: sqlite3 ** ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables) ** has a unique 64-bit signed @@ -1935,6 +1940,7 @@ sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); /* ** CAPI3REF: Count The Number Of Rows Modified +** METHOD: sqlite3 ** ** ^This function returns the number of rows modified, inserted or ** deleted by the most recently completed INSERT, UPDATE or DELETE @@ -1987,6 +1993,7 @@ int sqlite3_changes(sqlite3*); /* ** CAPI3REF: Total Number Of Rows Modified +** METHOD: sqlite3 ** ** ^This function returns the total number of rows inserted, modified or ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed @@ -2010,6 +2017,7 @@ int sqlite3_total_changes(sqlite3*); /* ** CAPI3REF: Interrupt A Long-Running Query +** METHOD: sqlite3 ** ** ^This function causes any pending database operation to abort and ** return at its earliest opportunity. This routine is typically @@ -2086,6 +2094,7 @@ int sqlite3_complete16(const void *sql); /* ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors ** KEYWORDS: {busy-handler callback} {busy handler} +** METHOD: sqlite3 ** ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X ** that might be invoked with argument P whenever @@ -2145,6 +2154,7 @@ int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); /* ** CAPI3REF: Set A Busy Timeout +** METHOD: sqlite3 ** ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps ** for a specified amount of time when a table is locked. ^The handler @@ -2167,6 +2177,7 @@ int sqlite3_busy_timeout(sqlite3*, int ms); /* ** CAPI3REF: Convenience Routines For Running Queries +** METHOD: sqlite3 ** ** This is a legacy interface that is preserved for backwards compatibility. ** Use of this interface is not recommended. @@ -2502,6 +2513,7 @@ void sqlite3_randomness(int N, void *P); /* ** CAPI3REF: Compile-Time Authorization Callbacks +** METHOD: sqlite3 ** ** ^This routine registers an authorizer callback with a particular ** [database connection], supplied in the first argument. @@ -2658,6 +2670,7 @@ int sqlite3_set_authorizer( /* ** CAPI3REF: Tracing And Profiling Functions +** METHOD: sqlite3 ** ** These routines register callback functions that can be used for ** tracing and profiling the execution of SQL statements. @@ -2690,6 +2703,7 @@ SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, /* ** CAPI3REF: Query Progress Callbacks +** METHOD: sqlite3 ** ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback ** function X to be invoked periodically during long running calls to @@ -2723,6 +2737,7 @@ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); /* ** CAPI3REF: Opening A New Database Connection +** CONSTRUCTOR: sqlite3 ** ** ^These routines open an SQLite database file as specified by the ** filename argument. ^The filename argument is interpreted as UTF-8 for @@ -3008,6 +3023,7 @@ sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64); /* ** CAPI3REF: Error Codes And Messages +** METHOD: sqlite3 ** ** ^If the most recent sqlite3_* API call associated with ** [database connection] D failed, then the sqlite3_errcode(D) interface @@ -3053,33 +3069,34 @@ const void *sqlite3_errmsg16(sqlite3*); const char *sqlite3_errstr(int); /* -** CAPI3REF: SQL Statement Object +** CAPI3REF: Prepared Statement Object ** KEYWORDS: {prepared statement} {prepared statements} ** -** An instance of this object represents a single SQL statement. -** This object is variously known as a "prepared statement" or a -** "compiled SQL statement" or simply as a "statement". +** An instance of this object represents a single SQL statement that +** has been compiled into binary form and is ready to be evaluated. ** -** The life of a statement object goes something like this: +** Think of each SQL statement as a separate computer program. The +** original SQL text is source code. A prepared statement object +** is the compiled object code. All SQL must be converted into a +** prepared statement before it can be run. +** +** The life-cycle of a prepared statement object usually goes like this: ** **
    -**
  1. Create the object using [sqlite3_prepare_v2()] or a related -** function. -**
  2. Bind values to [host parameters] using the sqlite3_bind_*() +**
  3. Create the prepared statement object using [sqlite3_prepare_v2()]. +**
  4. Bind values to [parameters] using the sqlite3_bind_*() ** interfaces. **
  5. Run the SQL by calling [sqlite3_step()] one or more times. -**
  6. Reset the statement using [sqlite3_reset()] then go back +**
  7. Reset the prepared statement using [sqlite3_reset()] then go back ** to step 2. Do this zero or more times. **
  8. Destroy the object using [sqlite3_finalize()]. **
-** -** Refer to documentation on individual methods above for additional -** information. */ typedef struct sqlite3_stmt sqlite3_stmt; /* ** CAPI3REF: Run-time Limits +** METHOD: sqlite3 ** ** ^(This interface allows the size of various constructs to be limited ** on a connection by connection basis. The first parameter is the @@ -3191,6 +3208,8 @@ int sqlite3_limit(sqlite3*, int id, int newVal); /* ** CAPI3REF: Compiling An SQL Statement ** KEYWORDS: {SQL statement compiler} +** METHOD: sqlite3 +** CONSTRUCTOR: sqlite3_stmt ** ** To execute an SQL query, it must first be compiled into a byte-code ** program using one of these routines. @@ -3298,6 +3317,7 @@ int sqlite3_prepare16_v2( /* ** CAPI3REF: Retrieving Statement SQL +** METHOD: sqlite3_stmt ** ** ^This interface can be used to retrieve a saved copy of the original ** SQL text used to create a [prepared statement] if that statement was @@ -3307,6 +3327,7 @@ const char *sqlite3_sql(sqlite3_stmt *pStmt); /* ** CAPI3REF: Determine If An SQL Statement Writes The Database +** METHOD: sqlite3_stmt ** ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if ** and only if the [prepared statement] X makes no direct changes to @@ -3338,6 +3359,7 @@ int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); /* ** CAPI3REF: Determine If A Prepared Statement Has Been Reset +** METHOD: sqlite3_stmt ** ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the ** [prepared statement] S has been stepped at least once using @@ -3412,6 +3434,7 @@ typedef struct sqlite3_context sqlite3_context; ** CAPI3REF: Binding Values To Prepared Statements ** KEYWORDS: {host parameter} {host parameters} {host parameter name} ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} +** METHOD: sqlite3_stmt ** ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, ** literals may be replaced by a [parameter] that matches one of following @@ -3530,6 +3553,7 @@ int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); /* ** CAPI3REF: Number Of SQL Parameters +** METHOD: sqlite3_stmt ** ** ^This routine can be used to find the number of [SQL parameters] ** in a [prepared statement]. SQL parameters are tokens of the @@ -3550,6 +3574,7 @@ int sqlite3_bind_parameter_count(sqlite3_stmt*); /* ** CAPI3REF: Name Of A Host Parameter +** METHOD: sqlite3_stmt ** ** ^The sqlite3_bind_parameter_name(P,N) interface returns ** the name of the N-th [SQL parameter] in the [prepared statement] P. @@ -3577,6 +3602,7 @@ const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); /* ** CAPI3REF: Index Of A Parameter With A Given Name +** METHOD: sqlite3_stmt ** ** ^Return the index of an SQL parameter given its name. ^The ** index value returned is suitable for use as the second @@ -3593,6 +3619,7 @@ int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); /* ** CAPI3REF: Reset All Bindings On A Prepared Statement +** METHOD: sqlite3_stmt ** ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset ** the [sqlite3_bind_blob | bindings] on a [prepared statement]. @@ -3602,6 +3629,7 @@ int sqlite3_clear_bindings(sqlite3_stmt*); /* ** CAPI3REF: Number Of Columns In A Result Set +** METHOD: sqlite3_stmt ** ** ^Return the number of columns in the result set returned by the ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL @@ -3613,6 +3641,7 @@ int sqlite3_column_count(sqlite3_stmt *pStmt); /* ** CAPI3REF: Column Names In A Result Set +** METHOD: sqlite3_stmt ** ** ^These routines return the name assigned to a particular column ** in the result set of a [SELECT] statement. ^The sqlite3_column_name() @@ -3642,6 +3671,7 @@ const void *sqlite3_column_name16(sqlite3_stmt*, int N); /* ** CAPI3REF: Source Of Data In A Query Result +** METHOD: sqlite3_stmt ** ** ^These routines provide a means to determine the database, table, and ** table column that is the origin of a particular result column in @@ -3694,6 +3724,7 @@ const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); /* ** CAPI3REF: Declared Datatype Of A Query Result +** METHOD: sqlite3_stmt ** ** ^(The first parameter is a [prepared statement]. ** If this statement is a [SELECT] statement and the Nth column of the @@ -3726,6 +3757,7 @@ const void *sqlite3_column_decltype16(sqlite3_stmt*,int); /* ** CAPI3REF: Evaluate An SQL Statement +** METHOD: sqlite3_stmt ** ** After a [prepared statement] has been prepared using either ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy @@ -3805,6 +3837,7 @@ int sqlite3_step(sqlite3_stmt*); /* ** CAPI3REF: Number of columns in a result set +** METHOD: sqlite3_stmt ** ** ^The sqlite3_data_count(P) interface returns the number of columns in the ** current row of the result set of [prepared statement] P. @@ -3858,6 +3891,7 @@ int sqlite3_data_count(sqlite3_stmt *pStmt); /* ** CAPI3REF: Result Values From A Query ** KEYWORDS: {column access functions} +** METHOD: sqlite3_stmt ** ** These routines form the "result set" interface. ** @@ -4030,6 +4064,7 @@ sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); /* ** CAPI3REF: Destroy A Prepared Statement Object +** DESTRUCTOR: sqlite3_stmt ** ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. ** ^If the most recent evaluation of the statement encountered no errors @@ -4057,6 +4092,7 @@ int sqlite3_finalize(sqlite3_stmt *pStmt); /* ** CAPI3REF: Reset A Prepared Statement Object +** METHOD: sqlite3_stmt ** ** The sqlite3_reset() function is called to reset a [prepared statement] ** object back to its initial state, ready to be re-executed. @@ -4086,6 +4122,7 @@ int sqlite3_reset(sqlite3_stmt *pStmt); ** KEYWORDS: {function creation routines} ** KEYWORDS: {application-defined SQL function} ** KEYWORDS: {application-defined SQL functions} +** METHOD: sqlite3 ** ** ^These functions (collectively known as "function creation routines") ** are used to add SQL functions or aggregates or to redefine the behavior @@ -4255,6 +4292,7 @@ SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), /* ** CAPI3REF: Obtaining SQL Function Parameter Values +** METHOD: sqlite3_value ** ** The C-language implementation of SQL functions and aggregates uses ** this set of interface routines to access the parameter values on @@ -4313,6 +4351,7 @@ int sqlite3_value_numeric_type(sqlite3_value*); /* ** CAPI3REF: Obtain Aggregate Function Context +** METHOD: sqlite3_context ** ** Implementations of aggregate SQL functions use this ** routine to allocate memory for storing their state. @@ -4357,6 +4396,7 @@ void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); /* ** CAPI3REF: User Data For Functions +** METHOD: sqlite3_context ** ** ^The sqlite3_user_data() interface returns a copy of ** the pointer that was the pUserData parameter (the 5th parameter) @@ -4371,6 +4411,7 @@ void *sqlite3_user_data(sqlite3_context*); /* ** CAPI3REF: Database Connection For Functions +** METHOD: sqlite3_context ** ** ^The sqlite3_context_db_handle() interface returns a copy of ** the pointer to the [database connection] (the 1st parameter) @@ -4382,6 +4423,7 @@ sqlite3 *sqlite3_context_db_handle(sqlite3_context*); /* ** CAPI3REF: Function Auxiliary Data +** METHOD: sqlite3_context ** ** These functions may be used by (non-aggregate) SQL functions to ** associate metadata with argument values. If the same value is passed to @@ -4454,6 +4496,7 @@ typedef void (*sqlite3_destructor_type)(void*); /* ** CAPI3REF: Setting The Result Of An SQL Function +** METHOD: sqlite3_context ** ** These routines are used by the xFunc or xFinal callbacks that ** implement SQL functions and aggregates. See @@ -4589,6 +4632,7 @@ void sqlite3_result_zeroblob(sqlite3_context*, int n); /* ** CAPI3REF: Define New Collating Sequences +** METHOD: sqlite3 ** ** ^These functions add, remove, or modify a [collation] associated ** with the [database connection] specified as the first argument. @@ -4691,6 +4735,7 @@ int sqlite3_create_collation16( /* ** CAPI3REF: Collation Needed Callbacks +** METHOD: sqlite3 ** ** ^To avoid having to register all collation sequences before a database ** can be used, a single callback function may be registered with the @@ -4898,6 +4943,7 @@ SQLITE_EXTERN char *sqlite3_data_directory; /* ** CAPI3REF: Test For Auto-Commit Mode ** KEYWORDS: {autocommit mode} +** METHOD: sqlite3 ** ** ^The sqlite3_get_autocommit() interface returns non-zero or ** zero if the given database connection is or is not in autocommit mode, @@ -4920,6 +4966,7 @@ int sqlite3_get_autocommit(sqlite3*); /* ** CAPI3REF: Find The Database Handle Of A Prepared Statement +** METHOD: sqlite3_stmt ** ** ^The sqlite3_db_handle interface returns the [database connection] handle ** to which a [prepared statement] belongs. ^The [database connection] @@ -4932,6 +4979,7 @@ sqlite3 *sqlite3_db_handle(sqlite3_stmt*); /* ** CAPI3REF: Return The Filename For A Database Connection +** METHOD: sqlite3 ** ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename ** associated with database N of connection D. ^The main database file @@ -4948,6 +4996,7 @@ const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); /* ** CAPI3REF: Determine if a database is read-only +** METHOD: sqlite3 ** ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N ** of connection D is read-only, 0 if it is read/write, or -1 if N is not @@ -4957,6 +5006,7 @@ int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); /* ** CAPI3REF: Find the next prepared statement +** METHOD: sqlite3 ** ** ^This interface returns a pointer to the next [prepared statement] after ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL @@ -4972,6 +5022,7 @@ sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); /* ** CAPI3REF: Commit And Rollback Notification Callbacks +** METHOD: sqlite3 ** ** ^The sqlite3_commit_hook() interface registers a callback ** function to be invoked whenever a transaction is [COMMIT | committed]. @@ -5021,6 +5072,7 @@ void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); /* ** CAPI3REF: Data Change Notification Callbacks +** METHOD: sqlite3 ** ** ^The sqlite3_update_hook() interface registers a callback function ** with the [database connection] identified by the first argument @@ -5127,6 +5179,7 @@ int sqlite3_release_memory(int); /* ** CAPI3REF: Free Memory Used By A Database Connection +** METHOD: sqlite3 ** ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap ** memory as possible from database connection D. Unlike the @@ -5204,6 +5257,7 @@ SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); /* ** CAPI3REF: Extract Metadata About A Column Of A Table +** METHOD: sqlite3 ** ** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns ** information about column C of table T in database D @@ -5282,6 +5336,7 @@ int sqlite3_table_column_metadata( /* ** CAPI3REF: Load An Extension +** METHOD: sqlite3 ** ** ^This interface loads an SQLite extension library from the named file. ** @@ -5323,6 +5378,7 @@ int sqlite3_load_extension( /* ** CAPI3REF: Enable Or Disable Extension Loading +** METHOD: sqlite3 ** ** ^So as not to open security holes in older applications that are ** unprepared to deal with [extension loading], and as a means of disabling @@ -5572,6 +5628,7 @@ struct sqlite3_index_info { /* ** CAPI3REF: Register A Virtual Table Implementation +** METHOD: sqlite3 ** ** ^These routines are used to register a new [virtual table module] name. ** ^Module names must be registered before @@ -5668,6 +5725,7 @@ int sqlite3_declare_vtab(sqlite3*, const char *zSQL); /* ** CAPI3REF: Overload A Function For A Virtual Table +** METHOD: sqlite3 ** ** ^(Virtual tables can provide alternative implementations of functions ** using the [xFindFunction] method of the [virtual table module]. @@ -5710,6 +5768,8 @@ typedef struct sqlite3_blob sqlite3_blob; /* ** CAPI3REF: Open A BLOB For Incremental I/O +** METHOD: sqlite3 +** CONSTRUCTOR: sqlite3_blob ** ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located ** in row iRow, column zColumn, table zTable in database zDb; @@ -5791,6 +5851,7 @@ int sqlite3_blob_open( /* ** CAPI3REF: Move a BLOB Handle to a New Row +** METHOD: sqlite3_blob ** ** ^This function is used to move an existing blob handle so that it points ** to a different row of the same database table. ^The new row is identified @@ -5815,6 +5876,7 @@ SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); /* ** CAPI3REF: Close A BLOB Handle +** DESTRUCTOR: sqlite3_blob ** ** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed ** unconditionally. Even if this routine returns an error code, the @@ -5837,6 +5899,7 @@ int sqlite3_blob_close(sqlite3_blob *); /* ** CAPI3REF: Return The Size Of An Open BLOB +** METHOD: sqlite3_blob ** ** ^Returns the size in bytes of the BLOB accessible via the ** successfully opened [BLOB handle] in its only argument. ^The @@ -5852,6 +5915,7 @@ int sqlite3_blob_bytes(sqlite3_blob *); /* ** CAPI3REF: Read Data From A BLOB Incrementally +** METHOD: sqlite3_blob ** ** ^(This function is used to read data from an open [BLOB handle] into a ** caller-supplied buffer. N bytes of data are copied into buffer Z @@ -5880,6 +5944,7 @@ int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); /* ** CAPI3REF: Write Data Into A BLOB Incrementally +** METHOD: sqlite3_blob ** ** ^(This function is used to write data into an open [BLOB handle] from a ** caller-supplied buffer. N bytes of data are copied from the buffer Z @@ -6207,6 +6272,7 @@ int sqlite3_mutex_notheld(sqlite3_mutex*); /* ** CAPI3REF: Retrieve the mutex for a database connection +** METHOD: sqlite3 ** ** ^This interface returns a pointer the [sqlite3_mutex] object that ** serializes access to the [database connection] given in the argument @@ -6218,6 +6284,7 @@ sqlite3_mutex *sqlite3_db_mutex(sqlite3*); /* ** CAPI3REF: Low-Level Control Of Database Files +** METHOD: sqlite3 ** ** ^The [sqlite3_file_control()] interface makes a direct call to the ** xFileControl method for the [sqlite3_io_methods] object associated @@ -6434,6 +6501,7 @@ int sqlite3_status64( /* ** CAPI3REF: Database Connection Status +** METHOD: sqlite3 ** ** ^This interface is used to retrieve runtime status information ** about a single [database connection]. ^The first argument is the @@ -6562,6 +6630,7 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); /* ** CAPI3REF: Prepared Statement Status +** METHOD: sqlite3_stmt ** ** ^(Each prepared statement maintains various ** [SQLITE_STMTSTATUS counters] that measure the number @@ -7065,6 +7134,7 @@ int sqlite3_backup_pagecount(sqlite3_backup *p); /* ** CAPI3REF: Unlock Notification +** METHOD: sqlite3 ** ** ^When running in shared-cache mode, a database operation may fail with ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or @@ -7235,6 +7305,7 @@ void sqlite3_log(int iErrCode, const char *zFormat, ...); /* ** CAPI3REF: Write-Ahead Log Commit Hook +** METHOD: sqlite3 ** ** ^The [sqlite3_wal_hook()] function is used to register a callback that ** is invoked each time data is committed to a database in wal mode. @@ -7274,6 +7345,7 @@ void *sqlite3_wal_hook( /* ** CAPI3REF: Configure an auto-checkpoint +** METHOD: sqlite3 ** ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around ** [sqlite3_wal_hook()] that causes any database on [database connection] D @@ -7304,6 +7376,7 @@ int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); /* ** CAPI3REF: Checkpoint a database +** METHOD: sqlite3 ** ** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to ** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^ @@ -7325,6 +7398,7 @@ int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); /* ** CAPI3REF: Checkpoint a database +** METHOD: sqlite3 ** ** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint ** operation on database X of [database connection] D in mode M. Status @@ -7579,6 +7653,7 @@ int sqlite3_vtab_on_conflict(sqlite3 *); /* ** CAPI3REF: Prepared Statement Scan Status +** METHOD: sqlite3_stmt ** ** This interface returns information about the predicted and measured ** performance for pStmt. Advanced applications can use this @@ -7616,6 +7691,7 @@ SQLITE_EXPERIMENTAL int sqlite3_stmt_scanstatus( /* ** CAPI3REF: Zero Scan-Status Counters +** METHOD: sqlite3_stmt ** ** ^Zero all [sqlite3_stmt_scanstatus()] related event counters. ** From 8a1cd765dfae89bb23a8ce61101f299d8a225334 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 14 Apr 2015 19:01:08 +0000 Subject: [PATCH 13/28] Add the --summary option to the sqldiff command-line tool. FossilOrigin-Name: 88b22761c59b06fa86c57f8d22a46046ad17d5d5 --- manifest | 12 +-- manifest.uuid | 2 +- tool/sqldiff.c | 238 ++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 192 insertions(+), 60 deletions(-) diff --git a/manifest b/manifest index c795bef110..821eb96f29 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sAPI\sdocumentation\sto\sidentify\smany\sfunctions\sas\smethods\son\sobjects.\nNo\schanges\sto\scode. -D 2015-04-14T15:14:06.177 +C Add\sthe\s--summary\soption\sto\sthe\ssqldiff\scommand-line\stool. +D 2015-04-14T19:01:08.549 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1239,7 +1239,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c -F tool/sqldiff.c 51c05cc1435507736b8b5a41a0498016041b3e48 +F tool/sqldiff.c 5c16cf3a1f566873abbdecac0d13a6691437564f F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 211411d02c0729c9af0e3cc7e4910db2e7e0d08e -R 32297e2ca295bdee2feb4a534c04bc42 +P b549cbcee1c11f9ffedf763ca672b125eac87bfe +R 64950626ad311356247b51bbef2cd09d U drh -Z 358af9cd25fc843b833aaa97a1900951 +Z 2d35d7a2b23bff60413bdff46818cee3 diff --git a/manifest.uuid b/manifest.uuid index 5721ce9565..674f6cdaa2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b549cbcee1c11f9ffedf763ca672b125eac87bfe \ No newline at end of file +88b22761c59b06fa86c57f8d22a46046ad17d5d5 \ No newline at end of file diff --git a/tool/sqldiff.c b/tool/sqldiff.c index 4455c582ef..c7b59400df 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -356,18 +356,18 @@ static char **columnNames(const char *zDb, const char *zTab, int *pnPKey){ /* ** Print the sqlite3_value X as an SQL literal. */ -static void printQuoted(sqlite3_value *X){ +static void printQuoted(FILE *out, sqlite3_value *X){ switch( sqlite3_value_type(X) ){ case SQLITE_FLOAT: { double r1; char zBuf[50]; r1 = sqlite3_value_double(X); sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.15g", r1); - printf("%s", zBuf); + fprintf(out, "%s", zBuf); break; } case SQLITE_INTEGER: { - printf("%lld", sqlite3_value_int64(X)); + fprintf(out, "%lld", sqlite3_value_int64(X)); break; } case SQLITE_BLOB: { @@ -375,13 +375,13 @@ static void printQuoted(sqlite3_value *X){ int nBlob = sqlite3_value_bytes(X); if( zBlob ){ int i; - printf("x'"); + fprintf(out, "x'"); for(i=0; i Date: Wed, 15 Apr 2015 04:10:50 +0000 Subject: [PATCH 14/28] An oversize hex literal can cause a parsing error while generating code for constants that are factored out of the main body of the VDBE program. So allow for that case. FossilOrigin-Name: a084690b4fcabba20d9770ebf3a014dda84e2954 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/build.c | 2 +- test/hexlit.test | 5 +++++ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 821eb96f29..70d58da81f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s--summary\soption\sto\sthe\ssqldiff\scommand-line\stool. -D 2015-04-14T19:01:08.549 +C An\soversize\shex\sliteral\scan\scause\sa\sparsing\serror\swhile\sgenerating\scode\sfor\nconstants\sthat\sare\sfactored\sout\sof\sthe\smain\sbody\sof\sthe\sVDBE\sprogram.\s\sSo\nallow\sfor\sthat\scase. +D 2015-04-15T04:10:50.814 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -176,7 +176,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 67648f6532c2da79d3b3fb6853aa1a0c3ba0e1ad F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4 -F src/build.c fa4795bc795077388aa4e746e1b25ef97bc10489 +F src/build.c 01b969b20a44a3d9620e597d9af8242348123540 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 @@ -633,7 +633,7 @@ F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26 F test/fuzzer1.test d4c52aaf3ef923da293a2653cfab33d02f718a36 F test/fuzzerfault.test 8792cd77fd5bce765b05d0c8e01b9edcf8af8536 F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 -F test/hexlit.test f9ecde8145bfc2341573473256c74ae37a200497 +F test/hexlit.test 1d312fa816dfd3650a3bb488093bc09a0c927f67 F test/hook.test 162d7cef7a2d2b04839fe14402934e6a1b79442f F test/icu.test 70df4faca133254c042d02ae342c0a141f2663f4 F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b549cbcee1c11f9ffedf763ca672b125eac87bfe -R 64950626ad311356247b51bbef2cd09d +P 88b22761c59b06fa86c57f8d22a46046ad17d5d5 +R a0a6eb36c09cbd9c15f1359867fe74af U drh -Z 2d35d7a2b23bff60413bdff46818cee3 +Z 7045f923a68da4f66662aff61189246b diff --git a/manifest.uuid b/manifest.uuid index 674f6cdaa2..81075d42b9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -88b22761c59b06fa86c57f8d22a46046ad17d5d5 \ No newline at end of file +a084690b4fcabba20d9770ebf3a014dda84e2954 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 9d8465561f..3021ad4e51 100644 --- a/src/build.c +++ b/src/build.c @@ -226,7 +226,7 @@ void sqlite3FinishCoding(Parse *pParse){ /* Get the VDBE program ready for execution */ - if( v && ALWAYS(pParse->nErr==0) && !db->mallocFailed ){ + if( v && pParse->nErr==0 && !db->mallocFailed ){ assert( pParse->iCacheLevel==0 ); /* Disables and re-enables match */ /* A minimum of one cursor is required if autoincrement is used * See ticket [a696379c1f08866] */ diff --git a/test/hexlit.test b/test/hexlit.test index 10909e6f4c..2edd458e89 100644 --- a/test/hexlit.test +++ b/test/hexlit.test @@ -109,6 +109,11 @@ do_execsql_test hexlit-301 { do_catchsql_test hexlist-400 { SELECT 0x10000000000000000; } {1 {hex literal too big: 0x10000000000000000}} +do_catchsql_test hexlist-410 { + DROP TABLE IF EXISTS t1; + CREATE TABLE t1(x); + INSERT INTO t1 VALUES(1+0x10000000000000000); +} {1 {hex literal too big: 0x10000000000000000}} finish_test From 311efc70a74a01d22b4d90c87490cda41b0b110a Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 04:20:58 +0000 Subject: [PATCH 15/28] Add a test case for what was formerly thought to be an unreachable condition: when the LHS of an OR operator contains an error and the RHS contains an IN operator. FossilOrigin-Name: 3872742591add4e94033484c2844e7d7ab69674b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/expr.c | 2 +- test/in.test | 6 ++++++ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 70d58da81f..8ac7986648 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C An\soversize\shex\sliteral\scan\scause\sa\sparsing\serror\swhile\sgenerating\scode\sfor\nconstants\sthat\sare\sfactored\sout\sof\sthe\smain\sbody\sof\sthe\sVDBE\sprogram.\s\sSo\nallow\sfor\sthat\scase. -D 2015-04-15T04:10:50.814 +C Add\sa\stest\scase\sfor\swhat\swas\sformerly\sthought\sto\sbe\san\sunreachable\scondition:\nwhen\sthe\sLHS\sof\san\sOR\soperator\scontains\san\serror\sand\sthe\sRHS\scontains\san\sIN\noperator. +D 2015-04-15T04:20:58.065 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -182,7 +182,7 @@ F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e -F src/expr.c d09dac67d53c78880ba31d56e8ba2be3a6490553 +F src/expr.c aba4f0547aac1fcbd965d548ab2e36efd5a4481c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 3343d551a8d810782257244fb33f2ce191493c39 F src/func.c 1414c24c873c48796ad45942257a179a423ba42f @@ -637,7 +637,7 @@ F test/hexlit.test 1d312fa816dfd3650a3bb488093bc09a0c927f67 F test/hook.test 162d7cef7a2d2b04839fe14402934e6a1b79442f F test/icu.test 70df4faca133254c042d02ae342c0a141f2663f4 F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8 -F test/in.test 047c4671328e9032ab95666a67021adbbd36e98e +F test/in.test b52fa96bcf6cebc5c8829c822315d0f87af9c6c2 F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75 F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0 F test/in4.test d2b38cba404bc4320f4fe1b595b3d163f212c068 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 88b22761c59b06fa86c57f8d22a46046ad17d5d5 -R a0a6eb36c09cbd9c15f1359867fe74af +P a084690b4fcabba20d9770ebf3a014dda84e2954 +R fcf0b4147f04a74e05def15e3b1a56b8 U drh -Z 7045f923a68da4f66662aff61189246b +Z 041867bd4c7c23a09c20a9ae6f8ff29f diff --git a/manifest.uuid b/manifest.uuid index 81075d42b9..f94b10f78e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a084690b4fcabba20d9770ebf3a014dda84e2954 \ No newline at end of file +3872742591add4e94033484c2844e7d7ab69674b \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index e6ac0f6796..6a30755aa5 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1691,7 +1691,7 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, u32 inFlags, int *prRhsHasNull){ ** ephemeral table. */ p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0); - if( ALWAYS(pParse->nErr==0) && isCandidateForInOpt(p) ){ + if( pParse->nErr==0 && isCandidateForInOpt(p) ){ sqlite3 *db = pParse->db; /* Database connection */ Table *pTab; /* Table . */ Expr *pExpr; /* Expression */ diff --git a/test/in.test b/test/in.test index 515e598c12..de38c22456 100644 --- a/test/in.test +++ b/test/in.test @@ -615,6 +615,12 @@ do_test in-13.14 { } } {} +do_test in-13.15 { + catchsql { + SELECT 0 WHERE (SELECT 0,0) OR (0 IN (1,2)); + } +} {1 {only a single result allowed for a SELECT that is part of an expression}} + do_test in-13.X { db nullvalue "" From 0ec68f845c1ab87995f8956c2617c7017809a963 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 04:51:28 +0000 Subject: [PATCH 16/28] When doing the (dubious) conversion of double-quoted identifier into string literal for MySQL compatibility, be sure to also clear the iTable value from the Expr entry to avoid an assert. FossilOrigin-Name: d7211b68107ea669de39e0aa81a1be40901e1487 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/resolve.c | 1 + test/misc1.test | 5 +++++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 8ac7986648..c64b26440d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\scase\sfor\swhat\swas\sformerly\sthought\sto\sbe\san\sunreachable\scondition:\nwhen\sthe\sLHS\sof\san\sOR\soperator\scontains\san\serror\sand\sthe\sRHS\scontains\san\sIN\noperator. -D 2015-04-15T04:20:58.065 +C When\sdoing\sthe\s(dubious)\sconversion\sof\sdouble-quoted\sidentifier\sinto\sstring\nliteral\sfor\sMySQL\scompatibility,\sbe\ssure\sto\salso\sclear\sthe\siTable\svalue\sfrom\nthe\sExpr\sentry\sto\savoid\san\sassert. +D 2015-04-15T04:51:28.676 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -228,7 +228,7 @@ F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f F src/prepare.c 173a5a499138451b2561614ecb87d78f9f4644b9 F src/printf.c 8ae1fa9d30c1200a9268a390ba9e9cea9197b27a F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 -F src/resolve.c 41aa91af56d960e9414ce1d7c17cfb68e0d1c6cb +F src/resolve.c 7bd67ded824a2fe8b356cd45e053d9c94b1874c2 F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 117e0f9ac9254a6f7472fac5144eba21ba0b2ec1 F src/shell.c 84a1593bd86aaa14f4da8a8f9b16fbc239d262aa @@ -743,7 +743,7 @@ F test/minmax.test 42fbad0e81afaa6e0de41c960329f2b2c3526efd F test/minmax2.test b44bae787fc7b227597b01b0ca5575c7cb54d3bc F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 F test/minmax4.test 936941484ebdceb8adec7c86b6cd9b6e5e897c1f -F test/misc1.test f3f59b3941c84a10860c06c07e86ad367a74ec92 +F test/misc1.test 9abcae9a0b8785d6fa92925dbb19c309ae9ea077 F test/misc2.test 00d7de54eda90e237fc9a38b9e5ccc769ebf6d4d F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a084690b4fcabba20d9770ebf3a014dda84e2954 -R fcf0b4147f04a74e05def15e3b1a56b8 +P 3872742591add4e94033484c2844e7d7ab69674b +R 3d936303913ff5357294410059be6467 U drh -Z 041867bd4c7c23a09c20a9ae6f8ff29f +Z adb676b9f25e7eed8c83dbf9762c49f4 diff --git a/manifest.uuid b/manifest.uuid index f94b10f78e..f2359bbae0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3872742591add4e94033484c2844e7d7ab69674b \ No newline at end of file +d7211b68107ea669de39e0aa81a1be40901e1487 \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index a7b14cd005..d66de27958 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -460,6 +460,7 @@ static int lookupName( if( cnt==0 && zTab==0 && ExprHasProperty(pExpr,EP_DblQuoted) ){ pExpr->op = TK_STRING; pExpr->pTab = 0; + pExpr->iTable = -1; return WRC_Prune; } diff --git a/test/misc1.test b/test/misc1.test index 0f4881fb61..1b98eafc6a 100644 --- a/test/misc1.test +++ b/test/misc1.test @@ -639,4 +639,9 @@ do_catchsql_test misc1-21.2 { VALUES(0,0x0MATCH#0; } {1 {near ";": syntax error}} +# 2015-04-15 +do_execsql_test misc1-22.1 { + SELECT ""+3 FROM (SELECT ""+5); +} {3} + finish_test From 1978d171cb1f64765b18c81ad3d8bde62c2d434c Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 05:20:44 +0000 Subject: [PATCH 17/28] When adding the implied "LIMIT 1" to the end of a scalar subquery, make sure that subquery is not a VALUES-only query as such queries cannot deal with LIMIT clauses. FossilOrigin-Name: 7c27310bdf6b4af44a0811a2787ed64966d720d2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/expr.c | 1 + test/select4.test | 7 +++++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c64b26440d..3a48ca3967 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sdoing\sthe\s(dubious)\sconversion\sof\sdouble-quoted\sidentifier\sinto\sstring\nliteral\sfor\sMySQL\scompatibility,\sbe\ssure\sto\salso\sclear\sthe\siTable\svalue\sfrom\nthe\sExpr\sentry\sto\savoid\san\sassert. -D 2015-04-15T04:51:28.676 +C When\sadding\sthe\simplied\s"LIMIT\s1"\sto\sthe\send\sof\sa\sscalar\ssubquery,\smake\ssure\nthat\ssubquery\sis\snot\sa\sVALUES-only\squery\sas\ssuch\squeries\scannot\sdeal\swith\nLIMIT\sclauses. +D 2015-04-15T05:20:44.109 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -182,7 +182,7 @@ F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887 F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e -F src/expr.c aba4f0547aac1fcbd965d548ab2e36efd5a4481c +F src/expr.c 8800584340a9b4f4c0ca55c360de751c6da0b11a F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 3343d551a8d810782257244fb33f2ce191493c39 F src/func.c 1414c24c873c48796ad45942257a179a423ba42f @@ -839,7 +839,7 @@ F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5 F test/select1.test fc2a61f226a649393664ad54bc5376631801517c F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054 -F test/select4.test e20e8ce47b558de80616102ef273704cf0d48a3b +F test/select4.test af938bb5f55c6f3925047fc7cd837c894566f5db F test/select5.test e758b8ef94f69b111df4cb819008856655dcd535 F test/select6.test 39eac4a5c03650b2b473c532882273283ee8b7a0 F test/select7.test 7fd2ef598cfabb6b9ff6ac13973b91d0527df49d @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3872742591add4e94033484c2844e7d7ab69674b -R 3d936303913ff5357294410059be6467 +P d7211b68107ea669de39e0aa81a1be40901e1487 +R 880c9defd1fb09406a80bcc7ed2c9c3e U drh -Z adb676b9f25e7eed8c83dbf9762c49f4 +Z 868124641765b45b984dc6b337325865 diff --git a/manifest.uuid b/manifest.uuid index f2359bbae0..783f8ed725 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d7211b68107ea669de39e0aa81a1be40901e1487 \ No newline at end of file +7c27310bdf6b4af44a0811a2787ed64966d720d2 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 6a30755aa5..77eb35aa74 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2016,6 +2016,7 @@ int sqlite3CodeSubselect( pSel->pLimit = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[1]); pSel->iLimit = 0; + pSel->selFlags &= ~SF_AllValues; if( sqlite3Select(pParse, pSel, &dest) ){ return 0; } diff --git a/test/select4.test b/test/select4.test index 47a44081f4..71171def33 100644 --- a/test/select4.test +++ b/test/select4.test @@ -863,5 +863,12 @@ do_execsql_test select4-14.8 { do_execsql_test select4-14.9 { SELECT * FROM t14 UNION ALL VALUES(3,2,1),(2,3,1),(1,2,3),(2,1,3); } {1 2 3 4 5 6 3 2 1 2 3 1 1 2 3 2 1 3} +do_execsql_test select4-14.10 { + SELECT (VALUES(1),(2),(3),(4)) +} {1} +do_execsql_test select4-14.11 { + SELECT (SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4) +} {1} + finish_test From 65df68e8c56bf3b79a31a7a1e853f4067998e207 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 05:31:02 +0000 Subject: [PATCH 18/28] Correctly deal with an unknown collating sequence on an indexed DISTINCT query. FossilOrigin-Name: a0b6e2fed3e95cf78ed0515c6e4da7510af4e86a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 2 +- test/collate3.test | 7 ++++++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 3a48ca3967..2b31601281 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sadding\sthe\simplied\s"LIMIT\s1"\sto\sthe\send\sof\sa\sscalar\ssubquery,\smake\ssure\nthat\ssubquery\sis\snot\sa\sVALUES-only\squery\sas\ssuch\squeries\scannot\sdeal\swith\nLIMIT\sclauses. -D 2015-04-15T05:20:44.109 +C Correctly\sdeal\swith\san\sunknown\scollating\ssequence\son\san\sindexed\sDISTINCT\squery. +D 2015-04-15T05:31:02.899 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -307,7 +307,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 753995db83247f20361a8e8a874990b21a75abd9 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 -F src/where.c 9952e4749f481707595692f2f13d3ce3b64ffdc8 +F src/where.c 8a05434f5a75a38c64c45e316b00167ba0fd7ad3 F src/whereInt.h cbe4aa57326998d89e7698ca65bb7c28541d483c F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -401,7 +401,7 @@ F test/closure01.test b1703ba40639cfc9b295cf478d70739415eec6a4 F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91 F test/collate1.test 7fcfe78f9613dc4a7e247d6bd27749955f108741 F test/collate2.test 9aaa410a00734e48bcb27f3872617d6f69b2a621 -F test/collate3.test 79558a286362cb9ed603c6fa543f1cda7f563f0f +F test/collate3.test 89defc49983ddfbf0a0555aca8c0521a676f56a5 F test/collate4.test f04d5168685f2eef637ecfa2d4ddf8ec0d600177 F test/collate5.test 65d928034d30d2d263a80f6359f7549ee1598ec6 F test/collate6.test 8be65a182abaac8011a622131486dafb8076e907 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d7211b68107ea669de39e0aa81a1be40901e1487 -R 880c9defd1fb09406a80bcc7ed2c9c3e +P 7c27310bdf6b4af44a0811a2787ed64966d720d2 +R 97d8aa531c1ae9c06ffcd147c2fe4f6f U drh -Z 868124641765b45b984dc6b337325865 +Z 3a34d92eb0e2b45ff65d57bcfcec8b05 diff --git a/manifest.uuid b/manifest.uuid index 783f8ed725..4b837de064 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c27310bdf6b4af44a0811a2787ed64966d720d2 \ No newline at end of file +a0b6e2fed3e95cf78ed0515c6e4da7510af4e86a \ No newline at end of file diff --git a/src/where.c b/src/where.c index 42e950e41e..e1c5f4ecaa 100644 --- a/src/where.c +++ b/src/where.c @@ -1532,7 +1532,7 @@ static int findIndexCol( && p->iTable==iBase ){ CollSeq *pColl = sqlite3ExprCollSeq(pParse, pList->a[i].pExpr); - if( ALWAYS(pColl) && 0==sqlite3StrICmp(pColl->zName, zColl) ){ + if( pColl && 0==sqlite3StrICmp(pColl->zName, zColl) ){ return i; } } diff --git a/test/collate3.test b/test/collate3.test index 2c051cb9a7..99640d05b8 100644 --- a/test/collate3.test +++ b/test/collate3.test @@ -32,7 +32,7 @@ source $testdir/tester.tcl # do_test collate3-1.0 { execsql { - CREATE TABLE collate3t1(c1); + CREATE TABLE collate3t1(c1 UNIQUE); } } {} do_test collate3-1.1 { @@ -40,6 +40,11 @@ do_test collate3-1.1 { SELECT * FROM collate3t1 ORDER BY 1 collate garbage; } } {1 {no such collation sequence: garbage}} +do_test collate3-1.1.2 { + catchsql { + SELECT DISTINCT c1 COLLATE garbage FROM collate3t1; + } +} {1 {no such collation sequence: garbage}} do_test collate3-1.2 { catchsql { CREATE TABLE collate3t2(c1 collate garbage); From 3457338ced7a521be2fb0aab1808648128a3d43e Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 05:38:35 +0000 Subject: [PATCH 19/28] Fix a faulty assert() in the sqlite3StrAccumAppend() routine. FossilOrigin-Name: 998cfdb8dcda2cac94b83326751e16dcef8b267f --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/printf.c | 2 +- test/printf2.test | 3 +++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 2b31601281..94e960af32 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correctly\sdeal\swith\san\sunknown\scollating\ssequence\son\san\sindexed\sDISTINCT\squery. -D 2015-04-15T05:31:02.899 +C Fix\sa\sfaulty\sassert()\sin\sthe\ssqlite3StrAccumAppend()\sroutine. +D 2015-04-15T05:38:35.928 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -226,7 +226,7 @@ F src/pcache1.c 69d137620a305f814398bd29a0c998038c0695e9 F src/pragma.c ac4f3f856b4234e85f55b0f069698a4766011100 F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f F src/prepare.c 173a5a499138451b2561614ecb87d78f9f4644b9 -F src/printf.c 8ae1fa9d30c1200a9268a390ba9e9cea9197b27a +F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 7bd67ded824a2fe8b356cd45e053d9c94b1874c2 F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e @@ -798,7 +798,7 @@ F test/pragma.test ad99d05e411c7687302124be56f3b362204be041 F test/pragma2.test f624a496a95ee878e81e59961eade66d5c00c028 F test/pragma3.test 6f849ccffeee7e496d2f2b5e74152306c0b8757c F test/printf.test b3ff34e73d59124140eaf89f7672e21bc2ca5fcc -F test/printf2.test b4acd4bf8734243257f01ddefa17c4fb090acc8a +F test/printf2.test 0b61566dd1c0f0b802f59dffa228c5dc5aa6b054 F test/progress.test a282973d1d17f08071bc58a77d6b80f2a81c354d F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/queryonly.test 5f653159e0f552f0552d43259890c1089391dcca @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7c27310bdf6b4af44a0811a2787ed64966d720d2 -R 97d8aa531c1ae9c06ffcd147c2fe4f6f +P a0b6e2fed3e95cf78ed0515c6e4da7510af4e86a +R bd008e3cfd1613a5e1f1a28458fbfaad U drh -Z 3a34d92eb0e2b45ff65d57bcfcec8b05 +Z cf565eb6ae4e94564c05e7f944eb18e5 diff --git a/manifest.uuid b/manifest.uuid index 4b837de064..1adef81d5f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a0b6e2fed3e95cf78ed0515c6e4da7510af4e86a \ No newline at end of file +998cfdb8dcda2cac94b83326751e16dcef8b267f \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 9714fa1565..1a978dc5ca 100644 --- a/src/printf.c +++ b/src/printf.c @@ -826,7 +826,7 @@ static void SQLITE_NOINLINE enlargeAndAppend(StrAccum *p, const char *z, int N){ ** size of the memory allocation for StrAccum if necessary. */ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){ - assert( z!=0 ); + assert( z!=0 || N==0 ); assert( p->zText!=0 || p->nChar==0 || p->accError ); assert( N>=0 ); assert( p->accError==0 || p->nAlloc==0 ); diff --git a/test/printf2.test b/test/printf2.test index 21deeb779d..fb031bd68f 100644 --- a/test/printf2.test +++ b/test/printf2.test @@ -58,6 +58,9 @@ do_execsql_test printf2-1.10 { do_execsql_test printf2-1.11 { SELECT printf('%lld%n',314159.2653,'hi'); } {314159} +do_execsql_test printf2-1.12 { + SELECT printf('%n',0); +} {{}} # EVIDENCE-OF: R-17002-27534 The %z format is interchangeable with %s. # From 6456b7710c1ff87a5a6b6f58a8d1471a16553434 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 05:57:50 +0000 Subject: [PATCH 20/28] Correctly handle COLLATE operators applied to COLLATE operators in an ORDER BY clause. FossilOrigin-Name: 9e1f837b08facbc7a2b6196770599a58233e725c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/resolve.c | 8 +++++--- test/collate1.test | 18 ++++++++++++++++-- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 94e960af32..355bd09e61 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sfaulty\sassert()\sin\sthe\ssqlite3StrAccumAppend()\sroutine. -D 2015-04-15T05:38:35.928 +C Correctly\shandle\sCOLLATE\soperators\sapplied\sto\sCOLLATE\soperators\sin\san\nORDER\sBY\sclause. +D 2015-04-15T05:57:50.327 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -228,7 +228,7 @@ F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f F src/prepare.c 173a5a499138451b2561614ecb87d78f9f4644b9 F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 -F src/resolve.c 7bd67ded824a2fe8b356cd45e053d9c94b1874c2 +F src/resolve.c 03fe2a8640b7f1477e6cbca6f3bc1b5549263a47 F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 117e0f9ac9254a6f7472fac5144eba21ba0b2ec1 F src/shell.c 84a1593bd86aaa14f4da8a8f9b16fbc239d262aa @@ -399,7 +399,7 @@ F test/check.test 5831ddb6f2c687782eaf2e1a07b6e17f24c4f763 F test/close.test 340bd24cc58b16c6bc01967402755027c37eb815 F test/closure01.test b1703ba40639cfc9b295cf478d70739415eec6a4 F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91 -F test/collate1.test 7fcfe78f9613dc4a7e247d6bd27749955f108741 +F test/collate1.test 08c18e7512a5a32c97938854263fa15362eeb846 F test/collate2.test 9aaa410a00734e48bcb27f3872617d6f69b2a621 F test/collate3.test 89defc49983ddfbf0a0555aca8c0521a676f56a5 F test/collate4.test f04d5168685f2eef637ecfa2d4ddf8ec0d600177 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a0b6e2fed3e95cf78ed0515c6e4da7510af4e86a -R bd008e3cfd1613a5e1f1a28458fbfaad +P 998cfdb8dcda2cac94b83326751e16dcef8b267f +R 365a6b3d3d3943322095f384b9ee1504 U drh -Z cf565eb6ae4e94564c05e7f944eb18e5 +Z eaf1d275b82a1bdf74f8de064c4444e7 diff --git a/manifest.uuid b/manifest.uuid index 1adef81d5f..a0184f5e23 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -998cfdb8dcda2cac94b83326751e16dcef8b267f \ No newline at end of file +9e1f837b08facbc7a2b6196770599a58233e725c \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index d66de27958..aa4cddfef2 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -994,9 +994,11 @@ static int resolveCompoundOrderBy( if( pItem->pExpr==pE ){ pItem->pExpr = pNew; }else{ - assert( pItem->pExpr->op==TK_COLLATE ); - assert( pItem->pExpr->pLeft==pE ); - pItem->pExpr->pLeft = pNew; + Expr *pParent = pItem->pExpr; + assert( pParent->op==TK_COLLATE ); + while( pParent->pLeft->op==TK_COLLATE ) pParent = pParent->pLeft; + assert( pParent->pLeft==pE ); + pParent->pLeft = pNew; } sqlite3ExprDelete(db, pE); pItem->u.x.iOrderByCol = (u16)iCol; diff --git a/test/collate1.test b/test/collate1.test index 0716ac743f..7cf5698454 100644 --- a/test/collate1.test +++ b/test/collate1.test @@ -385,6 +385,20 @@ do_execsql_test 6.8 { SELECT x, y FROM c1 ORDER BY y COLLATE """"""""; } {2 abb 1 ABC 4 WXY 3 wxz} +# 2015-04-15: Nested COLLATE operators +# +do_execsql_test 7.0 { + SELECT 'abc' UNION ALL SELECT 'DEF' + ORDER BY 1 COLLATE nocase COLLATE nocase COLLATE nocase COLLATE nocase; +} {abc DEF} +do_execsql_test 7.1 { + SELECT 'abc' UNION ALL SELECT 'DEF' + ORDER BY 1 COLLATE nocase COLLATE nocase COLLATE nocase COLLATE binary; +} {DEF abc} +do_execsql_test 7.2 { + SELECT 'abc' UNION ALL SELECT 'DEF' + ORDER BY 1 COLLATE binary COLLATE binary COLLATE binary COLLATE nocase; +} {abc DEF} + + finish_test - - From a43f02efc613826511132be78c9445e239f91ddd Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 06:45:13 +0000 Subject: [PATCH 21/28] Fix a faulty assert() statement in the name resolver associated with the optimization that converts compound selects with ORDER BY COLLATE into subqueries. FossilOrigin-Name: c72324ef9243946550ae3d974826502b1cc5eb10 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/resolve.c | 2 +- test/selectE.test | 5 +++++ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 355bd09e61..b179c36ad3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correctly\shandle\sCOLLATE\soperators\sapplied\sto\sCOLLATE\soperators\sin\san\nORDER\sBY\sclause. -D 2015-04-15T05:57:50.327 +C Fix\sa\sfaulty\sassert()\sstatement\sin\sthe\sname\sresolver\sassociated\swith\sthe\noptimization\sthat\sconverts\scompound\sselects\swith\sORDER\sBY\sCOLLATE\sinto\nsubqueries. +D 2015-04-15T06:45:13.856 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -228,7 +228,7 @@ F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f F src/prepare.c 173a5a499138451b2561614ecb87d78f9f4644b9 F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 -F src/resolve.c 03fe2a8640b7f1477e6cbca6f3bc1b5549263a47 +F src/resolve.c 66cfe49a9c3b449ef13b89a8c47036a4ed167eab F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 117e0f9ac9254a6f7472fac5144eba21ba0b2ec1 F src/shell.c 84a1593bd86aaa14f4da8a8f9b16fbc239d262aa @@ -849,7 +849,7 @@ F test/selectA.test e452bdb975f488ea46d091382a9185b5853ed2c7 F test/selectB.test 954e4e49cf1f896d61794e440669e03a27ceea25 F test/selectC.test 871fb55d884d3de5943c4057ebd22c2459e71977 F test/selectD.test b0f02a04ef7737decb24e08be2c39b9664b43394 -F test/selectE.test fc02a1eb04c8eb537091482644b7d778ae8759b7 +F test/selectE.test a8730ca330fcf40ace158f134f4fe0eb00c7edbf F test/selectF.test 21c94e6438f76537b72532fa9fd4710cdd455fc3 F test/selectG.test e8600e379589e85e9fefd2fe4d44a4cdd63f6982 F test/server1.test 46803bd3fe8b99b30dbc5ff38ffc756f5c13a118 @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 998cfdb8dcda2cac94b83326751e16dcef8b267f -R 365a6b3d3d3943322095f384b9ee1504 +P 9e1f837b08facbc7a2b6196770599a58233e725c +R d99053241fb4278349e47e2aa3bd86a0 U drh -Z eaf1d275b82a1bdf74f8de064c4444e7 +Z d2955d105f5f67e57ae3e9b26664c585 diff --git a/manifest.uuid b/manifest.uuid index a0184f5e23..3d0d30286b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9e1f837b08facbc7a2b6196770599a58233e725c \ No newline at end of file +c72324ef9243946550ae3d974826502b1cc5eb10 \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index aa4cddfef2..6294ba26e1 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -1198,7 +1198,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ ** after the names have been resolved. */ if( p->selFlags & SF_Converted ){ Select *pSub = p->pSrc->a[0].pSelect; - assert( p->pSrc->nSrc==1 && isCompound==0 && p->pOrderBy ); + assert( p->pSrc->nSrc==1 && p->pOrderBy ); assert( pSub->pPrior && pSub->pOrderBy==0 ); pSub->pOrderBy = p->pOrderBy; p->pOrderBy = 0; diff --git a/test/selectE.test b/test/selectE.test index d7592bbbc5..1cabeff370 100644 --- a/test/selectE.test +++ b/test/selectE.test @@ -92,4 +92,9 @@ do_test selectE-2.2 { } } {} +do_catchsql_test selectE-3.1 { + SELECT 1 EXCEPT SELECT 2 ORDER BY 1 COLLATE nocase EXCEPT SELECT 3; +} {1 {ORDER BY clause should come after EXCEPT not before}} + + finish_test From 3dc4cc66b3a7ff48cff042751a5e9eee41b08f24 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 07:10:25 +0000 Subject: [PATCH 22/28] Change the multiSelectOrderBy() routine to return non-zero if there has been any prior error. FossilOrigin-Name: 14784c317bff05dd0a74e2596432dfd12c139391 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 2 +- test/select4.test | 5 +++++ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index b179c36ad3..8fb373a6c9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sfaulty\sassert()\sstatement\sin\sthe\sname\sresolver\sassociated\swith\sthe\noptimization\sthat\sconverts\scompound\sselects\swith\sORDER\sBY\sCOLLATE\sinto\nsubqueries. -D 2015-04-15T06:45:13.856 +C Change\sthe\smultiSelectOrderBy()\sroutine\sto\sreturn\snon-zero\sif\sthere\shas\nbeen\sany\sprior\serror. +D 2015-04-15T07:10:25.034 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +230,7 @@ F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 66cfe49a9c3b449ef13b89a8c47036a4ed167eab F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c 117e0f9ac9254a6f7472fac5144eba21ba0b2ec1 +F src/select.c 93260bc9e7e0e6dfe1b7cb8815b0ed4cad8be9e3 F src/shell.c 84a1593bd86aaa14f4da8a8f9b16fbc239d262aa F src/sqlite.h.in ca27603a36fcacdaac5a19d8ee35aaff8ce8516f F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -839,7 +839,7 @@ F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5 F test/select1.test fc2a61f226a649393664ad54bc5376631801517c F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054 -F test/select4.test af938bb5f55c6f3925047fc7cd837c894566f5db +F test/select4.test 16fa1cafb942f42294ec85cbb78954c2f2d15a44 F test/select5.test e758b8ef94f69b111df4cb819008856655dcd535 F test/select6.test 39eac4a5c03650b2b473c532882273283ee8b7a0 F test/select7.test 7fd2ef598cfabb6b9ff6ac13973b91d0527df49d @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9e1f837b08facbc7a2b6196770599a58233e725c -R d99053241fb4278349e47e2aa3bd86a0 +P c72324ef9243946550ae3d974826502b1cc5eb10 +R a18a17a9c69cd2c9e7e0fb3024e1e22e U drh -Z d2955d105f5f67e57ae3e9b26664c585 +Z 56fd45c34ac20b50b5d25609e083b049 diff --git a/manifest.uuid b/manifest.uuid index 3d0d30286b..b9b981e38f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c72324ef9243946550ae3d974826502b1cc5eb10 \ No newline at end of file +14784c317bff05dd0a74e2596432dfd12c139391 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 930a099e80..bed1f80be0 100644 --- a/src/select.c +++ b/src/select.c @@ -3071,7 +3071,7 @@ static int multiSelectOrderBy( /*** TBD: Insert subroutine calls to close cursors on incomplete **** subqueries ****/ explainComposite(pParse, p->op, iSub1, iSub2, 0); - return SQLITE_OK; + return pParse->nErr!=0; } #endif diff --git a/test/select4.test b/test/select4.test index 71171def33..2f3ddbe96a 100644 --- a/test/select4.test +++ b/test/select4.test @@ -799,6 +799,11 @@ do_test select4-11.15 { SELECT x FROM t2 } } {1 {SELECTs to the left and right of UNION do not have the same number of result columns}} +do_test select4-11.16 { + catchsql { + INSERT INTO t2(rowid) VALUES(2) UNION SELECT 3,4 UNION SELECT 5,6 ORDER BY 1; + } +} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}} do_test select4-12.1 { sqlite3 db2 :memory: From 1b6789697d13ab232b99f8064b0d106c6b5184a0 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 07:19:27 +0000 Subject: [PATCH 23/28] Remove an incorrect ALWAYS() from the table_info pragma. FossilOrigin-Name: 0e087c0183bc7a758cf2a1d39158bc24fde833a2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pragma.c | 2 +- test/pragma.test | 10 ++++++++++ 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 8fb373a6c9..82ef7926f4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\smultiSelectOrderBy()\sroutine\sto\sreturn\snon-zero\sif\sthere\shas\nbeen\sany\sprior\serror. -D 2015-04-15T07:10:25.034 +C Remove\san\sincorrect\sALWAYS()\sfrom\sthe\stable_info\spragma. +D 2015-04-15T07:19:27.406 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -223,7 +223,7 @@ F src/parse.y 1299c66e7b1707322ccd8af43a359b8fb0d46d72 F src/pcache.c 10539fb959849ad6efff80050541cab3d25089d4 F src/pcache.h b44658c9c932d203510279439d891a2a83e12ba8 F src/pcache1.c 69d137620a305f814398bd29a0c998038c0695e9 -F src/pragma.c ac4f3f856b4234e85f55b0f069698a4766011100 +F src/pragma.c 3965ae4e82bed39fb97ce04c5fe18c9bc3ee6a88 F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f F src/prepare.c 173a5a499138451b2561614ecb87d78f9f4644b9 F src/printf.c 08fa675c200aac29e561c6153f91f909ed17612f @@ -794,7 +794,7 @@ F test/pcache.test b09104b03160aca0d968d99e8cd2c5b1921a993d F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff F test/permutations.test f9cc1dd987986c9d4949211c7a4ed55ec9aecba1 -F test/pragma.test ad99d05e411c7687302124be56f3b362204be041 +F test/pragma.test e6605ce89c66db930aef561e43a22281a09ffc66 F test/pragma2.test f624a496a95ee878e81e59961eade66d5c00c028 F test/pragma3.test 6f849ccffeee7e496d2f2b5e74152306c0b8757c F test/printf.test b3ff34e73d59124140eaf89f7672e21bc2ca5fcc @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P c72324ef9243946550ae3d974826502b1cc5eb10 -R a18a17a9c69cd2c9e7e0fb3024e1e22e +P 14784c317bff05dd0a74e2596432dfd12c139391 +R 275812afa820df20388de5de5b05e3ce U drh -Z 56fd45c34ac20b50b5d25609e083b049 +Z c974cc37b6f1891bf4b4ede9ca413ca2 diff --git a/manifest.uuid b/manifest.uuid index b9b981e38f..a860fba913 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -14784c317bff05dd0a74e2596432dfd12c139391 \ No newline at end of file +0e087c0183bc7a758cf2a1d39158bc24fde833a2 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index ef11d5840f..8f6ac64754 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1041,7 +1041,7 @@ void sqlite3Pragma( }else if( pPk==0 ){ k = 1; }else{ - for(k=1; ALWAYS(k<=pTab->nCol) && pPk->aiColumn[k-1]!=i; k++){} + for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){} } sqlite3VdbeAddOp2(v, OP_Integer, k, 6); sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6); diff --git a/test/pragma.test b/test/pragma.test index d164702643..e8a53f442d 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -752,6 +752,16 @@ do_test pragma-6.7 { {3 four REAL 0 X'abcdef' 0} \ {4 five {} 0 CURRENT_TIME 0} \ ] +do_test pragma-6.8 { + execsql { + CREATE TABLE t68(a,b,c,PRIMARY KEY(a,b,a,c)); + PRAGMA table_info(t68); + } +} [concat \ + {0 a {} 0 {} 1} \ + {1 b {} 0 {} 2} \ + {2 c {} 0 {} 4} \ +] } ;# ifcapable schema_pragmas # Miscellaneous tests # From 29031837c19e371ae6056e2dc3efb03f3f7895b4 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 07:34:25 +0000 Subject: [PATCH 24/28] Remove an incorrect ALWAYS() from the automatic index generator. FossilOrigin-Name: eeb4bd06bf69e411736cc6077d1d64af6bd8fb09 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 2 +- test/autoindex1.test | 7 +++++++ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 82ef7926f4..f61d8e0c34 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sincorrect\sALWAYS()\sfrom\sthe\stable_info\spragma. -D 2015-04-15T07:19:27.406 +C Remove\san\sincorrect\sALWAYS()\sfrom\sthe\sautomatic\sindex\sgenerator. +D 2015-04-15T07:34:25.165 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -307,7 +307,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 753995db83247f20361a8e8a874990b21a75abd9 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 -F src/where.c 8a05434f5a75a38c64c45e316b00167ba0fd7ad3 +F src/where.c 8ba8ff31dc9bf1b69fe771d35d8764d5a1efd310 F src/whereInt.h cbe4aa57326998d89e7698ca65bb7c28541d483c F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -349,7 +349,7 @@ F test/auth.test 855233ef26eb3601b6886567ea4e326c72959360 F test/auth2.test 264c6af53cad9aba5218c68bbe18036e39007bfa F test/auth3.test 5cfa94ed90c6617c42b7ba4b133fd79678b251c7 F test/autoinc.test c58912526998a39e11f66b533e23cfabea7f25b7 -F test/autoindex1.test 7008c9f604141fdabe31b7bb95b5ff31b518251f +F test/autoindex1.test 14b63a9f1e405fe6d5bfc8c8d00249c2ebaf13ea F test/autoindex2.test af7e595c6864cc6ef5fc38d5db579a3e34940cb8 F test/autoindex3.test a3be0d1a53a7d2edff208a5e442312957047e972 F test/autoindex4.test 49d3cd791a9baa16fb461d7ea3de80d019a819cf @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 14784c317bff05dd0a74e2596432dfd12c139391 -R 275812afa820df20388de5de5b05e3ce +P 0e087c0183bc7a758cf2a1d39158bc24fde833a2 +R 45168c2ae417f665e937b47961f47d47 U drh -Z c974cc37b6f1891bf4b4ede9ca413ca2 +Z fe2feaff56a77a679eecea2f54332501 diff --git a/manifest.uuid b/manifest.uuid index a860fba913..2e89d53bd1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0e087c0183bc7a758cf2a1d39158bc24fde833a2 \ No newline at end of file +eeb4bd06bf69e411736cc6077d1d64af6bd8fb09 \ No newline at end of file diff --git a/src/where.c b/src/where.c index e1c5f4ecaa..3467a68626 100644 --- a/src/where.c +++ b/src/where.c @@ -1806,7 +1806,7 @@ static void constructAutomaticIndex( idxCols |= cMask; pIdx->aiColumn[n] = pTerm->u.leftColumn; pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); - pIdx->azColl[n] = ALWAYS(pColl) ? pColl->zName : "BINARY"; + pIdx->azColl[n] = pColl ? pColl->zName : "BINARY"; n++; } } diff --git a/test/autoindex1.test b/test/autoindex1.test index c5ce42c1d4..e2b8b1529e 100644 --- a/test/autoindex1.test +++ b/test/autoindex1.test @@ -512,5 +512,12 @@ do_execsql_test autoindex1-901 { WHERE t1.x IN (1,2,3); } {/USING AUTOMATIC COVERING INDEX/} +# 2015-04-15: A NULL CollSeq pointer in automatic index creation. +# +do_execsql_test autoindex1-920 { + CREATE TABLE t920(x); + INSERT INTO t920 VALUES(3),(4),(5); + SELECT * FROM t920,(SELECT 0 FROM t920),(VALUES(9)) WHERE 5 IN (x); +} {5 0 9 5 0 9 5 0 9} finish_test From 347bdc39a70e092247a3fc0c3e4e99aef24d92fe Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 07:57:27 +0000 Subject: [PATCH 25/28] Fix the error message generator for illegal token errors so that it does not leak memory if it immediately follows another erroneous SQL statement. FossilOrigin-Name: 3576973f8b88b6109fbefdebfa53468ffa137009 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/tokenize.c | 4 +--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index f61d8e0c34..983d068c58 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sincorrect\sALWAYS()\sfrom\sthe\sautomatic\sindex\sgenerator. -D 2015-04-15T07:34:25.165 +C Fix\sthe\serror\smessage\sgenerator\sfor\sillegal\stoken\serrors\sso\sthat\sit\sdoes\snot\nleak\smemory\sif\sit\simmediately\sfollows\sanother\serroneous\sSQL\sstatement. +D 2015-04-15T07:57:27.369 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -287,7 +287,7 @@ F src/test_vfs.c b7e6831e6fcf04c5090accff30640ec5c9630739 F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 6bbcc9fe50c917864d48287b4792d46d6e873481 -F src/tokenize.c a8d270b06e5f709930f7b67cf70a847969cb5bf3 +F src/tokenize.c 2b93d338833be43cba93644562e85a24ff3d97d1 F src/trigger.c 69a91bed7c94e46223e37ffccfeeb35e34b999ac F src/update.c 3c4ecc282accf12d39edb8d524cf089645e55a13 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0e087c0183bc7a758cf2a1d39158bc24fde833a2 -R 45168c2ae417f665e937b47961f47d47 +P eeb4bd06bf69e411736cc6077d1d64af6bd8fb09 +R a12d30eac869033c520f48032e05590c U drh -Z fe2feaff56a77a679eecea2f54332501 +Z d83a0172461932509217291c59869b0d diff --git a/manifest.uuid b/manifest.uuid index 2e89d53bd1..ff52dd674e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eeb4bd06bf69e411736cc6077d1d64af6bd8fb09 \ No newline at end of file +3576973f8b88b6109fbefdebfa53468ffa137009 \ No newline at end of file diff --git a/src/tokenize.c b/src/tokenize.c index 5068742f31..a4d20c8641 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -430,10 +430,8 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ break; } case TK_ILLEGAL: { - sqlite3DbFree(db, *pzErrMsg); - *pzErrMsg = sqlite3MPrintf(db, "unrecognized token: \"%T\"", + sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"", &pParse->sLastToken); - nErr++; goto abort_parse; } case TK_SEMI: { From 2deb12be2beea8ef9f392db2bba6fab1239b9e0c Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 15 Apr 2015 08:20:50 +0000 Subject: [PATCH 26/28] Fix a problem causing an assert() to fail if a snippet containing 0 tokens was requested from fts3. FossilOrigin-Name: eafd0a1e3f25f38d551603f177ff4634cf79de77 --- ext/fts3/fts3.c | 2 ++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/fts3snippet.test | 19 +++++++++++++++++++ 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 42b9663a1b..eb62c195df 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -3527,6 +3527,8 @@ static void fts3SnippetFunc( } if( !zEllipsis || !zEnd || !zStart ){ sqlite3_result_error_nomem(pContext); + }else if( nToken==0 ){ + sqlite3_result_text(pContext, "", -1, SQLITE_STATIC); }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){ sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken); } diff --git a/manifest b/manifest index 983d068c58..f9c5dae3b3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\serror\smessage\sgenerator\sfor\sillegal\stoken\serrors\sso\sthat\sit\sdoes\snot\nleak\smemory\sif\sit\simmediately\sfollows\sanother\serroneous\sSQL\sstatement. -D 2015-04-15T07:57:27.369 +C Fix\sa\sproblem\scausing\san\sassert()\sto\sfail\sif\sa\ssnippet\scontaining\s0\stokens\swas\srequested\sfrom\sfts3. +D 2015-04-15T08:20:50.158 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -78,7 +78,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 57d863c3bd360e575ecc293570af7c9b0bdd2209 +F ext/fts3/fts3.c ed6624d7c5fb5aee5d47f884b2d184169fa7a7d4 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 394858c12a17740f7a1f6bd372c4606d4425a8d1 F ext/fts3/fts3_aux.c 5c211e17a64885faeb16b9ba7772f9d5445c2365 @@ -599,7 +599,7 @@ F test/fts3prefix2.test e1f0a822ca661dced7f12ce392e14eaf65609dce F test/fts3query.test c838b18f2b859e15fd31c64be3d79ef1556803ca F test/fts3rnd.test 1320d8826a845e38a96e769562bf83d7a92a15d0 F test/fts3shared.test 57e26a801f21027b7530da77db54286a6fe4997e -F test/fts3snippet.test 03c2f3be7d3b7c8bb105ed237f204833392bd57f +F test/fts3snippet.test 63dbd687d5bf5191f1b8e6a0977aa9c1e28a7004 F test/fts3sort.test ed34c716a11cc2009a35210e84ad5f9c102362ca F test/fts3tok1.test c551043de056b0b1582a54e878991f57bad074bc F test/fts3tok_err.test 52273cd193b9036282f7bacb43da78c6be87418d @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P eeb4bd06bf69e411736cc6077d1d64af6bd8fb09 -R a12d30eac869033c520f48032e05590c -U drh -Z d83a0172461932509217291c59869b0d +P 3576973f8b88b6109fbefdebfa53468ffa137009 +R 3265dd5ed99bf273b3517690abeeedc9 +U dan +Z a6b618f03dfa759db2c6c3b930aa2a83 diff --git a/manifest.uuid b/manifest.uuid index ff52dd674e..e0df72f85f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3576973f8b88b6109fbefdebfa53468ffa137009 \ No newline at end of file +eafd0a1e3f25f38d551603f177ff4634cf79de77 \ No newline at end of file diff --git a/test/fts3snippet.test b/test/fts3snippet.test index e97db586e6..4e1d123b2f 100644 --- a/test/fts3snippet.test +++ b/test/fts3snippet.test @@ -538,6 +538,25 @@ do_execsql_test 3.4 { SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'one OR two OR three'; } {{[one two three]}} +#------------------------------------------------------------------------- +# Request a snippet 0 tokens in size. This is always an empty string. +do_execsql_test 4.1 { + CREATE VIRTUAL TABLE t4 USING fts4; + INSERT INTO t4 VALUES('a b c d'); + SELECT snippet(t4, '[', ']', '...', 0, 0) FROM t4 WHERE t4 MATCH 'b'; +} {{}} + +do_test 4.2 { + set x35 [string trim [string repeat "x " 35]] + execsql "INSERT INTO t4 VALUES('$x35 E $x35 F $x35 G $x35');" + llength [db one { + SELECT snippet(t4, '', '', '', 0, 64) FROM t4 WHERE t4 MATCH 'E' + }] +} {64} + + + + set sqlite_fts3_enable_parentheses 0 finish_test From 0be0cf672183a6767439657e0312e4b388a2d7c8 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Apr 2015 08:37:42 +0000 Subject: [PATCH 27/28] Remove a branch that became unreachable due to one of the earlier check-ins today. FossilOrigin-Name: fa0956edf866f48f448967836709a3ad822ff917 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/tokenize.c | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index f9c5dae3b3..5fed9110db 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\scausing\san\sassert()\sto\sfail\sif\sa\ssnippet\scontaining\s0\stokens\swas\srequested\sfrom\sfts3. -D 2015-04-15T08:20:50.158 +C Remove\sa\sbranch\sthat\sbecame\sunreachable\sdue\sto\sone\sof\sthe\searlier\scheck-ins\ntoday. +D 2015-04-15T08:37:42.853 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -287,7 +287,7 @@ F src/test_vfs.c b7e6831e6fcf04c5090accff30640ec5c9630739 F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 6bbcc9fe50c917864d48287b4792d46d6e873481 -F src/tokenize.c 2b93d338833be43cba93644562e85a24ff3d97d1 +F src/tokenize.c a8234a67577308935cdf13e618cd66556f5f45d1 F src/trigger.c 69a91bed7c94e46223e37ffccfeeb35e34b999ac F src/update.c 3c4ecc282accf12d39edb8d524cf089645e55a13 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3576973f8b88b6109fbefdebfa53468ffa137009 -R 3265dd5ed99bf273b3517690abeeedc9 -U dan -Z a6b618f03dfa759db2c6c3b930aa2a83 +P eafd0a1e3f25f38d551603f177ff4634cf79de77 +R cd3636389f675a46c2832548029faa61 +U drh +Z 0baf8e6f8836d6dbdde447c335370222 diff --git a/manifest.uuid b/manifest.uuid index e0df72f85f..0fa4f22d90 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eafd0a1e3f25f38d551603f177ff4634cf79de77 \ No newline at end of file +fa0956edf866f48f448967836709a3ad822ff917 \ No newline at end of file diff --git a/src/tokenize.c b/src/tokenize.c index a4d20c8641..2f8fd98ede 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -449,7 +449,8 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ } } abort_parse: - if( zSql[i]==0 && nErr==0 && pParse->rc==SQLITE_OK ){ + assert( nErr==0 ); + if( zSql[i]==0 && pParse->rc==SQLITE_OK ){ if( lastTokenParsed!=TK_SEMI ){ sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse); pParse->zTail = &zSql[i]; From 0d01ec8de83b4e0d7523d67c5f92a44f0ba79b8e Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 15 Apr 2015 09:16:39 +0000 Subject: [PATCH 28/28] Remove an incorrect assert() statement from sqlite3Fts3Dequote(). FossilOrigin-Name: bd06eeb8d06237dc2d54d8a03e8bf525cb811c9e --- ext/fts3/fts3.c | 9 ++++++++- ext/fts3/fts3Int.h | 5 +++++ manifest | 18 +++++++++--------- manifest.uuid | 2 +- test/fts3tok1.test | 10 ++++++++++ 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index eb62c195df..eab8ad63ad 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -313,6 +313,13 @@ static int fts3EvalStart(Fts3Cursor *pCsr); static int fts3TermSegReaderCursor( Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **); +#ifndef SQLITE_AMALGAMATION +# if defined(SQLITE_DEBUG) +int sqlite3Fts3Always(int b) { assert( b ); return b; } +int sqlite3Fts3Never(int b) { assert( !b ); return b; } +# endif +#endif + /* ** Write a 64-bit variable-length integer to memory starting at p[0]. ** The length of data written will be between 1 and FTS3_VARINT_MAX bytes. @@ -422,7 +429,7 @@ void sqlite3Fts3Dequote(char *z){ /* If the first byte was a '[', then the close-quote character is a ']' */ if( quote=='[' ) quote = ']'; - while( ALWAYS(z[iIn]) ){ + while( z[iIn] ){ if( z[iIn]==quote ){ if( z[iIn+1]!=quote ) break; z[iOut++] = quote; diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index 1b8b7bd97e..8285f8aaf5 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -134,6 +134,11 @@ SQLITE_EXTENSION_INIT3 #ifdef SQLITE_COVERAGE_TEST # define ALWAYS(x) (1) # define NEVER(X) (0) +#elif defined(SQLITE_DEBUG) +# define ALWAYS(x) sqlite3Fts3Always((x)!=0) +# define NEVER(x) sqlite3Fts3Never((x)!=0) +int sqlite3Fts3Always(int b); +int sqlite3Fts3Never(int b); #else # define ALWAYS(x) (x) # define NEVER(x) (x) diff --git a/manifest b/manifest index 5fed9110db..7337ec7673 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sa\sbranch\sthat\sbecame\sunreachable\sdue\sto\sone\sof\sthe\searlier\scheck-ins\ntoday. -D 2015-04-15T08:37:42.853 +C Remove\san\sincorrect\sassert()\sstatement\sfrom\ssqlite3Fts3Dequote(). +D 2015-04-15T09:16:39.633 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -78,9 +78,9 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c ed6624d7c5fb5aee5d47f884b2d184169fa7a7d4 +F ext/fts3/fts3.c 4bd75289875b63c04f943d6ed7c31737da99cd74 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h 394858c12a17740f7a1f6bd372c4606d4425a8d1 +F ext/fts3/fts3Int.h 3626655d6ba903a3919bb44e1c38e5f0f9d6be82 F ext/fts3/fts3_aux.c 5c211e17a64885faeb16b9ba7772f9d5445c2365 F ext/fts3/fts3_expr.c 40123785eaa3ebd4c45c9b23407cc44ac0c49905 F ext/fts3/fts3_hash.c 29b986e43f4e9dd40110eafa377dc0d63c422c60 @@ -601,7 +601,7 @@ F test/fts3rnd.test 1320d8826a845e38a96e769562bf83d7a92a15d0 F test/fts3shared.test 57e26a801f21027b7530da77db54286a6fe4997e F test/fts3snippet.test 63dbd687d5bf5191f1b8e6a0977aa9c1e28a7004 F test/fts3sort.test ed34c716a11cc2009a35210e84ad5f9c102362ca -F test/fts3tok1.test c551043de056b0b1582a54e878991f57bad074bc +F test/fts3tok1.test 178c050199af8c05299b1ad572514ce1c54b7827 F test/fts3tok_err.test 52273cd193b9036282f7bacb43da78c6be87418d F test/fts3varint.test 752c08ed5d32c5d7dc211b056f4ed68a76b7e36e F test/fts4aa.test 10aac8e9d62c7357590acfabe3fad01e9a9ce1cb @@ -1250,7 +1250,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P eafd0a1e3f25f38d551603f177ff4634cf79de77 -R cd3636389f675a46c2832548029faa61 -U drh -Z 0baf8e6f8836d6dbdde447c335370222 +P fa0956edf866f48f448967836709a3ad822ff917 +R ae90fdb352a7af37163dde65a0adec8a +U dan +Z a5cd9462fba20ef05f7047cbd877b3d9 diff --git a/manifest.uuid b/manifest.uuid index 0fa4f22d90..6c106f0137 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fa0956edf866f48f448967836709a3ad822ff917 \ No newline at end of file +bd06eeb8d06237dc2d54d8a03e8bf525cb811c9e \ No newline at end of file diff --git a/test/fts3tok1.test b/test/fts3tok1.test index e6fbbe10a2..09b07e9db1 100644 --- a/test/fts3tok1.test +++ b/test/fts3tok1.test @@ -110,5 +110,15 @@ do_catchsql_test 2.1 { SELECT * FROM t4; } {1 {SQL logic error or missing database}} +do_catchsql_test 2.2 { + CREATE VIRTUAL TABLE t USING fts4(tokenize=simple""); +} {0 {}} + +ifcapable fts3_unicode { + do_catchsql_test 2.3 { + CREATE VIRTUAL TABLE u USING fts4(tokenize=unicode61""); + } {1 {unknown tokenizer}} +} + finish_test