From c62aab5ba80a504384d529340ef4692fd35c6439 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 11 Jun 2017 18:26:15 +0000 Subject: [PATCH 01/39] Fix a potential null-pointer deference following OOM introduced by check-in [e39795d7] (unreleased). FossilOrigin-Name: a2f77285fa44df86863eed576271f1030ec60f15480daf175908c5082c27774b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 46c79b6a42..c46ee266ff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sdocumentation\sto\smake\sit\sclear\sthat\sthe\stable\sname\sparameter\nto\ssqlite3_table_column_metadata()\smay\snot\sbe\sNULL. -D 2017-06-09T11:43:53.133 +C Fix\sa\spotential\snull-pointer\sdeference\sfollowing\sOOM\sintroduced\sby\ncheck-in\s[e39795d7]\s(unreleased). +D 2017-06-11T18:26:15.910 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -348,7 +348,7 @@ F src/auth.c 79f96c6f33bf0e5da8d1c282cee5ebb1852bb8a6ccca3e485d7c459b035d9c3c F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca -F src/btree.c 896b823adae998afb0e87555c7d24c04f9536adb189184e295335f93311287f6 +F src/btree.c 430e34151e6ef37e42d3f956bb062907c80ff91e1380704b967b8c1a02a98f64 F src/btree.h 3edc5329bc59534d2d15b4f069a9f54b779a7e51289e98fa481ae3c0e526a5ca F src/btreeInt.h a392d353104b4add58b4a59cb185f5d5693dde832c565b77d8d4c343ed98f610 F src/build.c 88a8cdc11d1c081ed565aa3e795bdf9160f4556463b4c4555e9860b59dd80340 @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3168e2c92ad0a0dafc78a27ee1d87ac89f426585f506f418a0182141335dc68b -R 58bb1b2ee6d8923f8cbdc89765f652d8 +P 2881ab1ed24ed72760086785bdf224c4e687cf39a02fd349ae13c6e1235e24da +R eff5a2801e4f5c4f13f1233ced3d979d U drh -Z 16b157f827867d5307cac641f1800459 +Z 536f1c03466db48b164b1acec1d59851 diff --git a/manifest.uuid b/manifest.uuid index d35d601767..010eb76337 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2881ab1ed24ed72760086785bdf224c4e687cf39a02fd349ae13c6e1235e24da \ No newline at end of file +a2f77285fa44df86863eed576271f1030ec60f15480daf175908c5082c27774b \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index c54433c8e0..1f06e45031 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5716,7 +5716,7 @@ static int allocateBtreePage( } testcase( iTrunk==mxPage ); if( iTrunk>mxPage || nSearch++ > n ){ - rc = SQLITE_CORRUPT_PGNO(pPrevTrunk->pgno); + rc = SQLITE_CORRUPT_PGNO(pPrevTrunk ? pPrevTrunk->pgno : 1); }else{ rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0); } From e46c63d5658b223451b68bac6fb8b30d6604c669 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 11 Jun 2017 19:40:34 +0000 Subject: [PATCH 02/39] Fix the sessiondiff test module so that it does not run if the session extension is not enabled. FossilOrigin-Name: 8f92b7a6223a69304dc8a6ab3b43a49cbb87f572a1e65d8a0c6dc09fca38e1a8 --- ext/session/sessiondiff.test | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/session/sessiondiff.test b/ext/session/sessiondiff.test index f2a8a2c724..b00af0eb3b 100644 --- a/ext/session/sessiondiff.test +++ b/ext/session/sessiondiff.test @@ -16,6 +16,7 @@ if {![info exists testdir]} { set testdir [file join [file dirname [info script]] .. .. test] } source $testdir/tester.tcl +ifcapable !session {finish_test; return} set testprefix sessiondiff set PROG [test_find_sqldiff] @@ -111,4 +112,3 @@ do_changeset_test 1.2 { } finish_test - diff --git a/manifest b/manifest index c46ee266ff..6774e93ff4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spotential\snull-pointer\sdeference\sfollowing\sOOM\sintroduced\sby\ncheck-in\s[e39795d7]\s(unreleased). -D 2017-06-11T18:26:15.910 +C Fix\sthe\ssessiondiff\stest\smodule\sso\sthat\sit\sdoes\snot\srun\sif\sthe\ssession\nextension\sis\snot\senabled. +D 2017-06-11T19:40:34.394 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -316,7 +316,7 @@ F ext/session/sessionG.test 01ef705096a9d3984eebdcca79807a211dee1b60 F ext/session/session_common.tcl 7776eda579773113b30c7abfd4545c445228cb73 F ext/session/session_speed_test.c edc1f96fd5e0e4b16eb03e2a73041013d59e8723 F ext/session/sessionat.test b25d61d663ebc795506bf74079dc4ba0092fad25 -F ext/session/sessiondiff.test 7889d8e84cd130fe3712ed7c511f883e0b2a398ed2905d54e48a24edce49bfab +F ext/session/sessiondiff.test ad13dd65664bae26744e1f18eb3cbd5588349b7e9118851d8f9364248d67bcec F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2881ab1ed24ed72760086785bdf224c4e687cf39a02fd349ae13c6e1235e24da -R eff5a2801e4f5c4f13f1233ced3d979d +P a2f77285fa44df86863eed576271f1030ec60f15480daf175908c5082c27774b +R c6eaeb2a09080e7f27a1ec8231e7dfbc U drh -Z 536f1c03466db48b164b1acec1d59851 +Z b837419d9c3a128c40e355059cbb84a3 diff --git a/manifest.uuid b/manifest.uuid index 010eb76337..c9e4a0fc39 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a2f77285fa44df86863eed576271f1030ec60f15480daf175908c5082c27774b \ No newline at end of file +8f92b7a6223a69304dc8a6ab3b43a49cbb87f572a1e65d8a0c6dc09fca38e1a8 \ No newline at end of file From eafc6dfe2b7fbab936645594ae8eb696b1210032 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 11 Jun 2017 19:51:36 +0000 Subject: [PATCH 03/39] When reusing a materialized view, make sure the estimated number of output rows is correctly initialized to avoid confusing the query planner. FossilOrigin-Name: 87aceb417a813a2925b636cffa660fe25f3b7e3b3c84bb2108951bf0af644376 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/select.c | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 6774e93ff4..20adf38926 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\ssessiondiff\stest\smodule\sso\sthat\sit\sdoes\snot\srun\sif\sthe\ssession\nextension\sis\snot\senabled. -D 2017-06-11T19:40:34.394 +C When\sreusing\sa\smaterialized\sview,\smake\ssure\sthe\sestimated\snumber\sof\noutput\srows\sis\scorrectly\sinitialized\sto\savoid\sconfusing\sthe\squery\splanner. +D 2017-06-11T19:51:36.949 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -405,7 +405,7 @@ F src/printf.c 8757834f1b54dae512fb25eb1acc8e94a0d15dd2290b58f2563f65973265adb2 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c adf3ef9843135b1383321ad751f16f5a40c3f37925154555a3e61653d2a954e8 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac -F src/select.c d93205e43af302d9eb147fddecc956509ee9d0dde6297ee3f93c591f60f0e295 +F src/select.c 0d2afdbdba5fbc61432c5454a35e0236e7aa4aa3756986a7d51b81a508e8083a F src/shell.c a43292634af8e3528fec5c6e3360f122fc807a0af619d566ea44fdb98dcfca78 F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a2f77285fa44df86863eed576271f1030ec60f15480daf175908c5082c27774b -R c6eaeb2a09080e7f27a1ec8231e7dfbc +P 8f92b7a6223a69304dc8a6ab3b43a49cbb87f572a1e65d8a0c6dc09fca38e1a8 +R a9d0a03ba641ed87c89d84acdaf499c1 U drh -Z b837419d9c3a128c40e355059cbb84a3 +Z 6f34a8996840968a8347834320cb43af diff --git a/manifest.uuid b/manifest.uuid index c9e4a0fc39..6adf670bf5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8f92b7a6223a69304dc8a6ab3b43a49cbb87f572a1e65d8a0c6dc09fca38e1a8 \ No newline at end of file +87aceb417a813a2925b636cffa660fe25f3b7e3b3c84bb2108951bf0af644376 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 51cd089a2f..6c99776e19 100644 --- a/src/select.c +++ b/src/select.c @@ -5290,6 +5290,8 @@ int sqlite3Select( if( pPrior ){ sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor); explainSetInteger(pItem->iSelectId, pPrior->iSelectId); + assert( pPrior->pSelect!=0 ); + pSub->nSelectRow = pPrior->pSelect->nSelectRow; }else{ sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor); explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId); From 56790ea56762469ed200e3575065b4e85e76b20e Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 11 Jun 2017 20:17:02 +0000 Subject: [PATCH 04/39] Fix an off-by-one error that messes up the display of loop codes in the ".wheretrace" debugging output for queries with more than 62 candidate loops when SQLITE_ENABLE_WHERETRACE is on. FossilOrigin-Name: 0bbdaf2801e4102d952db65e53962e534b67b8b72e76fadb4ce404a6249129d9 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 20adf38926..7dc9f6e8ee 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sreusing\sa\smaterialized\sview,\smake\ssure\sthe\sestimated\snumber\sof\noutput\srows\sis\scorrectly\sinitialized\sto\savoid\sconfusing\sthe\squery\splanner. -D 2017-06-11T19:51:36.949 +C Fix\san\soff-by-one\serror\sthat\smesses\sup\sthe\sdisplay\sof\sloop\scodes\sin\sthe\n".wheretrace"\sdebugging\soutput\sfor\squeries\swith\smore\sthan\s62\scandidate\nloops\swhen\sSQLITE_ENABLE_WHERETRACE\sis\son. +D 2017-06-11T20:17:02.600 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -486,7 +486,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 40c543f0a2195d1b0dc88ef12142bea690009344 F src/wal.h 06b2a0b599cc0f53ea97f497cf8c6b758c999f71 F src/walker.c d46044e7a5842560dfe7122d93ff5145dd4a96f4d0bf5ba5910a7731b8c01e79 -F src/where.c 67f98714b07ec3c1d5e033a63d23c0fd70c24861b7b46b69b10700f22dca6ffe +F src/where.c aa213e1b1c29eb8946a9f25108a18666a745ae5bac41b58d0be98730937a7785 F src/whereInt.h 2a4b634d63ce488b46d4b0da8f2eaa8f9aeab202bc25ef76f007de5e3fba1f20 F src/wherecode.c 339ee802d9d311acf0cba8b5a9a092e167ef71c3a777d4b3e57de25d193251c7 F src/whereexpr.c a2fe3811d45af45a5c6667caabc15e01054fe6228c64e86e1f7d2ba5ef5284f9 @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8f92b7a6223a69304dc8a6ab3b43a49cbb87f572a1e65d8a0c6dc09fca38e1a8 -R a9d0a03ba641ed87c89d84acdaf499c1 +P 87aceb417a813a2925b636cffa660fe25f3b7e3b3c84bb2108951bf0af644376 +R 5d137f03dd98c6947d396116cfd8bb62 U drh -Z 6f34a8996840968a8347834320cb43af +Z 9a468aee323b8155a594f5ff05c91ea1 diff --git a/manifest.uuid b/manifest.uuid index 6adf670bf5..8abd922d2d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -87aceb417a813a2925b636cffa660fe25f3b7e3b3c84bb2108951bf0af644376 \ No newline at end of file +0bbdaf2801e4102d952db65e53962e534b67b8b72e76fadb4ce404a6249129d9 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 89c4edeb8c..99b0df4e5d 100644 --- a/src/where.c +++ b/src/where.c @@ -4577,7 +4577,7 @@ WhereInfo *sqlite3WhereBegin( static const char zLabel[] = "0123456789abcdefghijklmnopqrstuvwyxz" "ABCDEFGHIJKLMNOPQRSTUVWYXZ"; for(p=pWInfo->pLoops, i=0; p; p=p->pNextLoop, i++){ - p->cId = zLabel[i%sizeof(zLabel)]; + p->cId = zLabel[i%(sizeof(zLabel)-1)]; whereLoopPrint(p, sWLB.pWC); } } From 6e3bccd5c97a32e5686d04793a12556c4f41e537 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 13 Jun 2017 04:31:54 +0000 Subject: [PATCH 05/39] Fix the processing of double-negatives in WHERE clause constraints with STAT4. Ticket [cfa2c908f2182] FossilOrigin-Name: 35b34bdf0843b49be39e13ed212e918c2d45afdb8374b5cd02ba6d2d5b16b3b9 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbemem.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 7dc9f6e8ee..376e64ba53 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\soff-by-one\serror\sthat\smesses\sup\sthe\sdisplay\sof\sloop\scodes\sin\sthe\n".wheretrace"\sdebugging\soutput\sfor\squeries\swith\smore\sthan\s62\scandidate\nloops\swhen\sSQLITE_ENABLE_WHERETRACE\sis\son. -D 2017-06-11T20:17:02.600 +C Fix\sthe\sprocessing\sof\sdouble-negatives\sin\sWHERE\sclause\sconstraints\swith\nSTAT4.\s\sTicket\s[cfa2c908f2182] +D 2017-06-13T04:31:54.016 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -478,7 +478,7 @@ F src/vdbeInt.h cdcdabad4f5d6bf7a3beb826a7f33ee6f8f1cb220042bedd5b7d4bf2ea1d179f F src/vdbeapi.c c961d8d9e0f52e2df60a6ddbbccd7d99dc4d00103db7e53f77fcef44fbd23178 F src/vdbeaux.c bc9b3228f6d99bef0d0ecaf3a0e0e8358b3873242d0d2fe944226de3fdf9521e F src/vdbeblob.c 359891617358deefc85bef7bcf787fa6b77facb9 -F src/vdbemem.c 2c70f8f5de6c71fb99a22c5b83be9fab5c47cdd8e279fa44a8c00cfed06d7e89 +F src/vdbemem.c 94b17d851f31d4fd075d47d373d4b33ed3962a6ecb82cf385018025751091360 F src/vdbesort.c f512c68d0bf7e0105316a5594c4329358c8ee9cae3b25138df041d97516c0372 F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834 F src/vtab.c 35b9bdc2b41de32a417141d12097bcc4e29a77ed7cdb8f836d1d2305d946b61b @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 87aceb417a813a2925b636cffa660fe25f3b7e3b3c84bb2108951bf0af644376 -R 5d137f03dd98c6947d396116cfd8bb62 +P 0bbdaf2801e4102d952db65e53962e534b67b8b72e76fadb4ce404a6249129d9 +R f2f95fcabff93258ae6c63b2d0970c78 U drh -Z 9a468aee323b8155a594f5ff05c91ea1 +Z 010cf979d0ebcfd760d21c84533c2792 diff --git a/manifest.uuid b/manifest.uuid index 8abd922d2d..2adbdfe579 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0bbdaf2801e4102d952db65e53962e534b67b8b72e76fadb4ce404a6249129d9 \ No newline at end of file +35b34bdf0843b49be39e13ed212e918c2d45afdb8374b5cd02ba6d2d5b16b3b9 \ No newline at end of file diff --git a/src/vdbemem.c b/src/vdbemem.c index e95a8d1b9d..88c57f1aba 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1325,7 +1325,7 @@ static int valueFromExpr( } }else if( op==TK_UMINUS ) { /* This branch happens for multiple negative signs. Ex: -(-5) */ - if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) + if( SQLITE_OK==valueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal,pCtx) && pVal!=0 ){ sqlite3VdbeMemNumerify(pVal); From 2ebf8f474e3740f52992d4fa1b143452e7b6f994 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 13 Jun 2017 16:52:34 +0000 Subject: [PATCH 06/39] Fix sqlite3rbu_close() so that the pzErrmsg parameter may be passed NULL. FossilOrigin-Name: c433672dd8ab625628bde2f4f40a2dc000ed915dbe91833d3f753d8ab51baf25 --- ext/rbu/rbuvacuum.test | 8 ++++++++ ext/rbu/sqlite3rbu.c | 6 +++++- ext/rbu/sqlite3rbu.h | 8 ++++---- ext/rbu/test_rbu.c | 8 +++++++- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/ext/rbu/rbuvacuum.test b/ext/rbu/rbuvacuum.test index 86f4aa770e..dba0ef37e0 100644 --- a/ext/rbu/rbuvacuum.test +++ b/ext/rbu/rbuvacuum.test @@ -298,6 +298,14 @@ do_test 2.1.2 { list [catch { rbu close } msg] $msg } {1 {SQLITE_ERROR - cannot vacuum wal mode database}} +do_test 2.1.3 { + sqlite3rbu_vacuum rbu test.db state.db + rbu step +} {SQLITE_ERROR} +do_test 2.1.4 { + list [catch { rbu close_no_error } msg] $msg +} {1 SQLITE_ERROR} + reset_db do_execsql_test 2.2.0 { CREATE TABLE tx(a PRIMARY KEY, b BLOB); diff --git a/ext/rbu/sqlite3rbu.c b/ext/rbu/sqlite3rbu.c index 7dd232b4b5..e0f413f021 100644 --- a/ext/rbu/sqlite3rbu.c +++ b/ext/rbu/sqlite3rbu.c @@ -3787,7 +3787,11 @@ int sqlite3rbu_close(sqlite3rbu *p, char **pzErrmsg){ rbuEditErrmsg(p); rc = p->rc; - *pzErrmsg = p->zErrmsg; + if( pzErrmsg ){ + *pzErrmsg = p->zErrmsg; + }else{ + sqlite3_free(p->zErrmsg); + } sqlite3_free(p->zState); sqlite3_free(p); }else{ diff --git a/ext/rbu/sqlite3rbu.h b/ext/rbu/sqlite3rbu.h index 12112c14e1..e55fe4685d 100644 --- a/ext/rbu/sqlite3rbu.h +++ b/ext/rbu/sqlite3rbu.h @@ -420,10 +420,10 @@ int sqlite3rbu_savestate(sqlite3rbu *pRbu); ** ** If an error has already occurred as part of an sqlite3rbu_step() ** or sqlite3rbu_open() call, or if one occurs within this function, an -** SQLite error code is returned. Additionally, *pzErrmsg may be set to -** point to a buffer containing a utf-8 formatted English language error -** message. It is the responsibility of the caller to eventually free any -** such buffer using sqlite3_free(). +** SQLite error code is returned. Additionally, if pzErrmsg is not NULL, +** *pzErrmsg may be set to point to a buffer containing a utf-8 formatted +** English language error message. It is the responsibility of the caller to +** eventually free any such buffer using sqlite3_free(). ** ** Otherwise, if no error occurs, this function returns SQLITE_OK if the ** update has been partially applied, or SQLITE_DONE if it has been diff --git a/ext/rbu/test_rbu.c b/ext/rbu/test_rbu.c index b1a2252741..fba90dcdc4 100644 --- a/ext/rbu/test_rbu.c +++ b/ext/rbu/test_rbu.c @@ -78,6 +78,7 @@ static int SQLITE_TCLAPI test_sqlite3rbu_cmd( {"db", 3, "RBU"}, /* 6 */ {"state", 2, ""}, /* 7 */ {"progress", 2, ""}, /* 8 */ + {"close_no_error", 2, ""}, /* 9 */ {0,0,0} }; int iCmd; @@ -102,11 +103,16 @@ static int SQLITE_TCLAPI test_sqlite3rbu_cmd( break; } + case 9: /* close_no_error */ case 1: /* close */ { char *zErrmsg = 0; int rc; Tcl_DeleteCommand(interp, Tcl_GetString(objv[0])); - rc = sqlite3rbu_close(pRbu, &zErrmsg); + if( iCmd==1 ){ + rc = sqlite3rbu_close(pRbu, &zErrmsg); + }else{ + rc = sqlite3rbu_close(pRbu, 0); + } if( rc==SQLITE_OK || rc==SQLITE_DONE ){ Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); assert( zErrmsg==0 ); diff --git a/manifest b/manifest index 376e64ba53..8d1aada1f4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sprocessing\sof\sdouble-negatives\sin\sWHERE\sclause\sconstraints\swith\nSTAT4.\s\sTicket\s[cfa2c908f2182] -D 2017-06-13T04:31:54.016 +C Fix\ssqlite3rbu_close()\sso\sthat\sthe\spzErrmsg\sparameter\smay\sbe\spassed\sNULL. +D 2017-06-13T16:52:34.629 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -268,11 +268,11 @@ F ext/rbu/rbufts.test 828cd689da825f0a7b7c53ffc1f6f7fdb6fa5bda F ext/rbu/rbuprogress.test 1849d4e0e50616edf5ce75ce7db86622e656b5cf F ext/rbu/rburesume.test 8acb77f4a422ff55acfcfc9cc15a5cb210b1de83 F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48 -F ext/rbu/rbuvacuum.test 4a977447c15c2581ab668781d9ef4294382530e0 +F ext/rbu/rbuvacuum.test ff357e9b556ca7ad4673da0ff7f244def919ff858e0f9f350d3e30fdd83a62a8 F ext/rbu/rbuvacuum2.test 2074ab14fe66e1c7e7210c62562650dcd215bbaa -F ext/rbu/sqlite3rbu.c 2a89efba9eeba8e6c89a498dc195e8efbdde2694 -F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba -F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 +F ext/rbu/sqlite3rbu.c d1438580a451eebda3bfd42ef69b677512f00125285e0e4e789b6131a45f6dd8 +F ext/rbu/sqlite3rbu.h fc25e1fcd99b5c6d32b1b5b1c73122632e873ac89bd0be9bf646db362b7ce02c +F ext/rbu/test_rbu.c ec18cfc69a104309df23c359e3c80306c9a6bdd1d2c53c8b70ae158e9832dcd6 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/rtree.c 8205d6e4466f766e57ce1b8aa38224ac9e1cec2d2bf4684cd1cc5a6ddf9b7014 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0bbdaf2801e4102d952db65e53962e534b67b8b72e76fadb4ce404a6249129d9 -R f2f95fcabff93258ae6c63b2d0970c78 -U drh -Z 010cf979d0ebcfd760d21c84533c2792 +P 35b34bdf0843b49be39e13ed212e918c2d45afdb8374b5cd02ba6d2d5b16b3b9 +R 58bee221956dd673cf4d01eef24c120c +U dan +Z 30654fd7d5ea417a1e606ee3f07ebb27 diff --git a/manifest.uuid b/manifest.uuid index 2adbdfe579..02ab3583d2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -35b34bdf0843b49be39e13ed212e918c2d45afdb8374b5cd02ba6d2d5b16b3b9 \ No newline at end of file +c433672dd8ab625628bde2f4f40a2dc000ed915dbe91833d3f753d8ab51baf25 \ No newline at end of file From c74d962a1f7145f8676f23cb84ac82b51e80fd1d Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 15 Jun 2017 00:52:03 +0000 Subject: [PATCH 07/39] Enhance the sqlite3_analyzer.exe utility so that it computes and shows the number of bytes of metadata on btree pages and per table and index entry. FossilOrigin-Name: 43ad41efa9e1fdd79a9804197a227491236495f14ed56c656224d6ce181703c1 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/spaceanal.tcl | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 8d1aada1f4..0c507aca09 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssqlite3rbu_close()\sso\sthat\sthe\spzErrmsg\sparameter\smay\sbe\spassed\sNULL. -D 2017-06-13T16:52:34.629 +C Enhance\sthe\ssqlite3_analyzer.exe\sutility\sso\sthat\sit\scomputes\sand\sshows\sthe\nnumber\sof\sbytes\sof\smetadata\son\sbtree\spages\sand\sper\stable\sand\sindex\sentry. +D 2017-06-15T00:52:03.263 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -1541,7 +1541,7 @@ F tool/showlocks.c 9920bcc64f58378ff1118caead34147201f48c68 F tool/showstat4.c b14159aa062f661b394ba37b6b7b94bfb8012ab9 F tool/showwal.c ad9d768f96ca6199ad3a8c9562d679680bd032dd01204ea3e5ea6fb931d81847 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe -F tool/spaceanal.tcl ab7d9bf68062907282a64b3e12ccbfad47193c5a +F tool/spaceanal.tcl a91e09e9e3dd10e67ffe4a01155161fb5e6b6d399002716593780493452c4b28 F tool/speed-check.sh 9630ba0468b609c52f48309243d4eb6e9c34deda F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c ecb6542862151c3e6509bbc00509b234562ae81e @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 35b34bdf0843b49be39e13ed212e918c2d45afdb8374b5cd02ba6d2d5b16b3b9 -R 58bee221956dd673cf4d01eef24c120c -U dan -Z 30654fd7d5ea417a1e606ee3f07ebb27 +P c433672dd8ab625628bde2f4f40a2dc000ed915dbe91833d3f753d8ab51baf25 +R 3118b76870f7c5e12e646d6dc51a9560 +U drh +Z 30d19856ae4fa68d439f06a24db9ac5d diff --git a/manifest.uuid b/manifest.uuid index 02ab3583d2..a8b314a01d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c433672dd8ab625628bde2f4f40a2dc000ed915dbe91833d3f753d8ab51baf25 \ No newline at end of file +43ad41efa9e1fdd79a9804197a227491236495f14ed56c656224d6ce181703c1 \ No newline at end of file diff --git a/tool/spaceanal.tcl b/tool/spaceanal.tcl index e7ce846f86..0309e5f2f4 100644 --- a/tool/spaceanal.tcl +++ b/tool/spaceanal.tcl @@ -424,6 +424,7 @@ proc subreport {title where showFrag} { # avg_payload: Average payload per btree entry. # avg_fanout: Average fanout for internal pages. # avg_unused: Average unused bytes per btree entry. + # avg_meta: Average metadata overhead per entry. # ovfl_cnt_percent: Percentage of btree entries that use overflow pages. # set total_pages [expr {$leaf_pages+$int_pages+$ovfl_pages}] @@ -433,6 +434,10 @@ proc subreport {title where showFrag} { set total_unused [expr {$ovfl_unused+$int_unused+$leaf_unused}] set avg_payload [divide $payload $nentry] set avg_unused [divide $total_unused $nentry] + set total_meta [expr {$storage - $payload - $total_unused}] + set total_meta [expr {$total_meta + 4*($ovfl_pages - $ovfl_cnt)}] + set meta_percent [percent $total_meta $storage {of metadata}] + set avg_meta [divide $total_meta $nentry] if {$int_pages>0} { # TODO: Is this formula correct? set nTab [mem eval " @@ -460,9 +465,11 @@ proc subreport {title where showFrag} { statline {Bytes used after compression} $compressed_size $pct } statline {Bytes of payload} $payload $payload_percent + statline {Bytes of metadata} $total_meta $meta_percent if {$cnt==1} {statline {B-tree depth} $depth} statline {Average payload per entry} $avg_payload statline {Average unused bytes per entry} $avg_unused + statline {Average metadata per entry} $avg_meta if {[info exists avg_fanout]} { statline {Average fanout} $avg_fanout } @@ -757,6 +764,15 @@ Bytes of payload at the right is the bytes of payload divided by the bytes of storage consumed. +Bytes of metadata + + The amount of formatting and structural information stored on for the + table or index. Metadata includes the btree page header, the cell pointer + array, the size field for each cell, the left child pointer or non-leaf + cells, the overflow pointers for overflow cells, and the rowid value for + rowid table cells. In other words, metadata is everything that is not + unused space and that is not content. + Average payload per entry The average amount of payload on each entry. This is just the bytes of From 20c9c3f4ebe8f83a1e2ee4c81ea58a81ff7c6e7f Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 15 Jun 2017 12:21:09 +0000 Subject: [PATCH 08/39] In the command-line shell, enhance the ".schema" command show that it shows the schema for ATTACH-ed databases in addition to "main". FossilOrigin-Name: 48e086284a76da10a85315bc992e2294bd4711e35ec5a5abaa16e39a6a69d206 --- manifest | 12 ++--- manifest.uuid | 2 +- src/shell.c | 132 ++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 119 insertions(+), 27 deletions(-) diff --git a/manifest b/manifest index 0c507aca09..3f17a44ce2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\ssqlite3_analyzer.exe\sutility\sso\sthat\sit\scomputes\sand\sshows\sthe\nnumber\sof\sbytes\sof\smetadata\son\sbtree\spages\sand\sper\stable\sand\sindex\sentry. -D 2017-06-15T00:52:03.263 +C In\sthe\scommand-line\sshell,\senhance\sthe\s".schema"\scommand\sshow\sthat\sit\nshows\sthe\sschema\sfor\sATTACH-ed\sdatabases\sin\saddition\sto\s"main". +D 2017-06-15T12:21:09.255 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -406,7 +406,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c adf3ef9843135b1383321ad751f16f5a40c3f37925154555a3e61653d2a954e8 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 0d2afdbdba5fbc61432c5454a35e0236e7aa4aa3756986a7d51b81a508e8083a -F src/shell.c a43292634af8e3528fec5c6e3360f122fc807a0af619d566ea44fdb98dcfca78 +F src/shell.c 41671b1b9cfed9d1686699ae91ce6ee6e2a8cac5d148a99e2a363a209c549ad8 F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c433672dd8ab625628bde2f4f40a2dc000ed915dbe91833d3f753d8ab51baf25 -R 3118b76870f7c5e12e646d6dc51a9560 +P 43ad41efa9e1fdd79a9804197a227491236495f14ed56c656224d6ce181703c1 +R d9f0817a6699b9c8517903bc72312e9f U drh -Z 30d19856ae4fa68d439f06a24db9ac5d +Z 79d9a69908657f1d338372f7df43a962 diff --git a/manifest.uuid b/manifest.uuid index a8b314a01d..533cc2e1a1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -43ad41efa9e1fdd79a9804197a227491236495f14ed56c656224d6ce181703c1 \ No newline at end of file +48e086284a76da10a85315bc992e2294bd4711e35ec5a5abaa16e39a6a69d206 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 36f6970d1f..706d3ada68 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1185,6 +1185,61 @@ static unsigned char *SHA3Final(SHA3Context *p){ return &p->u.x[p->nRate]; } +/* +** SQL function: shell_add_schema(S,X) +** +** Add the schema name X to the CREATE statement in S and return the result. +** Examples: +** +** CREATE TABLE t1(x) -> CREATE TABLE xyz.t1(x); +** +** Also works on +** +** CREATE INDEX +** CREATE UNIQUE INDEX +** CREATE VIEW +** CREATE TRIGGER +** CREATE VIRTUAL TABLE +** +** This UDF is used by the .schema command to insert the schema name of +** attached databases into the middle of the sqlite_master.sql field. +*/ +static void shellAddSchemaName( + sqlite3_context *pCtx, + int nVal, + sqlite3_value **apVal +){ + static const char *aPrefix[] = { + "TABLE", + "INDEX", + "UNIQUE INDEX", + "VIEW", + "TRIGGER", + "VIRTUAL TABLE" + }; + int i = 0, n; + const char *zIn = (const char*)sqlite3_value_text(apVal[0]); + const char *zSchema = (const char*)sqlite3_value_text(apVal[1]); + assert( nVal==2 ); + if( zIn!=0 && strncmp(zIn, "CREATE ", 7)==0 ){ + for(i=0; idb, "sha3_query", 2, SQLITE_UTF8, 0, sha3QueryFunc, 0, 0); + sqlite3_create_function(p->db, "shell_add_schema", 2, SQLITE_UTF8, 0, + shellAddSchemaName, 0, 0); + } } @@ -5689,12 +5747,17 @@ static int do_meta_command(char *zLine, ShellState *p){ }else if( c=='s' && strncmp(azArg[0], "schema", n)==0 ){ + ShellText sSelect; ShellState data; char *zErrMsg = 0; + const char *zDiv = 0; + int iSchema = 0; + open_db(p, 0); memcpy(&data, p, sizeof(data)); data.showHeader = 0; data.cMode = data.mode = MODE_Semi; + initText(&sSelect); if( nArg>=2 && optionMatch(azArg[1], "indent") ){ data.cMode = data.mode = MODE_Pretty; nArg--; @@ -5732,33 +5795,62 @@ static int do_meta_command(char *zLine, ShellState *p){ callback(&data, 1, new_argv, new_colv); rc = SQLITE_OK; }else{ - char *zSql; - zSql = sqlite3_mprintf( - "SELECT sql FROM " - " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x" - " FROM sqlite_master UNION ALL" - " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) " - "WHERE lower(tbl_name) LIKE %Q" - " AND type!='meta' AND sql NOTNULL " - "ORDER BY rowid", azArg[1]); - rc = sqlite3_exec(p->db, zSql, callback, &data, &zErrMsg); - sqlite3_free(zSql); + zDiv = "("; } }else if( nArg==1 ){ - rc = sqlite3_exec(p->db, - "SELECT sql FROM " - " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x" - " FROM sqlite_master UNION ALL" - " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) " - "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' " - "ORDER BY rowid", - callback, &data, &zErrMsg - ); + zDiv = "("; }else{ raw_printf(stderr, "Usage: .schema ?--indent? ?LIKE-PATTERN?\n"); rc = 1; goto meta_command_exit; } + if( zDiv ){ + sqlite3_stmt *pStmt = 0; + sqlite3_prepare_v2(p->db, "SELECT name FROM pragma_database_list", + -1, &pStmt, 0); + appendText(&sSelect, "SELECT sql FROM", 0); + iSchema = 0; + while( sqlite3_step(pStmt)==SQLITE_ROW ){ + const char *zDb = (const char*)sqlite3_column_text(pStmt, 0); + char zScNum[30]; + sqlite3_snprintf(sizeof(zScNum), zScNum, "%d", ++iSchema); + appendText(&sSelect, zDiv, 0); + zDiv = " UNION ALL "; + if( strcmp(zDb, "main")!=0 ){ + appendText(&sSelect, "SELECT shell_add_schema(sql,", 0); + appendText(&sSelect, sqlite3_column_text(pStmt, 0), '"'); + appendText(&sSelect, ") AS sql, type, tbl_name, name, rowid,", 0); + appendText(&sSelect, zScNum, 0); + appendText(&sSelect, " AS snum, ", 0); + appendText(&sSelect, zDb, '\''); + appendText(&sSelect, " AS sname FROM ", 0); + appendText(&sSelect, sqlite3_column_text(pStmt, 0), '"'); + appendText(&sSelect, ".sqlite_master", 0); + }else{ + appendText(&sSelect, "SELECT sql, type, tbl_name, name, rowid, ", 0); + appendText(&sSelect, zScNum, 0); + appendText(&sSelect, " AS snum, 'main' AS sname FROM sqlite_master",0); + } + } + sqlite3_finalize(pStmt); + appendText(&sSelect, ") WHERE ", 0); + if( nArg>1 ){ + char *zQarg = sqlite3_mprintf("%Q", azArg[1]); + if( strchr(azArg[1], '.') ){ + appendText(&sSelect, "lower(printf('%s.%s',sname,tbl_name))", 0); + }else{ + appendText(&sSelect, "lower(tbl_name)", 0); + } + appendText(&sSelect, strchr(azArg[1], '*') ? " GLOB " : " LIKE ", 0); + appendText(&sSelect, zQarg, 0); + appendText(&sSelect, " AND ", 0); + sqlite3_free(zQarg); + } + appendText(&sSelect, "type!='meta' AND sql IS NOT NULL" + " ORDER BY snum, rowid", 0); + rc = sqlite3_exec(p->db, sSelect.z, callback, &data, &zErrMsg); + freeText(&sSelect); + } if( zErrMsg ){ utf8_printf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); From 594ccd09b130c17653696fc8b8fd413ab14e49d0 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 15 Jun 2017 12:50:47 +0000 Subject: [PATCH 09/39] Improvements to the ".tables" command in the command-line shell so that it shows the name of all schemas if the name is anything other than "main". FossilOrigin-Name: c7f778b7cee16a1dcebccd256408ee1d08ef2b62e388a9ebba5738a0a89bf3a0 --- manifest | 12 +++++------ manifest.uuid | 2 +- src/shell.c | 60 +++++++++++++++++++++------------------------------ 3 files changed, 31 insertions(+), 43 deletions(-) diff --git a/manifest b/manifest index 3f17a44ce2..bce2fd980f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\scommand-line\sshell,\senhance\sthe\s".schema"\scommand\sshow\sthat\sit\nshows\sthe\sschema\sfor\sATTACH-ed\sdatabases\sin\saddition\sto\s"main". -D 2017-06-15T12:21:09.255 +C Improvements\sto\sthe\s".tables"\scommand\sin\sthe\scommand-line\sshell\sso\sthat\nit\sshows\sthe\sname\sof\sall\sschemas\sif\sthe\sname\sis\sanything\sother\sthan\s"main". +D 2017-06-15T12:50:47.020 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -406,7 +406,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c adf3ef9843135b1383321ad751f16f5a40c3f37925154555a3e61653d2a954e8 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 0d2afdbdba5fbc61432c5454a35e0236e7aa4aa3756986a7d51b81a508e8083a -F src/shell.c 41671b1b9cfed9d1686699ae91ce6ee6e2a8cac5d148a99e2a363a209c549ad8 +F src/shell.c 9be3234b47eede8451b791c08f40dfe188b43704733ab47ef882102eb3a8a8ca F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 43ad41efa9e1fdd79a9804197a227491236495f14ed56c656224d6ce181703c1 -R d9f0817a6699b9c8517903bc72312e9f +P 48e086284a76da10a85315bc992e2294bd4711e35ec5a5abaa16e39a6a69d206 +R f0a1a3360ef0fa824ad1508573cdd91a U drh -Z 79d9a69908657f1d338372f7df43a962 +Z 8b4c48c5024c7add103abe54a8cb3650 diff --git a/manifest.uuid b/manifest.uuid index 533cc2e1a1..7328249fb2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -48e086284a76da10a85315bc992e2294bd4711e35ec5a5abaa16e39a6a69d206 \ No newline at end of file +c7f778b7cee16a1dcebccd256408ee1d08ef2b62e388a9ebba5738a0a89bf3a0 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 706d3ada68..18d36775e0 100644 --- a/src/shell.c +++ b/src/shell.c @@ -6399,59 +6399,47 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_stmt *pStmt; char **azResult; int nRow, nAlloc; - char *zSql = 0; int ii; + ShellText s; + initText(&s); open_db(p, 0); rc = sqlite3_prepare_v2(p->db, "PRAGMA database_list", -1, &pStmt, 0); if( rc ) return shellDatabaseError(p->db); - /* Create an SQL statement to query for the list of tables in the - ** main and all attached databases where the table name matches the - ** LIKE pattern bound to variable "?1". */ - if( c=='t' ){ - zSql = sqlite3_mprintf( - "SELECT name FROM sqlite_master" - " WHERE type IN ('table','view')" - " AND name NOT LIKE 'sqlite_%%'" - " AND name LIKE ?1"); - }else if( nArg>2 ){ + if( nArg>2 && c=='i' ){ /* It is an historical accident that the .indexes command shows an error ** when called with the wrong number of arguments whereas the .tables ** command does not. */ raw_printf(stderr, "Usage: .indexes ?LIKE-PATTERN?\n"); rc = 1; goto meta_command_exit; - }else{ - zSql = sqlite3_mprintf( - "SELECT name FROM sqlite_master" - " WHERE type='index'" - " AND tbl_name LIKE ?1"); } - for(ii=0; zSql && sqlite3_step(pStmt)==SQLITE_ROW; ii++){ + for(ii=0; sqlite3_step(pStmt)==SQLITE_ROW; ii++){ const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1); - if( zDbName==0 || ii==0 ) continue; - if( c=='t' ){ - zSql = sqlite3_mprintf( - "%z UNION ALL " - "SELECT '%q.' || name FROM \"%w\".sqlite_master" - " WHERE type IN ('table','view')" - " AND name NOT LIKE 'sqlite_%%'" - " AND name LIKE ?1", zSql, zDbName, zDbName); + if( zDbName==0 ) continue; + if( s.z && s.z[0] ) appendText(&s, " UNION ALL ", 0); + if( sqlite3_stricmp(zDbName, "main")==0 ){ + appendText(&s, "SELECT name FROM ", 0); }else{ - zSql = sqlite3_mprintf( - "%z UNION ALL " - "SELECT '%q.' || name FROM \"%w\".sqlite_master" - " WHERE type='index'" - " AND tbl_name LIKE ?1", zSql, zDbName, zDbName); + appendText(&s, "SELECT ", 0); + appendText(&s, zDbName, '\''); + appendText(&s, "||'.'||name FROM ", 0); + } + appendText(&s, zDbName, '"'); + appendText(&s, ".sqlite_master ", 0); + if( c=='t' ){ + appendText(&s," WHERE type IN ('table','view')" + " AND name NOT LIKE 'sqlite_%'" + " AND name LIKE ?1", 0); + }else{ + appendText(&s," WHERE type='index'" + " AND tbl_name LIKE ?1", 0); } } rc = sqlite3_finalize(pStmt); - if( zSql && rc==SQLITE_OK ){ - zSql = sqlite3_mprintf("%z ORDER BY 1", zSql); - if( zSql ) rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); - } - sqlite3_free(zSql); - if( !zSql ) return shellNomemError(); + appendText(&s, " ORDER BY 1", 0); + rc = sqlite3_prepare_v2(p->db, s.z, -1, &pStmt, 0); + freeText(&s); if( rc ) return shellDatabaseError(p->db); /* Run the SQL statement prepared by the above block. Store the results From 90cdec067201d6e45d5b82d641279795ca02de82 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 15 Jun 2017 13:07:56 +0000 Subject: [PATCH 10/39] Fix harmless compiler warnings in the shell.c file FossilOrigin-Name: 9afd7a2ffd3a39456190ad05e85ff6485298aae262d9e0698a58c1d73507a36f --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index bce2fd980f..e98acb5f54 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\s".tables"\scommand\sin\sthe\scommand-line\sshell\sso\sthat\nit\sshows\sthe\sname\sof\sall\sschemas\sif\sthe\sname\sis\sanything\sother\sthan\s"main". -D 2017-06-15T12:50:47.020 +C Fix\sharmless\scompiler\swarnings\sin\sthe\sshell.c\sfile +D 2017-06-15T13:07:56.351 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -406,7 +406,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c adf3ef9843135b1383321ad751f16f5a40c3f37925154555a3e61653d2a954e8 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 0d2afdbdba5fbc61432c5454a35e0236e7aa4aa3756986a7d51b81a508e8083a -F src/shell.c 9be3234b47eede8451b791c08f40dfe188b43704733ab47ef882102eb3a8a8ca +F src/shell.c c45ae9a95faf5a495280bfa2d6b7956c707f347e56eb8b1985c852d152e46894 F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 48e086284a76da10a85315bc992e2294bd4711e35ec5a5abaa16e39a6a69d206 -R f0a1a3360ef0fa824ad1508573cdd91a +P c7f778b7cee16a1dcebccd256408ee1d08ef2b62e388a9ebba5738a0a89bf3a0 +R 2abdc374b32c7bda232d41622d54318f U drh -Z 8b4c48c5024c7add103abe54a8cb3650 +Z 65a79c7805978f50bb15716d0b6d13ff diff --git a/manifest.uuid b/manifest.uuid index 7328249fb2..9e0af2d154 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c7f778b7cee16a1dcebccd256408ee1d08ef2b62e388a9ebba5738a0a89bf3a0 \ No newline at end of file +9afd7a2ffd3a39456190ad05e85ff6485298aae262d9e0698a58c1d73507a36f \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 18d36775e0..0c109720a0 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1217,7 +1217,7 @@ static void shellAddSchemaName( "TRIGGER", "VIRTUAL TABLE" }; - int i = 0, n; + int i = 0; const char *zIn = (const char*)sqlite3_value_text(apVal[0]); const char *zSchema = (const char*)sqlite3_value_text(apVal[1]); assert( nVal==2 ); @@ -5818,13 +5818,13 @@ static int do_meta_command(char *zLine, ShellState *p){ zDiv = " UNION ALL "; if( strcmp(zDb, "main")!=0 ){ appendText(&sSelect, "SELECT shell_add_schema(sql,", 0); - appendText(&sSelect, sqlite3_column_text(pStmt, 0), '"'); + appendText(&sSelect, zDb, '"'); appendText(&sSelect, ") AS sql, type, tbl_name, name, rowid,", 0); appendText(&sSelect, zScNum, 0); appendText(&sSelect, " AS snum, ", 0); appendText(&sSelect, zDb, '\''); appendText(&sSelect, " AS sname FROM ", 0); - appendText(&sSelect, sqlite3_column_text(pStmt, 0), '"'); + appendText(&sSelect, zDb, '"'); appendText(&sSelect, ".sqlite_master", 0); }else{ appendText(&sSelect, "SELECT sql, type, tbl_name, name, rowid, ", 0); From f217f3b68c866186a5c3fb5c21436018302280ac Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 15 Jun 2017 16:45:23 +0000 Subject: [PATCH 11/39] Fix typo and improve the wording of the description of "Metadata" in the output of the sqlite3_analyzer tool. FossilOrigin-Name: ca1ff70780e07e5ee930fe7972db02e887d9b085d8ab78e878d7f966b6d684d4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/spaceanal.tcl | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index e98acb5f54..45ac624396 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sthe\sshell.c\sfile -D 2017-06-15T13:07:56.351 +C Fix\stypo\sand\simprove\sthe\swording\sof\sthe\sdescription\sof\s"Metadata"\sin\sthe\noutput\sof\sthe\ssqlite3_analyzer\stool. +D 2017-06-15T16:45:23.229 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -1541,7 +1541,7 @@ F tool/showlocks.c 9920bcc64f58378ff1118caead34147201f48c68 F tool/showstat4.c b14159aa062f661b394ba37b6b7b94bfb8012ab9 F tool/showwal.c ad9d768f96ca6199ad3a8c9562d679680bd032dd01204ea3e5ea6fb931d81847 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe -F tool/spaceanal.tcl a91e09e9e3dd10e67ffe4a01155161fb5e6b6d399002716593780493452c4b28 +F tool/spaceanal.tcl f40dc82b4d5e39d040a02a3ec38268e324068815e4292a15ffa30ee93208bbfd F tool/speed-check.sh 9630ba0468b609c52f48309243d4eb6e9c34deda F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c ecb6542862151c3e6509bbc00509b234562ae81e @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c7f778b7cee16a1dcebccd256408ee1d08ef2b62e388a9ebba5738a0a89bf3a0 -R 2abdc374b32c7bda232d41622d54318f +P 9afd7a2ffd3a39456190ad05e85ff6485298aae262d9e0698a58c1d73507a36f +R d7d9e08f1b748cb64c86b209b3f80ec6 U drh -Z 65a79c7805978f50bb15716d0b6d13ff +Z ab25672babe6d73331acc6dc2b1d5532 diff --git a/manifest.uuid b/manifest.uuid index 9e0af2d154..d899e0cce8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9afd7a2ffd3a39456190ad05e85ff6485298aae262d9e0698a58c1d73507a36f \ No newline at end of file +ca1ff70780e07e5ee930fe7972db02e887d9b085d8ab78e878d7f966b6d684d4 \ No newline at end of file diff --git a/tool/spaceanal.tcl b/tool/spaceanal.tcl index 0309e5f2f4..9db108dc26 100644 --- a/tool/spaceanal.tcl +++ b/tool/spaceanal.tcl @@ -766,12 +766,13 @@ Bytes of payload Bytes of metadata - The amount of formatting and structural information stored on for the + The amount of formatting and structural information stored in the table or index. Metadata includes the btree page header, the cell pointer array, the size field for each cell, the left child pointer or non-leaf cells, the overflow pointers for overflow cells, and the rowid value for - rowid table cells. In other words, metadata is everything that is not - unused space and that is not content. + rowid table cells. In other words, metadata is everything that is neither + unused space nor content. The record header in the payload is counted as + content, not metadata. Average payload per entry From 0942559a14ccdfc0fe487f317169c3f1d47b2ff3 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 15 Jun 2017 16:56:05 +0000 Subject: [PATCH 12/39] Move the "shell_add_schema()" SQL function used by the ".schema" command of the command-line shell to a different spot in the shell.c source file so that it is not in the middle of an unrelated module. FossilOrigin-Name: 254617a1ccfa1736d4e53d670d80319c79c4d93ebf1de69d89ebdba3949bc270 --- manifest | 12 +++--- manifest.uuid | 2 +- src/shell.c | 110 +++++++++++++++++++++++++------------------------- 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/manifest b/manifest index 45ac624396..52563b2b98 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sand\simprove\sthe\swording\sof\sthe\sdescription\sof\s"Metadata"\sin\sthe\noutput\sof\sthe\ssqlite3_analyzer\stool. -D 2017-06-15T16:45:23.229 +C Move\sthe\s"shell_add_schema()"\sSQL\sfunction\sused\sby\sthe\s".schema"\scommand\nof\sthe\scommand-line\sshell\sto\sa\sdifferent\sspot\sin\sthe\sshell.c\ssource\sfile\nso\sthat\sit\sis\snot\sin\sthe\smiddle\sof\san\sunrelated\smodule. +D 2017-06-15T16:56:05.134 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -406,7 +406,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c adf3ef9843135b1383321ad751f16f5a40c3f37925154555a3e61653d2a954e8 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 0d2afdbdba5fbc61432c5454a35e0236e7aa4aa3756986a7d51b81a508e8083a -F src/shell.c c45ae9a95faf5a495280bfa2d6b7956c707f347e56eb8b1985c852d152e46894 +F src/shell.c bcd3358ad6cb3f3dc7ec76ad3bd8191f123ed2425360c5c48fe431780eceb729 F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9afd7a2ffd3a39456190ad05e85ff6485298aae262d9e0698a58c1d73507a36f -R d7d9e08f1b748cb64c86b209b3f80ec6 +P ca1ff70780e07e5ee930fe7972db02e887d9b085d8ab78e878d7f966b6d684d4 +R 726cc59902873bb7eaa232bba10d7407 U drh -Z ab25672babe6d73331acc6dc2b1d5532 +Z 1749d6289173114f89482a05c36735c7 diff --git a/manifest.uuid b/manifest.uuid index d899e0cce8..5621a335b6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ca1ff70780e07e5ee930fe7972db02e887d9b085d8ab78e878d7f966b6d684d4 \ No newline at end of file +254617a1ccfa1736d4e53d670d80319c79c4d93ebf1de69d89ebdba3949bc270 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 0c109720a0..a6818b8bfd 100644 --- a/src/shell.c +++ b/src/shell.c @@ -729,6 +729,61 @@ static char quoteChar(const char *zName){ return 0; } +/* +** SQL function: shell_add_schema(S,X) +** +** Add the schema name X to the CREATE statement in S and return the result. +** Examples: +** +** CREATE TABLE t1(x) -> CREATE TABLE xyz.t1(x); +** +** Also works on +** +** CREATE INDEX +** CREATE UNIQUE INDEX +** CREATE VIEW +** CREATE TRIGGER +** CREATE VIRTUAL TABLE +** +** This UDF is used by the .schema command to insert the schema name of +** attached databases into the middle of the sqlite_master.sql field. +*/ +static void shellAddSchemaName( + sqlite3_context *pCtx, + int nVal, + sqlite3_value **apVal +){ + static const char *aPrefix[] = { + "TABLE", + "INDEX", + "UNIQUE INDEX", + "VIEW", + "TRIGGER", + "VIRTUAL TABLE" + }; + int i = 0; + const char *zIn = (const char*)sqlite3_value_text(apVal[0]); + const char *zSchema = (const char*)sqlite3_value_text(apVal[1]); + assert( nVal==2 ); + if( zIn!=0 && strncmp(zIn, "CREATE ", 7)==0 ){ + for(i=0; iu.x[p->nRate]; } -/* -** SQL function: shell_add_schema(S,X) -** -** Add the schema name X to the CREATE statement in S and return the result. -** Examples: -** -** CREATE TABLE t1(x) -> CREATE TABLE xyz.t1(x); -** -** Also works on -** -** CREATE INDEX -** CREATE UNIQUE INDEX -** CREATE VIEW -** CREATE TRIGGER -** CREATE VIRTUAL TABLE -** -** This UDF is used by the .schema command to insert the schema name of -** attached databases into the middle of the sqlite_master.sql field. -*/ -static void shellAddSchemaName( - sqlite3_context *pCtx, - int nVal, - sqlite3_value **apVal -){ - static const char *aPrefix[] = { - "TABLE", - "INDEX", - "UNIQUE INDEX", - "VIEW", - "TRIGGER", - "VIRTUAL TABLE" - }; - int i = 0; - const char *zIn = (const char*)sqlite3_value_text(apVal[0]); - const char *zSchema = (const char*)sqlite3_value_text(apVal[1]); - assert( nVal==2 ); - if( zIn!=0 && strncmp(zIn, "CREATE ", 7)==0 ){ - for(i=0; i Date: Fri, 16 Jun 2017 13:43:37 +0000 Subject: [PATCH 13/39] Prevent pagesize changes on VACUUM in encrypted databases even when running the VACUUM on an attached database. FossilOrigin-Name: 11693849342a308ad929e2d9ead67faabacb523af76128c6973ed6cc8b62c11e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vacuum.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 52563b2b98..6554d8d870 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Move\sthe\s"shell_add_schema()"\sSQL\sfunction\sused\sby\sthe\s".schema"\scommand\nof\sthe\scommand-line\sshell\sto\sa\sdifferent\sspot\sin\sthe\sshell.c\ssource\sfile\nso\sthat\sit\sis\snot\sin\sthe\smiddle\sof\san\sunrelated\smodule. -D 2017-06-15T16:56:05.134 +C Prevent\spagesize\schanges\son\sVACUUM\sin\sencrypted\sdatabases\seven\swhen\srunning\nthe\sVACUUM\son\san\sattached\sdatabase. +D 2017-06-16T13:43:37.982 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -471,7 +471,7 @@ F src/trigger.c d1cae560bfacc8bfb3a072d73658245c1714c0389097da69b4cb23877a082d7e F src/update.c c443935c652af9365e033f756550b5032d02e1b06eb2cb890ed7511ae0c051dc F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c fc081ec6f63448dcd80d3dfad35baecfa104823254a815b081a4d9fe76e1db23 -F src/vacuum.c 1fe4555cd8c9b263afb85b5b4ee3a4a4181ad569 +F src/vacuum.c 874c0f2f15ab2908748297d587d22d485ea96d55aaec91d4775dddb2e24d2ecf F src/vdbe.c 6783778df820f3e0c68289fe5d12ddd34168b0eb1acf248668fec6e2ea1012d5 F src/vdbe.h 70a409d171d4e51b962f0d53abf15c33c404c6aa4c9d62fb3a931b5a62ba9615 F src/vdbeInt.h cdcdabad4f5d6bf7a3beb826a7f33ee6f8f1cb220042bedd5b7d4bf2ea1d179f @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ca1ff70780e07e5ee930fe7972db02e887d9b085d8ab78e878d7f966b6d684d4 -R 726cc59902873bb7eaa232bba10d7407 +P 254617a1ccfa1736d4e53d670d80319c79c4d93ebf1de69d89ebdba3949bc270 +R 2fae9403d6a69bdf81964eef17b517dd U drh -Z 1749d6289173114f89482a05c36735c7 +Z 67d8e34c53b15ad85020fb42b5ae1f85 diff --git a/manifest.uuid b/manifest.uuid index 5621a335b6..f34136b989 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -254617a1ccfa1736d4e53d670d80319c79c4d93ebf1de69d89ebdba3949bc270 \ No newline at end of file +11693849342a308ad929e2d9ead67faabacb523af76128c6973ed6cc8b62c11e \ No newline at end of file diff --git a/src/vacuum.c b/src/vacuum.c index 9e471b8d9c..841aa52009 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -201,7 +201,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){ extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*); int nKey; char *zKey; - sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey); + sqlite3CodecGetKey(db, iDb, (void**)&zKey, &nKey); if( nKey ) db->nextPagesize = 0; } #endif From ba87c6c2cd80fa19503e576f954605fca78a86fd Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 16 Jun 2017 18:31:30 +0000 Subject: [PATCH 14/39] Minor refactoring change to clarify how ATTACH works. No functional changes. FossilOrigin-Name: 3944a32e1dd90ff903bcbaaa7cb497cebcfcb2ba2a326726ec2268505e524ae3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/attach.c | 31 ++++++++++++++++--------------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 6554d8d870..f763fdfac0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Prevent\spagesize\schanges\son\sVACUUM\sin\sencrypted\sdatabases\seven\swhen\srunning\nthe\sVACUUM\son\san\sattached\sdatabase. -D 2017-06-16T13:43:37.982 +C Minor\srefactoring\schange\sto\sclarify\show\sATTACH\sworks.\s\sNo\sfunctional\schanges. +D 2017-06-16T18:31:30.375 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -343,7 +343,7 @@ F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 3b23977620ce9662ac54443f65b87ba996e36121 F src/analyze.c 0d0ccf7520a201d8747ea2f02c92c26e26f801bc161f714f27b9f7630dde0421 -F src/attach.c 8c476f8bd5d2afe11d925f890d30e527e5b0ce43 +F src/attach.c 3bd555e28382603e80d430dfebb2270f86e1e375b4c4be3e1ab1aec3a0c44943 F src/auth.c 79f96c6f33bf0e5da8d1c282cee5ebb1852bb8a6ccca3e485d7c459b035d9c3c F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 @@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 254617a1ccfa1736d4e53d670d80319c79c4d93ebf1de69d89ebdba3949bc270 -R 2fae9403d6a69bdf81964eef17b517dd +P 11693849342a308ad929e2d9ead67faabacb523af76128c6973ed6cc8b62c11e +R a34795f4d0fcef5a05bf2f69a4f53c3a U drh -Z 67d8e34c53b15ad85020fb42b5ae1f85 +Z 099d10b7bf311f5813d7dd796aa1a1dd diff --git a/manifest.uuid b/manifest.uuid index f34136b989..480e594a2c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -11693849342a308ad929e2d9ead67faabacb523af76128c6973ed6cc8b62c11e \ No newline at end of file +3944a32e1dd90ff903bcbaaa7cb497cebcfcb2ba2a326726ec2268505e524ae3 \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index 393c46ccb6..4a80008cbb 100644 --- a/src/attach.c +++ b/src/attach.c @@ -69,7 +69,8 @@ static void attachFunc( char *zPath = 0; char *zErr = 0; unsigned int flags; - Db *aNew; + Db *aNew; /* New array of Db pointers */ + Db *pNew; /* Db object for the newly attached database */ char *zErrDyn = 0; sqlite3_vfs *pVfs; @@ -117,8 +118,8 @@ static void attachFunc( if( aNew==0 ) return; } db->aDb = aNew; - aNew = &db->aDb[db->nDb]; - memset(aNew, 0, sizeof(*aNew)); + pNew = &db->aDb[db->nDb]; + memset(pNew, 0, sizeof(*pNew)); /* Open the database file. If the btree is successfully opened, use ** it to obtain the database schema. At this point the schema may @@ -134,7 +135,7 @@ static void attachFunc( } assert( pVfs ); flags |= SQLITE_OPEN_MAIN_DB; - rc = sqlite3BtreeOpen(pVfs, zPath, db, &aNew->pBt, 0, flags); + rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags); sqlite3_free( zPath ); db->nDb++; db->skipBtreeMutex = 0; @@ -143,28 +144,28 @@ static void attachFunc( zErrDyn = sqlite3MPrintf(db, "database is already attached"); }else if( rc==SQLITE_OK ){ Pager *pPager; - aNew->pSchema = sqlite3SchemaGet(db, aNew->pBt); - if( !aNew->pSchema ){ + pNew->pSchema = sqlite3SchemaGet(db, pNew->pBt); + if( !pNew->pSchema ){ rc = SQLITE_NOMEM_BKPT; - }else if( aNew->pSchema->file_format && aNew->pSchema->enc!=ENC(db) ){ + }else if( pNew->pSchema->file_format && pNew->pSchema->enc!=ENC(db) ){ zErrDyn = sqlite3MPrintf(db, "attached databases must use the same text encoding as main database"); rc = SQLITE_ERROR; } - sqlite3BtreeEnter(aNew->pBt); - pPager = sqlite3BtreePager(aNew->pBt); + sqlite3BtreeEnter(pNew->pBt); + pPager = sqlite3BtreePager(pNew->pBt); sqlite3PagerLockingMode(pPager, db->dfltLockMode); - sqlite3BtreeSecureDelete(aNew->pBt, + sqlite3BtreeSecureDelete(pNew->pBt, sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) ); #ifndef SQLITE_OMIT_PAGER_PRAGMAS - sqlite3BtreeSetPagerFlags(aNew->pBt, + sqlite3BtreeSetPagerFlags(pNew->pBt, PAGER_SYNCHRONOUS_FULL | (db->flags & PAGER_FLAGS_MASK)); #endif - sqlite3BtreeLeave(aNew->pBt); + sqlite3BtreeLeave(pNew->pBt); } - aNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1; - aNew->zDbSName = sqlite3DbStrDup(db, zName); - if( rc==SQLITE_OK && aNew->zDbSName==0 ){ + pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1; + pNew->zDbSName = sqlite3DbStrDup(db, zName); + if( rc==SQLITE_OK && pNew->zDbSName==0 ){ rc = SQLITE_NOMEM_BKPT; } From da1f49b83f2ef60c9e1ecd81245e210b594ac923 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 16 Jun 2017 19:51:47 +0000 Subject: [PATCH 15/39] Rework the code in ctime.c a bit to report on more compile time options. And to only output configuration options passed in to SQLite, not the default values of #define symbols set automatically. Also generate the large array in ctime.c using new script tool/mkctime.tcl, instead of entering it manually. FossilOrigin-Name: bc1951d699e6eeacbe15776a37cd0f5cf3f09eb85d3ae01cff43293cb286fcd7 --- manifest | 26 +-- manifest.uuid | 2 +- src/ctime.c | 395 +++++++++++++++++++++++++++++++++++++------- src/main.c | 52 ++++++ src/sqliteInt.h | 2 + test/ctime.test | 57 +++---- tool/mkctimec.tcl | 303 +++++++++++++++++++++++++++++++++ tool/mksqlite3c.tcl | 2 +- 8 files changed, 725 insertions(+), 114 deletions(-) create mode 100644 tool/mkctimec.tcl diff --git a/manifest b/manifest index f763fdfac0..59ad1f94f0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\srefactoring\schange\sto\sclarify\show\sATTACH\sworks.\s\sNo\sfunctional\schanges. -D 2017-06-16T18:31:30.375 +C Rework\sthe\scode\sin\sctime.c\sa\sbit\sto\sreport\son\smore\scompile\stime\soptions.\sAnd\nto\sonly\soutput\sconfiguration\soptions\spassed\sin\sto\sSQLite,\snot\sthe\sdefault\nvalues\sof\s#define\ssymbols\sset\sautomatically.\sAlso\sgenerate\sthe\slarge\sarray\sin\nctime.c\susing\snew\sscript\stool/mkctime.tcl,\sinstead\sof\sentering\sit\smanually. +D 2017-06-16T19:51:47.668 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -354,7 +354,7 @@ F src/btreeInt.h a392d353104b4add58b4a59cb185f5d5693dde832c565b77d8d4c343ed98f61 F src/build.c 88a8cdc11d1c081ed565aa3e795bdf9160f4556463b4c4555e9860b59dd80340 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c 47d91a25ad8f199a71a5b1b7b169d6dd0d6e98c5719eca801568798743d1161c +F src/ctime.c 6327cb262d3468bcd3af863db42b4daed033441ddd5e612ccf9079ac2e23247f F src/date.c cc42a41c7422389860d40419a5e3bce5eaf6e7835c3ba2677751dc653550a5c7 F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c 3213547e97b676c6fa79948b7a9ede4801ea04a01a2043241deafedf132ecf5d @@ -370,7 +370,7 @@ F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 974499a3999d339a4c1ba8ef129a988d9f136b3789e423808b38cdc19d28adbe F src/legacy.c e88ed13c2d531decde75d42c2e35623fb9ce3cb0 F src/loadext.c a72909474dadce771d3669bf84bf689424f6f87d471fee898589c3ef9b2acfd9 -F src/main.c 65eb6093de90ab4372f2ae0d0cd0acfe718ea26ef0145435e0d9eecb854c9d7e +F src/main.c 18f2145d572069dae91161add89446aec680aab296492a92ae5afcc2fc7c6b5a F src/malloc.c e20bb2b48abec52d3faf01cce12e8b4f95973755fafec98d45162dfdab111978 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de @@ -410,7 +410,7 @@ F src/shell.c bcd3358ad6cb3f3dc7ec76ad3bd8191f123ed2425360c5c48fe431780eceb729 F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 -F src/sqliteInt.h f90955604b4d8e5a1f672bd230978640be89e0bbbf833d352cf4945ce3a799df +F src/sqliteInt.h bdbc175a05b29293505530412a994fb259c7dfb63b06aa2016f13ef641229fa5 F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 @@ -645,7 +645,7 @@ F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/csv01.test e0ba3caaa57e4c667a0b45977689fb8082f14348 -F test/ctime.test ff6c38e822459d6ca743c34901caf57740b08b54 +F test/ctime.test d19124daeadb9194f2af349b0e06cff723d6e3e7ac14903b4472edaf88b1839d F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 8457e93d97f665f23f97cdbc8477d16e3480331b F test/date.test 9b73bbeb1b82d9c1f44dec5cf563bf7da58d2373 @@ -1515,6 +1515,7 @@ F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca F tool/max-limits.c cbb635fbb37ae4d05f240bfb5b5270bb63c54439 F tool/mkautoconfamal.sh e855df211ecbcc7131dee817110ff386cfb112f7 +F tool/mkctimec.tcl 4751d3c3e3ca8551b4c707574661db03e231b2b5a300af3f613eae4d39e4445a F tool/mkkeywordhash.c f7f3b342211ac6a14258b9726d5b97cf4f548f22 F tool/mkmsvcmin.tcl cbd93f1cfa3a0a9ae56fc958510aa3fc3ac65e29cb111716199e3d0e66eefaa4 F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c @@ -1523,7 +1524,7 @@ F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkpragmatab.tcl 32bb40741df11bddc8451de9ea4d130e7b4476d8064794b1cf402ac110840fba F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl fef88397668ae83166735c41af99d79f56afaabb -F tool/mksqlite3c.tcl 06b2e6a0f21cc0a5d70fbbd136b3e0a96470645e +F tool/mksqlite3c.tcl 226da6d794d7d43a31e159a6fa89db867bf1f5eafe4b37d031222287ef8dbadc F tool/mksqlite3h.tcl 51bd5e7e840a920388a5966c9f2ccc618f434c57bd68c1bab4085b2553e1e237 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5 @@ -1582,7 +1583,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 11693849342a308ad929e2d9ead67faabacb523af76128c6973ed6cc8b62c11e -R a34795f4d0fcef5a05bf2f69a4f53c3a -U drh -Z 099d10b7bf311f5813d7dd796aa1a1dd +P 3944a32e1dd90ff903bcbaaa7cb497cebcfcb2ba2a326726ec2268505e524ae3 +R 7b6facdeed4814ee6f89b7d52660f8c0 +T *branch * ctime-refactor +T *sym-ctime-refactor * +T -sym-trunk * +U dan +Z 9b2fed7077fb54fd01f0379fb1045ffa diff --git a/manifest.uuid b/manifest.uuid index 480e594a2c..6039069bcb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3944a32e1dd90ff903bcbaaa7cb497cebcfcb2ba2a326726ec2268505e524ae3 \ No newline at end of file +bc1951d699e6eeacbe15776a37cd0f5cf3f09eb85d3ae01cff43293cb286fcd7 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index 20e94edba5..b04736e808 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -16,7 +16,11 @@ #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS -#include "sqliteInt.h" + +/* These macros are provided to "stringify" the value of the define +** for those options in which the value is meaningful. */ +#define CTIMEOPT_VAL_(opt) #opt +#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt) /* ** An array of names of all compile-time options. This array should @@ -28,17 +32,30 @@ */ static const char * const azCompileOpt[] = { -/* These macros are provided to "stringify" the value of the define -** for those options in which the value is meaningful. */ -#define CTIMEOPT_VAL_(opt) #opt -#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt) - +/* +** BEGIN CODE GENERATED BY tool/mkctime.tcl +*/ #if SQLITE_32BIT_ROWID "32BIT_ROWID", #endif #if SQLITE_4_BYTE_ALIGNED_MALLOC "4_BYTE_ALIGNED_MALLOC", #endif +#if SQLITE_64BIT_STATS + "64BIT_STATS", +#endif +#if SQLITE_ALLOW_COVERING_INDEX_SCAN + "ALLOW_COVERING_INDEX_SCAN", +#endif +#if SQLITE_ALLOW_URI_AUTHORITY + "ALLOW_URI_AUTHORITY", +#endif +#ifdef SQLITE_BITMASK_TYPE + "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE), +#endif +#if SQLITE_BUG_COMPATIBLE_20160819 + "BUG_COMPATIBLE_20160819", +#endif #if SQLITE_CASE_SENSITIVE_LIKE "CASE_SENSITIVE_LIKE", #endif @@ -57,31 +74,100 @@ static const char * const azCompileOpt[] = { #if SQLITE_COVERAGE_TEST "COVERAGE_TEST", #endif -#ifdef SQLITE_DEBUG +#if SQLITE_DEBUG "DEBUG", #endif -#if SQLITE_DEFAULT_LOCKING_MODE +#if SQLITE_DEFAULT_AUTOMATIC_INDEX + "DEFAULT_AUTOMATIC_INDEX", +#endif +#if SQLITE_DEFAULT_AUTOVACUUM + "DEFAULT_AUTOVACUUM", +#endif +#ifdef SQLITE_DEFAULT_CACHE_SIZE + "DEFAULT_CACHE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE), +#endif +#if SQLITE_DEFAULT_CKPTFULLFSYNC + "DEFAULT_CKPTFULLFSYNC", +#endif +#ifdef SQLITE_DEFAULT_FILE_FORMAT + "DEFAULT_FILE_FORMAT=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT), +#endif +#ifdef SQLITE_DEFAULT_FILE_PERMISSIONS + "DEFAULT_FILE_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS), +#endif +#if SQLITE_DEFAULT_FOREIGN_KEYS + "DEFAULT_FOREIGN_KEYS", +#endif +#ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT + "DEFAULT_JOURNAL_SIZE_LIMIT=" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT), +#endif +#ifdef SQLITE_DEFAULT_LOCKING_MODE "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE), #endif -#if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc) +#ifdef SQLITE_DEFAULT_LOOKASIDE + "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOOKASIDE), +#endif +#if SQLITE_DEFAULT_MEMSTATUS + "DEFAULT_MEMSTATUS", +#endif +#ifdef SQLITE_DEFAULT_MMAP_SIZE "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE), #endif -#if SQLITE_DEFAULT_SYNCHRONOUS +#ifdef SQLITE_DEFAULT_PAGE_SIZE + "DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE), +#endif +#ifdef SQLITE_DEFAULT_PCACHE_INITSZ + "DEFAULT_PCACHE_INITSZ=" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ), +#endif +#ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS + "DEFAULT_PROXYDIR_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS), +#endif +#if SQLITE_DEFAULT_RECURSIVE_TRIGGERS + "DEFAULT_RECURSIVE_TRIGGERS", +#endif +#ifdef SQLITE_DEFAULT_ROWEST + "DEFAULT_ROWEST=" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST), +#endif +#ifdef SQLITE_DEFAULT_SECTOR_SIZE + "DEFAULT_SECTOR_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE), +#endif +#ifdef SQLITE_DEFAULT_SYNCHRONOUS "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS), #endif -#if SQLITE_DEFAULT_WAL_SYNCHRONOUS +#ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT + "DEFAULT_WAL_AUTOCHECKPOINT=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT), +#endif +#ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS), #endif +#ifdef SQLITE_DEFAULT_WORKER_THREADS + "DEFAULT_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS), +#endif #if SQLITE_DIRECT_OVERFLOW_READ "DIRECT_OVERFLOW_READ", #endif #if SQLITE_DISABLE_DIRSYNC "DISABLE_DIRSYNC", #endif +#if SQLITE_DISABLE_FTS3_UNICODE + "DISABLE_FTS3_UNICODE", +#endif +#if SQLITE_DISABLE_FTS4_DEFERRED + "DISABLE_FTS4_DEFERRED", +#endif +#if SQLITE_DISABLE_INTRINSIC + "DISABLE_INTRINSIC", +#endif #if SQLITE_DISABLE_LFS "DISABLE_LFS", #endif -#if SQLITE_ENABLE_8_3_NAMES +#if SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS + "DISABLE_PAGECACHE_OVERFLOW_STATS", +#endif +#if SQLITE_DISABLE_SKIPAHEAD_DISTINCT + "DISABLE_SKIPAHEAD_DISTINCT", +#endif +#ifdef SQLITE_ENABLE_8_3_NAMES "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES), #endif #if SQLITE_ENABLE_API_ARMOR @@ -96,6 +182,15 @@ static const char * const azCompileOpt[] = { #if SQLITE_ENABLE_COLUMN_METADATA "ENABLE_COLUMN_METADATA", #endif +#if SQLITE_ENABLE_COLUMN_USED_MASK + "ENABLE_COLUMN_USED_MASK", +#endif +#if SQLITE_ENABLE_COSTMULT + "ENABLE_COSTMULT", +#endif +#if SQLITE_ENABLE_CURSOR_HINTS + "ENABLE_CURSOR_HINTS", +#endif #if SQLITE_ENABLE_DBSTAT_VTAB "ENABLE_DBSTAT_VTAB", #endif @@ -114,12 +209,18 @@ static const char * const azCompileOpt[] = { #if SQLITE_ENABLE_FTS3_PARENTHESIS "ENABLE_FTS3_PARENTHESIS", #endif +#if SQLITE_ENABLE_FTS3_TOKENIZER + "ENABLE_FTS3_TOKENIZER", +#endif #if SQLITE_ENABLE_FTS4 "ENABLE_FTS4", #endif #if SQLITE_ENABLE_FTS5 "ENABLE_FTS5", #endif +#if SQLITE_ENABLE_HIDDEN_COLUMNS + "ENABLE_HIDDEN_COLUMNS", +#endif #if SQLITE_ENABLE_ICU "ENABLE_ICU", #endif @@ -132,7 +233,7 @@ static const char * const azCompileOpt[] = { #if SQLITE_ENABLE_LOAD_EXTENSION "ENABLE_LOAD_EXTENSION", #endif -#if SQLITE_ENABLE_LOCKING_STYLE +#ifdef SQLITE_ENABLE_LOCKING_STYLE "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE), #endif #if SQLITE_ENABLE_MEMORY_MANAGEMENT @@ -144,26 +245,86 @@ static const char * const azCompileOpt[] = { #if SQLITE_ENABLE_MEMSYS5 "ENABLE_MEMSYS5", #endif +#if SQLITE_ENABLE_MULTIPLEX + "ENABLE_MULTIPLEX", +#endif +#if SQLITE_ENABLE_NULL_TRIM + "ENABLE_NULL_TRIM", +#endif #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK "ENABLE_OVERSIZE_CELL_CHECK", #endif +#if SQLITE_ENABLE_PREUPDATE_HOOK + "ENABLE_PREUPDATE_HOOK", +#endif +#if SQLITE_ENABLE_RBU + "ENABLE_RBU", +#endif #if SQLITE_ENABLE_RTREE "ENABLE_RTREE", #endif +#if SQLITE_ENABLE_SELECTTRACE + "ENABLE_SELECTTRACE", +#endif +#if SQLITE_ENABLE_SESSION + "ENABLE_SESSION", +#endif +#if SQLITE_ENABLE_SNAPSHOT + "ENABLE_SNAPSHOT", +#endif +#if SQLITE_ENABLE_SQLLOG + "ENABLE_SQLLOG", +#endif #if defined(SQLITE_ENABLE_STAT4) "ENABLE_STAT4", #elif defined(SQLITE_ENABLE_STAT3) "ENABLE_STAT3", #endif +#if SQLITE_ENABLE_STMT_SCANSTATUS + "ENABLE_STMT_SCANSTATUS", +#endif +#if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION + "ENABLE_UNKNOWN_SQL_FUNCTION", +#endif #if SQLITE_ENABLE_UNLOCK_NOTIFY "ENABLE_UNLOCK_NOTIFY", #endif #if SQLITE_ENABLE_UPDATE_DELETE_LIMIT "ENABLE_UPDATE_DELETE_LIMIT", #endif -#if defined(SQLITE_ENABLE_URI_00_ERROR) +#if SQLITE_ENABLE_URI_00_ERROR "ENABLE_URI_00_ERROR", #endif +#if SQLITE_ENABLE_VFSTRACE + "ENABLE_VFSTRACE", +#endif +#if SQLITE_ENABLE_WHERETRACE + "ENABLE_WHERETRACE", +#endif +#if SQLITE_ENABLE_ZIPVFS + "ENABLE_ZIPVFS", +#endif +#if SQLITE_EXPLAIN_ESTIMATED_ROWS + "EXPLAIN_ESTIMATED_ROWS", +#endif +#if SQLITE_EXTRA_IFNULLROW + "EXTRA_IFNULLROW", +#endif +#ifdef SQLITE_EXTRA_INIT + "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT), +#endif +#ifdef SQLITE_EXTRA_SHUTDOWN + "EXTRA_SHUTDOWN=" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN), +#endif +#ifdef SQLITE_FTS3_MAX_EXPR_DEPTH + "FTS3_MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH), +#endif +#if SQLITE_FTS5_ENABLE_TEST_MI + "FTS5_ENABLE_TEST_MI", +#endif +#if SQLITE_FTS5_NO_WITHOUT_ROWID + "FTS5_NO_WITHOUT_ROWID", +#endif #if SQLITE_HAS_CODEC "HAS_CODEC", #endif @@ -179,27 +340,114 @@ static const char * const azCompileOpt[] = { #if SQLITE_IGNORE_FLOCK_LOCK_ERRORS "IGNORE_FLOCK_LOCK_ERRORS", #endif -#ifdef SQLITE_INT64_TYPE +#if SQLITE_INLINE_MEMCPY + "INLINE_MEMCPY", +#endif +#if SQLITE_INT64_TYPE "INT64_TYPE", #endif -#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS +#ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX + "INTEGRITY_CHECK_ERROR_MAX=" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX), +#endif +#if SQLITE_LIKE_DOESNT_MATCH_BLOBS "LIKE_DOESNT_MATCH_BLOBS", #endif #if SQLITE_LOCK_TRACE "LOCK_TRACE", #endif -#if defined(SQLITE_MAX_MMAP_SIZE) && !defined(SQLITE_MAX_MMAP_SIZE_xc) +#if SQLITE_LOG_CACHE_SPILL + "LOG_CACHE_SPILL", +#endif +#ifdef SQLITE_MALLOC_SOFT_LIMIT + "MALLOC_SOFT_LIMIT=" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT), +#endif +#ifdef SQLITE_MAX_ATTACHED + "MAX_ATTACHED=" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED), +#endif +#ifdef SQLITE_MAX_COLUMN + "MAX_COLUMN=" CTIMEOPT_VAL(SQLITE_MAX_COLUMN), +#endif +#ifdef SQLITE_MAX_COMPOUND_SELECT + "MAX_COMPOUND_SELECT=" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT), +#endif +#ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE + "MAX_DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE), +#endif +#ifdef SQLITE_MAX_EXPR_DEPTH + "MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH), +#endif +#ifdef SQLITE_MAX_FUNCTION_ARG + "MAX_FUNCTION_ARG=" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG), +#endif +#ifdef SQLITE_MAX_LENGTH + "MAX_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LENGTH), +#endif +#ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH + "MAX_LIKE_PATTERN_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH), +#endif +#ifdef SQLITE_MAX_MEMORY + "MAX_MEMORY=" CTIMEOPT_VAL(SQLITE_MAX_MEMORY), +#endif +#ifdef SQLITE_MAX_MMAP_SIZE "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE), #endif +#ifdef SQLITE_MAX_MMAP_SIZE_ + "MAX_MMAP_SIZE_=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_), +#endif +#ifdef SQLITE_MAX_PAGE_COUNT + "MAX_PAGE_COUNT=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT), +#endif +#ifdef SQLITE_MAX_PAGE_SIZE + "MAX_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE), +#endif #ifdef SQLITE_MAX_SCHEMA_RETRY "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY), #endif +#ifdef SQLITE_MAX_SQL_LENGTH + "MAX_SQL_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH), +#endif +#ifdef SQLITE_MAX_TRIGGER_DEPTH + "MAX_TRIGGER_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH), +#endif +#ifdef SQLITE_MAX_VARIABLE_NUMBER + "MAX_VARIABLE_NUMBER=" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER), +#endif +#ifdef SQLITE_MAX_VDBE_OP + "MAX_VDBE_OP=" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP), +#endif +#ifdef SQLITE_MAX_WORKER_THREADS + "MAX_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS), +#endif #if SQLITE_MEMDEBUG "MEMDEBUG", #endif #if SQLITE_MIXED_ENDIAN_64BIT_FLOAT "MIXED_ENDIAN_64BIT_FLOAT", #endif +#if SQLITE_MMAP_READWRITE + "MMAP_READWRITE", +#endif +#if SQLITE_MUTEX_NOOP + "MUTEX_NOOP", +#endif +#if SQLITE_MUTEX_NREF + "MUTEX_NREF", +#endif +#if SQLITE_MUTEX_OMIT + "MUTEX_OMIT", +#endif +#if SQLITE_MUTEX_PTHREADS + "MUTEX_PTHREADS", +#endif +#if SQLITE_MUTEX_W32 + "MUTEX_W32", +#endif +#if SQLITE_NEED_ERR_NAME + "NEED_ERR_NAME", +#endif +#if SQLITE_NOINLINE + "NOINLINE", +#endif #if SQLITE_NO_SYNC "NO_SYNC", #endif @@ -251,6 +499,9 @@ static const char * const azCompileOpt[] = { #if SQLITE_OMIT_COMPOUND_SELECT "OMIT_COMPOUND_SELECT", #endif +#if SQLITE_OMIT_CONFLICT_CLAUSE + "OMIT_CONFLICT_CLAUSE", +#endif #if SQLITE_OMIT_CTE "OMIT_CTE", #endif @@ -281,6 +532,9 @@ static const char * const azCompileOpt[] = { #if SQLITE_OMIT_GET_TABLE "OMIT_GET_TABLE", #endif +#if SQLITE_OMIT_HEX_INTEGER + "OMIT_HEX_INTEGER", +#endif #if SQLITE_OMIT_INCRBLOB "OMIT_INCRBLOB", #endif @@ -308,6 +562,12 @@ static const char * const azCompileOpt[] = { #if SQLITE_OMIT_PAGER_PRAGMAS "OMIT_PAGER_PRAGMAS", #endif +#if SQLITE_OMIT_PARSER_TRACE + "OMIT_PARSER_TRACE", +#endif +#if SQLITE_OMIT_POPEN + "OMIT_POPEN", +#endif #if SQLITE_OMIT_PRAGMA "OMIT_PRAGMA", #endif @@ -329,6 +589,9 @@ static const char * const azCompileOpt[] = { #if SQLITE_OMIT_SHARED_CACHE "OMIT_SHARED_CACHE", #endif +#if SQLITE_OMIT_SHUTDOWN_DIRECTORIES + "OMIT_SHUTDOWN_DIRECTORIES", +#endif #if SQLITE_OMIT_SUBQUERY "OMIT_SUBQUERY", #endif @@ -338,6 +601,9 @@ static const char * const azCompileOpt[] = { #if SQLITE_OMIT_TEMPDB "OMIT_TEMPDB", #endif +#if SQLITE_OMIT_TEST_CONTROL + "OMIT_TEST_CONTROL", +#endif #if SQLITE_OMIT_TRACE "OMIT_TRACE", #endif @@ -368,12 +634,24 @@ static const char * const azCompileOpt[] = { #if SQLITE_OMIT_XFER_OPT "OMIT_XFER_OPT", #endif +#if SQLITE_PCACHE_SEPARATE_HEADER + "PCACHE_SEPARATE_HEADER", +#endif #if SQLITE_PERFORMANCE_TRACE "PERFORMANCE_TRACE", #endif +#if SQLITE_POWERSAFE_OVERWRITE + "POWERSAFE_OVERWRITE", +#endif +#if SQLITE_PREFER_PROXY_LOCKING + "PREFER_PROXY_LOCKING", +#endif #if SQLITE_PROXY_DEBUG "PROXY_DEBUG", #endif +#if SQLITE_REVERSE_UNORDERED_SELECTS + "REVERSE_UNORDERED_SELECTS", +#endif #if SQLITE_RTREE_INT_ONLY "RTREE_INT_ONLY", #endif @@ -383,81 +661,72 @@ static const char * const azCompileOpt[] = { #if SQLITE_SMALL_STACK "SMALL_STACK", #endif +#ifdef SQLITE_SORTER_PMASZ + "SORTER_PMASZ=" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ), +#endif #if SQLITE_SOUNDEX "SOUNDEX", #endif +#ifdef SQLITE_STAT4_SAMPLES + "STAT4_SAMPLES=" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES), +#endif +#ifdef SQLITE_STMTJRNL_SPILL + "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL), +#endif +#if SQLITE_SUBSTR_COMPATIBILITY + "SUBSTR_COMPATIBILITY", +#endif #if SQLITE_SYSTEM_MALLOC "SYSTEM_MALLOC", #endif #if SQLITE_TCL "TCL", #endif -#if defined(SQLITE_TEMP_STORE) && !defined(SQLITE_TEMP_STORE_xc) +#ifdef SQLITE_TEMP_STORE "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE), #endif #if SQLITE_TEST "TEST", #endif -#if defined(SQLITE_THREADSAFE) +#ifdef SQLITE_THREADSAFE "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE), #endif +#if SQLITE_UNLINK_AFTER_CLOSE + "UNLINK_AFTER_CLOSE", +#endif #if SQLITE_UNTESTABLE - "UNTESTABLE" + "UNTESTABLE", +#endif +#if SQLITE_USER_AUTHENTICATION + "USER_AUTHENTICATION", #endif #if SQLITE_USE_ALLOCA "USE_ALLOCA", #endif -#if SQLITE_USER_AUTHENTICATION - "USER_AUTHENTICATION", +#if SQLITE_USE_FCNTL_TRACE + "USE_FCNTL_TRACE", +#endif +#if SQLITE_USE_URI + "USE_URI", +#endif +#if SQLITE_VDBE_COVERAGE + "VDBE_COVERAGE", #endif #if SQLITE_WIN32_MALLOC "WIN32_MALLOC", #endif #if SQLITE_ZERO_MALLOC - "ZERO_MALLOC" + "ZERO_MALLOC", #endif +/* +** END CODE GENERATED BY tool/mkctime.tcl +*/ }; -/* -** Given the name of a compile-time option, return true if that option -** was used and false if not. -** -** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix -** is not required for a match. -*/ -int sqlite3_compileoption_used(const char *zOptName){ - int i, n; - -#if SQLITE_ENABLE_API_ARMOR - if( zOptName==0 ){ - (void)SQLITE_MISUSE_BKPT; - return 0; - } -#endif - if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7; - n = sqlite3Strlen30(zOptName); - - /* Since ArraySize(azCompileOpt) is normally in single digits, a - ** linear search is adequate. No need for a binary search. */ - for(i=0; i=0 && N=0 && N Date: Sat, 17 Jun 2017 17:29:24 +0000 Subject: [PATCH 17/39] Ensure that the value of the THREADSAFE symbol is always included when reporting compile time options, even if it was not explicitly configured. FossilOrigin-Name: 95141c642697dc037e57f9e4992ff3460155995d3caef6259235601ee722cb93 --- manifest | 21 +++++++++------------ manifest.uuid | 2 +- src/ctime.c | 6 +++++- src/sqliteInt.h | 8 +++++--- test/ctime.test | 39 ++++++++++++++++++++++++++++++++++++++- tool/mkctimec.tcl | 10 +++++++++- 6 files changed, 67 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 59ad1f94f0..e38e4f6571 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rework\sthe\scode\sin\sctime.c\sa\sbit\sto\sreport\son\smore\scompile\stime\soptions.\sAnd\nto\sonly\soutput\sconfiguration\soptions\spassed\sin\sto\sSQLite,\snot\sthe\sdefault\nvalues\sof\s#define\ssymbols\sset\sautomatically.\sAlso\sgenerate\sthe\slarge\sarray\sin\nctime.c\susing\snew\sscript\stool/mkctime.tcl,\sinstead\sof\sentering\sit\smanually. -D 2017-06-16T19:51:47.668 +C Ensure\sthat\sthe\svalue\sof\sthe\sTHREADSAFE\ssymbol\sis\salways\sincluded\swhen\nreporting\scompile\stime\soptions,\seven\sif\sit\swas\snot\sexplicitly\sconfigured. +D 2017-06-17T17:29:24.923 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -354,7 +354,7 @@ F src/btreeInt.h a392d353104b4add58b4a59cb185f5d5693dde832c565b77d8d4c343ed98f61 F src/build.c 88a8cdc11d1c081ed565aa3e795bdf9160f4556463b4c4555e9860b59dd80340 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c 6327cb262d3468bcd3af863db42b4daed033441ddd5e612ccf9079ac2e23247f +F src/ctime.c ce45bd3078346f08f04d87ad4cb04af573490c46ca5c55a23a45166589542a6f F src/date.c cc42a41c7422389860d40419a5e3bce5eaf6e7835c3ba2677751dc653550a5c7 F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c 3213547e97b676c6fa79948b7a9ede4801ea04a01a2043241deafedf132ecf5d @@ -410,7 +410,7 @@ F src/shell.c bcd3358ad6cb3f3dc7ec76ad3bd8191f123ed2425360c5c48fe431780eceb729 F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 -F src/sqliteInt.h bdbc175a05b29293505530412a994fb259c7dfb63b06aa2016f13ef641229fa5 +F src/sqliteInt.h 17e9bce594ea0c38c44ad0cbff4aa50cbff4b25f4bac9d38306caf9f1f028ac9 F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 @@ -645,7 +645,7 @@ F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/csv01.test e0ba3caaa57e4c667a0b45977689fb8082f14348 -F test/ctime.test d19124daeadb9194f2af349b0e06cff723d6e3e7ac14903b4472edaf88b1839d +F test/ctime.test 78749e6c9a5f0010d67985be80788f841e3cd2da18114e2ed6010399a7d807f3 F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 8457e93d97f665f23f97cdbc8477d16e3480331b F test/date.test 9b73bbeb1b82d9c1f44dec5cf563bf7da58d2373 @@ -1515,7 +1515,7 @@ F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca F tool/max-limits.c cbb635fbb37ae4d05f240bfb5b5270bb63c54439 F tool/mkautoconfamal.sh e855df211ecbcc7131dee817110ff386cfb112f7 -F tool/mkctimec.tcl 4751d3c3e3ca8551b4c707574661db03e231b2b5a300af3f613eae4d39e4445a +F tool/mkctimec.tcl dd183b73ae1c28249669741c250525f0407e579a70482371668fd5f130d9feb3 F tool/mkkeywordhash.c f7f3b342211ac6a14258b9726d5b97cf4f548f22 F tool/mkmsvcmin.tcl cbd93f1cfa3a0a9ae56fc958510aa3fc3ac65e29cb111716199e3d0e66eefaa4 F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c @@ -1583,10 +1583,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3944a32e1dd90ff903bcbaaa7cb497cebcfcb2ba2a326726ec2268505e524ae3 -R 7b6facdeed4814ee6f89b7d52660f8c0 -T *branch * ctime-refactor -T *sym-ctime-refactor * -T -sym-trunk * +P bc1951d699e6eeacbe15776a37cd0f5cf3f09eb85d3ae01cff43293cb286fcd7 +R 45624ce11a236a8a994baa28885733aa U dan -Z 9b2fed7077fb54fd01f0379fb1045ffa +Z 71fa8cc8dcaaff976fb71d5480f74630 diff --git a/manifest.uuid b/manifest.uuid index 6039069bcb..7d0d40655b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bc1951d699e6eeacbe15776a37cd0f5cf3f09eb85d3ae01cff43293cb286fcd7 \ No newline at end of file +95141c642697dc037e57f9e4992ff3460155995d3caef6259235601ee722cb93 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index b04736e808..93b23d49eb 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -688,8 +688,12 @@ static const char * const azCompileOpt[] = { #if SQLITE_TEST "TEST", #endif -#ifdef SQLITE_THREADSAFE +#if defined(SQLITE_THREADSAFE) "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE), +#elif defined(THREADSAFE) + "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE), +#else + "THREADSAFE=1" #endif #if SQLITE_UNLINK_AFTER_CLOSE "UNLINK_AFTER_CLOSE", diff --git a/src/sqliteInt.h b/src/sqliteInt.h index ed1b98c7e4..89cb8c33e5 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -274,6 +274,11 @@ ** ** Older versions of SQLite used an optional THREADSAFE macro. ** We support that for legacy. +** +** To ensure that the correct value of "THREADSAFE" is reported when querying +** for compile-time options at runtime (e.g. "PRAGMA compile_options"), this +** logic is partially replicated in ctime.c. If it is updated here, it should +** also be updated there. */ #if !defined(SQLITE_THREADSAFE) # if defined(THREADSAFE) @@ -589,7 +594,6 @@ */ #ifndef SQLITE_TEMP_STORE # define SQLITE_TEMP_STORE 1 -# define SQLITE_TEMP_STORE_xc 1 /* Exclude from ctime.c */ #endif /* @@ -890,7 +894,6 @@ typedef INT16_TYPE LogEst; # else # define SQLITE_MAX_MMAP_SIZE 0 # endif -# define SQLITE_MAX_MMAP_SIZE_xc 1 /* exclude from ctime.c */ #endif /* @@ -900,7 +903,6 @@ typedef INT16_TYPE LogEst; */ #ifndef SQLITE_DEFAULT_MMAP_SIZE # define SQLITE_DEFAULT_MMAP_SIZE 0 -# define SQLITE_DEFAULT_MMAP_SIZE_xc 1 /* Exclude from ctime.c */ #endif #if SQLITE_DEFAULT_MMAP_SIZE>SQLITE_MAX_MMAP_SIZE # undef SQLITE_DEFAULT_MMAP_SIZE diff --git a/test/ctime.test b/test/ctime.test index 7624b625e3..1f07c1a947 100644 --- a/test/ctime.test +++ b/test/ctime.test @@ -79,12 +79,49 @@ ifcapable threadsafe2 { } } +# SQLITE_THREADSAFE should pretty much always be defined +# one way or the other, and it must have a value of 0 or 1. do_test ctime-1.4.1 { + catchsql { + SELECT sqlite_compileoption_used('SQLITE_THREADSAFE'); + } +} {0 1} +do_test ctime-1.4.2 { + catchsql { + SELECT sqlite_compileoption_used('THREADSAFE'); + } +} {0 1} +do_test ctime-1.4.3 { + catchsql { + SELECT sqlite_compileoption_used("THREADSAFE"); + } +} {0 1} + +do_test ctime-1.5 { + set ans1 [ catchsql { + SELECT sqlite_compileoption_used('THREADSAFE=0'); + } ] + set ans2 [ catchsql { + SELECT sqlite_compileoption_used('THREADSAFE=1'); + } ] + set ans3 [ catchsql { + SELECT sqlite_compileoption_used('THREADSAFE=2'); + } ] + lsort [ list $ans1 $ans2 $ans3 ] +} {{0 0} {0 0} {0 1}} + +do_test ctime-1.6 { + execsql { + SELECT sqlite_compileoption_used('THREADSAFE='); + } +} {0} + +do_test ctime-1.7.1 { execsql { SELECT sqlite_compileoption_used('SQLITE_OMIT_COMPILEOPTION_DIAGS'); } } {0} -do_test ctime-1.4.2 { +do_test ctime-1.7.2 { execsql { SELECT sqlite_compileoption_used('OMIT_COMPILEOPTION_DIAGS'); } diff --git a/tool/mkctimec.tcl b/tool/mkctimec.tcl index c1f5137497..499d5a5639 100644 --- a/tool/mkctimec.tcl +++ b/tool/mkctimec.tcl @@ -241,7 +241,6 @@ set value_options { SQLITE_STAT4_SAMPLES SQLITE_STMTJRNL_SPILL SQLITE_TEMP_STORE - SQLITE_THREADSAFE } # Options that require custom code. @@ -269,6 +268,15 @@ set options(HAVE_ISNAN) { "HAVE_ISNAN", #endif } +set options(THREADSAFE) { +#if defined(SQLITE_THREADSAFE) + "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE), +#elif defined(THREADSAFE) + "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE), +#else + "THREADSAFE=1" +#endif +} proc trim_name {in} { set ret $in From 40db2fd7a3018eae064e2b250ba78b23bfa6c3d8 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 17 Jun 2017 18:49:50 +0000 Subject: [PATCH 18/39] Fix a missing comma in the previous check-in. FossilOrigin-Name: f3db02f49073c3f08c3fd7816d85e5472d5e22df20d862fe4886eb2a97efb15f --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/ctime.c | 3 +-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index f480884f71..7ff1732e8e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rework\sthe\scode\sin\sctime.c\sa\sbit\sto\sreport\son\smore\scompile\stime\soptions.\sAnd\nto\sonly\soutput\sconfiguration\soptions\spassed\sin\sto\sSQLite,\snot\sthe\sdefault\nvalues\sof\s#define\ssymbols\sset\sautomatically.\sAlso\sgenerate\sthe\slarge\sarray\sin\nctime.c\susing\snew\sscript\stool/mkctime.tcl,\sinstead\sof\sentering\sit\smanually. -D 2017-06-17T17:55:33.959 +C Fix\sa\smissing\scomma\sin\sthe\sprevious\scheck-in. +D 2017-06-17T18:49:50.823 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -354,7 +354,7 @@ F src/btreeInt.h a392d353104b4add58b4a59cb185f5d5693dde832c565b77d8d4c343ed98f61 F src/build.c 88a8cdc11d1c081ed565aa3e795bdf9160f4556463b4c4555e9860b59dd80340 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c ce45bd3078346f08f04d87ad4cb04af573490c46ca5c55a23a45166589542a6f +F src/ctime.c eeff225a310b2d9a2a6cb413acaf78ab301b142ed3bcd83f0c06298f609373cb F src/date.c cc42a41c7422389860d40419a5e3bce5eaf6e7835c3ba2677751dc653550a5c7 F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c 3213547e97b676c6fa79948b7a9ede4801ea04a01a2043241deafedf132ecf5d @@ -1583,7 +1583,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 603838fc9a65adda831a6a17b31b2e80f5b56e5946a9f0c1fa2c83d2f2a67f6a 95141c642697dc037e57f9e4992ff3460155995d3caef6259235601ee722cb93 -R 358dbf3fdae5ca4611427e66902abaf4 -U dan -Z 1d5d7e50e2cd625a1568a19566c46408 +P 9a443397a6b110f60cae32e1f758914d72931e16ddb423e4d4a119df526bf340 +R 48cf46cf5e03c592f1eb729aae9e27b1 +U drh +Z 1075564756c6da5b66b28900b7b4b32b diff --git a/manifest.uuid b/manifest.uuid index e04de06795..64f264fc2c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9a443397a6b110f60cae32e1f758914d72931e16ddb423e4d4a119df526bf340 \ No newline at end of file +f3db02f49073c3f08c3fd7816d85e5472d5e22df20d862fe4886eb2a97efb15f \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index 93b23d49eb..cbb6aea8ae 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -693,7 +693,7 @@ static const char * const azCompileOpt[] = { #elif defined(THREADSAFE) "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE), #else - "THREADSAFE=1" + "THREADSAFE=1", #endif #if SQLITE_UNLINK_AFTER_CLOSE "UNLINK_AFTER_CLOSE", @@ -733,4 +733,3 @@ const char **sqlite3CompileOptions(int *pnOpt){ } #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ - From bd11a2acbb29dd6548dc49961d78694c5e0c3f7e Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 20 Jun 2017 17:43:26 +0000 Subject: [PATCH 19/39] Ensure that the query planner knows that any column of a flattened LEFT JOIN can be NULL even if that column is labeled with "NOT NULL". Fix for ticket [892fc34f173e99d8]. FossilOrigin-Name: 483462682d3a57fb9dd85b4772596e9738f1694a454b8ebbc480b9452733e88d --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/select.c | 9 ++++++--- test/join.test | 17 +++++++++++++++++ 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 7ff1732e8e..4b98d1d665 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smissing\scomma\sin\sthe\sprevious\scheck-in. -D 2017-06-17T18:49:50.823 +C Ensure\sthat\sthe\squery\splanner\sknows\sthat\sany\scolumn\sof\sa\sflattened\sLEFT\sJOIN\ncan\sbe\sNULL\seven\sif\sthat\scolumn\sis\slabeled\swith\s"NOT\sNULL".\nFix\sfor\sticket\s[892fc34f173e99d8]. +D 2017-06-20T17:43:26.613 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -405,7 +405,7 @@ F src/printf.c 8757834f1b54dae512fb25eb1acc8e94a0d15dd2290b58f2563f65973265adb2 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c adf3ef9843135b1383321ad751f16f5a40c3f37925154555a3e61653d2a954e8 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac -F src/select.c 0d2afdbdba5fbc61432c5454a35e0236e7aa4aa3756986a7d51b81a508e8083a +F src/select.c 35ccfae64cecfa843d54a5898c4ab7d6595ce03d147267fa5eecdc8eab39cd6a F src/shell.c bcd3358ad6cb3f3dc7ec76ad3bd8191f123ed2425360c5c48fe431780eceb729 F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -908,7 +908,7 @@ F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd F test/ioerr4.test f130fe9e71008577b342b8874d52984bd04ede2c F test/ioerr5.test 2edfa4fb0f896f733071303b42224df8bedd9da4 F test/ioerr6.test a395a6ab144b26a9e3e21059a1ab6a7149cca65b -F test/join.test 302f164f4a41c240d16ebd780762834233be77b852f15232c9a48a6fe37ac0fa +F test/join.test 442c462eea85cf065d70a663c626b780a95af6e11585d909bb63b87598afe678 F test/join2.test a48f723c5692e2cbb23a9297ac2720cb77d51a70 F test/join3.test 6f0c774ff1ba0489e6c88a3e77b9d3528fb4fda0 F test/join4.test 1a352e4e267114444c29266ce79e941af5885916 @@ -1583,7 +1583,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9a443397a6b110f60cae32e1f758914d72931e16ddb423e4d4a119df526bf340 -R 48cf46cf5e03c592f1eb729aae9e27b1 -U drh -Z 1075564756c6da5b66b28900b7b4b32b +P f3db02f49073c3f08c3fd7816d85e5472d5e22df20d862fe4886eb2a97efb15f +R 65c6dcf56f692aabb1488a88a7fa82bd +U dan +Z a6ca5a5b1b0df383164124d4a74591e8 diff --git a/manifest.uuid b/manifest.uuid index 64f264fc2c..dc950391b8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f3db02f49073c3f08c3fd7816d85e5472d5e22df20d862fe4886eb2a97efb15f \ No newline at end of file +483462682d3a57fb9dd85b4772596e9738f1694a454b8ebbc480b9452733e88d \ No newline at end of file diff --git a/src/select.c b/src/select.c index 6c99776e19..74747fadc2 100644 --- a/src/select.c +++ b/src/select.c @@ -3205,9 +3205,12 @@ static Expr *substExpr( pCopy = &ifNullRow; } pNew = sqlite3ExprDup(db, pCopy, 0); - if( pNew && (pExpr->flags & EP_FromJoin) ){ + if( pNew && pSubst->isLeftJoin ){ + ExprSetProperty(pNew, EP_CanBeNull); + } + if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){ pNew->iRightJoinTable = pExpr->iRightJoinTable; - pNew->flags |= EP_FromJoin; + ExprSetProperty(pNew, EP_FromJoin); } sqlite3ExprDelete(db, pExpr); pExpr = pNew; @@ -3500,7 +3503,7 @@ static int flattenSubquery( ** ** If the subquery is the right operand of a LEFT JOIN, then the outer ** query cannot be an aggregate. This is an artifact of the way aggregates - ** are processed - there is not mechanism to determine if the LEFT JOIN + ** are processed - there is no mechanism to determine if the LEFT JOIN ** table should be all-NULL. ** ** See also tickets #306, #350, and #3300. diff --git a/test/join.test b/test/join.test index ac536df4e5..4df586d8ab 100644 --- a/test/join.test +++ b/test/join.test @@ -763,4 +763,21 @@ do_execsql_test join-14.12 { SELECT *, '|' FROM t3 LEFT JOIN v2 ON a=x ORDER BY b; } {4 {} {} | 2 2 1 |} +# Verify the fix for ticket +# https://www.sqlite.org/src/info/892fc34f173e99d8 +# +db close +sqlite3 db :memory: +do_execsql_test join-14.20 { + CREATE TABLE t1(id INTEGER PRIMARY KEY); + CREATE TABLE t2(id INTEGER PRIMARY KEY, c2 INTEGER); + CREATE TABLE t3(id INTEGER PRIMARY KEY, c3 INTEGER); + INSERT INTO t1(id) VALUES(456); + INSERT INTO t3(id) VALUES(1),(2); + SELECT t1.id, x2.id, x3.id + FROM t1 + LEFT JOIN (SELECT * FROM t2) AS x2 ON t1.id=x2.c2 + LEFT JOIN t3 AS x3 ON x2.id=x3.c3; +} {456 {} {}} + finish_test From f383f35e6cd4569a88dae3efa46f32727502de60 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 20 Jun 2017 18:19:16 +0000 Subject: [PATCH 20/39] Rename the azCompileOpt global constant to avoid a harmless compiler warning about a name conflict with a local variable. FossilOrigin-Name: 94e420ecfb4ec047eb7d1d3125ca8487c90d466760b7f7183759ff922bd868d1 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/ctime.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 4b98d1d665..76a0a7bcf8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sthe\squery\splanner\sknows\sthat\sany\scolumn\sof\sa\sflattened\sLEFT\sJOIN\ncan\sbe\sNULL\seven\sif\sthat\scolumn\sis\slabeled\swith\s"NOT\sNULL".\nFix\sfor\sticket\s[892fc34f173e99d8]. -D 2017-06-20T17:43:26.613 +C Rename\sthe\sazCompileOpt\sglobal\sconstant\sto\savoid\sa\sharmless\scompiler\swarning\nabout\sa\sname\sconflict\swith\sa\slocal\svariable. +D 2017-06-20T18:19:16.728 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -354,7 +354,7 @@ F src/btreeInt.h a392d353104b4add58b4a59cb185f5d5693dde832c565b77d8d4c343ed98f61 F src/build.c 88a8cdc11d1c081ed565aa3e795bdf9160f4556463b4c4555e9860b59dd80340 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c eeff225a310b2d9a2a6cb413acaf78ab301b142ed3bcd83f0c06298f609373cb +F src/ctime.c ca1b2403003ef5d0e331ad2d73ee812ac33b8efc55f8e525ffa8ce5ac1f2c4ea F src/date.c cc42a41c7422389860d40419a5e3bce5eaf6e7835c3ba2677751dc653550a5c7 F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c 3213547e97b676c6fa79948b7a9ede4801ea04a01a2043241deafedf132ecf5d @@ -1583,7 +1583,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f3db02f49073c3f08c3fd7816d85e5472d5e22df20d862fe4886eb2a97efb15f -R 65c6dcf56f692aabb1488a88a7fa82bd -U dan -Z a6ca5a5b1b0df383164124d4a74591e8 +P 483462682d3a57fb9dd85b4772596e9738f1694a454b8ebbc480b9452733e88d +R e2bade6a64e1049141b8f35e27012e03 +U drh +Z 3ee9a1608fd465be0ecf3abf15580493 diff --git a/manifest.uuid b/manifest.uuid index dc950391b8..f42455f6cb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -483462682d3a57fb9dd85b4772596e9738f1694a454b8ebbc480b9452733e88d \ No newline at end of file +94e420ecfb4ec047eb7d1d3125ca8487c90d466760b7f7183759ff922bd868d1 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index cbb6aea8ae..5644e5314b 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -30,7 +30,7 @@ ** only a handful of compile-time options, so most times this array is usually ** rather short and uses little memory space. */ -static const char * const azCompileOpt[] = { +static const char * const sqlite3azCompileOpt[] = { /* ** BEGIN CODE GENERATED BY tool/mkctime.tcl @@ -728,8 +728,8 @@ static const char * const azCompileOpt[] = { }; const char **sqlite3CompileOptions(int *pnOpt){ - *pnOpt = sizeof(azCompileOpt) / sizeof(azCompileOpt[0]); - return (const char**)azCompileOpt; + *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]); + return (const char**)sqlite3azCompileOpt; } #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ From c45fdb2a7f7935cbaa4d13d2e0410a1dce2dbcbf Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 21 Jun 2017 01:36:30 +0000 Subject: [PATCH 21/39] Enable pragma virtual tables for the integrity_check, quick_check, and foreign_key_check pragmas. FossilOrigin-Name: 118f7bb33a6f78951bbffa957f48015d1bce5aaf9246a99262a90bc8ad52e5a3 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pragma.h | 6 +++--- tool/mkpragmatab.tcl | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 76a0a7bcf8..24b18868ac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rename\sthe\sazCompileOpt\sglobal\sconstant\sto\savoid\sa\sharmless\scompiler\swarning\nabout\sa\sname\sconflict\swith\sa\slocal\svariable. -D 2017-06-20T18:19:16.728 +C Enable\spragma\svirtual\stables\sfor\sthe\sintegrity_check,\squick_check,\sand\nforeign_key_check\spragmas. +D 2017-06-21T01:36:30.804 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -399,7 +399,7 @@ F src/pcache.c 62835bed959e2914edd26afadfecce29ece0e870 F src/pcache.h 521bb9610d38ef17a3cc9b5ddafd4546c2ea67fa3d0e464823d73c2a28d50e11 F src/pcache1.c 1195a21fe28e223e024f900b2011e80df53793f0356a24caace4188b098540dc F src/pragma.c 2362670a9d28b71708aecb2b9b10b3f7be71f4c950961c07e81dc400e3ce6371 -F src/pragma.h 37a1311d0388db480388d7ec09054f7103045eff20d4971f8a433b77f40b9921 +F src/pragma.h a8a949000214fefb6210330eed8ccbbb4f752619a9871f31b3dedd4a240277fd F src/prepare.c b1140c3d0cf59bc85ace00ce363153041b424b7a F src/printf.c 8757834f1b54dae512fb25eb1acc8e94a0d15dd2290b58f2563f65973265adb2 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 @@ -1521,7 +1521,7 @@ F tool/mkmsvcmin.tcl cbd93f1cfa3a0a9ae56fc958510aa3fc3ac65e29cb111716199e3d0e66e F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c F tool/mkopcodeh.tcl a01d2c1d8a6205b03fc635adf3735b4c523befd3 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e -F tool/mkpragmatab.tcl 32bb40741df11bddc8451de9ea4d130e7b4476d8064794b1cf402ac110840fba +F tool/mkpragmatab.tcl bdd4c76449e9e0874ae7f0846868c42583e63b47a081b177a97f94e2b702b3e7 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl fef88397668ae83166735c41af99d79f56afaabb F tool/mksqlite3c.tcl 226da6d794d7d43a31e159a6fa89db867bf1f5eafe4b37d031222287ef8dbadc @@ -1583,7 +1583,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 483462682d3a57fb9dd85b4772596e9738f1694a454b8ebbc480b9452733e88d -R e2bade6a64e1049141b8f35e27012e03 +P 94e420ecfb4ec047eb7d1d3125ca8487c90d466760b7f7183759ff922bd868d1 +R bb441c04952674b0d2cabd8a1e6870d3 U drh -Z 3ee9a1608fd465be0ecf3abf15580493 +Z cb37bb49734166773486fcb21706d402 diff --git a/manifest.uuid b/manifest.uuid index f42455f6cb..82f0dac969 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -94e420ecfb4ec047eb7d1d3125ca8487c90d466760b7f7183759ff922bd868d1 \ No newline at end of file +118f7bb33a6f78951bbffa957f48015d1bce5aaf9246a99262a90bc8ad52e5a3 \ No newline at end of file diff --git a/src/pragma.h b/src/pragma.h index d05657c799..bf0f648f07 100644 --- a/src/pragma.h +++ b/src/pragma.h @@ -267,7 +267,7 @@ static const PragmaName aPragmaName[] = { #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) {/* zName: */ "foreign_key_check", /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK, - /* ePragFlg: */ PragFlg_NeedSchema, + /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0, /* ColNames: */ 39, 4, /* iArg: */ 0 }, #endif @@ -354,7 +354,7 @@ static const PragmaName aPragmaName[] = { #if !defined(SQLITE_OMIT_INTEGRITY_CHECK) {/* zName: */ "integrity_check", /* ePragTyp: */ PragTyp_INTEGRITY_CHECK, - /* ePragFlg: */ PragFlg_NeedSchema, + /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1, /* ColNames: */ 0, 0, /* iArg: */ 0 }, #endif @@ -449,7 +449,7 @@ static const PragmaName aPragmaName[] = { #if !defined(SQLITE_OMIT_INTEGRITY_CHECK) {/* zName: */ "quick_check", /* ePragTyp: */ PragTyp_INTEGRITY_CHECK, - /* ePragFlg: */ PragFlg_NeedSchema, + /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1, /* ColNames: */ 0, 0, /* iArg: */ 0 }, #endif diff --git a/tool/mkpragmatab.tcl b/tool/mkpragmatab.tcl index 080e3da003..8eb8250535 100644 --- a/tool/mkpragmatab.tcl +++ b/tool/mkpragmatab.tcl @@ -263,7 +263,7 @@ set pragma_def { IF: !defined(SQLITE_OMIT_FOREIGN_KEY) NAME: foreign_key_check - FLAG: NeedSchema + FLAG: NeedSchema Result0 COLS: table rowid parent fkid IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) @@ -274,12 +274,12 @@ set pragma_def { FLAG: NoColumns NAME: integrity_check - FLAG: NeedSchema + FLAG: NeedSchema Result0 Result1 IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK) NAME: quick_check TYPE: INTEGRITY_CHECK - FLAG: NeedSchema + FLAG: NeedSchema Result0 Result1 IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK) NAME: encoding From c456a76fb326d99e6d09a2d13f732fc9d15b3d33 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 22 Jun 2017 16:51:16 +0000 Subject: [PATCH 22/39] When generating individual loops for each ORed term of an OR scan, move any constant WHERE expressions outside of the loop, as is done for top-level loops. FossilOrigin-Name: e4a022be4b069b08cfdfda5295461676b99d28e17bbbedfbcb362dec69de59bd --- manifest | 25 +++++++++++---------- manifest.uuid | 2 +- src/fkey.c | 10 +++++---- src/tclsqlite.c | 8 +++++-- src/where.c | 55 ++++++++++++++++++++++++++++++++++++---------- test/eqp.test | 6 ++--- test/whereF.test | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 131 insertions(+), 32 deletions(-) diff --git a/manifest b/manifest index 24b18868ac..f564f142d1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enable\spragma\svirtual\stables\sfor\sthe\sintegrity_check,\squick_check,\sand\nforeign_key_check\spragmas. -D 2017-06-21T01:36:30.804 +C When\sgenerating\sindividual\sloops\sfor\seach\sORed\sterm\sof\san\sOR\sscan,\smove\sany\nconstant\sWHERE\sexpressions\soutside\sof\sthe\sloop,\sas\sis\sdone\sfor\stop-level\nloops. +D 2017-06-22T16:51:16.239 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -360,7 +360,7 @@ F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c 3213547e97b676c6fa79948b7a9ede4801ea04a01a2043241deafedf132ecf5d F src/expr.c 452c6f3aa656aabf3eefe96bb5f316b2c987fbc12c647964e4ed880f193ca31f F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 -F src/fkey.c db65492ae549c3b548c9ef1f279ce1684f1c473b116e1c56a90878cd5dcf968d +F src/fkey.c 5ff2c895fe087756d8085dc1a9bc229b5670e2a65c3929dd87c71e43649af333 F src/func.c 9d52522cc8ae7f5cdadfe14594262f1618bc1f86083c4cd6da861b4cf5af6174 F src/global.c 8a6ab6b4d91effb96ffa81b39f0d70c862abca157f8aaa194600a4a8b7923344 F src/hash.c 63d0ee752a3b92d4695b2b1f5259c4621b2cfebd @@ -414,7 +414,7 @@ F src/sqliteInt.h 17e9bce594ea0c38c44ad0cbff4aa50cbff4b25f4bac9d38306caf9f1f028a F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 -F src/tclsqlite.c c8cf60d0c5411d5e70e7c136470d29dbe760d250f55198b71682c67086524e4a +F src/tclsqlite.c 1ac29f18b1b3787a30b45dbbdf6fdc4aa4f1a2f8c7c8fe586beba1b177eba97d F src/test1.c c99f0442918a7a5d5b68a95d6024c211989e6c782c15ced5a558994baaf76a5e F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5 F src/test3.c b8434949dfb8aff8dfa082c8b592109e77844c2135ed3c492113839b6956255b @@ -486,7 +486,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 40c543f0a2195d1b0dc88ef12142bea690009344 F src/wal.h 06b2a0b599cc0f53ea97f497cf8c6b758c999f71 F src/walker.c d46044e7a5842560dfe7122d93ff5145dd4a96f4d0bf5ba5910a7731b8c01e79 -F src/where.c aa213e1b1c29eb8946a9f25108a18666a745ae5bac41b58d0be98730937a7785 +F src/where.c d4f329d9055dbdb475d697f205db1104af886aad4400168fb9b957f6251ea926 F src/whereInt.h 2a4b634d63ce488b46d4b0da8f2eaa8f9aeab202bc25ef76f007de5e3fba1f20 F src/wherecode.c 339ee802d9d311acf0cba8b5a9a092e167ef71c3a777d4b3e57de25d193251c7 F src/whereexpr.c a2fe3811d45af45a5c6667caabc15e01054fe6228c64e86e1f7d2ba5ef5284f9 @@ -695,7 +695,7 @@ F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea F test/enc2.test 83437a79ba1545a55fb549309175c683fb334473 F test/enc3.test 6807f7a7740a00361ca8d0ccd66bc60c8dc5f2b6 F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020 -F test/eqp.test 3fe051af50921284189d1970eb653f9fcf5117d2 +F test/eqp.test 3f9ba0b2594837c7beaa3ba824e2137cfe857308f020ec5a0c7a62b444e837b0 F test/errmsg.test f31592a594b44ee121371d25ddd5d63497bb3401 F test/eval.test a64c9105d6ff163df7cf09d6ac29cdad5922078c F test/exclusive.test 9a57bd66e39144b888ca75c309914fcdefb4e3f9 @@ -1465,7 +1465,7 @@ F test/whereB.test 0def95db3bdec220a731c7e4bec5930327c1d8c5 F test/whereC.test cae295158703cb3fc23bf1a108a9ab730efff0f6 F test/whereD.test 711d4df58d6d4fb9b3f5ce040b818564198be002 F test/whereE.test b3a055eef928c992b0a33198a7b8dc10eea5ad2f -F test/whereF.test 5b2ba0dbe8074aa13e416b37c753991f0a2492d7 +F test/whereF.test 97a86ecdfa4c21684fdff501dbd2cb7397689be8676d0dbad1f5a0892c6b56a3 F test/whereG.test dde4c52a97385a55be6a7cd46be8373f0cf35501 F test/whereH.test e4b07f7a3c2f5d31195cd33710054c78667573b2 F test/whereI.test eab5b226bbc344ac70d7dc09b963a064860ae6d7 @@ -1583,7 +1583,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 94e420ecfb4ec047eb7d1d3125ca8487c90d466760b7f7183759ff922bd868d1 -R bb441c04952674b0d2cabd8a1e6870d3 -U drh -Z cb37bb49734166773486fcb21706d402 +P 118f7bb33a6f78951bbffa957f48015d1bce5aaf9246a99262a90bc8ad52e5a3 +R b4aae75660dcec44ff13144cfab52224 +T *branch * or-optimization +T *sym-or-optimization * +T -sym-trunk * +U dan +Z 7d390f8e00d309abb459da345f7f0ca9 diff --git a/manifest.uuid b/manifest.uuid index 82f0dac969..03b32f8844 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -118f7bb33a6f78951bbffa957f48015d1bce5aaf9246a99262a90bc8ad52e5a3 \ No newline at end of file +e4a022be4b069b08cfdfda5295461676b99d28e17bbbedfbcb362dec69de59bd \ No newline at end of file diff --git a/src/fkey.c b/src/fkey.c index f91a6de547..0012768a39 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -633,10 +633,12 @@ static void fkScanChildren( /* Create VDBE to loop through the entries in pSrc that match the WHERE ** clause. For each row found, increment either the deferred or immediate ** foreign key constraint counter. */ - pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0); - sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr); - if( pWInfo ){ - sqlite3WhereEnd(pWInfo); + if( pParse->nErr==0 ){ + pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0); + sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr); + if( pWInfo ){ + sqlite3WhereEnd(pWInfo); + } } /* Clean up the WHERE clause constructed above. */ diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 754775e8e8..bb7c9e5b82 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -161,6 +161,7 @@ struct SqliteDb { int nStmt; /* Number of statements in stmtList */ IncrblobChannel *pIncrblob;/* Linked list of open incrblob channels */ int nStep, nSort, nIndex; /* Statistics for most recent operation */ + int nVMStep; /* Another statistic for most recent operation */ int nTransaction; /* Number of nested [transaction] methods */ int openFlags; /* Flags used to open. (SQLITE_OPEN_URI) */ #ifdef SQLITE_TEST @@ -1588,6 +1589,7 @@ static int dbEvalStep(DbEvalContext *p){ pDb->nStep = sqlite3_stmt_status(pStmt,SQLITE_STMTSTATUS_FULLSCAN_STEP,1); pDb->nSort = sqlite3_stmt_status(pStmt,SQLITE_STMTSTATUS_SORT,1); pDb->nIndex = sqlite3_stmt_status(pStmt,SQLITE_STMTSTATUS_AUTOINDEX,1); + pDb->nVMStep = sqlite3_stmt_status(pStmt,SQLITE_STMTSTATUS_VM_STEP,1); dbReleaseColumnNames(p); p->pPreStmt = 0; @@ -2855,7 +2857,7 @@ static int SQLITE_TCLAPI DbObjCmd( } /* - ** $db status (step|sort|autoindex) + ** $db status (step|sort|autoindex|vmstep) ** ** Display SQLITE_STMTSTATUS_FULLSCAN_STEP or ** SQLITE_STMTSTATUS_SORT for the most recent eval. @@ -2874,9 +2876,11 @@ static int SQLITE_TCLAPI DbObjCmd( v = pDb->nSort; }else if( strcmp(zOp, "autoindex")==0 ){ v = pDb->nIndex; + }else if( strcmp(zOp, "vmstep")==0 ){ + v = pDb->nVMStep; }else{ Tcl_AppendResult(interp, - "bad argument: should be autoindex, step, or sort", + "bad argument: should be autoindex, step, sort or vmstep", (char*)0); return TCL_ERROR; } diff --git a/src/where.c b/src/where.c index 99b0df4e5d..1cd5d70330 100644 --- a/src/where.c +++ b/src/where.c @@ -4294,6 +4294,31 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ return 0; } +/* +** Helper function for exprIsDeterministic(). +*/ +static int exprNodeIsDeterministic(Walker *pWalker, Expr *pExpr){ + if( pExpr->op==TK_FUNCTION && ExprHasProperty(pExpr, EP_ConstFunc)==0 ){ + pWalker->eCode = 0; + return WRC_Abort; + } + return WRC_Continue; +} + +/* +** Return true if the expression contains no non-deterministic SQL +** functions. Do not consider non-deterministic SQL functions that are +** part of sub-select statements. +*/ +static int exprIsDeterministic(Expr *p){ + Walker w; + memset(&w, 0, sizeof(w)); + w.eCode = 1; + w.xExprCallback = exprNodeIsDeterministic; + sqlite3WalkExpr(&w, p); + return w.eCode; +} + /* ** Generate the beginning of the loop used for WHERE clause processing. ** The return value is a pointer to an opaque structure that contains @@ -4492,17 +4517,6 @@ WhereInfo *sqlite3WhereBegin( sqlite3WhereClauseInit(&pWInfo->sWC, pWInfo); sqlite3WhereSplit(&pWInfo->sWC, pWhere, TK_AND); - /* Special case: a WHERE clause that is constant. Evaluate the - ** expression and either jump over all of the code or fall thru. - */ - for(ii=0; iinTerm; ii++){ - if( nTabList==0 || sqlite3ExprIsConstantNotJoin(sWLB.pWC->a[ii].pExpr) ){ - sqlite3ExprIfFalse(pParse, sWLB.pWC->a[ii].pExpr, pWInfo->iBreak, - SQLITE_JUMPIFNULL); - sWLB.pWC->a[ii].wtFlags |= TERM_CODED; - } - } - /* Special case: No FROM clause */ if( nTabList==0 ){ @@ -4541,6 +4555,25 @@ WhereInfo *sqlite3WhereBegin( sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC); if( db->mallocFailed ) goto whereBeginError; + /* Special case: WHERE terms that do not refer to any tables in the join + ** (constant expressions). Evaluate each such term, and jump over all the + ** generated code if the result is not true. + ** + ** Do not do this if the expression contains non-deterministic functions + ** that are not within a sub-select. This is not strictly required, but + ** preserves SQLite's legacy behaviour in the following two cases: + ** + ** FROM ... WHERE random()>0; -- eval random() once per row + ** FROM ... WHERE (SELECT random())>0; -- eval random() once overall + */ + for(ii=0; iinTerm; ii++){ + WhereTerm *pT = &sWLB.pWC->a[ii]; + if( pT->prereqAll==0 && (nTabList==0 || exprIsDeterministic(pT->pExpr)) ){ + sqlite3ExprIfFalse(pParse, pT->pExpr, pWInfo->iBreak, SQLITE_JUMPIFNULL); + pT->wtFlags |= TERM_CODED; + } + } + if( wctrlFlags & WHERE_WANT_DISTINCT ){ if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){ /* The DISTINCT marking is pointless. Ignore it. */ diff --git a/test/eqp.test b/test/eqp.test index c955a80c21..30fcdf287f 100644 --- a/test/eqp.test +++ b/test/eqp.test @@ -188,24 +188,24 @@ do_eqp_test 3.1.1 { do_eqp_test 3.1.2 { SELECT * FROM t1 WHERE (SELECT x FROM t1 AS sub); } { - 0 0 0 {SCAN TABLE t1} 0 0 0 {EXECUTE SCALAR SUBQUERY 1} 1 0 0 {SCAN TABLE t1 AS sub} + 0 0 0 {SCAN TABLE t1} } do_eqp_test 3.1.3 { SELECT * FROM t1 WHERE (SELECT x FROM t1 AS sub ORDER BY y); } { - 0 0 0 {SCAN TABLE t1} 0 0 0 {EXECUTE SCALAR SUBQUERY 1} 1 0 0 {SCAN TABLE t1 AS sub} 1 0 0 {USE TEMP B-TREE FOR ORDER BY} + 0 0 0 {SCAN TABLE t1} } do_eqp_test 3.1.4 { SELECT * FROM t1 WHERE (SELECT x FROM t2 ORDER BY x); } { - 0 0 0 {SCAN TABLE t1} 0 0 0 {EXECUTE SCALAR SUBQUERY 1} 1 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1} + 0 0 0 {SCAN TABLE t1} } det 3.2.1 { diff --git a/test/whereF.test b/test/whereF.test index b9580bb196..3b938aa203 100644 --- a/test/whereF.test +++ b/test/whereF.test @@ -119,4 +119,61 @@ do_execsql_test 4.0 { EXPLAIN QUERY PLAN SELECT rowid FROM t4 WHERE a=? AND b=?; } {/a=. AND b=./} +#------------------------------------------------------------------------- +# Test the following case: +# +# ... FROM t1, t2 WHERE ( +# t2.rowid = +t1.rowid OR (t2.f2 = t1.f1 AND t1.f1!=-1) +# ) +# +# where there is an index on t2(f2). The planner should use "t1" as the +# outer loop. The inner loop, on "t2", is an OR optimization. One pass +# for: +# +# t2.rowid = $1 +# +# and another for: +# +# t2.f2=$1 AND $1!=-1 +# +# the test is to ensure that on the second pass, the ($1!=-1) condition +# is tested before any seek operations are performed - i.e. outside of +# the loop through the f2=$1 range of the t2(f2) index. +# +reset_db +do_execsql_test 5.0 { + CREATE TABLE t1(f1); + CREATE TABLE t2(f2); + CREATE INDEX t2f ON t2(f2); + + INSERT INTO t1 VALUES(-1); + INSERT INTO t1 VALUES(-1); + INSERT INTO t1 VALUES(-1); + INSERT INTO t1 VALUES(-1); + + WITH w(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM w WHERE i<1000 + ) + INSERT INTO t2 SELECT -1 FROM w; +} + +do_execsql_test 5.1 { + SELECT count(*) FROM t1, t2 WHERE t2.rowid = +t1.rowid +} {4} +do_test 5.2 { expr [db status vmstep]<200 } 1 + +do_execsql_test 5.3 { + SELECT count(*) FROM t1, t2 WHERE ( + t2.rowid = +t1.rowid OR t2.f2 = t1.f1 + ) +} {4000} +do_test 5.4 { expr [db status vmstep]>1000 } 1 + +do_execsql_test 5.5 { + SELECT count(*) FROM t1, t2 WHERE ( + t2.rowid = +t1.rowid OR (t2.f2 = t1.f1 AND t1.f1!=-1) + ) +} {4} +do_test 5.6 { expr [db status vmstep]<200 } 1 + finish_test From 45e7d7dd1c50a99a1a9b989ece56e4b7533b386e Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 24 Jun 2017 13:31:40 +0000 Subject: [PATCH 23/39] Make sure enough memory is allocated for pathological quoting cases when computing a quoted table name in the command-line shell. FossilOrigin-Name: 0583b84ab444db3ae3c93db619b67bf84b0305ab989200e77214e02ff2dc923a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 04e0a42467..efa1c2f2d7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sgenerating\sindividual\sloops\sfor\seach\sORed\sterm\sof\san\sOR\sscan,\smove\sany\nconstant\sWHERE\sexpressions\soutside\sof\sthe\sloop,\sas\sis\sdone\sfor\stop-level\nloops. -D 2017-06-23T15:47:05.684 +C Make\ssure\senough\smemory\sis\sallocated\sfor\spathological\squoting\scases\swhen\ncomputing\sa\squoted\stable\sname\sin\sthe\scommand-line\sshell. +D 2017-06-24T13:31:40.345 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -406,7 +406,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c adf3ef9843135b1383321ad751f16f5a40c3f37925154555a3e61653d2a954e8 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 35ccfae64cecfa843d54a5898c4ab7d6595ce03d147267fa5eecdc8eab39cd6a -F src/shell.c bcd3358ad6cb3f3dc7ec76ad3bd8191f123ed2425360c5c48fe431780eceb729 +F src/shell.c 2026e88e7892ba177eae79936285d781f1c449f7a7b4e8d86fd02739d4ead26b F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 @@ -1583,7 +1583,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 118f7bb33a6f78951bbffa957f48015d1bce5aaf9246a99262a90bc8ad52e5a3 e4a022be4b069b08cfdfda5295461676b99d28e17bbbedfbcb362dec69de59bd -R b4aae75660dcec44ff13144cfab52224 -U dan -Z 2d5bd4652bc9ff6cf87670159c4dccb2 +P 712267c9c08fdcef5d59cedc672657b55fd6a77472711711599f0bd653e6d880 +R 64992782c16c9df1983fe8b9246941a3 +U drh +Z f16ca2ff8d7abe355c19c0847ea61db0 diff --git a/manifest.uuid b/manifest.uuid index 9d93b6b581..1e0312badb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -712267c9c08fdcef5d59cedc672657b55fd6a77472711711599f0bd653e6d880 \ No newline at end of file +0583b84ab444db3ae3c93db619b67bf84b0305ab989200e77214e02ff2dc923a \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index a6818b8bfd..490c922e60 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2363,7 +2363,7 @@ static void set_table_name(ShellState *p, const char *zName){ if( zName==0 ) return; cQuote = quoteChar(zName); n = strlen30(zName); - if( cQuote ) n += 2; + if( cQuote ) n += n+2; z = p->zDestTable = malloc( n+1 ); if( z==0 ){ raw_printf(stderr,"Error: out of memory\n"); From 54ac445d53512b3215ed41f8594815a46f9005cc Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 24 Jun 2017 16:03:18 +0000 Subject: [PATCH 24/39] Query planner tuning: When deciding between two plans with the same cost, bias the selection toward the one that does not use the sorter. FossilOrigin-Name: f0ec36d479ac4efaa0efd0594d032dd7b8ccdf84a4dc3644cd688762186fbcca --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index efa1c2f2d7..0a810fc0b4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\senough\smemory\sis\sallocated\sfor\spathological\squoting\scases\swhen\ncomputing\sa\squoted\stable\sname\sin\sthe\scommand-line\sshell. -D 2017-06-24T13:31:40.345 +C Query\splanner\stuning:\s\sWhen\sdeciding\sbetween\stwo\splans\swith\sthe\ssame\scost,\nbias\sthe\sselection\stoward\sthe\sone\sthat\sdoes\snot\suse\sthe\ssorter. +D 2017-06-24T16:03:18.634 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -486,7 +486,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 40c543f0a2195d1b0dc88ef12142bea690009344 F src/wal.h 06b2a0b599cc0f53ea97f497cf8c6b758c999f71 F src/walker.c d46044e7a5842560dfe7122d93ff5145dd4a96f4d0bf5ba5910a7731b8c01e79 -F src/where.c d4f329d9055dbdb475d697f205db1104af886aad4400168fb9b957f6251ea926 +F src/where.c 74b0a05487e44e8c5d28ebe3bd77ca9719b1d5114235bed48079aee309a0bb4e F src/whereInt.h 2a4b634d63ce488b46d4b0da8f2eaa8f9aeab202bc25ef76f007de5e3fba1f20 F src/wherecode.c 339ee802d9d311acf0cba8b5a9a092e167ef71c3a777d4b3e57de25d193251c7 F src/whereexpr.c a2fe3811d45af45a5c6667caabc15e01054fe6228c64e86e1f7d2ba5ef5284f9 @@ -1583,7 +1583,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 712267c9c08fdcef5d59cedc672657b55fd6a77472711711599f0bd653e6d880 -R 64992782c16c9df1983fe8b9246941a3 +P 0583b84ab444db3ae3c93db619b67bf84b0305ab989200e77214e02ff2dc923a +R 39ce7bbd8ca958eae50225863d2f437b U drh -Z f16ca2ff8d7abe355c19c0847ea61db0 +Z 7b78ee1e3867abb438b738ced43fb1d9 diff --git a/manifest.uuid b/manifest.uuid index 1e0312badb..991b8f5458 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0583b84ab444db3ae3c93db619b67bf84b0305ab989200e77214e02ff2dc923a \ No newline at end of file +f0ec36d479ac4efaa0efd0594d032dd7b8ccdf84a4dc3644cd688762186fbcca \ No newline at end of file diff --git a/src/where.c b/src/where.c index 1cd5d70330..41bcb30314 100644 --- a/src/where.c +++ b/src/where.c @@ -3972,6 +3972,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ rUnsorted, rCost)); }else{ rCost = rUnsorted; + rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */ } /* Check to see if pWLoop should be added to the set of From 7f2d1cd2b0c2583c5a472982701b66d97c4528d0 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 24 Jun 2017 16:35:00 +0000 Subject: [PATCH 25/39] Make sure the config.h header is included by ctime.c, if that header exists. FossilOrigin-Name: c2ea62937ec8fabec72d3c7cd38d8e2cabbb5ce48638f8ce7ebefd6cd2716fd3 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/ctime.c | 8 ++++++++ src/sqliteInt.h | 3 ++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 0a810fc0b4..3b122ca8bd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Query\splanner\stuning:\s\sWhen\sdeciding\sbetween\stwo\splans\swith\sthe\ssame\scost,\nbias\sthe\sselection\stoward\sthe\sone\sthat\sdoes\snot\suse\sthe\ssorter. -D 2017-06-24T16:03:18.634 +C Make\ssure\sthe\sconfig.h\sheader\sis\sincluded\sby\sctime.c,\sif\sthat\sheader\sexists. +D 2017-06-24T16:35:00.182 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -354,7 +354,7 @@ F src/btreeInt.h a392d353104b4add58b4a59cb185f5d5693dde832c565b77d8d4c343ed98f61 F src/build.c 88a8cdc11d1c081ed565aa3e795bdf9160f4556463b4c4555e9860b59dd80340 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c ca1b2403003ef5d0e331ad2d73ee812ac33b8efc55f8e525ffa8ce5ac1f2c4ea +F src/ctime.c e9a6db1321c2353fe922533f202b85abb3084cdf569450abcabf55e21e104550 F src/date.c cc42a41c7422389860d40419a5e3bce5eaf6e7835c3ba2677751dc653550a5c7 F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c 3213547e97b676c6fa79948b7a9ede4801ea04a01a2043241deafedf132ecf5d @@ -410,7 +410,7 @@ F src/shell.c 2026e88e7892ba177eae79936285d781f1c449f7a7b4e8d86fd02739d4ead26b F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 -F src/sqliteInt.h 17e9bce594ea0c38c44ad0cbff4aa50cbff4b25f4bac9d38306caf9f1f028ac9 +F src/sqliteInt.h 34a54fb47de2da1465f3d3ba1cd373db880bd5d588b0fe862a073ecacd6ddaae F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 @@ -1583,7 +1583,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0583b84ab444db3ae3c93db619b67bf84b0305ab989200e77214e02ff2dc923a -R 39ce7bbd8ca958eae50225863d2f437b +P f0ec36d479ac4efaa0efd0594d032dd7b8ccdf84a4dc3644cd688762186fbcca +R 372aadc61aabb2f352679729d647f91e U drh -Z 7b78ee1e3867abb438b738ced43fb1d9 +Z 70448a4a6b9d4ba9f8d312e19786de1b diff --git a/manifest.uuid b/manifest.uuid index 991b8f5458..7e2f512050 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f0ec36d479ac4efaa0efd0594d032dd7b8ccdf84a4dc3644cd688762186fbcca \ No newline at end of file +c2ea62937ec8fabec72d3c7cd38d8e2cabbb5ce48638f8ce7ebefd6cd2716fd3 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index 5644e5314b..25df46c629 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -16,6 +16,14 @@ #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS +/* +** Include the configuration header output by 'configure' if we're using the +** autoconf-based build +*/ +#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H) +#include "config.h" +#define SQLITECONFIG_H 1 +#endif /* These macros are provided to "stringify" the value of the define ** for those options in which the value is meaningful. */ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 89cb8c33e5..ee83a511f2 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -178,8 +178,9 @@ ** Include the configuration header output by 'configure' if we're using the ** autoconf-based build */ -#ifdef _HAVE_SQLITE_CONFIG_H +#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H) #include "config.h" +#define SQLITECONFIG_H 1 #endif #include "sqliteLimit.h" From a22dd3860a3491d621fec0d0d507c7a0a60d9b6b Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 24 Jun 2017 19:21:48 +0000 Subject: [PATCH 26/39] Disable shell tests for the .schema command if virtual tables are not available. FossilOrigin-Name: c8186874b3fec737445ad5c4ba3eaecd922af664b387d89dc31eea60476a0294 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/shell1.test | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 3b122ca8bd..915d31b911 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthe\sconfig.h\sheader\sis\sincluded\sby\sctime.c,\sif\sthat\sheader\sexists. -D 2017-06-24T16:35:00.182 +C Disable\sshell\stests\sfor\sthe\s.schema\scommand\sif\svirtual\stables\sare\snot\savailable. +D 2017-06-24T19:21:48.519 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -1126,7 +1126,7 @@ F test/sharedA.test 0cdf1a76dfa00e6beee66af5b534b1e8df2720f5 F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e F test/shared_err.test 2f2aee20db294b9924e81f6ccbe60f19e21e8506 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell1.test 50226a3a66bbd42a902e9f7698f768927eb33a56e9cfc55b7c157c38eb3e80ac +F test/shell1.test 65f55c120ab289bc72ec0e534d104e078124d94aeac75dc7444c338c4d84fd0d F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b F test/shell3.test 9b95ba643eaa228376f06a898fb410ee9b6e57c1 F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d @@ -1583,7 +1583,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f0ec36d479ac4efaa0efd0594d032dd7b8ccdf84a4dc3644cd688762186fbcca -R 372aadc61aabb2f352679729d647f91e +P c2ea62937ec8fabec72d3c7cd38d8e2cabbb5ce48638f8ce7ebefd6cd2716fd3 +R 9f5da0e29f079e233ed155fcb887700c U drh -Z 70448a4a6b9d4ba9f8d312e19786de1b +Z e393ac92ea73930e7d0783c651bf561b diff --git a/manifest.uuid b/manifest.uuid index 7e2f512050..0bae5da8dd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c2ea62937ec8fabec72d3c7cd38d8e2cabbb5ce48638f8ce7ebefd6cd2716fd3 \ No newline at end of file +c8186874b3fec737445ad5c4ba3eaecd922af664b387d89dc31eea60476a0294 \ No newline at end of file diff --git a/test/shell1.test b/test/shell1.test index ac3403f810..4a4bbd5cf2 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -558,6 +558,7 @@ do_test shell1-3.20.4 { catchcmd "test.db" ".restore FOO BAR BAD" } {1 {Usage: .restore ?DB? FILE}} +ifcapable vtab { # .schema ?TABLE? Show the CREATE statements # If TABLE specified, only show tables matching # LIKE pattern TABLE. @@ -583,6 +584,7 @@ do_test shell1-3.21.4 { CREATE VIEW v2 AS SELECT x+1 AS y FROM t1; CREATE VIEW v1 AS SELECT y+1 FROM v2;}} db eval {DROP VIEW v1; DROP VIEW v2; DROP TABLE t1;} +} # .separator STRING Change column separator used by output and .import do_test shell1-3.22.1 { From 169dd928c521144e3be5b1fa81aefaa43eb2803f Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 26 Jun 2017 13:57:49 +0000 Subject: [PATCH 27/39] Add the SQLITE_DBCONFIG_ENABLE_QPSG option to activate the query planner stability guarantee. This involves refactoring the sqlite3.flags bitvector to carve out a free bit to use. FossilOrigin-Name: 7076e8283ebae1b45a5d85d9538b49b6da399d38c3c6935de100f948f814f6a9 --- manifest | 39 ++++++++++++++++--------------- manifest.uuid | 2 +- src/btree.c | 10 ++++---- src/main.c | 4 ++++ src/pragma.h | 4 ++-- src/prepare.c | 8 +++---- src/sqlite.h.in | 12 ++++++++++ src/sqliteInt.h | 55 ++++++++++++++++++++++++-------------------- src/test1.c | 1 + src/vdbe.c | 2 +- src/vdbeaux.c | 2 +- src/vdbemem.c | 6 ++--- test/analyze3.test | 30 ++++++++++++++++++++++++ test/like.test | 46 ++++++++++++++++++++++++++++++++++-- tool/mkpragmatab.tcl | 4 ++-- 15 files changed, 160 insertions(+), 65 deletions(-) diff --git a/manifest b/manifest index 915d31b911..dc3b1665b6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sshell\stests\sfor\sthe\s.schema\scommand\sif\svirtual\stables\sare\snot\savailable. -D 2017-06-24T19:21:48.519 +C Add\sthe\sSQLITE_DBCONFIG_ENABLE_QPSG\soption\sto\sactivate\sthe\squery\splanner\nstability\sguarantee.\s\sThis\sinvolves\srefactoring\sthe\ssqlite3.flags\sbitvector\nto\scarve\sout\sa\sfree\sbit\sto\suse. +D 2017-06-26T13:57:49.311 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -348,7 +348,7 @@ F src/auth.c 79f96c6f33bf0e5da8d1c282cee5ebb1852bb8a6ccca3e485d7c459b035d9c3c F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca -F src/btree.c 430e34151e6ef37e42d3f956bb062907c80ff91e1380704b967b8c1a02a98f64 +F src/btree.c 00579ff9c2831d6f98cc993f8f2a34c0ff996e89b3cd2f27928f75796bc3a58a F src/btree.h 3edc5329bc59534d2d15b4f069a9f54b779a7e51289e98fa481ae3c0e526a5ca F src/btreeInt.h a392d353104b4add58b4a59cb185f5d5693dde832c565b77d8d4c343ed98f610 F src/build.c 88a8cdc11d1c081ed565aa3e795bdf9160f4556463b4c4555e9860b59dd80340 @@ -370,7 +370,7 @@ F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 974499a3999d339a4c1ba8ef129a988d9f136b3789e423808b38cdc19d28adbe F src/legacy.c e88ed13c2d531decde75d42c2e35623fb9ce3cb0 F src/loadext.c a72909474dadce771d3669bf84bf689424f6f87d471fee898589c3ef9b2acfd9 -F src/main.c 18f2145d572069dae91161add89446aec680aab296492a92ae5afcc2fc7c6b5a +F src/main.c 747ec45346c3826113bc081cafe1aa2df945e50540c4b3fb13ec02b5e231c3db F src/malloc.c e20bb2b48abec52d3faf01cce12e8b4f95973755fafec98d45162dfdab111978 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de @@ -399,23 +399,23 @@ F src/pcache.c 62835bed959e2914edd26afadfecce29ece0e870 F src/pcache.h 521bb9610d38ef17a3cc9b5ddafd4546c2ea67fa3d0e464823d73c2a28d50e11 F src/pcache1.c 1195a21fe28e223e024f900b2011e80df53793f0356a24caace4188b098540dc F src/pragma.c 2362670a9d28b71708aecb2b9b10b3f7be71f4c950961c07e81dc400e3ce6371 -F src/pragma.h a8a949000214fefb6210330eed8ccbbb4f752619a9871f31b3dedd4a240277fd -F src/prepare.c b1140c3d0cf59bc85ace00ce363153041b424b7a +F src/pragma.h 99d3df4a3d2f12c5227ad403f767334910e6356325b6d155a9a99b4037093460 +F src/prepare.c a80a740b306a5fb2f2594d68776aade4ce1920687932e7c4dc0320ebdadcbb5d F src/printf.c 8757834f1b54dae512fb25eb1acc8e94a0d15dd2290b58f2563f65973265adb2 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c adf3ef9843135b1383321ad751f16f5a40c3f37925154555a3e61653d2a954e8 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 35ccfae64cecfa843d54a5898c4ab7d6595ce03d147267fa5eecdc8eab39cd6a F src/shell.c 2026e88e7892ba177eae79936285d781f1c449f7a7b4e8d86fd02739d4ead26b -F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6 +F src/sqlite.h.in 2555ff1b79a1aadeb4eb761740351dc3027fa08120bf84511633ba75a630e7a8 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 -F src/sqliteInt.h 34a54fb47de2da1465f3d3ba1cd373db880bd5d588b0fe862a073ecacd6ddaae +F src/sqliteInt.h 620093497e54998c6b2a01ad98aed9b561716c3db4bde0cc37c8bf2416200bed F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 F src/tclsqlite.c 1ac29f18b1b3787a30b45dbbdf6fdc4aa4f1a2f8c7c8fe586beba1b177eba97d -F src/test1.c c99f0442918a7a5d5b68a95d6024c211989e6c782c15ced5a558994baaf76a5e +F src/test1.c 735f7711e787f30ad4e0001220c580ce456d9f731e22e0e5f86dd5c7e41ccd4d F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5 F src/test3.c b8434949dfb8aff8dfa082c8b592109e77844c2135ed3c492113839b6956255b F src/test4.c 18ec393bb4d0ad1de729f0b94da7267270f3d8e6 @@ -472,13 +472,13 @@ F src/update.c c443935c652af9365e033f756550b5032d02e1b06eb2cb890ed7511ae0c051dc F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c fc081ec6f63448dcd80d3dfad35baecfa104823254a815b081a4d9fe76e1db23 F src/vacuum.c 874c0f2f15ab2908748297d587d22d485ea96d55aaec91d4775dddb2e24d2ecf -F src/vdbe.c 6783778df820f3e0c68289fe5d12ddd34168b0eb1acf248668fec6e2ea1012d5 +F src/vdbe.c 50f4f47bb190099b61fe87e239de17ad00636a522a271dd9b28329053091401d F src/vdbe.h 70a409d171d4e51b962f0d53abf15c33c404c6aa4c9d62fb3a931b5a62ba9615 F src/vdbeInt.h cdcdabad4f5d6bf7a3beb826a7f33ee6f8f1cb220042bedd5b7d4bf2ea1d179f F src/vdbeapi.c c961d8d9e0f52e2df60a6ddbbccd7d99dc4d00103db7e53f77fcef44fbd23178 -F src/vdbeaux.c bc9b3228f6d99bef0d0ecaf3a0e0e8358b3873242d0d2fe944226de3fdf9521e +F src/vdbeaux.c c03e96a20476f003a26d638da01264abc49288aa3a47d2a62aac16efe4a98ee7 F src/vdbeblob.c 359891617358deefc85bef7bcf787fa6b77facb9 -F src/vdbemem.c 94b17d851f31d4fd075d47d373d4b33ed3962a6ecb82cf385018025751091360 +F src/vdbemem.c dc204ad331409d4b7116d3112b8ff665e6a2927e1ac9e5cdd2c6b27e4ed8093f F src/vdbesort.c f512c68d0bf7e0105316a5594c4329358c8ee9cae3b25138df041d97516c0372 F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834 F src/vtab.c 35b9bdc2b41de32a417141d12097bcc4e29a77ed7cdb8f836d1d2305d946b61b @@ -504,7 +504,7 @@ F test/alter4.test b6d7b86860111864f6cddb54af313f5862dda23b F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f F test/analyze.test 3eb35a4af972f98422e5dc0586501b17d103d321 -F test/analyze3.test 1dccda46a6c374018af617fba00bfe297a61d442 +F test/analyze3.test 8b3ef8ba6d1096b76c40e0925c0fe51e700d2b779cdda40914580de3f9b9d80f F test/analyze4.test eff2df19b8dd84529966420f29ea52edc6b56213 F test/analyze5.test 765c4e284aa69ca172772aa940946f55629bc8c4 F test/analyze6.test f1c552ce39cca4ec922a7e4e0e5d0203d6b3281f @@ -928,7 +928,7 @@ F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff F test/kvtest.c d2b8cfc91047ebf6cac4f3a04f19c3a864e4ecfd683bbb65c395df450b8dc79c F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 -F test/like.test 0603f4fa0dad50987f70032c05800cbfa8985302 +F test/like.test e7b1e724c731a219c4338e37cfe2c5861cd1cd7a856bbdd1d6045ae4f83dc7c7 F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da F test/like3.test 3608a2042b6f922f900fbfd5d3ce4e7eca57f7c4 F test/limit.test 0c99a27a87b14c646a9d583c7c89fd06c352663e @@ -1521,7 +1521,7 @@ F tool/mkmsvcmin.tcl cbd93f1cfa3a0a9ae56fc958510aa3fc3ac65e29cb111716199e3d0e66e F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c F tool/mkopcodeh.tcl a01d2c1d8a6205b03fc635adf3735b4c523befd3 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e -F tool/mkpragmatab.tcl bdd4c76449e9e0874ae7f0846868c42583e63b47a081b177a97f94e2b702b3e7 +F tool/mkpragmatab.tcl aa94395a91b5bd47022b7db0c08126f047887e0d299cc19ec1c23a9e5b136961 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl fef88397668ae83166735c41af99d79f56afaabb F tool/mksqlite3c.tcl 226da6d794d7d43a31e159a6fa89db867bf1f5eafe4b37d031222287ef8dbadc @@ -1583,7 +1583,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c2ea62937ec8fabec72d3c7cd38d8e2cabbb5ce48638f8ce7ebefd6cd2716fd3 -R 9f5da0e29f079e233ed155fcb887700c +P c8186874b3fec737445ad5c4ba3eaecd922af664b387d89dc31eea60476a0294 +R aa6192592198c78cf22d0f0e4a80cfa8 +T *branch * enable-QPSG +T *sym-enable-QPSG * +T -sym-trunk * U drh -Z e393ac92ea73930e7d0783c651bf561b +Z bed31a9a72b1edbf482f280709a5296c diff --git a/manifest.uuid b/manifest.uuid index 0bae5da8dd..7edf40f7c3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c8186874b3fec737445ad5c4ba3eaecd922af664b387d89dc31eea60476a0294 \ No newline at end of file +7076e8283ebae1b45a5d85d9538b49b6da399d38c3c6935de100f948f814f6a9 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 1f06e45031..be6c0dd171 100644 --- a/src/btree.c +++ b/src/btree.c @@ -152,7 +152,7 @@ static int hasSharedCacheTableLock( ** Return true immediately. */ if( (pBtree->sharable==0) - || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommitted)) + || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommit)) ){ return 1; } @@ -229,7 +229,7 @@ static int hasReadConflicts(Btree *pBtree, Pgno iRoot){ for(p=pBtree->pBt->pCursor; p; p=p->pNext){ if( p->pgnoRoot==iRoot && p->pBtree!=pBtree - && 0==(p->pBtree->db->flags & SQLITE_ReadUncommitted) + && 0==(p->pBtree->db->flags & SQLITE_ReadUncommit) ){ return 1; } @@ -251,7 +251,7 @@ static int querySharedCacheTableLock(Btree *p, Pgno iTab, u8 eLock){ assert( sqlite3BtreeHoldsMutex(p) ); assert( eLock==READ_LOCK || eLock==WRITE_LOCK ); assert( p->db!=0 ); - assert( !(p->db->flags&SQLITE_ReadUncommitted)||eLock==WRITE_LOCK||iTab==1 ); + assert( !(p->db->flags&SQLITE_ReadUncommit)||eLock==WRITE_LOCK||iTab==1 ); /* If requesting a write-lock, then the Btree must have an open write ** transaction on this file. And, obviously, for this to be so there @@ -329,7 +329,7 @@ static int setSharedCacheTableLock(Btree *p, Pgno iTable, u8 eLock){ ** obtain a read-lock using this function. The only read-lock obtained ** by a connection in read-uncommitted mode is on the sqlite_master ** table, and that lock is obtained in BtreeBeginTrans(). */ - assert( 0==(p->db->flags&SQLITE_ReadUncommitted) || eLock==WRITE_LOCK ); + assert( 0==(p->db->flags&SQLITE_ReadUncommit) || eLock==WRITE_LOCK ); /* This function should only be called on a sharable b-tree after it ** has been determined that no other b-tree holds a conflicting lock. */ @@ -3021,7 +3021,7 @@ static int lockBtree(BtShared *pBt){ pageSize-usableSize); return rc; } - if( (pBt->db->flags & SQLITE_RecoveryMode)==0 && nPage>nPageFile ){ + if( (pBt->db->flags & SQLITE_WriteSchema)==0 && nPage>nPageFile ){ rc = SQLITE_CORRUPT_BKPT; goto page1_init_failed; } diff --git a/src/main.c b/src/main.c index 6a48f93d17..f119426661 100644 --- a/src/main.c +++ b/src/main.c @@ -811,6 +811,7 @@ int sqlite3_db_config(sqlite3 *db, int op, ...){ { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer }, { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension }, { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose }, + { SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG }, }; unsigned int i; rc = SQLITE_ERROR; /* IMP: R-42790-23372 */ @@ -2915,6 +2916,9 @@ static int openDatabase( #endif #if defined(SQLITE_ENABLE_FTS3_TOKENIZER) | SQLITE_Fts3Tokenizer +#endif +#if defined(SQLITE_ENABLE_QPSG) + | SQLITE_EnableQPSG #endif ; sqlite3HashInit(&db->aCollSeq); diff --git a/src/pragma.h b/src/pragma.h index bf0f648f07..76e59cbc6b 100644 --- a/src/pragma.h +++ b/src/pragma.h @@ -458,7 +458,7 @@ static const PragmaName aPragmaName[] = { /* ePragTyp: */ PragTyp_FLAG, /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1, /* ColNames: */ 0, 0, - /* iArg: */ SQLITE_ReadUncommitted }, + /* iArg: */ SQLITE_ReadUncommit }, {/* zName: */ "recursive_triggers", /* ePragTyp: */ PragTyp_FLAG, /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1, @@ -610,7 +610,7 @@ static const PragmaName aPragmaName[] = { /* ePragTyp: */ PragTyp_FLAG, /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1, /* ColNames: */ 0, 0, - /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode }, + /* iArg: */ SQLITE_WriteSchema }, #endif }; /* Number of pragmas: 60 on by default, 74 total. */ diff --git a/src/prepare.c b/src/prepare.c index 74127bc76b..395b9e4045 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -25,7 +25,7 @@ static void corruptSchema( const char *zExtra /* Error information */ ){ sqlite3 *db = pData->db; - if( !db->mallocFailed && (db->flags & SQLITE_RecoveryMode)==0 ){ + if( !db->mallocFailed && (db->flags & SQLITE_WriteSchema)==0 ){ char *z; if( zObj==0 ) zObj = "?"; z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj); @@ -312,8 +312,8 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ rc = SQLITE_NOMEM_BKPT; sqlite3ResetAllSchemasOfConnection(db); } - if( rc==SQLITE_OK || (db->flags&SQLITE_RecoveryMode)){ - /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider + if( rc==SQLITE_OK || (db->flags&SQLITE_WriteSchema)){ + /* Black magic: If the SQLITE_WriteSchema flag is set, then consider ** the schema loaded, even if errors occurred. In this situation the ** current sqlite3_prepare() operation will fail, but the following one ** will attempt to compile the supplied statement against whatever subset @@ -561,7 +561,7 @@ static int sqlite3Prepare( if( rc ){ const char *zDb = db->aDb[i].zDbSName; sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb); - testcase( db->flags & SQLITE_ReadUncommitted ); + testcase( db->flags & SQLITE_ReadUncommit ); goto end_prepare; } } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 1e4389215d..2f72f83f5d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2007,6 +2007,17 @@ struct sqlite3_mem_methods { ** have been disabled - 0 if they are not disabled, 1 if they are. ** ** +**
SQLITE_DBCONFIG_ENABLE_QPSG
+**
The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates +** the [query planner stability guarantee] (QPSG). When the QPSG is active, +** a single SQL query statement will always use the same algorithm regardless +** of values of [bound parameters]. The QPSG disables some query optimizations +** that look at the values of bound parameters, which can make some queries +** slower. But the QPSG has the advantage of more predictable behavior. With +** the QPSG active, SQLite will always use the same query plan in the field as +** was used during testing in the lab. +**
+** ** */ #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ @@ -2016,6 +2027,7 @@ struct sqlite3_mem_methods { #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */ #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */ +#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */ /* diff --git a/src/sqliteInt.h b/src/sqliteInt.h index ee83a511f2..cc51197d65 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1450,8 +1450,8 @@ struct sqlite3 { ** SQLITE_CkptFullFSync == PAGER_CKPT_FULLFSYNC ** SQLITE_CacheSpill == PAGER_CACHE_SPILL */ -#define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */ -#define SQLITE_InternChanges 0x00000002 /* Uncommitted Hash table changes */ +#define SQLITE_WriteSchema 0x00000001 /* OK to update SQLITE_MASTER */ +#define SQLITE_LegacyFileFmt 0x00000002 /* Create new databases in format 1 */ #define SQLITE_FullColNames 0x00000004 /* Show full column names on SELECT */ #define SQLITE_FullFSync 0x00000008 /* Use full fsync on the backend */ #define SQLITE_CkptFullFSync 0x00000010 /* Use full fsync for checkpoint */ @@ -1462,29 +1462,34 @@ struct sqlite3 { /* the count using a callback. */ #define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */ /* result set is empty */ -#define SQLITE_SqlTrace 0x00000200 /* Debug print SQL as it executes */ -#define SQLITE_VdbeListing 0x00000400 /* Debug listings of VDBE programs */ -#define SQLITE_WriteSchema 0x00000800 /* OK to update SQLITE_MASTER */ -#define SQLITE_VdbeAddopTrace 0x00001000 /* Trace sqlite3VdbeAddOp() calls */ -#define SQLITE_IgnoreChecks 0x00002000 /* Do not enforce check constraints */ -#define SQLITE_ReadUncommitted 0x0004000 /* For shared-cache mode */ -#define SQLITE_LegacyFileFmt 0x00008000 /* Create new databases in format 1 */ -#define SQLITE_RecoveryMode 0x00010000 /* Ignore schema errors */ -#define SQLITE_ReverseOrder 0x00020000 /* Reverse unordered SELECTs */ -#define SQLITE_RecTriggers 0x00040000 /* Enable recursive triggers */ -#define SQLITE_ForeignKeys 0x00080000 /* Enforce foreign key constraints */ -#define SQLITE_AutoIndex 0x00100000 /* Enable automatic indexes */ -#define SQLITE_PreferBuiltin 0x00200000 /* Preference to built-in funcs */ -#define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */ -#define SQLITE_LoadExtFunc 0x00800000 /* Enable load_extension() SQL func */ -#define SQLITE_EnableTrigger 0x01000000 /* True to enable triggers */ -#define SQLITE_DeferFKs 0x02000000 /* Defer all FK constraints */ -#define SQLITE_QueryOnly 0x04000000 /* Disable database changes */ -#define SQLITE_VdbeEQP 0x08000000 /* Debug EXPLAIN QUERY PLAN */ -#define SQLITE_Vacuum 0x10000000 /* Currently in a VACUUM */ -#define SQLITE_CellSizeCk 0x20000000 /* Check btree cell sizes on load */ -#define SQLITE_Fts3Tokenizer 0x40000000 /* Enable fts3_tokenizer(2) */ -#define SQLITE_NoCkptOnClose 0x80000000 /* No checkpoint on close()/DETACH */ +#define SQLITE_IgnoreChecks 0x00000200 /* Do not enforce check constraints */ +#define SQLITE_ReadUncommit 0x00000400 /* READ UNCOMMITTED in shared-cache */ +#define SQLITE_NoCkptOnClose 0x00000800 /* No checkpoint on close()/DETACH */ +#define SQLITE_ReverseOrder 0x00001000 /* Reverse unordered SELECTs */ +#define SQLITE_RecTriggers 0x00002000 /* Enable recursive triggers */ +#define SQLITE_ForeignKeys 0x00004000 /* Enforce foreign key constraints */ +#define SQLITE_AutoIndex 0x00008000 /* Enable automatic indexes */ +#define SQLITE_LoadExtension 0x00010000 /* Enable load_extension */ +#define SQLITE_EnableTrigger 0x00020000 /* True to enable triggers */ +#define SQLITE_DeferFKs 0x00040000 /* Defer all FK constraints */ +#define SQLITE_QueryOnly 0x00080000 /* Disable database changes */ +#define SQLITE_CellSizeCk 0x00100000 /* Check btree cell sizes on load */ +#define SQLITE_Fts3Tokenizer 0x00200000 /* Enable fts3_tokenizer(2) */ +#define SQLITE_EnableQPSG 0x00400000 /* Query Planner Stability Guarantee */ +/* The next four values are not used by PRAGMAs or by sqlite3_dbconfig() and +** could be factored out into a separate bit vector of the sqlite3 object. */ +#define SQLITE_InternChanges 0x00800000 /* Uncommitted Hash table changes */ +#define SQLITE_LoadExtFunc 0x01000000 /* Enable load_extension() SQL func */ +#define SQLITE_PreferBuiltin 0x02000000 /* Preference to built-in funcs */ +#define SQLITE_Vacuum 0x04000000 /* Currently in a VACUUM */ +/* Flags used only if debugging */ +#ifdef SQLITE_DEBUG +#define SQLITE_SqlTrace 0x08000000 /* Debug print SQL as it executes */ +#define SQLITE_VdbeListing 0x10000000 /* Debug listings of VDBE programs */ +#define SQLITE_VdbeTrace 0x20000000 /* True to trace VDBE execution */ +#define SQLITE_VdbeAddopTrace 0x40000000 /* Trace sqlite3VdbeAddOp() calls */ +#define SQLITE_VdbeEQP 0x80000000 /* Debug EXPLAIN QUERY PLAN */ +#endif /* diff --git a/src/test1.c b/src/test1.c index 87b255c9e9..eaafd87755 100644 --- a/src/test1.c +++ b/src/test1.c @@ -7317,6 +7317,7 @@ static int SQLITE_TCLAPI test_sqlite3_db_config( { "FTS3_TOKENIZER", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER }, { "LOAD_EXTENSION", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION }, { "NO_CKPT_ON_CLOSE",SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE }, + { "QPSG", SQLITE_DBCONFIG_ENABLE_QPSG }, }; int i; int v; diff --git a/src/vdbe.c b/src/vdbe.c index 4a412b4e50..ecdd92be9c 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6571,7 +6571,7 @@ case OP_Expire: { */ case OP_TableLock: { u8 isWriteLock = (u8)pOp->p3; - if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommitted) ){ + if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommit) ){ int p1 = pOp->p1; assert( p1>=0 && p1nDb ); assert( DbMaskTest(p->btreeMask, p1) ); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 5dfbe4f5bd..846bf7c8d2 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -4540,7 +4540,7 @@ sqlite3 *sqlite3VdbeDb(Vdbe *v){ */ sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){ assert( iVar>0 ); - if( v ){ + if( v && (v->db->flags & SQLITE_EnableQPSG)==0 ){ Mem *pMem = &v->aVar[iVar-1]; if( 0==(pMem->flags & MEM_Null) ){ sqlite3_value *pRet = sqlite3ValueNew(v->db); diff --git a/src/vdbemem.c b/src/vdbemem.c index 88c57f1aba..dc24f44684 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1493,13 +1493,11 @@ static int stat4ValueFromExpr( Vdbe *v; int iBindVar = pExpr->iColumn; sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar); - if( (v = pParse->pReprepare)!=0 ){ + if( (v = pParse->pReprepare)!=0 && (db->flags & SQLITE_EnableQPSG)==0 ){ pVal = valueNew(db, pAlloc); if( pVal ){ rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]); - if( rc==SQLITE_OK ){ - sqlite3ValueApplyAffinity(pVal, affinity, ENC(db)); - } + sqlite3ValueApplyAffinity(pVal, affinity, ENC(db)); pVal->db = pParse->db; } } diff --git a/test/analyze3.test b/test/analyze3.test index 2fb558d16a..3e721a0877 100644 --- a/test/analyze3.test +++ b/test/analyze3.test @@ -123,6 +123,36 @@ do_eqp_test analyze3-1.1.3 { SELECT sum(y) FROM t1 WHERE x>0 AND x<1100 } {0 0 0 {SCAN TABLE t1}} +# 2017-06-26: Verify that the SQLITE_DBCONFIG_ENABLE_QPSG setting disables +# the use of bound parameters by STAT4 +# +db cache flush +unset -nocomplain l +unset -nocomplain u +do_eqp_test analyze3-1.1.3.100 { + SELECT sum(y) FROM t1 WHERE x>$l AND x<$u +} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x>? AND x$l AND x<$u +} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x>? AND x$l AND x<$u +} {0 0 0 {SCAN TABLE t1}} +db cache flush +sqlite3_db_config db ENABLE_QPSG 1 +do_eqp_test analyze3-1.1.3.103 { + SELECT sum(y) FROM t1 WHERE x>$l AND x<$u +} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x>? AND x$l AND x<$u +} {0 0 0 {SCAN TABLE t1}} + do_test analyze3-1.1.4 { sf_execsql { SELECT sum(y) FROM t1 WHERE x>200 AND x<300 } } {199 0 14850} diff --git a/test/like.test b/test/like.test index 8082b35123..e07b4e0603 100644 --- a/test/like.test +++ b/test/like.test @@ -160,6 +160,7 @@ ifcapable !like_opt { # proc queryplan {sql} { set ::sqlite_sort_count 0 + db cache flush set data [execsql $sql] if {$::sqlite_sort_count} {set x sort} {set x nosort} lappend data $x @@ -196,7 +197,7 @@ do_test like-3.2 { # With an index on t1.x and case sensitivity on, optimize completely. # -do_test like-3.3 { +do_test like-3.3.100 { set sqlite_like_count 0 execsql { PRAGMA case_sensitive_like=on; @@ -206,10 +207,51 @@ do_test like-3.3 { SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1; } } {abc abcd nosort {} i1} -do_test like-3.4 { +do_test like-3.3.101 { set sqlite_like_count } 0 +# The like optimization works even when the pattern is a bound parameter +# +do_test like-3.3.102 { + set sqlite_like_count 0 + unset -nocomplain ::likepat + set ::likepat abc% + queryplan { + SELECT x FROM t1 WHERE x LIKE $::likepat ORDER BY 1; + } +} {abc abcd nosort {} i1} +do_test like-3.3.103 { + set sqlite_like_count +} 0 + +# Except, the like optimization does not work for bound parameters if +# the query planner stability guarantee is active. +# +do_test like-3.3.104 { + set sqlite_like_count 0 + sqlite3_db_config db QPSG 1 + queryplan { + SELECT x FROM t1 WHERE x LIKE $::likepat ORDER BY 1; + } +} {abc abcd nosort {} i1} +do_test like-3.3.105 { + set sqlite_like_count +} 12 + +# The query planner stability guarantee does not disrupt explicit patterns +# +do_test like-3.3.105 { + set sqlite_like_count 0 + queryplan { + SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1; + } +} {abc abcd nosort {} i1} +do_test like-3.3.106 { + set sqlite_like_count +} 0 +sqlite3_db_config db QPSG 0 + # The LIKE optimization still works when the RHS is a string with no # wildcard. Ticket [e090183531fc2747] # diff --git a/tool/mkpragmatab.tcl b/tool/mkpragmatab.tcl index 8eb8250535..c7001dc339 100644 --- a/tool/mkpragmatab.tcl +++ b/tool/mkpragmatab.tcl @@ -120,12 +120,12 @@ set pragma_def { NAME: writable_schema TYPE: FLAG - ARG: SQLITE_WriteSchema|SQLITE_RecoveryMode + ARG: SQLITE_WriteSchema IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) NAME: read_uncommitted TYPE: FLAG - ARG: SQLITE_ReadUncommitted + ARG: SQLITE_ReadUncommit IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS) NAME: recursive_triggers From 7df7475d0d0fcba529640a5b6080fcb9e7e6d0a5 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 26 Jun 2017 14:46:05 +0000 Subject: [PATCH 28/39] Make sure sqlite3VdbeSetVarmask() is never invoked when QPSG is enabled. FossilOrigin-Name: ebcfa73e1c8ebb4fc371a6dcf77f97b6e06e405a299c66182aa4b20423d519ec --- manifest | 19 ++++++++----------- manifest.uuid | 2 +- src/vdbeaux.c | 4 +++- src/vdbemem.c | 7 +++---- src/whereexpr.c | 2 +- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index dc3b1665b6..700203cf04 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_DBCONFIG_ENABLE_QPSG\soption\sto\sactivate\sthe\squery\splanner\nstability\sguarantee.\s\sThis\sinvolves\srefactoring\sthe\ssqlite3.flags\sbitvector\nto\scarve\sout\sa\sfree\sbit\sto\suse. -D 2017-06-26T13:57:49.311 +C Make\ssure\ssqlite3VdbeSetVarmask()\sis\snever\sinvoked\swhen\sQPSG\sis\senabled. +D 2017-06-26T14:46:05.008 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -476,9 +476,9 @@ F src/vdbe.c 50f4f47bb190099b61fe87e239de17ad00636a522a271dd9b28329053091401d F src/vdbe.h 70a409d171d4e51b962f0d53abf15c33c404c6aa4c9d62fb3a931b5a62ba9615 F src/vdbeInt.h cdcdabad4f5d6bf7a3beb826a7f33ee6f8f1cb220042bedd5b7d4bf2ea1d179f F src/vdbeapi.c c961d8d9e0f52e2df60a6ddbbccd7d99dc4d00103db7e53f77fcef44fbd23178 -F src/vdbeaux.c c03e96a20476f003a26d638da01264abc49288aa3a47d2a62aac16efe4a98ee7 +F src/vdbeaux.c d7c7a57f59dc22c05e9a16177615f604fe73588b0ebdc84b540ba5efe3ada430 F src/vdbeblob.c 359891617358deefc85bef7bcf787fa6b77facb9 -F src/vdbemem.c dc204ad331409d4b7116d3112b8ff665e6a2927e1ac9e5cdd2c6b27e4ed8093f +F src/vdbemem.c 8d78df62becfd2dce3c317f64b32a94ecaff8346d814bc8b0b877b38a1ad3718 F src/vdbesort.c f512c68d0bf7e0105316a5594c4329358c8ee9cae3b25138df041d97516c0372 F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834 F src/vtab.c 35b9bdc2b41de32a417141d12097bcc4e29a77ed7cdb8f836d1d2305d946b61b @@ -489,7 +489,7 @@ F src/walker.c d46044e7a5842560dfe7122d93ff5145dd4a96f4d0bf5ba5910a7731b8c01e79 F src/where.c 74b0a05487e44e8c5d28ebe3bd77ca9719b1d5114235bed48079aee309a0bb4e F src/whereInt.h 2a4b634d63ce488b46d4b0da8f2eaa8f9aeab202bc25ef76f007de5e3fba1f20 F src/wherecode.c 339ee802d9d311acf0cba8b5a9a092e167ef71c3a777d4b3e57de25d193251c7 -F src/whereexpr.c a2fe3811d45af45a5c6667caabc15e01054fe6228c64e86e1f7d2ba5ef5284f9 +F src/whereexpr.c 1aac918f82953c9b5c8bee948434cb6476af0262141002f5818842c503f8c95a F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d @@ -1583,10 +1583,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c8186874b3fec737445ad5c4ba3eaecd922af664b387d89dc31eea60476a0294 -R aa6192592198c78cf22d0f0e4a80cfa8 -T *branch * enable-QPSG -T *sym-enable-QPSG * -T -sym-trunk * +P 7076e8283ebae1b45a5d85d9538b49b6da399d38c3c6935de100f948f814f6a9 +R 2588e32e458f4a139c46205abd1223cf U drh -Z bed31a9a72b1edbf482f280709a5296c +Z b64d9ad639f986633210dd4158608eff diff --git a/manifest.uuid b/manifest.uuid index 7edf40f7c3..117824aa68 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7076e8283ebae1b45a5d85d9538b49b6da399d38c3c6935de100f948f814f6a9 \ No newline at end of file +ebcfa73e1c8ebb4fc371a6dcf77f97b6e06e405a299c66182aa4b20423d519ec \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 846bf7c8d2..aabc13275a 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -4540,8 +4540,9 @@ sqlite3 *sqlite3VdbeDb(Vdbe *v){ */ sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){ assert( iVar>0 ); - if( v && (v->db->flags & SQLITE_EnableQPSG)==0 ){ + if( v ){ Mem *pMem = &v->aVar[iVar-1]; + assert( (v->db->flags & SQLITE_EnableQPSG)==0 ); if( 0==(pMem->flags & MEM_Null) ){ sqlite3_value *pRet = sqlite3ValueNew(v->db); if( pRet ){ @@ -4561,6 +4562,7 @@ sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){ */ void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){ assert( iVar>0 ); + assert( (v->db->flags & SQLITE_EnableQPSG)==0 ); if( iVar>=32 ){ v->expmask |= 0x80000000; }else{ diff --git a/src/vdbemem.c b/src/vdbemem.c index dc24f44684..41bb9b5c43 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1482,18 +1482,17 @@ static int stat4ValueFromExpr( /* Skip over any TK_COLLATE nodes */ pExpr = sqlite3ExprSkipCollate(pExpr); + assert( pExpr==0 || pExpr->op!=TK_REGISTER || pExpr->op2!=TK_VARIABLE ); if( !pExpr ){ pVal = valueNew(db, pAlloc); if( pVal ){ sqlite3VdbeMemSetNull((Mem*)pVal); } - }else if( pExpr->op==TK_VARIABLE - || NEVER(pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE) - ){ + }else if( pExpr->op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){ Vdbe *v; int iBindVar = pExpr->iColumn; sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar); - if( (v = pParse->pReprepare)!=0 && (db->flags & SQLITE_EnableQPSG)==0 ){ + if( (v = pParse->pReprepare)!=0 ){ pVal = valueNew(db, pAlloc); if( pVal ){ rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]); diff --git a/src/whereexpr.c b/src/whereexpr.c index 3625efa1e3..7e08f4c1ef 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -216,7 +216,7 @@ static int isLikeOrGlob( pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr); op = pRight->op; - if( op==TK_VARIABLE ){ + if( op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){ Vdbe *pReprepare = pParse->pReprepare; int iCol = pRight->iColumn; pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_BLOB); From d5fbde80a2ecb0ceaadb09804e1e9af2586de9f9 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 26 Jun 2017 18:42:23 +0000 Subject: [PATCH 29/39] The ".import" command of the shell, and the csv virtual table extension both ignore a single UTF-8 BOM at the beginning of their input. FossilOrigin-Name: 7c15d762d99c2e3e534cd35dfe25ddcd317637eb1f2655fd24c2dd5f9d5a7613 --- ext/misc/csv.c | 18 ++++++++++++++++++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/shell.c | 17 +++++++++++++++++ test/shell5.test | 33 ++++++++++++++++++++++++++++++++- 5 files changed, 76 insertions(+), 10 deletions(-) diff --git a/ext/misc/csv.c b/ext/misc/csv.c index f887784ab8..bcafdc5263 100644 --- a/ext/misc/csv.c +++ b/ext/misc/csv.c @@ -77,6 +77,7 @@ struct CsvReader { int n; /* Number of bytes in z */ int nAlloc; /* Space allocated for z[] */ int nLine; /* Current line number */ + int bNotFirst; /* True if prior text has been seen */ char cTerm; /* Character that terminated the most recent field */ size_t iIn; /* Next unread character in the input buffer */ size_t nIn; /* Number of characters in the input buffer */ @@ -91,6 +92,7 @@ static void csv_reader_init(CsvReader *p){ p->n = 0; p->nAlloc = 0; p->nLine = 0; + p->bNotFirst = 0; p->nIn = 0; p->zIn = 0; p->zErr[0] = 0; @@ -251,6 +253,21 @@ static char *csv_read_one_field(CsvReader *p){ pc = c; } }else{ + /* If this is the first field being parsed and it begins with the + ** UTF-8 BOM (0xEF BB BF) then skip the BOM */ + if( (c&0xff)==0xef && p->bNotFirst==0 ){ + csv_append(p, c); + c = csv_getc(p); + if( (c&0xff)==0xbb ){ + csv_append(p, c); + c = csv_getc(p); + if( (c&0xff)==0xbf ){ + p->bNotFirst = 1; + p->n = 0; + return csv_read_one_field(p); + } + } + } while( c>',' || (c!=EOF && c!=',' && c!='\n') ){ if( csv_append(p, (char)c) ) return 0; c = csv_getc(p); @@ -262,6 +279,7 @@ static char *csv_read_one_field(CsvReader *p){ p->cTerm = (char)c; } if( p->z ) p->z[p->n] = 0; + p->bNotFirst = 1; return p->z; } diff --git a/manifest b/manifest index 915d31b911..938584607b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sshell\stests\sfor\sthe\s.schema\scommand\sif\svirtual\stables\sare\snot\savailable. -D 2017-06-24T19:21:48.519 +C The\s".import"\scommand\sof\sthe\sshell,\sand\sthe\scsv\svirtual\stable\sextension\sboth\nignore\sa\ssingle\sUTF-8\sBOM\sat\sthe\sbeginning\sof\stheir\sinput. +D 2017-06-26T18:42:23.729 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -214,7 +214,7 @@ F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a2 F ext/misc/carray.c 40c27641010a4dc67e3690bdb7c9d36ca58b3c2d F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 -F ext/misc/csv.c 531a46cbad789fca0aa9db69a0e6c8ac9e68767d +F ext/misc/csv.c 934ed645372e39e44aa84b1c3dd16ba6838bd18fa09a389965bdfa5a6f984a9f F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f @@ -406,7 +406,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c adf3ef9843135b1383321ad751f16f5a40c3f37925154555a3e61653d2a954e8 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 35ccfae64cecfa843d54a5898c4ab7d6595ce03d147267fa5eecdc8eab39cd6a -F src/shell.c 2026e88e7892ba177eae79936285d781f1c449f7a7b4e8d86fd02739d4ead26b +F src/shell.c 227b86f2bdd707d0a177a4805a5c0b0378ef8337ab1ad04f5d79dc479568735a F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 @@ -1130,7 +1130,7 @@ F test/shell1.test 65f55c120ab289bc72ec0e534d104e078124d94aeac75dc7444c338c4d84f F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b F test/shell3.test 9b95ba643eaa228376f06a898fb410ee9b6e57c1 F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d -F test/shell5.test 50a732c1c2158b1cd62cf53975ce1ea7ce6b9dc9 +F test/shell5.test 0d973866d0df8501486a840f51d1502ab0d9b38ca12c9b242ee26adc788af576 F test/shell6.test ab1592ebe881371f651f18ee6a0df21cbfb5310f88cb832ab642d4038f679772 F test/shell7.test 07751911b294698e0c5df67bcbd29e7d2f0f2907 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 @@ -1583,7 +1583,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c2ea62937ec8fabec72d3c7cd38d8e2cabbb5ce48638f8ce7ebefd6cd2716fd3 -R 9f5da0e29f079e233ed155fcb887700c +P c8186874b3fec737445ad5c4ba3eaecd922af664b387d89dc31eea60476a0294 +R ab3f395a40974200838735f2b7274cd8 U drh -Z e393ac92ea73930e7d0783c651bf561b +Z 910f6f462fbe04fd9eb737726ef5f52f diff --git a/manifest.uuid b/manifest.uuid index 0bae5da8dd..a5e6deba51 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c8186874b3fec737445ad5c4ba3eaecd922af664b387d89dc31eea60476a0294 \ No newline at end of file +7c15d762d99c2e3e534cd35dfe25ddcd317637eb1f2655fd24c2dd5f9d5a7613 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 490c922e60..ec255a6737 100644 --- a/src/shell.c +++ b/src/shell.c @@ -3822,6 +3822,7 @@ struct ImportCtx { int n; /* Number of bytes in z */ int nAlloc; /* Space allocated for z[] */ int nLine; /* Current line number */ + int bNotFirst; /* True if one or more bytes already read */ int cTerm; /* Character that terminated the most recent field */ int cColSep; /* The column separator character. (Usually ",") */ int cRowSep; /* The row separator character. (Usually "\n") */ @@ -3901,6 +3902,21 @@ static char *SQLITE_CDECL csv_read_one_field(ImportCtx *p){ pc = c; } }else{ + /* If this is the first field being parsed and it begins with the + ** UTF-8 BOM (0xEF BB BF) then skip the BOM */ + if( (c&0xff)==0xef && p->bNotFirst==0 ){ + import_append_char(p, c); + c = fgetc(p->in); + if( (c&0xff)==0xbb ){ + import_append_char(p, c); + c = fgetc(p->in); + if( (c&0xff)==0xbf ){ + p->bNotFirst = 1; + p->n = 0; + return csv_read_one_field(p); + } + } + } while( c!=EOF && c!=cSep && c!=rSep ){ import_append_char(p, c); c = fgetc(p->in); @@ -3912,6 +3928,7 @@ static char *SQLITE_CDECL csv_read_one_field(ImportCtx *p){ p->cTerm = c; } if( p->z ) p->z[p->n] = 0; + p->bNotFirst = 1; return p->z; } diff --git a/test/shell5.test b/test/shell5.test index bb2511a525..62b91ffa85 100644 --- a/test/shell5.test +++ b/test/shell5.test @@ -184,6 +184,36 @@ do_test shell5-1.4.10.2 { catchcmd "test.db" {SELECT b FROM t1 WHERE a='7';} } {0 {Now is the time for all good men to come to the aid of their country.}} +# import file with 2 rows, 2 columns and an initial BOM +# +do_test shell5-1.4.11 { + set in [open shell5.csv wb] + puts $in "\xef\xbb\xbf2|3" + puts $in "4|5" + close $in + set res [catchcmd "test.db" {CREATE TABLE t2(x INT, y INT); +.import shell5.csv t2 +.mode quote +.header on +SELECT * FROM t2;}] + string map {\n | \n\r |} $res +} {0 {'x','y'|2,3|4,5}} + +# import file with 2 rows, 2 columns or text with an initial BOM +# +do_test shell5-1.4.12 { + set in [open shell5.csv wb] + puts $in "\xef\xbb\xbf\"two\"|3" + puts $in "4|5" + close $in + set res [catchcmd "test.db" {DELETE FROM t2; +.import shell5.csv t2 +.mode quote +.header on +SELECT * FROM t2;}] + string map {\n | \n\r |} $res +} {0 {'x','y'|'two',3|4,5}} + # check importing very long field do_test shell5-1.5.1 { set str [string repeat X 999] @@ -210,7 +240,8 @@ do_test shell5-1.6.1 { set in [open shell5.csv w] puts $in $data close $in - set res [catchcmd "test.db" {.import shell5.csv t2 + set res [catchcmd "test.db" {DROP TABLE IF EXISTS t2; +.import shell5.csv t2 SELECT COUNT(*) FROM t2;}] } {0 1} From af38cdbc081576d290326631b2118670dcf35579 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 26 Jun 2017 21:08:32 +0000 Subject: [PATCH 30/39] Add the -withoutnulls option to the "db eval" method in the TCL interface. FossilOrigin-Name: 18f0616e15684ca327fb10a1d133331af1d3b75f609498982290f6ad69fcaced --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/tclsqlite.c | 43 +++++++++++++++++++++++++++++++++---------- test/tclsqlite.test | 40 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 80 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 938584607b..2b9d9ecf03 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\s".import"\scommand\sof\sthe\sshell,\sand\sthe\scsv\svirtual\stable\sextension\sboth\nignore\sa\ssingle\sUTF-8\sBOM\sat\sthe\sbeginning\sof\stheir\sinput. -D 2017-06-26T18:42:23.729 +C Add\sthe\s-withoutnulls\soption\sto\sthe\s"db\seval"\smethod\sin\sthe\sTCL\sinterface. +D 2017-06-26T21:08:32.812 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -414,7 +414,7 @@ F src/sqliteInt.h 34a54fb47de2da1465f3d3ba1cd373db880bd5d588b0fe862a073ecacd6dda F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 -F src/tclsqlite.c 1ac29f18b1b3787a30b45dbbdf6fdc4aa4f1a2f8c7c8fe586beba1b177eba97d +F src/tclsqlite.c cbf6313f86400acdf7dbf55fcd218cd28d43110a1210967efbc4f250646f81c0 F src/test1.c c99f0442918a7a5d5b68a95d6024c211989e6c782c15ced5a558994baaf76a5e F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5 F src/test3.c b8434949dfb8aff8dfa082c8b592109e77844c2135ed3c492113839b6956255b @@ -1187,7 +1187,7 @@ F test/tabfunc01.test 699251cb99651415218a891384510a685c7ab012 F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 -F test/tclsqlite.test 1d73b9203b1ca8798d7d7310742b8d3febc0d56e +F test/tclsqlite.test c3d7ac9449634b9f17fd048a3c0212e88a7448be810a9c5bd051acc1ffa00d2f F test/tempdb.test bd92eba8f20e16a9136e434e20b280794de3cdb6 F test/tempdb2.test 27e41ed540b2f9b056c2e77e9bddc1b875358507 F test/tempfault.test 0c0d349c9a99bf5f374655742577f8712c647900 @@ -1583,7 +1583,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c8186874b3fec737445ad5c4ba3eaecd922af664b387d89dc31eea60476a0294 -R ab3f395a40974200838735f2b7274cd8 +P 7c15d762d99c2e3e534cd35dfe25ddcd317637eb1f2655fd24c2dd5f9d5a7613 +R 444ece00921d566093c338ff4adc8e5d U drh -Z 910f6f462fbe04fd9eb737726ef5f52f +Z eb4d6ea47810159e5e12ebef5223a855 diff --git a/manifest.uuid b/manifest.uuid index a5e6deba51..425a3c3216 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c15d762d99c2e3e534cd35dfe25ddcd317637eb1f2655fd24c2dd5f9d5a7613 \ No newline at end of file +18f0616e15684ca327fb10a1d133331af1d3b75f609498982290f6ad69fcaced \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index bb7c9e5b82..2ef9296096 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -1451,10 +1451,13 @@ struct DbEvalContext { const char *zSql; /* Remaining SQL to execute */ SqlPreparedStmt *pPreStmt; /* Current statement */ int nCol; /* Number of columns returned by pStmt */ + int evalFlags; /* Flags used */ Tcl_Obj *pArray; /* Name of array variable */ Tcl_Obj **apColName; /* Array of column names */ }; +#define SQLITE_EVAL_WITHOUTNULLS 0x00001 /* Unset array(*) for NULL */ + /* ** Release any cache of column names currently held as part of ** the DbEvalContext structure passed as the first argument. @@ -1487,7 +1490,8 @@ static void dbEvalInit( DbEvalContext *p, /* Pointer to structure to initialize */ SqliteDb *pDb, /* Database handle */ Tcl_Obj *pSql, /* Object containing SQL script */ - Tcl_Obj *pArray /* Name of Tcl array to set (*) element of */ + Tcl_Obj *pArray, /* Name of Tcl array to set (*) element of */ + int evalFlags /* Flags controlling evaluation */ ){ memset(p, 0, sizeof(DbEvalContext)); p->pDb = pDb; @@ -1498,6 +1502,7 @@ static void dbEvalInit( p->pArray = pArray; Tcl_IncrRefCount(pArray); } + p->evalFlags = evalFlags; } /* @@ -1730,11 +1735,15 @@ static int SQLITE_TCLAPI DbEvalNextCmd( Tcl_Obj **apColName; dbEvalRowInfo(p, &nCol, &apColName); for(i=0; ievalFlags & SQLITE_EVAL_WITHOUTNULLS)!=0 + && sqlite3_column_type(p->pPreStmt->pStmt, i)==SQLITE_NULL + ){ + Tcl_UnsetVar2(interp, Tcl_GetString(pArray), + Tcl_GetString(apColName[i]), 0); }else{ - Tcl_ObjSetVar2(interp, pArray, apColName[i], pVal, 0); + Tcl_ObjSetVar2(interp, pArray, apColName[i], dbEvalColumnValue(p,i), 0); } } @@ -2447,7 +2456,7 @@ static int SQLITE_TCLAPI DbObjCmd( return TCL_ERROR; } - dbEvalInit(&sEval, pDb, objv[2], 0); + dbEvalInit(&sEval, pDb, objv[2], 0, 0); rc = dbEvalStep(&sEval); if( choice==DB_ONECOLUMN ){ if( rc==TCL_OK ){ @@ -2468,7 +2477,7 @@ static int SQLITE_TCLAPI DbObjCmd( } /* - ** $db eval $sql ?array? ?{ ...code... }? + ** $db eval ?options? $sql ?array? ?{ ...code... }? ** ** The SQL statement in $sql is evaluated. For each row, the values are ** placed in elements of the array named "array" and ...code... is executed. @@ -2477,8 +2486,22 @@ static int SQLITE_TCLAPI DbObjCmd( ** that have the same name as the fields extracted by the query. */ case DB_EVAL: { + int evalFlags = 0; + const char *zOpt; + while( objc>3 && (zOpt = Tcl_GetString(objv[2]))!=0 && zOpt[0]=='-' ){ + if( strcmp(zOpt, "-withoutnulls")==0 ){ + evalFlags |= SQLITE_EVAL_WITHOUTNULLS; + } + else{ + Tcl_AppendResult(interp, "unknown option: \"", zOpt, "\"", (void*)0); + return TCL_ERROR; + } + objc--; + objv++; + } if( objc<3 || objc>5 ){ - Tcl_WrongNumArgs(interp, 2, objv, "SQL ?ARRAY-NAME? ?SCRIPT?"); + Tcl_WrongNumArgs(interp, 2, objv, + "?OPTIONS? SQL ?ARRAY-NAME? ?SCRIPT?"); return TCL_ERROR; } @@ -2486,7 +2509,7 @@ static int SQLITE_TCLAPI DbObjCmd( DbEvalContext sEval; Tcl_Obj *pRet = Tcl_NewObj(); Tcl_IncrRefCount(pRet); - dbEvalInit(&sEval, pDb, objv[2], 0); + dbEvalInit(&sEval, pDb, objv[2], 0, 0); while( TCL_OK==(rc = dbEvalStep(&sEval)) ){ int i; int nCol; @@ -2507,14 +2530,14 @@ static int SQLITE_TCLAPI DbObjCmd( Tcl_Obj *pArray = 0; Tcl_Obj *pScript; - if( objc==5 && *(char *)Tcl_GetString(objv[3]) ){ + if( objc>=5 && *(char *)Tcl_GetString(objv[3]) ){ pArray = objv[3]; } pScript = objv[objc-1]; Tcl_IncrRefCount(pScript); p = (DbEvalContext *)Tcl_Alloc(sizeof(DbEvalContext)); - dbEvalInit(p, pDb, objv[2], pArray); + dbEvalInit(p, pDb, objv[2], pArray, evalFlags); cd2[0] = (void *)p; cd2[1] = (void *)pScript; diff --git a/test/tclsqlite.test b/test/tclsqlite.test index bdb0fc56d1..1b95a45a5c 100644 --- a/test/tclsqlite.test +++ b/test/tclsqlite.test @@ -113,7 +113,7 @@ ifcapable {complete} { do_test tcl-1.14 { set v [catch {db eval} msg] lappend v $msg -} {1 {wrong # args: should be "db eval SQL ?ARRAY-NAME? ?SCRIPT?"}} +} {1 {wrong # args: should be "db eval ?OPTIONS? SQL ?ARRAY-NAME? ?SCRIPT?"}} do_test tcl-1.15 { set v [catch {db function} msg] lappend v $msg @@ -665,6 +665,44 @@ do_test tcl-15.5 { } {0} +# 2017-06-26: The --withoutnulls flag to "db eval". +# +# In the "db eval --withoutnulls SQL ARRAY" form, NULL results cause the +# corresponding array entry to be unset. The default behavior (without +# the -withoutnulls flags) is for the corresponding array value to get +# the [db nullvalue] string. +# +catch {db close} +forcedelete test.db +sqlite3 db test.db +do_execsql_test tcl-16.100 { + CREATE TABLE t1(a,b); + INSERT INTO t1 VALUES(1,2),(2,NULL),(3,'xyz'); +} +do_test tcl-16.101 { + set res {} + unset -nocomplain x + db eval {SELECT * FROM t1} x { + lappend res $x(a) [array names x] + } + set res +} {1 {a b *} 2 {a b *} 3 {a b *}} +do_test tcl-16.102 { + set res [catch { + db eval -unknown {SELECT * FROM t1} x { + lappend res $x(a) [array names x] + } + } rc] + lappend res $rc +} {1 {unknown option: "-unknown"}} +do_test tcl-16.103 { + set res {} + unset -nocomplain x + db eval -withoutnulls {SELECT * FROM t1} x { + lappend res $x(a) [array names x] + } + set res +} {1 {a b *} 2 {a *} 3 {a b *}} From 210ec4c855c37eac5e79922aedf47c3f574dcf4e Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 27 Jun 2017 16:39:01 +0000 Subject: [PATCH 31/39] Fix a virtual table problem that can occur when the vtab is on the RHS of a LEFT JOIN and there is a MATCH constraint in the ON clause, or when the vtab is in a sub-query that is the RHS of a LEFT JOIN and there is a MATCH constraint in the WHERE clause of the sub-query. FossilOrigin-Name: 87b381663398f029f52cb5598aadd069b03034b6f833ce80ba762b406075a44e --- ext/fts5/test/fts5leftjoin.test | 45 +++++++++++++++++++++++++++++++++ manifest | 17 +++++++------ manifest.uuid | 2 +- src/whereexpr.c | 3 +++ test/fts3join.test | 20 +++++++++++++++ 5 files changed, 78 insertions(+), 9 deletions(-) create mode 100644 ext/fts5/test/fts5leftjoin.test diff --git a/ext/fts5/test/fts5leftjoin.test b/ext/fts5/test/fts5leftjoin.test new file mode 100644 index 0000000000..f13ca5206b --- /dev/null +++ b/ext/fts5/test/fts5leftjoin.test @@ -0,0 +1,45 @@ +# 2014 June 17 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# This file implements regression tests for SQLite library. The +# focus of this script is testing the FTS5 module. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5leftjoin + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE vt USING fts5(x); + INSERT INTO vt VALUES('abc'); + INSERT INTO vt VALUES('xyz'); + + CREATE TABLE t1(a INTEGER PRIMARY KEY); + INSERT INTO t1 VALUES(1), (2); +} + +do_execsql_test 1.1 { + SELECT * FROM t1 LEFT JOIN ( + SELECT rowid AS rrr, * FROM vt WHERE vt MATCH 'abc' + ) ON t1.a = rrr +} {1 1 abc 2 {} {}} + +do_execsql_test 1.2 { + SELECT * FROM t1 LEFT JOIN vt ON (vt MATCH 'abc') +} {1 abc 2 abc} + +finish_test + + diff --git a/manifest b/manifest index 2b9d9ecf03..6530946321 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s-withoutnulls\soption\sto\sthe\s"db\seval"\smethod\sin\sthe\sTCL\sinterface. -D 2017-06-26T21:08:32.812 +C Fix\sa\svirtual\stable\sproblem\sthat\scan\soccur\swhen\sthe\svtab\sis\son\sthe\sRHS\sof\sa\nLEFT\sJOIN\sand\sthere\sis\sa\sMATCH\sconstraint\sin\sthe\sON\sclause,\sor\swhen\sthe\svtab\nis\sin\sa\ssub-query\sthat\sis\sthe\sRHS\sof\sa\sLEFT\sJOIN\sand\sthere\sis\sa\sMATCH\nconstraint\sin\sthe\sWHERE\sclause\sof\sthe\ssub-query. +D 2017-06-27T16:39:01.302 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -168,6 +168,7 @@ F ext/fts5/test/fts5fuzz1.test bece4695fc169b61ab236ada7931c6e4942cbef9 F ext/fts5/test/fts5hash.test 06f9309ccb4d5050a131594e9e47d0b21456837d F ext/fts5/test/fts5integrity.test f5e4f8d284385875068ad0f3e894ce43e9de835d F ext/fts5/test/fts5lastrowid.test 4fac1aba696dd6c956e03b0cf91f6f1f3aaec494 +F ext/fts5/test/fts5leftjoin.test 513ad7a7c053f8a6b7968ed6c84d1fc8c7a84fd29cfde0d14cc085ae6ca682c6 F ext/fts5/test/fts5matchinfo.test f7dde99697bcb310ea8faa8eb2714d9f4dfc0e1b F ext/fts5/test/fts5merge.test 9f65f090d214ff865c56bef4f864aaa1182af6e3 F ext/fts5/test/fts5merge2.test a6da3c16d694235938d1939f503cfa53f0943d75 @@ -489,7 +490,7 @@ F src/walker.c d46044e7a5842560dfe7122d93ff5145dd4a96f4d0bf5ba5910a7731b8c01e79 F src/where.c 74b0a05487e44e8c5d28ebe3bd77ca9719b1d5114235bed48079aee309a0bb4e F src/whereInt.h 2a4b634d63ce488b46d4b0da8f2eaa8f9aeab202bc25ef76f007de5e3fba1f20 F src/wherecode.c 339ee802d9d311acf0cba8b5a9a092e167ef71c3a777d4b3e57de25d193251c7 -F src/whereexpr.c a2fe3811d45af45a5c6667caabc15e01054fe6228c64e86e1f7d2ba5ef5284f9 +F src/whereexpr.c 837c4a74cd023553b914e244c361a92c868a8b848783f4ff2387ccd61b6ccbc9 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d @@ -797,7 +798,7 @@ F test/fts3expr5.test f9abfffbf5e53d48a33e12a1e8f8ba2c551c9b49 F test/fts3fault.test 3764ecffb3d341c5b05b3abe64153f385880035e67706ca2fc719e5d3352aedb F test/fts3fault2.test 536bbe01fe2946ec24b063a5eee813e8fd90354a6ca0b8f941d299c405edd17e F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641 -F test/fts3join.test 34750f3ce1e29b2749eaf0f1be2fa6301c5d50da +F test/fts3join.test a758accc808cebaef8d622aac07994a2eae15c40eebc40888dcbbabc6f6bafb6 F test/fts3malloc.test b0e4c133b8d61d4f6d112d8110f8320e9e453ef6 F test/fts3matchinfo.test ce864e0bd92429df8008f31cf557269ba172482a F test/fts3misc.test 66e7b59576ce2c795f0baff6d47f7f6f57e6f41101cf85fad05989e43bb060dd @@ -1583,7 +1584,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7c15d762d99c2e3e534cd35dfe25ddcd317637eb1f2655fd24c2dd5f9d5a7613 -R 444ece00921d566093c338ff4adc8e5d -U drh -Z eb4d6ea47810159e5e12ebef5223a855 +P 18f0616e15684ca327fb10a1d133331af1d3b75f609498982290f6ad69fcaced +R 956ace4d151b9d18ca3bfa0998026b83 +U dan +Z 227909c502fe08051a0386f1253486e4 diff --git a/manifest.uuid b/manifest.uuid index 425a3c3216..fd2ba71cb2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -18f0616e15684ca327fb10a1d133331af1d3b75f609498982290f6ad69fcaced \ No newline at end of file +87b381663398f029f52cb5598aadd069b03034b6f833ce80ba762b406075a44e \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index 3625efa1e3..78e9c3ce4d 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -1178,6 +1178,9 @@ static void exprAnalyze( Expr *pNewExpr; pNewExpr = sqlite3PExpr(pParse, TK_MATCH, 0, sqlite3ExprDup(db, pRight, 0)); + if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){ + ExprSetProperty(pNewExpr, EP_FromJoin); + } idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC); testcase( idxNew==0 ); pNewTerm = &pWC->a[idxNew]; diff --git a/test/fts3join.test b/test/fts3join.test index 0fb8c62022..6bebd33d6a 100644 --- a/test/fts3join.test +++ b/test/fts3join.test @@ -61,4 +61,24 @@ do_catchsql_test 2.5 { SELECT * FROM ft3, ft2 WHERE y MATCH x AND x MATCH y; } {1 {unable to use function MATCH in the requested context}} +do_execsql_test 3.0 { + CREATE VIRTUAL TABLE vt USING fts3(x); + INSERT INTO vt VALUES('abc'); + INSERT INTO vt VALUES('xyz'); + + CREATE TABLE tt(a INTEGER PRIMARY KEY); + INSERT INTO tt VALUES(1), (2); +} + +do_execsql_test 3.1 { + SELECT * FROM tt LEFT JOIN ( + SELECT rowid AS rrr, * FROM vt WHERE vt MATCH 'abc' + ) ON tt.a = rrr +} {1 1 abc 2 {} {}} + +do_execsql_test 3.2 { + SELECT * FROM tt LEFT JOIN vt ON (vt MATCH 'abc') +} {1 abc 2 abc} + + finish_test From 3144df1264fb20a338ac13ef2d7070e0aff27e0f Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 28 Jun 2017 00:55:50 +0000 Subject: [PATCH 32/39] Avoid an unnecessary call to sqlite3XPrintf() in the code generator, for a performance improvement. FossilOrigin-Name: 29d6ceb3838394d902e248d1eab627625a857dccb5ed0bb66161a13fafc500c8 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/build.c | 4 +++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index f773d74cae..abc75e2692 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sSQLITE_DBCONFIG_ENABLE_QPSG\sthat\sforces\sthe\squery\splanner\sstability\nguarantee.\s\sThis\sis\sthe\sfix\sfor\sticket\s[b9f010107724c] -D 2017-06-27T23:36:44.838 +C Avoid\san\sunnecessary\scall\sto\ssqlite3XPrintf()\sin\sthe\scode\sgenerator,\sfor\na\sperformance\simprovement. +D 2017-06-28T00:55:50.411 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -352,7 +352,7 @@ F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca F src/btree.c 00579ff9c2831d6f98cc993f8f2a34c0ff996e89b3cd2f27928f75796bc3a58a F src/btree.h 3edc5329bc59534d2d15b4f069a9f54b779a7e51289e98fa481ae3c0e526a5ca F src/btreeInt.h a392d353104b4add58b4a59cb185f5d5693dde832c565b77d8d4c343ed98f610 -F src/build.c 88a8cdc11d1c081ed565aa3e795bdf9160f4556463b4c4555e9860b59dd80340 +F src/build.c b24e0889ba18ba0e93e03e2ef5c9f1a2ca043d77c5abbd3d333858a76b795da3 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c e9a6db1321c2353fe922533f202b85abb3084cdf569450abcabf55e21e104550 @@ -1584,8 +1584,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 87b381663398f029f52cb5598aadd069b03034b6f833ce80ba762b406075a44e ebcfa73e1c8ebb4fc371a6dcf77f97b6e06e405a299c66182aa4b20423d519ec -R bb6b907fdeee773111627b13bd53e940 -T +closed ebcfa73e1c8ebb4fc371a6dcf77f97b6e06e405a299c66182aa4b20423d519ec +P b82efd2a24914ace39acf99df75175042471fd73a8d31d66a40b15f63b342e10 +R 4655eadf37f65568436ba7b7c7775799 U drh -Z cfbd76746fc81ebc7a88eb549c6e1ee7 +Z 5d13438a82c29fffa946890a824367ff diff --git a/manifest.uuid b/manifest.uuid index 543f6e9587..c91cd5f1da 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b82efd2a24914ace39acf99df75175042471fd73a8d31d66a40b15f63b342e10 \ No newline at end of file +29d6ceb3838394d902e248d1eab627625a857dccb5ed0bb66161a13fafc500c8 \ No newline at end of file diff --git a/src/build.c b/src/build.c index c4bb0300a5..8a0624ea12 100644 --- a/src/build.c +++ b/src/build.c @@ -4185,7 +4185,9 @@ void sqlite3UniqueConstraint( assert( pIdx->aiColumn[j]>=0 ); zCol = pTab->aCol[pIdx->aiColumn[j]].zName; if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2); - sqlite3XPrintf(&errMsg, "%s.%s", pTab->zName, zCol); + sqlite3StrAccumAppendAll(&errMsg, pTab->zName); + sqlite3StrAccumAppend(&errMsg, ".", 1); + sqlite3StrAccumAppendAll(&errMsg, zCol); } } zErr = sqlite3StrAccumFinish(&errMsg); From 59a386ea03237500977d7082f92e3d45932b0fed Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 28 Jun 2017 01:12:53 +0000 Subject: [PATCH 33/39] Minor code simplification in the ALTER TABLE logic. FossilOrigin-Name: bfc4e7f30e4654b9603457fb6a4136828e346dcfe4e313fdf56ed62d131b7156 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/alter.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index abc75e2692..ed7df8dfc0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\san\sunnecessary\scall\sto\ssqlite3XPrintf()\sin\sthe\scode\sgenerator,\sfor\na\sperformance\simprovement. -D 2017-06-28T00:55:50.411 +C Minor\scode\ssimplification\sin\sthe\sALTER\sTABLE\slogic. +D 2017-06-28T01:12:53.264 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -342,7 +342,7 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a -F src/alter.c 3b23977620ce9662ac54443f65b87ba996e36121 +F src/alter.c 850ede4e607f12fa25ea4f3cb6ece2b2e29d1aa50e3f786ce49d615788849552 F src/analyze.c 0d0ccf7520a201d8747ea2f02c92c26e26f801bc161f714f27b9f7630dde0421 F src/attach.c 3bd555e28382603e80d430dfebb2270f86e1e375b4c4be3e1ab1aec3a0c44943 F src/auth.c 79f96c6f33bf0e5da8d1c282cee5ebb1852bb8a6ccca3e485d7c459b035d9c3c @@ -1584,7 +1584,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b82efd2a24914ace39acf99df75175042471fd73a8d31d66a40b15f63b342e10 -R 4655eadf37f65568436ba7b7c7775799 +P 29d6ceb3838394d902e248d1eab627625a857dccb5ed0bb66161a13fafc500c8 +R 6f0ea308ec1b73dd6e7772ec710252e2 U drh -Z 5d13438a82c29fffa946890a824367ff +Z 9c7b9d5e2b38deb9e56f410615351475 diff --git a/manifest.uuid b/manifest.uuid index c91cd5f1da..61af47f55a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -29d6ceb3838394d902e248d1eab627625a857dccb5ed0bb66161a13fafc500c8 \ No newline at end of file +bfc4e7f30e4654b9603457fb6a4136828e346dcfe4e313fdf56ed62d131b7156 \ No newline at end of file diff --git a/src/alter.c b/src/alter.c index 067cbb896d..8df06f0640 100644 --- a/src/alter.c +++ b/src/alter.c @@ -375,7 +375,7 @@ static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){ ** Or, if zName is not a system table, zero is returned. */ static int isSystemTable(Parse *pParse, const char *zName){ - if( sqlite3Strlen30(zName)>6 && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){ + if( 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){ sqlite3ErrorMsg(pParse, "table %s may not be altered", zName); return 1; } From 6e11b162825de78423834ee2c5ba94ebac544b8d Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 28 Jun 2017 01:21:16 +0000 Subject: [PATCH 34/39] Simplify error handling logic in sqlite3_exec() to save about 40 bytes. FossilOrigin-Name: 6480916c7266437cf8a70e5db2ca5c753ad71c361b68e41cbf8572f77c271920 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/legacy.c | 7 ++----- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index ed7df8dfc0..f56deb4aff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\scode\ssimplification\sin\sthe\sALTER\sTABLE\slogic. -D 2017-06-28T01:12:53.264 +C Simplify\serror\shandling\slogic\sin\ssqlite3_exec()\sto\ssave\sabout\s40\sbytes. +D 2017-06-28T01:21:16.224 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -369,7 +369,7 @@ F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 974499a3999d339a4c1ba8ef129a988d9f136b3789e423808b38cdc19d28adbe -F src/legacy.c e88ed13c2d531decde75d42c2e35623fb9ce3cb0 +F src/legacy.c 134ab3e3fae00a0f67a5187981d6935b24b337bcf0f4b3e5c9fa5763da95bf4e F src/loadext.c a72909474dadce771d3669bf84bf689424f6f87d471fee898589c3ef9b2acfd9 F src/main.c 747ec45346c3826113bc081cafe1aa2df945e50540c4b3fb13ec02b5e231c3db F src/malloc.c e20bb2b48abec52d3faf01cce12e8b4f95973755fafec98d45162dfdab111978 @@ -1584,7 +1584,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 29d6ceb3838394d902e248d1eab627625a857dccb5ed0bb66161a13fafc500c8 -R 6f0ea308ec1b73dd6e7772ec710252e2 +P bfc4e7f30e4654b9603457fb6a4136828e346dcfe4e313fdf56ed62d131b7156 +R 9ee65c1aa637763c0020e3a8027e1724 U drh -Z 9c7b9d5e2b38deb9e56f410615351475 +Z 46819a22d665678fea30894f28c71769 diff --git a/manifest.uuid b/manifest.uuid index 61af47f55a..61d9917324 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bfc4e7f30e4654b9603457fb6a4136828e346dcfe4e313fdf56ed62d131b7156 \ No newline at end of file +6480916c7266437cf8a70e5db2ca5c753ad71c361b68e41cbf8572f77c271920 \ No newline at end of file diff --git a/src/legacy.c b/src/legacy.c index df8e2780fb..40959a8544 100644 --- a/src/legacy.c +++ b/src/legacy.c @@ -127,11 +127,8 @@ exec_out: rc = sqlite3ApiExit(db, rc); if( rc!=SQLITE_OK && pzErrMsg ){ - int nErrMsg = 1 + sqlite3Strlen30(sqlite3_errmsg(db)); - *pzErrMsg = sqlite3Malloc(nErrMsg); - if( *pzErrMsg ){ - memcpy(*pzErrMsg, sqlite3_errmsg(db), nErrMsg); - }else{ + *pzErrMsg = sqlite3DbStrDup(0, sqlite3_errmsg(db)); + if( *pzErrMsg==0 ){ rc = SQLITE_NOMEM_BKPT; sqlite3Error(db, SQLITE_NOMEM); } From bd8fcc130afb9873eec8d762a41fac6d83f5158b Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 28 Jun 2017 11:56:18 +0000 Subject: [PATCH 35/39] In the lemon-generated parser, automatically promote SHIFTREDUCE actions on nonterminal systems to pure REDUCE actions, for a performance enhancement. FossilOrigin-Name: c46d94a8cde816ca383e771721ebd4900de77950cba700e35a26f70fd5b794a4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/lemon.c | 9 ++++++++- tool/lempar.c | 20 ++++++++++++-------- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index f56deb4aff..8586f644db 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplify\serror\shandling\slogic\sin\ssqlite3_exec()\sto\ssave\sabout\s40\sbytes. -D 2017-06-28T01:21:16.224 +C In\sthe\slemon-generated\sparser,\sautomatically\spromote\sSHIFTREDUCE\sactions\son\nnonterminal\ssystems\sto\spure\sREDUCE\sactions,\sfor\sa\sperformance\senhancement. +D 2017-06-28T11:56:18.525 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -1509,8 +1509,8 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f -F tool/lemon.c f4f1045743e12f86b132253a3192ef92c94bfceb7f41ac41b8e3b373aa78474e -F tool/lempar.c db1bdb4821f2d8fbd76e577cf3ab18642c8d08d1 +F tool/lemon.c 8f18c158ff3fb92e844d389a8f8802ef47d3065746139b9f065a34f8e3acba82 +F tool/lempar.c 12d9fc3b7fd504a413d578f8542a84227dd560c29dc2e829d01a333e09df035c F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1584,7 +1584,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bfc4e7f30e4654b9603457fb6a4136828e346dcfe4e313fdf56ed62d131b7156 -R 9ee65c1aa637763c0020e3a8027e1724 +P 6480916c7266437cf8a70e5db2ca5c753ad71c361b68e41cbf8572f77c271920 +R 01de758547ecf045b8fcd9d862711733 U drh -Z 46819a22d665678fea30894f28c71769 +Z e0e7b0df8e672e69a6f8d6e88a7b4646 diff --git a/manifest.uuid b/manifest.uuid index 61d9917324..05c0a7d81a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6480916c7266437cf8a70e5db2ca5c753ad71c361b68e41cbf8572f77c271920 \ No newline at end of file +c46d94a8cde816ca383e771721ebd4900de77950cba700e35a26f70fd5b794a4 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 37d2c781d9..8a00787a49 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -3297,7 +3297,14 @@ PRIVATE int compute_action(struct lemon *lemp, struct action *ap) int act; switch( ap->type ){ case SHIFT: act = ap->x.stp->statenum; break; - case SHIFTREDUCE: act = ap->x.rp->iRule + lemp->nstate; break; + case SHIFTREDUCE: { + act = ap->x.rp->iRule + lemp->nstate; + /* Since a SHIFT is inherient after a prior REDUCE, convert any + ** SHIFTREDUCE action with a nonterminal on the LHS into a simple + ** REDUCE action: */ + if( ap->sp->index>=lemp->nterminal ) act += lemp->nrule; + break; + } case REDUCE: act = ap->x.rp->iRule + lemp->nstate+lemp->nrule; break; case ERROR: act = lemp->nstate + lemp->nrule*2; break; case ACCEPT: act = lemp->nstate + lemp->nrule*2 + 1; break; diff --git a/tool/lempar.c b/tool/lempar.c index 21ed9d79ab..59fb6dfcd3 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -708,19 +708,23 @@ static void yy_reduce( yygoto = yyRuleInfo[yyruleno].lhs; yysize = yyRuleInfo[yyruleno].nrhs; yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); - if( yyact <= YY_MAX_SHIFTREDUCE ){ - if( yyact>YY_MAX_SHIFT ){ - yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; - } + + /* There are no SHIFTREDUCE actions on nonterminals because the table + ** generator has simplified them to pure REDUCE actions. */ + assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) ); + + /* It is not possible for a REDUCE to be followed by an error */ + assert( yyact!=YY_ERROR_ACTION ); + + if( yyact==YY_ACCEPT_ACTION ){ + yypParser->yytos -= yysize; + yy_accept(yypParser); + }else{ yymsp -= yysize-1; yypParser->yytos = yymsp; yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact); - }else{ - assert( yyact == YY_ACCEPT_ACTION ); - yypParser->yytos -= yysize; - yy_accept(yypParser); } } From 6be95366c7ea598b7a11ba09814db507472cabb0 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 28 Jun 2017 13:47:56 +0000 Subject: [PATCH 36/39] In the lemon-generated parser, store the number of symbols on the RHS of each rule as a negative number and add it to the stack pointer, rather than storing the value as a positive and subtracting it. This makes the parser faster. FossilOrigin-Name: b362f0d8ed34839bf3b29d10ed0853ab94245fba135ccd28e619caa6ee6992d5 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/lemon.c | 2 +- tool/lempar.c | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 8586f644db..048981d0cd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\slemon-generated\sparser,\sautomatically\spromote\sSHIFTREDUCE\sactions\son\nnonterminal\ssystems\sto\spure\sREDUCE\sactions,\sfor\sa\sperformance\senhancement. -D 2017-06-28T11:56:18.525 +C In\sthe\slemon-generated\sparser,\sstore\sthe\snumber\sof\ssymbols\son\sthe\sRHS\sof\seach\nrule\sas\sa\snegative\snumber\sand\sadd\sit\sto\sthe\sstack\spointer,\srather\sthan\sstoring\nthe\svalue\sas\sa\spositive\sand\ssubtracting\sit.\s\sThis\smakes\sthe\sparser\sfaster. +D 2017-06-28T13:47:56.467 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -1509,8 +1509,8 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f -F tool/lemon.c 8f18c158ff3fb92e844d389a8f8802ef47d3065746139b9f065a34f8e3acba82 -F tool/lempar.c 12d9fc3b7fd504a413d578f8542a84227dd560c29dc2e829d01a333e09df035c +F tool/lemon.c 5a04dff28578a67415cea5bf981b893c50cebfdd4388fb21254d1892525edfd8 +F tool/lempar.c 1653b07079a7b4c0eabe6cde5e354013da3cf4de30947d0dc00d045be1e2c9a1 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1584,7 +1584,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6480916c7266437cf8a70e5db2ca5c753ad71c361b68e41cbf8572f77c271920 -R 01de758547ecf045b8fcd9d862711733 +P c46d94a8cde816ca383e771721ebd4900de77950cba700e35a26f70fd5b794a4 +R 80bd1b22c47b401be9abca328e50fc2b U drh -Z e0e7b0df8e672e69a6f8d6e88a7b4646 +Z b7c98ba7d5a1b85e87e71ed5f99d7f82 diff --git a/manifest.uuid b/manifest.uuid index 05c0a7d81a..d258325f0f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c46d94a8cde816ca383e771721ebd4900de77950cba700e35a26f70fd5b794a4 \ No newline at end of file +b362f0d8ed34839bf3b29d10ed0853ab94245fba135ccd28e619caa6ee6992d5 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 8a00787a49..fe0fb4c615 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -4422,7 +4422,7 @@ void ReportTable( ** sequentually beginning with 0. */ for(rp=lemp->rule; rp; rp=rp->next){ - fprintf(out," { %d, %d },\n",rp->lhs->index,rp->nrhs); lineno++; + fprintf(out," { %d, %d },\n",rp->lhs->index,-rp->nrhs); lineno++; } tplt_xfer(lemp->name,in,out,&lineno); diff --git a/tool/lempar.c b/tool/lempar.c index 59fb6dfcd3..51adf672b3 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -635,8 +635,8 @@ static void yy_shift( ** is used during the reduce. */ static const struct { - YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ - unsigned char nrhs; /* Number of right-hand side symbols in the rule */ + YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ + signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { %% }; @@ -661,7 +661,7 @@ static void yy_reduce( if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ yysize = yyRuleInfo[yyruleno].nrhs; fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt, - yyRuleName[yyruleno], yymsp[-yysize].stateno); + yyRuleName[yyruleno], yymsp[yysize].stateno); } #endif /* NDEBUG */ @@ -707,7 +707,7 @@ static void yy_reduce( assert( yyrulenoyytos -= yysize; + yypParser->yytos += yysize; yy_accept(yypParser); }else{ - yymsp -= yysize-1; + yymsp += yysize+1; yypParser->yytos = yymsp; yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; From 6559e2cec7cf3a371725e0bc04ede815acb37856 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 28 Jun 2017 14:26:37 +0000 Subject: [PATCH 37/39] Minor tweak to the SQL grammar to make the parser tables a few bytes smaller. FossilOrigin-Name: cc4810b23e683e8c359f7c1a562338ec8501e43cac3475b2be002568fca5e6a4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/parse.y | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 048981d0cd..4370c5292a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\slemon-generated\sparser,\sstore\sthe\snumber\sof\ssymbols\son\sthe\sRHS\sof\seach\nrule\sas\sa\snegative\snumber\sand\sadd\sit\sto\sthe\sstack\spointer,\srather\sthan\sstoring\nthe\svalue\sas\sa\spositive\sand\ssubtracting\sit.\s\sThis\smakes\sthe\sparser\sfaster. -D 2017-06-28T13:47:56.467 +C Minor\stweak\sto\sthe\sSQL\sgrammar\sto\smake\sthe\sparser\stables\sa\sfew\sbytes\ssmaller. +D 2017-06-28T14:26:37.622 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -395,7 +395,7 @@ F src/os_win.c 2a6c73eef01c51a048cc4ddccd57f981afbec18a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 14f6982c470c05b8e85575c69e9c1712010602e20400f8670d8699e21283e0e4 F src/pager.h f2a99646c5533ffe11afa43e9e0bea74054e4efa -F src/parse.y 0513387ce02fea97897d8caef82d45f347818593f24f1bdc48e0c530a8af122d +F src/parse.y b13c9fc83cb634daf7fd5fef89127e8eafdf4904ab9a168d3e1862c5a3c7ae22 F src/pcache.c 62835bed959e2914edd26afadfecce29ece0e870 F src/pcache.h 521bb9610d38ef17a3cc9b5ddafd4546c2ea67fa3d0e464823d73c2a28d50e11 F src/pcache1.c 1195a21fe28e223e024f900b2011e80df53793f0356a24caace4188b098540dc @@ -1584,7 +1584,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c46d94a8cde816ca383e771721ebd4900de77950cba700e35a26f70fd5b794a4 -R 80bd1b22c47b401be9abca328e50fc2b +P b362f0d8ed34839bf3b29d10ed0853ab94245fba135ccd28e619caa6ee6992d5 +R 47fe456950b93480334e354c250c0848 U drh -Z b7c98ba7d5a1b85e87e71ed5f99d7f82 +Z 983cf2b86c0c77a70c157e39be586b00 diff --git a/manifest.uuid b/manifest.uuid index d258325f0f..ff73f3fd14 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b362f0d8ed34839bf3b29d10ed0853ab94245fba135ccd28e619caa6ee6992d5 \ No newline at end of file +cc4810b23e683e8c359f7c1a562338ec8501e43cac3475b2be002568fca5e6a4 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 522c805482..91e498214c 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1375,8 +1375,7 @@ trigger_decl(A) ::= temp(T) TRIGGER ifnotexists(NOERR) nm(B) dbnm(Z) } %type trigger_time {int} -trigger_time(A) ::= BEFORE. { A = TK_BEFORE; } -trigger_time(A) ::= AFTER. { A = TK_AFTER; } +trigger_time(A) ::= BEFORE|AFTER(X). { A = @X; /*A-overwrites-X*/ } trigger_time(A) ::= INSTEAD OF. { A = TK_INSTEAD;} trigger_time(A) ::= . { A = TK_BEFORE; } From 8b471e7e7961f0a2c898a009d053eb13822a2113 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 28 Jun 2017 15:01:35 +0000 Subject: [PATCH 38/39] Faster parser stack overflow detection. FossilOrigin-Name: 36e54cd8b1fb374fd41e3e09b34b86e34327bf07c9e4bfec58382163c5c5d279 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lempar.c | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 4370c5292a..d205da7170 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\stweak\sto\sthe\sSQL\sgrammar\sto\smake\sthe\sparser\stables\sa\sfew\sbytes\ssmaller. -D 2017-06-28T14:26:37.622 +C Faster\sparser\sstack\soverflow\sdetection. +D 2017-06-28T15:01:35.715 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -1510,7 +1510,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f F tool/lemon.c 5a04dff28578a67415cea5bf981b893c50cebfdd4388fb21254d1892525edfd8 -F tool/lempar.c 1653b07079a7b4c0eabe6cde5e354013da3cf4de30947d0dc00d045be1e2c9a1 +F tool/lempar.c f0dc07c2838febff4c34244651a6932fceb523065e6fe79bacfaa93019cc8cca F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1584,7 +1584,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b362f0d8ed34839bf3b29d10ed0853ab94245fba135ccd28e619caa6ee6992d5 -R 47fe456950b93480334e354c250c0848 +P cc4810b23e683e8c359f7c1a562338ec8501e43cac3475b2be002568fca5e6a4 +R aecb52c4ffe19d7ddc13e13ae7717a64 U drh -Z 983cf2b86c0c77a70c157e39be586b00 +Z deaa1ad68fb12d39469a0630e4b55aa7 diff --git a/manifest.uuid b/manifest.uuid index ff73f3fd14..f6a85fd8bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cc4810b23e683e8c359f7c1a562338ec8501e43cac3475b2be002568fca5e6a4 \ No newline at end of file +36e54cd8b1fb374fd41e3e09b34b86e34327bf07c9e4bfec58382163c5c5d279 \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index 51adf672b3..4a98d23700 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -221,6 +221,7 @@ struct yyParser { yyStackEntry yystk0; /* First stack entry */ #else yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ + yyStackEntry *yystackEnd; /* Last entry in the stack */ #endif }; typedef struct yyParser yyParser; @@ -338,6 +339,7 @@ void ParseInit(void *yypParser){ pParser->yytos = pParser->yystack; pParser->yystack[0].stateno = 0; pParser->yystack[0].major = 0; + pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1]; } #ifndef Parse_ENGINEALWAYSONSTACK @@ -607,7 +609,7 @@ static void yy_shift( } #endif #if YYSTACKDEPTH>0 - if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){ + if( yypParser->yytos>yypParser->yystackEnd ){ yypParser->yytos--; yyStackOverflow(yypParser); return; @@ -676,7 +678,7 @@ static void yy_reduce( } #endif #if YYSTACKDEPTH>0 - if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){ + if( yypParser->yytos>=yypParser->yystackEnd ){ yyStackOverflow(yypParser); return; } From 2fb960b545dd7bbdf101d8aced41d1448aa7477e Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 28 Jun 2017 15:17:31 +0000 Subject: [PATCH 39/39] Fix harmless compiler warnings in the CSV extension. FossilOrigin-Name: f02a54599de7620438aecd3753199fc52ce8919d7503bb8b2f5592b0e51dbf8c --- ext/misc/csv.c | 4 ++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/misc/csv.c b/ext/misc/csv.c index bcafdc5263..6d99634274 100644 --- a/ext/misc/csv.c +++ b/ext/misc/csv.c @@ -256,10 +256,10 @@ static char *csv_read_one_field(CsvReader *p){ /* If this is the first field being parsed and it begins with the ** UTF-8 BOM (0xEF BB BF) then skip the BOM */ if( (c&0xff)==0xef && p->bNotFirst==0 ){ - csv_append(p, c); + csv_append(p, (char)c); c = csv_getc(p); if( (c&0xff)==0xbb ){ - csv_append(p, c); + csv_append(p, (char)c); c = csv_getc(p); if( (c&0xff)==0xbf ){ p->bNotFirst = 1; diff --git a/manifest b/manifest index d205da7170..2801d1f79d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Faster\sparser\sstack\soverflow\sdetection. -D 2017-06-28T15:01:35.715 +C Fix\sharmless\scompiler\swarnings\sin\sthe\sCSV\sextension. +D 2017-06-28T15:17:31.371 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -215,7 +215,7 @@ F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a2 F ext/misc/carray.c 40c27641010a4dc67e3690bdb7c9d36ca58b3c2d F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 -F ext/misc/csv.c 934ed645372e39e44aa84b1c3dd16ba6838bd18fa09a389965bdfa5a6f984a9f +F ext/misc/csv.c d91c0388445b08f6e373dd0e8fc024d4551b1fcaf64e876a1c3f4fac8a63adc2 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f @@ -1584,7 +1584,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cc4810b23e683e8c359f7c1a562338ec8501e43cac3475b2be002568fca5e6a4 -R aecb52c4ffe19d7ddc13e13ae7717a64 +P 36e54cd8b1fb374fd41e3e09b34b86e34327bf07c9e4bfec58382163c5c5d279 +R 6108cfd499d3cf4cdcf025dbd8d46170 U drh -Z deaa1ad68fb12d39469a0630e4b55aa7 +Z 876994e9b4ab523dadf3076830cbada0 diff --git a/manifest.uuid b/manifest.uuid index f6a85fd8bf..b842682867 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -36e54cd8b1fb374fd41e3e09b34b86e34327bf07c9e4bfec58382163c5c5d279 \ No newline at end of file +f02a54599de7620438aecd3753199fc52ce8919d7503bb8b2f5592b0e51dbf8c \ No newline at end of file