From ad012d09dc3ef80fb041bcbe1afa7d85ae72daee Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 3 May 2017 15:54:53 +0000 Subject: [PATCH 01/22] Always enable URI filenames when compiling with SQLITE_HAS_CODEC. Also allow plaintext keys using the key= query parameter. FossilOrigin-Name: 31a51b4d168065fa59cc0e52ba798bd87ac82160c675bd531442b65133edb401 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/global.c | 9 ++++++++- src/main.c | 16 +++++++++------- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 84aba2e596..834674808b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sfts3EvalAverageDocsize()\sroutine\sso\sthat\sit\sreturns\serrors\sfrom\nsqlite3_reset()\srather\sthan\salways\sreturning\sSQLITE_OK. -D 2017-05-02T18:00:31.645 +C Always\senable\sURI\sfilenames\swhen\scompiling\swith\sSQLITE_HAS_CODEC.\s\sAlso\sallow\nplaintext\skeys\susing\sthe\skey=\squery\sparameter. +D 2017-05-03T15:54:53.280 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -359,7 +359,7 @@ F src/expr.c 965f5e6074ee61cf933be079c6a443c88414490c13ec270b5baaacaa920280fa F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c db65492ae549c3b548c9ef1f279ce1684f1c473b116e1c56a90878cd5dcf968d F src/func.c 9d52522cc8ae7f5cdadfe14594262f1618bc1f86083c4cd6da861b4cf5af6174 -F src/global.c 4a34512d82fc5aa13c802db06bcfff5e1d3de955 +F src/global.c 8a6ab6b4d91effb96ffa81b39f0d70c862abca157f8aaa194600a4a8b7923344 F src/hash.c 63d0ee752a3b92d4695b2b1f5259c4621b2cfebd F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da @@ -367,7 +367,7 @@ F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c d4bb3a135948553d18cf992f76f7ed7b18aa0327f250607b5a6671e55d9947d5 F src/legacy.c e88ed13c2d531decde75d42c2e35623fb9ce3cb0 F src/loadext.c a72909474dadce771d3669bf84bf689424f6f87d471fee898589c3ef9b2acfd9 -F src/main.c 158326243c5ddc8b98a1e983fa488650cf76d760 +F src/main.c 1e448d204045c1dcd604853639d9d8fe253aa9ec302a2f1ffd2e22752fd6b708 F src/malloc.c e20bb2b48abec52d3faf01cce12e8b4f95973755fafec98d45162dfdab111978 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de @@ -1578,7 +1578,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 9e35c89dbe744312f612e507b51ff9a5bb656def75392d25bc19fc638548cd1e -R ff82b9e0856a749852e0a40a30515627 +P 430f539cbb3f806fb89191e0b759a5f8b49d9e5b6c95fe9a4b55a1aa0875762a +R 9361fb55741f5070a358ac5ee22a5ad4 U drh -Z a7183f9c248f45ecd3f1461fb3e694c7 +Z 6969a550096004330a93c292edb36e97 diff --git a/manifest.uuid b/manifest.uuid index ee0d3109c4..3d5674cd54 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -430f539cbb3f806fb89191e0b759a5f8b49d9e5b6c95fe9a4b55a1aa0875762a \ No newline at end of file +31a51b4d168065fa59cc0e52ba798bd87ac82160c675bd531442b65133edb401 \ No newline at end of file diff --git a/src/global.c b/src/global.c index a105135561..fe63bbe140 100644 --- a/src/global.c +++ b/src/global.c @@ -137,9 +137,16 @@ const unsigned char sqlite3CtypeMap[256] = { ** EVIDENCE-OF: R-43642-56306 By default, URI handling is globally ** disabled. The default value may be changed by compiling with the ** SQLITE_USE_URI symbol defined. +** +** URI filenames are enabled by default if SQLITE_HAS_CODEC is +** enabled. */ #ifndef SQLITE_USE_URI -# define SQLITE_USE_URI 0 +# ifdef SQLITE_HAS_CODEC +# define SQLITE_USE_URI 1 +# else +# define SQLITE_USE_URI 0 +# endif #endif /* EVIDENCE-OF: R-38720-18127 The default setting is determined by the diff --git a/src/main.c b/src/main.c index 4ac5327e4f..32d00087f5 100644 --- a/src/main.c +++ b/src/main.c @@ -3095,16 +3095,18 @@ opendb_out: #endif #if defined(SQLITE_HAS_CODEC) if( rc==SQLITE_OK ){ - const char *zHexKey = sqlite3_uri_parameter(zOpen, "hexkey"); - if( zHexKey && zHexKey[0] ){ + const char *zKey; + if( (zKey = sqlite3_uri_parameter(zOpen, "hexkey"))!=0 && zKey[0] ){; u8 iByte; int i; - char zKey[40]; - for(i=0, iByte=0; i Date: Wed, 3 May 2017 17:44:28 +0000 Subject: [PATCH 02/22] Fix the sqlite3GetInt32() function so that it correctly returns 0 on a zero-length input string. FossilOrigin-Name: 05eba9e3a5f9bb2a40af1dacd885e1915fbcd20b9af4cf0eed79ac16dbeba31b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/util.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 834674808b..33d1b5fbef 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Always\senable\sURI\sfilenames\swhen\scompiling\swith\sSQLITE_HAS_CODEC.\s\sAlso\sallow\nplaintext\skeys\susing\sthe\skey=\squery\sparameter. -D 2017-05-03T15:54:53.280 +C Fix\sthe\ssqlite3GetInt32()\sfunction\sso\sthat\sit\scorrectly\sreturns\s0\son\sa\nzero-length\sinput\sstring. +D 2017-05-03T17:44:28.665 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -467,7 +467,7 @@ F src/treeview.c 6cf8d7fe9e63fae57dad1bb57f6615e14eac0c527e43d868e805042cae8ed1f F src/trigger.c c9f0810043b265724fdb1bdd466894f984dfc182 F src/update.c c443935c652af9365e033f756550b5032d02e1b06eb2cb890ed7511ae0c051dc F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c -F src/util.c ca8440ede81e155d15cff7c101654f60b55a9ae6 +F src/util.c fc081ec6f63448dcd80d3dfad35baecfa104823254a815b081a4d9fe76e1db23 F src/vacuum.c 1fe4555cd8c9b263afb85b5b4ee3a4a4181ad569 F src/vdbe.c 9bac2bc2313ed682e6f48ccff6644d3263341885bfcbb3cdea7b720c722be2d5 F src/vdbe.h f7d1456e28875c2dcb964056589b5b7149ab7edf39edeca801596a39bb3d3848 @@ -1578,7 +1578,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 430f539cbb3f806fb89191e0b759a5f8b49d9e5b6c95fe9a4b55a1aa0875762a -R 9361fb55741f5070a358ac5ee22a5ad4 +P 31a51b4d168065fa59cc0e52ba798bd87ac82160c675bd531442b65133edb401 +R 1a9ae67768895b2203701f1f99daf69e U drh -Z 6969a550096004330a93c292edb36e97 +Z 6a4f04dd64a8ebc17f6d0713668a32cd diff --git a/manifest.uuid b/manifest.uuid index 3d5674cd54..40ea5642bb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -31a51b4d168065fa59cc0e52ba798bd87ac82160c675bd531442b65133edb401 \ No newline at end of file +05eba9e3a5f9bb2a40af1dacd885e1915fbcd20b9af4cf0eed79ac16dbeba31b \ No newline at end of file diff --git a/src/util.c b/src/util.c index 9b6f4f9e1d..7c9c5f54b7 100644 --- a/src/util.c +++ b/src/util.c @@ -713,6 +713,7 @@ int sqlite3GetInt32(const char *zNum, int *pValue){ } } #endif + if( !sqlite3Isdigit(zNum[0]) ) return 0; while( zNum[0]=='0' ) zNum++; for(i=0; i<11 && (c = zNum[i] - '0')>=0 && c<=9; i++){ v = v*10 + c; From 30f01249a355d450d36565910db780cab7020adf Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 3 May 2017 19:36:50 +0000 Subject: [PATCH 03/22] Remove the unused "sqlite3_stack_used" TCL command from the test harness. FossilOrigin-Name: e24b73820cdca07eee87853fe6dd9f60d76e039eeb4aebef03654db3c7c94f14 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/test1.c | 47 ----------------------------------------------- 3 files changed, 7 insertions(+), 54 deletions(-) diff --git a/manifest b/manifest index 33d1b5fbef..959575b3fc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\ssqlite3GetInt32()\sfunction\sso\sthat\sit\scorrectly\sreturns\s0\son\sa\nzero-length\sinput\sstring. -D 2017-05-03T17:44:28.665 +C Remove\sthe\sunused\s"sqlite3_stack_used"\sTCL\scommand\sfrom\sthe\stest\sharness. +D 2017-05-03T19:36:50.091 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -412,7 +412,7 @@ F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6 F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 F src/tclsqlite.c 6c2151b6d8d98e183a04466d40df8889c0574d79 -F src/test1.c 8a98191a1da8e100f77cdb5cc716df67d405028d +F src/test1.c c99f0442918a7a5d5b68a95d6024c211989e6c782c15ced5a558994baaf76a5e F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5 F src/test3.c d03f5b5da9a2410b7a91c64b0d3306ed28ab6fee F src/test4.c 18ec393bb4d0ad1de729f0b94da7267270f3d8e6 @@ -1578,7 +1578,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 31a51b4d168065fa59cc0e52ba798bd87ac82160c675bd531442b65133edb401 -R 1a9ae67768895b2203701f1f99daf69e +P 05eba9e3a5f9bb2a40af1dacd885e1915fbcd20b9af4cf0eed79ac16dbeba31b +R cc73eb460d9854ad23aa843f2d63b269 U drh -Z 6a4f04dd64a8ebc17f6d0713668a32cd +Z ade9e12e596bfcbd80a3bdd31cc0c7fe diff --git a/manifest.uuid b/manifest.uuid index 40ea5642bb..de10786994 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -05eba9e3a5f9bb2a40af1dacd885e1915fbcd20b9af4cf0eed79ac16dbeba31b \ No newline at end of file +e24b73820cdca07eee87853fe6dd9f60d76e039eeb4aebef03654db3c7c94f14 \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index d17fc1022a..87b255c9e9 100644 --- a/src/test1.c +++ b/src/test1.c @@ -4949,52 +4949,6 @@ static int SQLITE_TCLAPI test_interrupt( return TCL_OK; } -static u8 *sqlite3_stack_baseline = 0; - -/* -** Fill the stack with a known bitpattern. -*/ -static void prepStack(void){ - int i; - u32 bigBuf[65536]; - for(i=0; i=0 && ((u32*)sqlite3_stack_baseline)[-i]==0xdeadbeef; i--){} - Tcl_SetObjResult(interp, Tcl_NewIntObj(i*4)); - return TCL_OK; -} - /* ** Usage: sqlite_delete_function DB function-name ** @@ -7473,7 +7427,6 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite_delete_function", (Tcl_CmdProc*)delete_function }, { "sqlite_delete_collation", (Tcl_CmdProc*)delete_collation }, { "sqlite3_get_autocommit", (Tcl_CmdProc*)get_autocommit }, - { "sqlite3_stack_used", (Tcl_CmdProc*)test_stack_used }, { "sqlite3_busy_timeout", (Tcl_CmdProc*)test_busy_timeout }, { "printf", (Tcl_CmdProc*)test_printf }, { "sqlite3IoTrace", (Tcl_CmdProc*)test_io_trace }, From 050b124ce205534662812764dee5701788fac738 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 4 May 2017 11:13:50 +0000 Subject: [PATCH 04/22] Fix a collision of the "B0" identifier name between the termios.h header file and the SHA3 implementation in the shell. FossilOrigin-Name: b9a58daca80a815e87e541cb5fff9bc8b93f131d223f322c5b83dd5a5f0c0312 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 959575b3fc..9a474a3732 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sunused\s"sqlite3_stack_used"\sTCL\scommand\sfrom\sthe\stest\sharness. -D 2017-05-03T19:36:50.091 +C Fix\sa\scollision\sof\sthe\s"B0"\sidentifier\sname\sbetween\sthe\stermios.h\sheader\nfile\sand\sthe\sSHA3\simplementation\sin\sthe\sshell. +D 2017-05-04T11:13:50.417 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -403,7 +403,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c 3e518b962d932a997fae373366880fc028c75706 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 4f0adefaa5e9417459b07757e0f6060cac97930a86f0fba9797bab233ced66c0 -F src/shell.c 21b79c0e1b93f8e35fd7b4087d6ba438326c3d7e285d0dd51dfd741475f858a1 +F src/shell.c e5950029da103c5d378e71d548759459b9a7fc76177a71562c22082c705745ab F src/sqlite.h.in eeb1da70a61d52e1d58e5b55446b85bbac571699421d3cf857421c56214013ce F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 @@ -1578,7 +1578,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 05eba9e3a5f9bb2a40af1dacd885e1915fbcd20b9af4cf0eed79ac16dbeba31b -R cc73eb460d9854ad23aa843f2d63b269 +P e24b73820cdca07eee87853fe6dd9f60d76e039eeb4aebef03654db3c7c94f14 +R e8b739e45c08ec8468647ac109d9456f U drh -Z ade9e12e596bfcbd80a3bdd31cc0c7fe +Z 82e99d9ee4b60fac8b8163f812301e67 diff --git a/manifest.uuid b/manifest.uuid index de10786994..c0dd2c30e8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e24b73820cdca07eee87853fe6dd9f60d76e039eeb4aebef03654db3c7c94f14 \ No newline at end of file +b9a58daca80a815e87e541cb5fff9bc8b93f131d223f322c5b83dd5a5f0c0312 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 15c88061c2..582d6f3142 100644 --- a/src/shell.c +++ b/src/shell.c @@ -744,6 +744,10 @@ struct SHA3Context { unsigned ixMask; /* Insert next input into u.x[nLoaded^ixMask]. */ }; +/* Allow the following routine to use the B0 variable, which is also +** a macro in the termios.h header file */ +#undef B0 + /* ** A single step of the Keccak mixing function for a 1600-bit state */ From f8a2e8c2d29d1e3953511425cd81653be647d54f Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 6 May 2017 17:12:52 +0000 Subject: [PATCH 05/22] Fix requirements marks and harmless compiler warnings. FossilOrigin-Name: 198ff4c01d86d193a54745764d69376cab8e94747a4daa444690f7e1ec87800b --- ext/rtree/rtree.c | 1 + manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/shell.c | 2 +- test/fkey5.test | 10 ++++++++-- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 8196e351bc..2f80af5644 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -3222,6 +3222,7 @@ static int rtreeRename(sqlite3_vtab *pVtab, const char *zNewName){ static int rtreeSavepoint(sqlite3_vtab *pVtab, int iSavepoint){ Rtree *pRtree = (Rtree *)pVtab; int iwt = pRtree->inWrTrans; + UNUSED_PARAMETER(iSavepoint); pRtree->inWrTrans = 0; nodeBlobReset(pRtree); pRtree->inWrTrans = iwt; diff --git a/manifest b/manifest index 9a474a3732..40eed6a73a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scollision\sof\sthe\s"B0"\sidentifier\sname\sbetween\sthe\stermios.h\sheader\nfile\sand\sthe\sSHA3\simplementation\sin\sthe\sshell. -D 2017-05-04T11:13:50.417 +C Fix\srequirements\smarks\sand\sharmless\scompiler\swarnings. +D 2017-05-06T17:12:52.313 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -272,7 +272,7 @@ F ext/rbu/sqlite3rbu.c 2a89efba9eeba8e6c89a498dc195e8efbdde2694 F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 37c603c6b8aed1a760661ceb5a025bd36bac14cf56d59949bd8de14b2a17e9ed +F ext/rtree/rtree.c 8205d6e4466f766e57ce1b8aa38224ac9e1cec2d2bf4684cd1cc5a6ddf9b7014 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test d5f0ba215b3bd1d05269ada86e74073b8445852aa0d33a63e10ec63a09c39473 F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -403,7 +403,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c 3e518b962d932a997fae373366880fc028c75706 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 4f0adefaa5e9417459b07757e0f6060cac97930a86f0fba9797bab233ced66c0 -F src/shell.c e5950029da103c5d378e71d548759459b9a7fc76177a71562c22082c705745ab +F src/shell.c a37d96b20b3644d0eb905df5aa7a0fcf9f6e73c15898337230c760a24a8df794 F src/sqlite.h.in eeb1da70a61d52e1d58e5b55446b85bbac571699421d3cf857421c56214013ce F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 @@ -709,7 +709,7 @@ F test/fkey1.test ba64806ff9a04eecab2679caad377ae99a5e94e4 F test/fkey2.test 155809016fad6b2a1491facf2ac53a551bc57c2c F test/fkey3.test 76d475c80b84ee7a5d062e56ccb6ea68882e2b49 F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d -F test/fkey5.test 19a9b73bafd78323c37fc883dba060191541503d6094f8aea67fe94d33118e20 +F test/fkey5.test 24dd28eb3d9f1b5a174f47e9899ace5facb08373a4223593c8c631e6cf9f7d5a F test/fkey6.test d078a1e323a740062bed38df32b8a736fd320dc0 F test/fkey7.test 72e915890ee4a005daaf3002cb208e8fe973ac13 F test/fkey8.test e5372e32cdb4481f121ec3550703eeb7b4e0762c @@ -1578,7 +1578,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 e24b73820cdca07eee87853fe6dd9f60d76e039eeb4aebef03654db3c7c94f14 -R e8b739e45c08ec8468647ac109d9456f +P b9a58daca80a815e87e541cb5fff9bc8b93f131d223f322c5b83dd5a5f0c0312 +R 7439e7b02aa88b692e04c05c6e92f9d2 U drh -Z 82e99d9ee4b60fac8b8163f812301e67 +Z 9b526b1df399cb1577efc1cd64d02ba1 diff --git a/manifest.uuid b/manifest.uuid index c0dd2c30e8..ab929d53dd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b9a58daca80a815e87e541cb5fff9bc8b93f131d223f322c5b83dd5a5f0c0312 \ No newline at end of file +198ff4c01d86d193a54745764d69376cab8e94747a4daa444690f7e1ec87800b \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 582d6f3142..d36f1fdd19 100644 --- a/src/shell.c +++ b/src/shell.c @@ -438,7 +438,7 @@ static void utf8_width_print(FILE *pOut, int w, const char *zUtf){ int n; int aw = w<0 ? -w : w; char zBuf[1000]; - if( aw>sizeof(zBuf)/3 ) aw = sizeof(zBuf)/3; + if( aw>(int)sizeof(zBuf)/3 ) aw = (int)sizeof(zBuf)/3; for(i=n=0; zUtf[i]; i++){ if( (zUtf[i]&0xc0)!=0x80 ){ n++; diff --git a/test/fkey5.test b/test/fkey5.test index e9bb47f895..3c44cd319f 100644 --- a/test/fkey5.test +++ b/test/fkey5.test @@ -115,8 +115,11 @@ do_test fkey5-1.6 { # EVIDENCE-OF: R-55672-01620 The first column is the name of the table # that contains the REFERENCES clause. # -# EVIDENCE-OF: R-25219-25618 The second column is the rowid of the row -# that contains the invalid REFERENCES clause. +# EVIDENCE-OF: R-00471-55166 The second column is the rowid of the row +# that contains the invalid REFERENCES clause, or NULL if the child +# table is a WITHOUT ROWID table. +# +# The second clause in the previous is tested by fkey5-10.3. # # EVIDENCE-OF: R-40482-20265 The third column is the name of the table # that is referred to. @@ -407,6 +410,9 @@ do_execsql_test 10.1 { do_execsql_test 10.2 { PRAGMA foreign_key_check; } +# EVIDENCE-OF: R-00471-55166 The second column is the rowid of the row +# that contains the invalid REFERENCES clause, or NULL if the child +# table is a WITHOUT ROWID table. do_execsql_test 10.3 { INSERT INTO c30 VALUES(45, 45); PRAGMA foreign_key_check; From ffe280596e90dcde7f319f66109aab779f0300ef Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 6 May 2017 18:09:36 +0000 Subject: [PATCH 06/22] Fix an obscure assertion fault that can follow an OOM. The problem was introduced by check-in [a1cf44763277b6c7]. FossilOrigin-Name: 04e7e5650efffdce759b46999beb67c250af6cf394a7779ab861f210a84c134d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/expr.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 40eed6a73a..564f7eec6f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\srequirements\smarks\sand\sharmless\scompiler\swarnings. -D 2017-05-06T17:12:52.313 +C Fix\san\sobscure\sassertion\sfault\sthat\scan\sfollow\san\sOOM.\s\s\sThe\sproblem\nwas\sintroduced\sby\scheck-in\s[a1cf44763277b6c7]. +D 2017-05-06T18:09:36.744 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -355,7 +355,7 @@ F src/ctime.c 47d91a25ad8f199a71a5b1b7b169d6dd0d6e98c5719eca801568798743d1161c F src/date.c cc42a41c7422389860d40419a5e3bce5eaf6e7835c3ba2677751dc653550a5c7 F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c 0d9d5549d42e79ce4d82ff1db1e6c81e36d2f67c -F src/expr.c 965f5e6074ee61cf933be079c6a443c88414490c13ec270b5baaacaa920280fa +F src/expr.c c980b2c9291a12a0f1de1e1e1aaa72c4579ded716e1e3a3ac1c3d898ba0df0a1 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c db65492ae549c3b548c9ef1f279ce1684f1c473b116e1c56a90878cd5dcf968d F src/func.c 9d52522cc8ae7f5cdadfe14594262f1618bc1f86083c4cd6da861b4cf5af6174 @@ -1578,7 +1578,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 b9a58daca80a815e87e541cb5fff9bc8b93f131d223f322c5b83dd5a5f0c0312 -R 7439e7b02aa88b692e04c05c6e92f9d2 +P 198ff4c01d86d193a54745764d69376cab8e94747a4daa444690f7e1ec87800b +R 32100f2588ee0aaab5e52c8f56365f52 U drh -Z 9b526b1df399cb1577efc1cd64d02ba1 +Z 5b7285d0420627775594602075610fb9 diff --git a/manifest.uuid b/manifest.uuid index ab929d53dd..e3ee6fe2dc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -198ff4c01d86d193a54745764d69376cab8e94747a4daa444690f7e1ec87800b \ No newline at end of file +04e7e5650efffdce759b46999beb67c250af6cf394a7779ab861f210a84c134d \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index a79b0b7495..b5d4ed1f96 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1550,7 +1550,7 @@ ExprList *sqlite3ExprListAppendVector( } } - if( pExpr->op==TK_SELECT && pList ){ + if( !db->mallocFailed && pExpr->op==TK_SELECT && ALWAYS(pList!=0) ){ Expr *pFirst = pList->a[iFirst].pExpr; assert( pFirst!=0 ); assert( pFirst->op==TK_SELECT_COLUMN ); From 2617c9bdd8e74801961eda4f96294b35403cb2ee Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 8 May 2017 18:29:36 +0000 Subject: [PATCH 07/22] Do not invoke codec macros when reading or writing an in-memory sub-journal. FossilOrigin-Name: 2c145ee6c9e7916f022331453384cbe61ee3654c08a1b88467f85235b5bc18c4 --- manifest | 18 +++++++----- manifest.uuid | 2 +- src/pager.c | 23 ++++++++++++--- test/subjournal.test | 70 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 12 deletions(-) create mode 100644 test/subjournal.test diff --git a/manifest b/manifest index 564f7eec6f..23d43394be 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sobscure\sassertion\sfault\sthat\scan\sfollow\san\sOOM.\s\s\sThe\sproblem\nwas\sintroduced\sby\scheck-in\s[a1cf44763277b6c7]. -D 2017-05-06T18:09:36.744 +C Do\snot\sinvoke\scodec\smacros\swhen\sreading\sor\swriting\san\sin-memory\ssub-journal. +D 2017-05-08T18:29:36.543 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -389,7 +389,7 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c 30e2c43e4955db990e5b5a81e901f8aa74cc8820 F src/os_win.c 2a6c73eef01c51a048cc4ddccd57f981afbec18a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c ff1232b3088a39806035ecfac4fffeb22717d80b +F src/pager.c e00e5844b1d61c0f1a44b09b26ab0be941ac9056c44b5973d8343ce80a3973d8 F src/pager.h f2a99646c5533ffe11afa43e9e0bea74054e4efa F src/parse.y 0513387ce02fea97897d8caef82d45f347818593f24f1bdc48e0c530a8af122d F src/pcache.c 62835bed959e2914edd26afadfecce29ece0e870 @@ -1168,6 +1168,7 @@ F test/sqllog.test 6af6cb0b09f4e44e1917e06ce85be7670302517a F test/stat.test f8f1279ffffabe6df825723af18cc6e0ae70a893 F test/statfault.test f525a7bf633e50afd027700e9a486090684b1ac1 F test/stmt.test 64844332db69cf1a735fcb3e11548557fc95392f +F test/subjournal.test 2121a93ef3d3e83d52bf236c8a02aef4009fbf52884754104b2b6cad9a041095 F test/subquery.test d7268d193dd33d5505df965399d3a594e76ae13f F test/subquery2.test 438f8a7da1457277b22e4176510f7659b286995f F test/subselect.test 0966aa8e720224dbd6a5e769a3ec2a723e332303 @@ -1578,7 +1579,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 198ff4c01d86d193a54745764d69376cab8e94747a4daa444690f7e1ec87800b -R 32100f2588ee0aaab5e52c8f56365f52 -U drh -Z 5b7285d0420627775594602075610fb9 +P 04e7e5650efffdce759b46999beb67c250af6cf394a7779ab861f210a84c134d +R 5b566eb883c6b6910bc0ff6faa539b38 +T *branch * codecless-inmemory-subjournal +T *sym-codecless-inmemory-subjournal * +T -sym-trunk * +U dan +Z f779b45aa1c983a004325ff10b211ada diff --git a/manifest.uuid b/manifest.uuid index e3ee6fe2dc..570c1ee5f4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -04e7e5650efffdce759b46999beb67c250af6cf394a7779ab861f210a84c134d \ No newline at end of file +2c145ee6c9e7916f022331453384cbe61ee3654c08a1b88467f85235b5bc18c4 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 40c4dd9d88..dc8b31fcff 100644 --- a/src/pager.c +++ b/src/pager.c @@ -2258,6 +2258,7 @@ static int pager_playback_one_page( char *aData; /* Temporary storage for the page */ sqlite3_file *jfd; /* The file descriptor for the journal file */ int isSynced; /* True if journal page is synced */ + const int jrnlEnc = (isMainJrnl || pPager->subjInMemory==0); assert( (isMainJrnl&~1)==0 ); /* isMainJrnl is 0 or 1 */ assert( (isSavepnt&~1)==0 ); /* isSavepnt is 0 or 1 */ @@ -2381,14 +2382,24 @@ static int pager_playback_one_page( i64 ofst = (pgno-1)*(i64)pPager->pageSize; testcase( !isSavepnt && pPg!=0 && (pPg->flags&PGHDR_NEED_SYNC)!=0 ); assert( !pagerUseWal(pPager) ); + + /* Write the data read from the journal back into the database file. + ** This is usually safe even for an encrypted database - as the data + ** was encrypted before it was written to the journal file. The exception + ** is if the data was just read from an in-memory sub-journal. In that + ** case it must be encrypted here before it is copied into the database + ** file. */ + if( !jrnlEnc ){CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT, aData);} rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst); + if( !jrnlEnc ){CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT);} + if( pgno>pPager->dbFileSize ){ pPager->dbFileSize = pgno; } if( pPager->pBackup ){ - CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT); + if( jrnlEnc ){CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT);} sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData); - CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT, aData); + if( jrnlEnc ){CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT,aData);} } }else if( !isMainJrnl && pPg==0 ){ /* If this is a rollback of a savepoint and data was not written to @@ -2440,7 +2451,7 @@ static int pager_playback_one_page( } /* Decode the page just read from disk */ - CODEC1(pPager, pData, pPg->pgno, 3, rc=SQLITE_NOMEM_BKPT); + if( jrnlEnc ) CODEC1(pPager, pData, pPg->pgno, 3, rc=SQLITE_NOMEM_BKPT); sqlite3PcacheRelease(pPg); } return rc; @@ -4453,7 +4464,11 @@ static int subjournalPage(PgHdr *pPg){ i64 offset = (i64)pPager->nSubRec*(4+pPager->pageSize); char *pData2; - CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM_BKPT, pData2); + if( pPager->subjInMemory ){ + pData2 = pData; + }else{ + CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM_BKPT, pData2); + } PAGERTRACE(("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno)); rc = write32bits(pPager->sjfd, offset, pPg->pgno); if( rc==SQLITE_OK ){ diff --git a/test/subjournal.test b/test/subjournal.test new file mode 100644 index 0000000000..d4ea643c6e --- /dev/null +++ b/test/subjournal.test @@ -0,0 +1,70 @@ +# 2017 May 9 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix subjournal + +do_execsql_test 1.0 { + PRAGMA temp_store = memory; + CREATE TABLE t1(a,b,c); + INSERT INTO t1 VALUES(1, 2, 3); +} {} +do_execsql_test 1.1 { + BEGIN; + INSERT INTO t1 VALUES(4, 5, 6); + SAVEPOINT one; + INSERT INTO t1 VALUES(7, 8, 9); + ROLLBACK TO one; + SELECT * FROM t1; +} {1 2 3 4 5 6} +do_execsql_test 1.2 { + COMMIT; +} + +do_execsql_test 2.0 { + PRAGMA cache_size = 5; + CREATE TABLE t2(a BLOB); + CREATE INDEX i2 ON t2(a); + WITH s(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100 + ) INSERT INTO t2 SELECT randomblob(500) FROM s; +} + +do_test 2.1 { + forcedelete test.db2 + sqlite3 db2 test2.db + sqlite3_backup B db2 main db main + set nPage [db one {PRAGMA page_count}] + B step [expr $nPage-10] +} {SQLITE_OK} + +do_execsql_test 2.2 { + BEGIN; + UPDATE t2 SET a=randomblob(499); + SAVEPOINT two; + UPDATE t2 SET a=randomblob(498); + ROLLBACK TO two; + COMMIT; + PRAGMA integrity_check; +} {ok} + +do_test 2.3 { + B step 1000 +} {SQLITE_DONE} +do_test 2.4 { + B finish + execsql { PRAGMA integrity_check } db2 +} {ok} + +finish_test + From 614c6a09f7e52fee2aab540d58ea1b1a7cb43fe4 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 May 2017 12:49:50 +0000 Subject: [PATCH 08/22] Do not invoke codec macros for in-memory subjournals. FossilOrigin-Name: d2bb0066f7c8413ef9992e6b07641cdf40ad260778074bd83cc22dcaba87860b --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/pager.c | 37 +++++++++++++++++++++++++++---------- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 23d43394be..832924d17a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sinvoke\scodec\smacros\swhen\sreading\sor\swriting\san\sin-memory\ssub-journal. -D 2017-05-08T18:29:36.543 +C Do\snot\sinvoke\scodec\smacros\sfor\sin-memory\ssubjournals. +D 2017-05-10T12:49:50.041 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -389,7 +389,7 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c 30e2c43e4955db990e5b5a81e901f8aa74cc8820 F src/os_win.c 2a6c73eef01c51a048cc4ddccd57f981afbec18a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c e00e5844b1d61c0f1a44b09b26ab0be941ac9056c44b5973d8343ce80a3973d8 +F src/pager.c 80893c0860199aebc6efa4f102ab11eebde338b7fdbb0c04d4b04647c2fd62d1 F src/pager.h f2a99646c5533ffe11afa43e9e0bea74054e4efa F src/parse.y 0513387ce02fea97897d8caef82d45f347818593f24f1bdc48e0c530a8af122d F src/pcache.c 62835bed959e2914edd26afadfecce29ece0e870 @@ -1579,10 +1579,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 04e7e5650efffdce759b46999beb67c250af6cf394a7779ab861f210a84c134d -R 5b566eb883c6b6910bc0ff6faa539b38 -T *branch * codecless-inmemory-subjournal -T *sym-codecless-inmemory-subjournal * -T -sym-trunk * -U dan -Z f779b45aa1c983a004325ff10b211ada +P 2c145ee6c9e7916f022331453384cbe61ee3654c08a1b88467f85235b5bc18c4 +R 036cd868b45040b2c72bb4968e138d5b +U drh +Z 70f7b9e85ac1b4ba86dc2c4c0ab20dce diff --git a/manifest.uuid b/manifest.uuid index 570c1ee5f4..9ad4ab0b71 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2c145ee6c9e7916f022331453384cbe61ee3654c08a1b88467f85235b5bc18c4 \ No newline at end of file +d2bb0066f7c8413ef9992e6b07641cdf40ad260778074bd83cc22dcaba87860b \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index dc8b31fcff..58d63dd439 100644 --- a/src/pager.c +++ b/src/pager.c @@ -2258,7 +2258,11 @@ static int pager_playback_one_page( char *aData; /* Temporary storage for the page */ sqlite3_file *jfd; /* The file descriptor for the journal file */ int isSynced; /* True if journal page is synced */ +#ifdef SQLITE_HAS_CODEC + /* The jrnlEnc flag is true if Journal pages should be passed through + ** the codec. It is false for pure in-memory journals. */ const int jrnlEnc = (isMainJrnl || pPager->subjInMemory==0); +#endif assert( (isMainJrnl&~1)==0 ); /* isMainJrnl is 0 or 1 */ assert( (isSavepnt&~1)==0 ); /* isSavepnt is 0 or 1 */ @@ -2389,17 +2393,27 @@ static int pager_playback_one_page( ** is if the data was just read from an in-memory sub-journal. In that ** case it must be encrypted here before it is copied into the database ** file. */ - if( !jrnlEnc ){CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT, aData);} +#ifdef SQLITE_HAS_CODEC + if( !jrnlEnc ){ + CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT, aData); + rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst); + CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT); + }else +#endif rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst); - if( !jrnlEnc ){CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT);} if( pgno>pPager->dbFileSize ){ pPager->dbFileSize = pgno; } if( pPager->pBackup ){ - if( jrnlEnc ){CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT);} +#ifdef SQLITE_HAS_CODEC + if( jrnlEnc ){ + CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT); + sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData); + CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT,aData); + }else +#endif sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData); - if( jrnlEnc ){CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT,aData);} } }else if( !isMainJrnl && pPg==0 ){ /* If this is a rollback of a savepoint and data was not written to @@ -2451,7 +2465,9 @@ static int pager_playback_one_page( } /* Decode the page just read from disk */ - if( jrnlEnc ) CODEC1(pPager, pData, pPg->pgno, 3, rc=SQLITE_NOMEM_BKPT); +#if SQLITE_HAS_CODEC + if( jrnlEnc ){ CODEC1(pPager, pData, pPg->pgno, 3, rc=SQLITE_NOMEM_BKPT); } +#endif sqlite3PcacheRelease(pPg); } return rc; @@ -4463,12 +4479,13 @@ static int subjournalPage(PgHdr *pPg){ void *pData = pPg->pData; i64 offset = (i64)pPager->nSubRec*(4+pPager->pageSize); char *pData2; - - if( pPager->subjInMemory ){ - pData2 = pData; - }else{ + +#if SQLITE_HAS_CODEC + if( !pPager->subjInMemory ){ CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM_BKPT, pData2); - } + }else +#endif + pData2 = pData; PAGERTRACE(("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno)); rc = write32bits(pPager->sjfd, offset, pPg->pgno); if( rc==SQLITE_OK ){ From 7b458519f22a868ac6c923bf8a51adc72676ae6c Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 10 May 2017 13:36:04 +0000 Subject: [PATCH 09/22] Fix a couple of test scripts so that they work with -DSQLITE_DISABLE_FTS4_DEFERRED builds. FossilOrigin-Name: 30018d31068f3182d713a6cf09753b27b16a6f912d39a5e6c1363da83bec3125 --- manifest | 17 ++++++++-------- manifest.uuid | 2 +- test/fts3fault.test | 16 ++++++++------- test/fts3misc.test | 48 +++++++++++++++++++++++---------------------- 4 files changed, 43 insertions(+), 40 deletions(-) diff --git a/manifest b/manifest index a29ea679b0..086883cb26 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sunnecessary\scodec\soperations\son\sin-memory\ssubjournals. -D 2017-05-10T12:58:34.110 +C Fix\sa\scouple\sof\stest\sscripts\sso\sthat\sthey\swork\swith\n-DSQLITE_DISABLE_FTS4_DEFERRED\sbuilds. +D 2017-05-10T13:36:04.868 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -791,13 +791,13 @@ F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a F test/fts3expr3.test c4d4a7d6327418428c96e0a3a1137c251b8dfbf8 F test/fts3expr4.test c39a15d676b14fc439d9bf845aa7bddcf4a74dc3 F test/fts3expr5.test f9abfffbf5e53d48a33e12a1e8f8ba2c551c9b49 -F test/fts3fault.test 268e9589f44f49d6694ef39a293f0e0f80c6230fb01cc6f34325412acceb99ae +F test/fts3fault.test 3764ecffb3d341c5b05b3abe64153f385880035e67706ca2fc719e5d3352aedb F test/fts3fault2.test 536bbe01fe2946ec24b063a5eee813e8fd90354a6ca0b8f941d299c405edd17e F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641 F test/fts3join.test 34750f3ce1e29b2749eaf0f1be2fa6301c5d50da F test/fts3malloc.test b0e4c133b8d61d4f6d112d8110f8320e9e453ef6 F test/fts3matchinfo.test ce864e0bd92429df8008f31cf557269ba172482a -F test/fts3misc.test f481128013b9555babdf3bc04c58ab59d59bebc24b5f780f50342b9ffe05b547 +F test/fts3misc.test 66e7b59576ce2c795f0baff6d47f7f6f57e6f41101cf85fad05989e43bb060dd F test/fts3near.test 7e3354d46f155a822b59c0e957fd2a70c1d7e905 F test/fts3offsets.test b85fd382abdc78ebce721d8117bd552dfb75094c F test/fts3prefix.test fa794eaab0bdae466494947b0b153d7844478ab2 @@ -1579,8 +1579,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 04e7e5650efffdce759b46999beb67c250af6cf394a7779ab861f210a84c134d d2bb0066f7c8413ef9992e6b07641cdf40ad260778074bd83cc22dcaba87860b -R 036cd868b45040b2c72bb4968e138d5b -T +closed d2bb0066f7c8413ef9992e6b07641cdf40ad260778074bd83cc22dcaba87860b -U drh -Z 4b970db82062c1fa9f8c0e5f1157ed72 +P 199b2a84992823b4687588a5ba20bec9c42579887068ac21caf08df3895f41ed +R aac74a43ca2ae14e0065de21361f39b3 +U dan +Z ef67ced9f009068f9285813993732c7e diff --git a/manifest.uuid b/manifest.uuid index 4c0989b52c..b143d46fb2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -199b2a84992823b4687588a5ba20bec9c42579887068ac21caf08df3895f41ed \ No newline at end of file +30018d31068f3182d713a6cf09753b27b16a6f912d39a5e6c1363da83bec3125 \ No newline at end of file diff --git a/test/fts3fault.test b/test/fts3fault.test index 2622e47136..56835f4e0e 100644 --- a/test/fts3fault.test +++ b/test/fts3fault.test @@ -177,13 +177,15 @@ do_test 8.0 { faultsim_save_and_close } {} -do_faultsim_test 8.1 -faults oom-t* -prep { - faultsim_restore_and_reopen - db func mit mit -} -body { - execsql { SELECT mit(matchinfo(t8, 'x')) FROM t8 WHERE t8 MATCH 'a b c' } -} -test { - faultsim_test_result {0 {{1 1 1 1 4 2 1 5 5}}} +ifcapable fts4_deferred { + do_faultsim_test 8.1 -faults oom-t* -prep { + faultsim_restore_and_reopen + db func mit mit + } -body { + execsql { SELECT mit(matchinfo(t8, 'x')) FROM t8 WHERE t8 MATCH 'a b c' } + } -test { + faultsim_test_result {0 {{1 1 1 1 4 2 1 5 5}}} + } } do_faultsim_test 8.2 -faults oom-t* -prep { diff --git a/test/fts3misc.test b/test/fts3misc.test index 0d003bd324..1fe0f500f7 100644 --- a/test/fts3misc.test +++ b/test/fts3misc.test @@ -147,30 +147,32 @@ do_execsql_test 3.1.5 { #------------------------------------------------------------------------- # reset_db -do_execsql_test 4.0 { - PRAGMA page_size = 512; - CREATE VIRTUAL TABLE t4 USING fts4; - WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<8000 ) - INSERT INTO t4 SELECT 'a b c a b c a b c' FROM s; +ifcapable fts4_deferred { + do_execsql_test 4.0 { + PRAGMA page_size = 512; + CREATE VIRTUAL TABLE t4 USING fts4; + WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<8000 ) + INSERT INTO t4 SELECT 'a b c a b c a b c' FROM s; + } + do_execsql_test 4.1 { + SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"' + } {8000} + do_execsql_test 4.2 { + SELECT quote(value) from t4_stat where id=0 + } {X'C03EC0B204C0A608'} + do_execsql_test 4.3 { + UPDATE t4_stat SET value = X'C03EC0B204C0A60800' WHERE id=0; + } + do_catchsql_test 4.4 { + SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"' + } {1 {database disk image is malformed}} + do_execsql_test 4.5 { + UPDATE t4_stat SET value = X'00C03EC0B204C0A608' WHERE id=0; + } + do_catchsql_test 4.6 { + SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"' + } {1 {database disk image is malformed}} } -do_execsql_test 4.1 { - SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"' -} {8000} -do_execsql_test 4.2 { - SELECT quote(value) from t4_stat where id=0 -} {X'C03EC0B204C0A608'} -do_execsql_test 4.3 { - UPDATE t4_stat SET value = X'C03EC0B204C0A60800' WHERE id=0; -} -do_catchsql_test 4.4 { - SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"' -} {1 {database disk image is malformed}} -do_execsql_test 4.5 { - UPDATE t4_stat SET value = X'00C03EC0B204C0A608' WHERE id=0; -} -do_catchsql_test 4.6 { - SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"' -} {1 {database disk image is malformed}} #------------------------------------------------------------------------- # From 701caf1eb113e407e8c3185fd7b50ab4b6020906 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 May 2017 16:12:00 +0000 Subject: [PATCH 10/22] Invoke the SQLITE_READ authorizer callback with a NULL column name for any table referenced by a query but from when no columns are extracted. FossilOrigin-Name: 92ab1f7257d2866c69eaaf4cf85990677b911ef425e9c5a36a96978cccfb551c --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/select.c | 25 +++++++++++++++++++++---- test/auth.test | 23 +++++++++++++++++++++++ 4 files changed, 53 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 086883cb26..713b860e89 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scouple\sof\stest\sscripts\sso\sthat\sthey\swork\swith\n-DSQLITE_DISABLE_FTS4_DEFERRED\sbuilds. -D 2017-05-10T13:36:04.868 +C Invoke\sthe\sSQLITE_READ\sauthorizer\scallback\swith\sa\sNULL\scolumn\sname\sfor\sany\ntable\sreferenced\sby\sa\squery\sbut\sfrom\swhen\sno\scolumns\sare\sextracted. +D 2017-05-10T16:12:00.855 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -402,7 +402,7 @@ F src/printf.c 8757834f1b54dae512fb25eb1acc8e94a0d15dd2290b58f2563f65973265adb2 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c 3e518b962d932a997fae373366880fc028c75706 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac -F src/select.c 4f0adefaa5e9417459b07757e0f6060cac97930a86f0fba9797bab233ced66c0 +F src/select.c 275ad2697c50392f5b198bd1e79fc3559573e00ec504d46741f02b158b151e4d F src/shell.c a37d96b20b3644d0eb905df5aa7a0fcf9f6e73c15898337230c760a24a8df794 F src/sqlite.h.in eeb1da70a61d52e1d58e5b55446b85bbac571699421d3cf857421c56214013ce F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -526,7 +526,7 @@ F test/attach2.test 0ec5defa340363de6cd50fd595046465e9aaba2d F test/attach3.test c59d92791070c59272e00183b7353eeb94915976 F test/attach4.test 53bf502f17647c6d6c5add46dda6bac8b6f4665c F test/attachmalloc.test 3a4bfca9545bfe906a8d2e622de10fbac5b711b0 -F test/auth.test c6ede04bee65637ff354b43fc1235aa560c0863e +F test/auth.test 5caf9c6d8ed7b2a5a760b418f5f479bf20f07c9d8be29efa977130816c587089 F test/auth2.test 9eb7fce9f34bf1f50d3f366fb3e606be5a2000a1 F test/auth3.test 0d48b901cf111c14b4b1b5205c7d28f1a278190f F test/autoanalyze1.test b9cc3f32a990fa56669b668d237c6d53e983554ae80c0604992e18869a0b2dec @@ -1579,7 +1579,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 199b2a84992823b4687588a5ba20bec9c42579887068ac21caf08df3895f41ed -R aac74a43ca2ae14e0065de21361f39b3 -U dan -Z ef67ced9f009068f9285813993732c7e +P 30018d31068f3182d713a6cf09753b27b16a6f912d39a5e6c1363da83bec3125 +R 71bda7ed75ab8a12c29ef59bf658a73c +U drh +Z c7a714534fd3aa3ba10b343e69f7143d diff --git a/manifest.uuid b/manifest.uuid index b143d46fb2..004e20e367 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -30018d31068f3182d713a6cf09753b27b16a6f912d39a5e6c1363da83bec3125 \ No newline at end of file +92ab1f7257d2866c69eaaf4cf85990677b911ef425e9c5a36a96978cccfb551c \ No newline at end of file diff --git a/src/select.c b/src/select.c index 573a6fa11e..57d0b93fb7 100644 --- a/src/select.c +++ b/src/select.c @@ -5115,13 +5115,30 @@ int sqlite3Select( } #endif - /* Generate code for all sub-queries in the FROM clause + /* For each term in the FROM clause, do two things: + ** (1) Authorized unreferenced tables + ** (2) Generate code for all sub-queries */ -#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) for(i=0; inSrc; i++){ struct SrcList_item *pItem = &pTabList->a[i]; SelectDest dest; - Select *pSub = pItem->pSelect; + Select *pSub; + + /* Issue SQLITE_READ authorizations with a NULL column name for any tables that + ** are referenced but from which no values are extracted. Examples of where these + ** kinds of null SQLITE_READ authorizations would occur: + ** + ** SELECT count(*) FROM t1; -- SQLITE_READ t1 null + ** SELECT t1.* FROM t1, t2; -- SQLITE_READ t2 null + */ + if( pItem->colUsed==0 ){ + sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, pItem->zDatabase, 0); + } + +#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) + /* Generate code for all sub-queries in the FROM clause + */ + pSub = pItem->pSelect; if( pSub==0 ) continue; /* Sometimes the code for a subquery will be generated more than @@ -5242,8 +5259,8 @@ int sqlite3Select( } if( db->mallocFailed ) goto select_end; pParse->nHeight -= sqlite3SelectExprHeight(p); - } #endif + } /* Various elements of the SELECT copied into local variables for ** convenience */ diff --git a/test/auth.test b/test/auth.test index 0044fddebe..13c912f2f7 100644 --- a/test/auth.test +++ b/test/auth.test @@ -2478,6 +2478,29 @@ do_test auth-7.4 { SQLITE_READ t7 c main {} \ ] +# If a table is referenced but no columns are read from the table, +# that causes a single SQLITE_READ authorization with a NULL column +# name. +# +set ::authargs [list] +do_test auth-8.1 { + execsql {SELECT count(*) FROM t7} + set ::authargs +} [list \ + SQLITE_SELECT {} {} {} {} \ + SQLITE_FUNCTION {} count {} {} \ + SQLITE_READ t7 {} {} {} \ + ] +set ::authargs [list] + +do_test auth-8.2 { + execsql {SELECT t6.a FROM t6, t7} + set ::authargs +} [list \ + SQLITE_SELECT {} {} {} {} \ + SQLITE_READ t6 a main {} \ + SQLITE_READ t7 {} {} {} \ + ] rename proc {} rename proc_real proc From 0d236a8bb09cda9f036f1ccd2e864b1e8436f644 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 May 2017 16:33:48 +0000 Subject: [PATCH 11/22] Improved documentation for the SQLITE_READ authorizer callback. No code changes. FossilOrigin-Name: 92c5ea7047323d10f762877c5f56d20a3e609e8b55efcfe4880ef3048821ac1f --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 5 +++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 713b860e89..c7de2f4121 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Invoke\sthe\sSQLITE_READ\sauthorizer\scallback\swith\sa\sNULL\scolumn\sname\sfor\sany\ntable\sreferenced\sby\sa\squery\sbut\sfrom\swhen\sno\scolumns\sare\sextracted. -D 2017-05-10T16:12:00.855 +C Improved\sdocumentation\sfor\sthe\sSQLITE_READ\sauthorizer\scallback.\sNo\scode\schanges. +D 2017-05-10T16:33:48.398 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -404,7 +404,7 @@ F src/resolve.c 3e518b962d932a997fae373366880fc028c75706 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 275ad2697c50392f5b198bd1e79fc3559573e00ec504d46741f02b158b151e4d F src/shell.c a37d96b20b3644d0eb905df5aa7a0fcf9f6e73c15898337230c760a24a8df794 -F src/sqlite.h.in eeb1da70a61d52e1d58e5b55446b85bbac571699421d3cf857421c56214013ce +F src/sqlite.h.in a13eae90f740278018605ae30e561f9789c227dc3b87a684054e07022d721719 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 F src/sqliteInt.h aea3aa1b81e0d07d5b1c39b8c5a54a1dc5e4f10136cb63da392aef9eb2a5108b @@ -1579,7 +1579,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 30018d31068f3182d713a6cf09753b27b16a6f912d39a5e6c1363da83bec3125 -R 71bda7ed75ab8a12c29ef59bf658a73c +P 92ab1f7257d2866c69eaaf4cf85990677b911ef425e9c5a36a96978cccfb551c +R 27c465138f2b6ced9e3bfb0a0cffcf42 U drh -Z c7a714534fd3aa3ba10b343e69f7143d +Z 9935b613ce03d191d190a39d6894fd05 diff --git a/manifest.uuid b/manifest.uuid index 004e20e367..019f031677 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -92ab1f7257d2866c69eaaf4cf85990677b911ef425e9c5a36a96978cccfb551c \ No newline at end of file +92c5ea7047323d10f762877c5f56d20a3e609e8b55efcfe4880ef3048821ac1f \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 9e1eab4a2c..2761ce66db 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2673,6 +2673,7 @@ void sqlite3_randomness(int N, void *P); /* ** CAPI3REF: Compile-Time Authorization Callbacks ** METHOD: sqlite3 +** KEYWORDS: {authorizer callback} ** ** ^This routine registers an authorizer callback with a particular ** [database connection], supplied in the first argument. @@ -2710,6 +2711,10 @@ void sqlite3_randomness(int N, void *P); ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] ** return can be used to deny an untrusted user access to individual ** columns of a table. +** ^When a table is referenced by a [SELECT] but no column values are +** extracted from that table (for example in a query like +** "SELECT count(*) FROM tab") then the [SQLITE_READ] authorizer callback +** is invoked once for that table with a NULL column name. ** ^If the action code is [SQLITE_DELETE] and the callback returns ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the ** [truncate optimization] is disabled and all rows are deleted individually. From e69413978827e61d746c8394f8b6345d44d4a6ef Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 May 2017 19:42:52 +0000 Subject: [PATCH 12/22] Rename fields of the internal AuxData object to make them unique and easier to search for. FossilOrigin-Name: 2be9850cef6492e168243807c34af72119ffbe414027a12c4eda6c421b5b950d --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/vdbeInt.h | 8 ++++---- src/vdbeapi.c | 25 +++++++++++++------------ src/vdbeaux.c | 13 +++++++------ 5 files changed, 33 insertions(+), 31 deletions(-) diff --git a/manifest b/manifest index c7de2f4121..08456e389b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\sdocumentation\sfor\sthe\sSQLITE_READ\sauthorizer\scallback.\sNo\scode\schanges. -D 2017-05-10T16:33:48.398 +C Rename\sfields\sof\sthe\sinternal\sAuxData\sobject\sto\smake\sthem\sunique\sand\seasier\nto\ssearch\sfor. +D 2017-05-10T19:42:52.377 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -471,9 +471,9 @@ F src/util.c fc081ec6f63448dcd80d3dfad35baecfa104823254a815b081a4d9fe76e1db23 F src/vacuum.c 1fe4555cd8c9b263afb85b5b4ee3a4a4181ad569 F src/vdbe.c 9bac2bc2313ed682e6f48ccff6644d3263341885bfcbb3cdea7b720c722be2d5 F src/vdbe.h f7d1456e28875c2dcb964056589b5b7149ab7edf39edeca801596a39bb3d3848 -F src/vdbeInt.h c070bc5c8b913bda0ceaa995cd4d939ded5e4fc96cf7c3c1c602d41b871f8ade -F src/vdbeapi.c 5b08d82592bcff4470601fe78aaabebd50837860 -F src/vdbeaux.c b4999c744e59deba7ab8733640219ecbc771721b362d7e26ce4c57db575ad80b +F src/vdbeInt.h 1ecdacc1322fdd3241ec30c32a480e328a6f864e532dc53fae8e0ab68121aebf +F src/vdbeapi.c 736dce6a84d67ff7d8ebc5667048c5938fb2e5b2c6eff4a770e177a3f2797cb0 +F src/vdbeaux.c 436a903111fcc184bae36f9016100da0d294da294d526bf4702328da1ddcde4b F src/vdbeblob.c 359891617358deefc85bef7bcf787fa6b77facb9 F src/vdbemem.c 2c70f8f5de6c71fb99a22c5b83be9fab5c47cdd8e279fa44a8c00cfed06d7e89 F src/vdbesort.c e72fe02a2121386ba767ede8942e9450878b8fc873abf3d1b6824485f092570c @@ -1579,7 +1579,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 92ab1f7257d2866c69eaaf4cf85990677b911ef425e9c5a36a96978cccfb551c -R 27c465138f2b6ced9e3bfb0a0cffcf42 +P 92c5ea7047323d10f762877c5f56d20a3e609e8b55efcfe4880ef3048821ac1f +R a1dfb8ab33a614a9584dd808f82aa7c9 U drh -Z 9935b613ce03d191d190a39d6894fd05 +Z b1e990c3c0d70850169897a6b280d967 diff --git a/manifest.uuid b/manifest.uuid index 019f031677..d43601b4e1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -92c5ea7047323d10f762877c5f56d20a3e609e8b55efcfe4880ef3048821ac1f \ No newline at end of file +2be9850cef6492e168243807c34af72119ffbe414027a12c4eda6c421b5b950d \ No newline at end of file diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 6ef155b5c3..65e47c33f3 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -287,11 +287,11 @@ struct sqlite3_value { ** when the VM is halted (if not before). */ struct AuxData { - int iOp; /* Instruction number of OP_Function opcode */ - int iArg; /* Index of function argument. */ + int iAuxOp; /* Instruction number of OP_Function opcode */ + int iAuxArg; /* Index of function argument. */ void *pAux; /* Aux data pointer */ - void (*xDelete)(void *); /* Destructor for the aux data */ - AuxData *pNext; /* Next element in list */ + void (*xDeleteAux)(void*); /* Destructor for the aux data */ + AuxData *pNextAux; /* Next element in list */ }; /* diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 1f2699dc4d..214710e8f3 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -814,11 +814,12 @@ void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ #else assert( pCtx->pVdbe!=0 ); #endif - for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){ - if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break; + for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){ + if( pAuxData->iAuxOp==pCtx->iOp && pAuxData->iAuxArg==iArg ){ + return pAuxData->pAux; + } } - - return (pAuxData ? pAuxData->pAux : 0); + return 0; } /* @@ -843,26 +844,26 @@ void sqlite3_set_auxdata( assert( pVdbe!=0 ); #endif - for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){ - if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break; + for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){ + if( pAuxData->iAuxOp==pCtx->iOp && pAuxData->iAuxArg==iArg ) break; } if( pAuxData==0 ){ pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData)); if( !pAuxData ) goto failed; - pAuxData->iOp = pCtx->iOp; - pAuxData->iArg = iArg; - pAuxData->pNext = pVdbe->pAuxData; + pAuxData->iAuxOp = pCtx->iOp; + pAuxData->iAuxArg = iArg; + pAuxData->pNextAux = pVdbe->pAuxData; pVdbe->pAuxData = pAuxData; if( pCtx->fErrorOrAux==0 ){ pCtx->isError = 0; pCtx->fErrorOrAux = 1; } - }else if( pAuxData->xDelete ){ - pAuxData->xDelete(pAuxData->pAux); + }else if( pAuxData->xDeleteAux ){ + pAuxData->xDeleteAux(pAuxData->pAux); } pAuxData->pAux = pAux; - pAuxData->xDelete = xDelete; + pAuxData->xDeleteAux = xDelete; return; failed: diff --git a/src/vdbeaux.c b/src/vdbeaux.c index b41ed95b2e..7d0e767897 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -2968,16 +2968,17 @@ void sqlite3VdbeDeleteAuxData(sqlite3 *db, AuxData **pp, int iOp, int mask){ while( *pp ){ AuxData *pAux = *pp; if( (iOp<0) - || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & MASKBIT32(pAux->iArg)))) + || (pAux->iAuxOp==iOp + && (pAux->iAuxArg>31 || !(mask & MASKBIT32(pAux->iAuxArg)))) ){ - testcase( pAux->iArg==31 ); - if( pAux->xDelete ){ - pAux->xDelete(pAux->pAux); + testcase( pAux->iAuxArg==31 ); + if( pAux->xDeleteAux ){ + pAux->xDeleteAux(pAux->pAux); } - *pp = pAux->pNext; + *pp = pAux->pNextAux; sqlite3DbFree(db, pAux); }else{ - pp= &pAux->pNext; + pp= &pAux->pNextAux; } } } From 2336c935af3200ce80f266e07e12baa80a58ae9f Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 11 May 2017 12:05:23 +0000 Subject: [PATCH 13/22] Change the SQLITE_READ authorization call for unreferenced tables to use an empty string for the column name, as this is less likely to impact legacy authorization callbacks that assume column names are always non-NULL. FossilOrigin-Name: 4139953ab528f20fa346409810edcb22adb6c1edc9d22f40b1b077ef842a2441 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 16 ++++++++++++---- src/sqlite.h.in | 2 +- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 08456e389b..2ebdfee650 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rename\sfields\sof\sthe\sinternal\sAuxData\sobject\sto\smake\sthem\sunique\sand\seasier\nto\ssearch\sfor. -D 2017-05-10T19:42:52.377 +C Change\sthe\sSQLITE_READ\sauthorization\scall\sfor\sunreferenced\stables\sto\suse\nan\sempty\sstring\sfor\sthe\scolumn\sname,\sas\sthis\sis\sless\slikely\sto\simpact\slegacy\nauthorization\scallbacks\sthat\sassume\scolumn\snames\sare\salways\snon-NULL. +D 2017-05-11T12:05:23.185 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -402,9 +402,9 @@ F src/printf.c 8757834f1b54dae512fb25eb1acc8e94a0d15dd2290b58f2563f65973265adb2 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c 3e518b962d932a997fae373366880fc028c75706 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac -F src/select.c 275ad2697c50392f5b198bd1e79fc3559573e00ec504d46741f02b158b151e4d +F src/select.c d74b1cde1d9ca6d08bec50b60a5be19440273646bc8ae16648d748c38161d5b7 F src/shell.c a37d96b20b3644d0eb905df5aa7a0fcf9f6e73c15898337230c760a24a8df794 -F src/sqlite.h.in a13eae90f740278018605ae30e561f9789c227dc3b87a684054e07022d721719 +F src/sqlite.h.in a0b959830616ab1849f340285014610eed39562127ec847d9d00c6d75ce2dc2c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 F src/sqliteInt.h aea3aa1b81e0d07d5b1c39b8c5a54a1dc5e4f10136cb63da392aef9eb2a5108b @@ -1579,7 +1579,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 92c5ea7047323d10f762877c5f56d20a3e609e8b55efcfe4880ef3048821ac1f -R a1dfb8ab33a614a9584dd808f82aa7c9 +P 2be9850cef6492e168243807c34af72119ffbe414027a12c4eda6c421b5b950d +R cc2897f8815fc5891c267021967cf110 U drh -Z b1e990c3c0d70850169897a6b280d967 +Z 1c34db1a72aa8aee36e8a2e6fd670e70 diff --git a/manifest.uuid b/manifest.uuid index d43601b4e1..a6263cfe0a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2be9850cef6492e168243807c34af72119ffbe414027a12c4eda6c421b5b950d \ No newline at end of file +4139953ab528f20fa346409810edcb22adb6c1edc9d22f40b1b077ef842a2441 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 57d0b93fb7..eabbcc8c94 100644 --- a/src/select.c +++ b/src/select.c @@ -5124,15 +5124,23 @@ int sqlite3Select( SelectDest dest; Select *pSub; - /* Issue SQLITE_READ authorizations with a NULL column name for any tables that + /* Issue SQLITE_READ authorizations with a fake column name for any tables that ** are referenced but from which no values are extracted. Examples of where these ** kinds of null SQLITE_READ authorizations would occur: ** - ** SELECT count(*) FROM t1; -- SQLITE_READ t1 null - ** SELECT t1.* FROM t1, t2; -- SQLITE_READ t2 null + ** SELECT count(*) FROM t1; -- SQLITE_READ t1."" + ** SELECT t1.* FROM t1, t2; -- SQLITE_READ t2."" + ** + ** The fake column name is an empty string. It is possible for a table to + ** have a column named by the empty string, in which case there is no way to + ** distinguish between an unreferenced table and an actual reference to the + ** "" column. The original design was for the fake column name to be a NULL, + ** which would be unambiguous. But legacy authorization callbacks might + ** assume the column name is non-NULL and segfault. The use of an empty string + ** for the fake column name seems safer. */ if( pItem->colUsed==0 ){ - sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, pItem->zDatabase, 0); + sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, "", pItem->zDatabase); } #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 2761ce66db..74edcb56b5 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2714,7 +2714,7 @@ void sqlite3_randomness(int N, void *P); ** ^When a table is referenced by a [SELECT] but no column values are ** extracted from that table (for example in a query like ** "SELECT count(*) FROM tab") then the [SQLITE_READ] authorizer callback -** is invoked once for that table with a NULL column name. +** is invoked once for that table with a column name that is an empty string. ** ^If the action code is [SQLITE_DELETE] and the callback returns ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the ** [truncate optimization] is disabled and all rows are deleted individually. From ee92eb80dbd0ee978c1ca33253a49e12ba7d3a3c Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 11 May 2017 12:27:21 +0000 Subject: [PATCH 14/22] Improvements to the sqlite3_set_authorizer() documentation. FossilOrigin-Name: 47629b1911e52445aad8ea969137bddf0019c55b4a4f0de8e77decb6a434c8a2 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 2ebdfee650..56f4080b37 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sSQLITE_READ\sauthorization\scall\sfor\sunreferenced\stables\sto\suse\nan\sempty\sstring\sfor\sthe\scolumn\sname,\sas\sthis\sis\sless\slikely\sto\simpact\slegacy\nauthorization\scallbacks\sthat\sassume\scolumn\snames\sare\salways\snon-NULL. -D 2017-05-11T12:05:23.185 +C Improvements\sto\sthe\ssqlite3_set_authorizer()\sdocumentation. +D 2017-05-11T12:27:21.511 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -404,7 +404,7 @@ F src/resolve.c 3e518b962d932a997fae373366880fc028c75706 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c d74b1cde1d9ca6d08bec50b60a5be19440273646bc8ae16648d748c38161d5b7 F src/shell.c a37d96b20b3644d0eb905df5aa7a0fcf9f6e73c15898337230c760a24a8df794 -F src/sqlite.h.in a0b959830616ab1849f340285014610eed39562127ec847d9d00c6d75ce2dc2c +F src/sqlite.h.in f70c07c37d5ad7fc2dbe6f6be57253ed77b7aecf9adfe01a8490e26f7bdd8d3f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 F src/sqliteInt.h aea3aa1b81e0d07d5b1c39b8c5a54a1dc5e4f10136cb63da392aef9eb2a5108b @@ -1579,7 +1579,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 2be9850cef6492e168243807c34af72119ffbe414027a12c4eda6c421b5b950d -R cc2897f8815fc5891c267021967cf110 +P 4139953ab528f20fa346409810edcb22adb6c1edc9d22f40b1b077ef842a2441 +R 439d581bae700f41f9bd0f879ef19838 U drh -Z 1c34db1a72aa8aee36e8a2e6fd670e70 +Z 3b3b1bb649cf5fdc934ca94a70bf1f6d diff --git a/manifest.uuid b/manifest.uuid index a6263cfe0a..3423e7f9c4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4139953ab528f20fa346409810edcb22adb6c1edc9d22f40b1b077ef842a2441 \ No newline at end of file +47629b1911e52445aad8ea969137bddf0019c55b4a4f0de8e77decb6a434c8a2 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 74edcb56b5..eb108138b5 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2701,8 +2701,10 @@ void sqlite3_randomness(int N, void *P); ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter ** to the callback is an integer [SQLITE_COPY | action code] that specifies ** the particular action to be authorized. ^The third through sixth parameters -** to the callback are zero-terminated strings that contain additional -** details about the action to be authorized. +** to the callback are either NULL pointers or zero-terminated strings +** that contain additional details about the action to be authorized. +** Applications must always be prepared to encounter a NULL pointer in any +** of the third through the sixth parameters of the authorization callback. ** ** ^If the action code is [SQLITE_READ] ** and the callback returns [SQLITE_IGNORE] then the From 9418921c599b7ce7e9ffcc2b3b00f3ff4391b964 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 11 May 2017 13:43:57 +0000 Subject: [PATCH 15/22] New requirements marks and documentation for the authorizer. FossilOrigin-Name: 3980ea0911b3ad3f86d7a7bdc6503f233315c274f473e18831e13eda2c238eeb --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/auth.c | 12 ++++++++++++ src/delete.c | 9 ++++++++- src/tclsqlite.c | 7 +++++++ test/auth.test | 23 +++++++++++++++++++++++ test/auth3.test | 4 ++++ 7 files changed, 65 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 56f4080b37..de491ca0b8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\ssqlite3_set_authorizer()\sdocumentation. -D 2017-05-11T12:27:21.511 +C New\srequirements\smarks\sand\sdocumentation\sfor\sthe\sauthorizer. +D 2017-05-11T13:43:57.931 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -341,7 +341,7 @@ F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 3b23977620ce9662ac54443f65b87ba996e36121 F src/analyze.c 0d0ccf7520a201d8747ea2f02c92c26e26f801bc161f714f27b9f7630dde0421 F src/attach.c 8c476f8bd5d2afe11d925f890d30e527e5b0ce43 -F src/auth.c 930b376a9c56998557367e6f7f8aaeac82a2a792 +F src/auth.c 79f96c6f33bf0e5da8d1c282cee5ebb1852bb8a6ccca3e485d7c459b035d9c3c F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca @@ -354,7 +354,7 @@ F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 47d91a25ad8f199a71a5b1b7b169d6dd0d6e98c5719eca801568798743d1161c F src/date.c cc42a41c7422389860d40419a5e3bce5eaf6e7835c3ba2677751dc653550a5c7 F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d -F src/delete.c 0d9d5549d42e79ce4d82ff1db1e6c81e36d2f67c +F src/delete.c 665e705641e5815c3f32d05820d1a5aa630274e568af73f377fdbc614fcf40b4 F src/expr.c c980b2c9291a12a0f1de1e1e1aaa72c4579ded716e1e3a3ac1c3d898ba0df0a1 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c db65492ae549c3b548c9ef1f279ce1684f1c473b116e1c56a90878cd5dcf968d @@ -411,7 +411,7 @@ F src/sqliteInt.h aea3aa1b81e0d07d5b1c39b8c5a54a1dc5e4f10136cb63da392aef9eb2a510 F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 -F src/tclsqlite.c 6c2151b6d8d98e183a04466d40df8889c0574d79 +F src/tclsqlite.c c8cf60d0c5411d5e70e7c136470d29dbe760d250f55198b71682c67086524e4a F src/test1.c c99f0442918a7a5d5b68a95d6024c211989e6c782c15ced5a558994baaf76a5e F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5 F src/test3.c d03f5b5da9a2410b7a91c64b0d3306ed28ab6fee @@ -526,9 +526,9 @@ F test/attach2.test 0ec5defa340363de6cd50fd595046465e9aaba2d F test/attach3.test c59d92791070c59272e00183b7353eeb94915976 F test/attach4.test 53bf502f17647c6d6c5add46dda6bac8b6f4665c F test/attachmalloc.test 3a4bfca9545bfe906a8d2e622de10fbac5b711b0 -F test/auth.test 5caf9c6d8ed7b2a5a760b418f5f479bf20f07c9d8be29efa977130816c587089 +F test/auth.test 32ee0e98593c9ea73870d9b0c8e50c2f43371d9fede388c09e9477c6bf5f8aab F test/auth2.test 9eb7fce9f34bf1f50d3f366fb3e606be5a2000a1 -F test/auth3.test 0d48b901cf111c14b4b1b5205c7d28f1a278190f +F test/auth3.test db21405b95257c24d29273b6b31d0efc59e1d337e3d5804ba2d1fd4897b1ae49 F test/autoanalyze1.test b9cc3f32a990fa56669b668d237c6d53e983554ae80c0604992e18869a0b2dec F test/autoinc.test 6ae8fb69c9f656962464ae4e6667045d0dfc3b46 F test/autoindex1.test 14b63a9f1e405fe6d5bfc8c8d00249c2ebaf13ea @@ -1579,7 +1579,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 4139953ab528f20fa346409810edcb22adb6c1edc9d22f40b1b077ef842a2441 -R 439d581bae700f41f9bd0f879ef19838 +P 47629b1911e52445aad8ea969137bddf0019c55b4a4f0de8e77decb6a434c8a2 +R 0c6451e367b2cefc9e69fa0621b4d931 U drh -Z 3b3b1bb649cf5fdc934ca94a70bf1f6d +Z 18c2f8082a296f2f15ab41c2498f7cb3 diff --git a/manifest.uuid b/manifest.uuid index 3423e7f9c4..4e27390c06 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -47629b1911e52445aad8ea969137bddf0019c55b4a4f0de8e77decb6a434c8a2 \ No newline at end of file +3980ea0911b3ad3f86d7a7bdc6503f233315c274f473e18831e13eda2c238eeb \ No newline at end of file diff --git a/src/auth.c b/src/auth.c index 77a95d4a8f..dabc435b4a 100644 --- a/src/auth.c +++ b/src/auth.c @@ -216,6 +216,18 @@ int sqlite3AuthCheck( if( db->xAuth==0 ){ return SQLITE_OK; } + + /* EVIDENCE-OF: R-43249-19882 The third through sixth parameters to the + ** callback are either NULL pointers or zero-terminated strings that + ** contain additional details about the action to be authorized. + ** + ** The following testcase() macros show that any of the 3rd through 6th + ** parameters can be either NULL or a string. */ + testcase( zArg1==0 ); + testcase( zArg2==0 ); + testcase( zArg3==0 ); + testcase( pParse->zAuthContext==0 ); + rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext #ifdef SQLITE_USER_AUTHENTICATION ,db->auth.zAuthUser diff --git a/src/delete.c b/src/delete.c index 0683f9b9dd..03c3417358 100644 --- a/src/delete.c +++ b/src/delete.c @@ -350,7 +350,14 @@ void sqlite3DeleteFrom( /* Special case: A DELETE without a WHERE clause deletes everything. ** It is easier just to erase the whole table. Prior to version 3.6.5, ** this optimization caused the row change count (the value returned by - ** API function sqlite3_count_changes) to be set incorrectly. */ + ** API function sqlite3_count_changes) to be set incorrectly. + ** + ** The "rcauth==SQLITE_OK" terms is the + ** IMPLEMENATION-OF: R-17228-37124 If the action code is SQLITE_DELETE and + ** the callback returns SQLITE_IGNORE then the DELETE operation proceeds but + ** the truncate optimization is disabled and all rows are deleted + ** individually. + */ if( rcauth==SQLITE_OK && pWhere==0 && !bComplex diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 9df023b45c..754775e8e8 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -1033,9 +1033,16 @@ static int auth_callback( Tcl_DString str; int rc; const char *zReply; + /* EVIDENCE-OF: R-38590-62769 The first parameter to the authorizer + ** callback is a copy of the third parameter to the + ** sqlite3_set_authorizer() interface. + */ SqliteDb *pDb = (SqliteDb*)pArg; if( pDb->disableAuth ) return SQLITE_OK; + /* EVIDENCE-OF: R-56518-44310 The second parameter to the callback is an + ** integer action code that specifies the particular action to be + ** authorized. */ switch( code ){ case SQLITE_COPY : zCode="SQLITE_COPY"; break; case SQLITE_CREATE_INDEX : zCode="SQLITE_CREATE_INDEX"; break; diff --git a/test/auth.test b/test/auth.test index 13c912f2f7..40a92e74e1 100644 --- a/test/auth.test +++ b/test/auth.test @@ -36,12 +36,20 @@ proc_real proc {name arguments script} { do_test auth-1.1.1 { db close set ::DB [sqlite3 db test.db] + proc authx {code arg1 arg2 arg3 arg4 args} {return SQLITE_DENY} proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { return SQLITE_DENY } return SQLITE_OK } + db authorizer ::authx + # EVIDENCE-OF: R-03993-24285 Only a single authorizer can be in place on + # a database connection at a time. Each call to sqlite3_set_authorizer + # overrides the previous call. + # + # The authx authorizer above is overridden by the auth authorizer below + # authx is never invoked. db authorizer ::auth catchsql {CREATE TABLE t1(a,b,c)} } {1 {not authorized}} @@ -60,6 +68,9 @@ do_test auth-1.1.4 { do_test auth-1.2 { execsql {SELECT name FROM sqlite_master} } {} +# EVIDENCE-OF: R-04452-49349 When the callback returns SQLITE_DENY, the +# sqlite3_prepare_v2() or equivalent call that triggered the authorizer +# will fail with an error message explaining that access is denied. do_test auth-1.3.1 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_TABLE"} { @@ -312,6 +323,10 @@ ifcapable attach { } {1 {access to two.t2.b is prohibited}} execsql {DETACH DATABASE two} } +# EVIDENCE-OF: R-38392-49970 If the action code is SQLITE_READ and the +# callback returns SQLITE_IGNORE then the prepared statement statement +# is constructed to substitute a NULL value in place of the table column +# that would have been read if SQLITE_OK had been returned. do_test auth-1.36 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} { @@ -1606,6 +1621,8 @@ do_test auth-1.248 { set ::authargs } {COMMIT {} {} {}} do_test auth-1.249 { + # EVIDENCE-OF: R-52112-44167 Disable the authorizer by installing a NULL + # callback. db authorizer {} catchsql {ROLLBACK} } {0 {}} @@ -2482,6 +2499,12 @@ do_test auth-7.4 { # that causes a single SQLITE_READ authorization with a NULL column # name. # +# EVIDENCE-OF: R-31520-16302 When a table is referenced by a SELECT but +# no column values are extracted from that table (for example in a query +# like "SELECT count(*) FROM tab") then the SQLITE_READ authorizer +# callback is invoked once for that table with a column name that is an +# empty string. +# set ::authargs [list] do_test auth-8.1 { execsql {SELECT count(*) FROM t7} diff --git a/test/auth3.test b/test/auth3.test index 013486e5a0..4377bcdc0f 100644 --- a/test/auth3.test +++ b/test/auth3.test @@ -53,6 +53,10 @@ do_test auth3.1.2 { set ::authcode SQLITE_DENY catchsql { DELETE FROM t1 } } {1 {not authorized}} +# EVIDENCE-OF: R-64962-58611 If the authorizer callback returns any +# value other than SQLITE_IGNORE, SQLITE_OK, or SQLITE_DENY then the +# sqlite3_prepare_v2() or equivalent call that triggered the authorizer +# will fail with an error message. do_test auth3.1.3 { set ::authcode SQLITE_INVALID catchsql { DELETE FROM t1 } From f7fa4e71f4ec1b14768fcda2ab3a7df909a738b4 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 11 May 2017 15:20:18 +0000 Subject: [PATCH 16/22] Negative N values in sqlite3_get_auxdata() and sqlite3_set_auxdata() can be used to access an auxiliary data cache over all functions in a single prepared statement. FossilOrigin-Name: ff5306752e83e760255a10f20168c0f090929a4fee2a5f720dfab36f0ee72fae --- manifest | 19 +++++++++++-------- manifest.uuid | 2 +- src/sqlite.h.in | 13 +++++++++---- src/vdbeapi.c | 19 ++++++++++++++++--- src/vdbeaux.c | 3 ++- 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index de491ca0b8..1276b9e334 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C New\srequirements\smarks\sand\sdocumentation\sfor\sthe\sauthorizer. -D 2017-05-11T13:43:57.931 +C Negative\sN\svalues\sin\ssqlite3_get_auxdata()\sand\ssqlite3_set_auxdata()\scan\sbe\nused\sto\saccess\san\sauxiliary\sdata\scache\sover\sall\sfunctions\sin\sa\ssingle\sprepared\s\nstatement. +D 2017-05-11T15:20:18.112 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -404,7 +404,7 @@ F src/resolve.c 3e518b962d932a997fae373366880fc028c75706 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c d74b1cde1d9ca6d08bec50b60a5be19440273646bc8ae16648d748c38161d5b7 F src/shell.c a37d96b20b3644d0eb905df5aa7a0fcf9f6e73c15898337230c760a24a8df794 -F src/sqlite.h.in f70c07c37d5ad7fc2dbe6f6be57253ed77b7aecf9adfe01a8490e26f7bdd8d3f +F src/sqlite.h.in 8dd468837a4f6d76713e3a4cc65bea48095009038593d41040ab46c1b351197f F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 F src/sqliteInt.h aea3aa1b81e0d07d5b1c39b8c5a54a1dc5e4f10136cb63da392aef9eb2a5108b @@ -472,8 +472,8 @@ F src/vacuum.c 1fe4555cd8c9b263afb85b5b4ee3a4a4181ad569 F src/vdbe.c 9bac2bc2313ed682e6f48ccff6644d3263341885bfcbb3cdea7b720c722be2d5 F src/vdbe.h f7d1456e28875c2dcb964056589b5b7149ab7edf39edeca801596a39bb3d3848 F src/vdbeInt.h 1ecdacc1322fdd3241ec30c32a480e328a6f864e532dc53fae8e0ab68121aebf -F src/vdbeapi.c 736dce6a84d67ff7d8ebc5667048c5938fb2e5b2c6eff4a770e177a3f2797cb0 -F src/vdbeaux.c 436a903111fcc184bae36f9016100da0d294da294d526bf4702328da1ddcde4b +F src/vdbeapi.c dc904b3c5e459727993c2421e653e29d63223846d129fae98adc782b0a996481 +F src/vdbeaux.c 01dcf59b2a96bd3cc9db8c0d7f266518d113587459a2b3316279c4f9c90f28a9 F src/vdbeblob.c 359891617358deefc85bef7bcf787fa6b77facb9 F src/vdbemem.c 2c70f8f5de6c71fb99a22c5b83be9fab5c47cdd8e279fa44a8c00cfed06d7e89 F src/vdbesort.c e72fe02a2121386ba767ede8942e9450878b8fc873abf3d1b6824485f092570c @@ -1579,7 +1579,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 47629b1911e52445aad8ea969137bddf0019c55b4a4f0de8e77decb6a434c8a2 -R 0c6451e367b2cefc9e69fa0621b4d931 +P 3980ea0911b3ad3f86d7a7bdc6503f233315c274f473e18831e13eda2c238eeb +R dd46ebd5214a15a152d68d903a52e3e5 +T *branch * auxdata-cache +T *sym-auxdata-cache * +T -sym-trunk * U drh -Z 18c2f8082a296f2f15ab41c2498f7cb3 +Z 41e6a797cec545b1cb4bc140fa542902 diff --git a/manifest.uuid b/manifest.uuid index 4e27390c06..5ff8b63dbf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3980ea0911b3ad3f86d7a7bdc6503f233315c274f473e18831e13eda2c238eeb \ No newline at end of file +ff5306752e83e760255a10f20168c0f090929a4fee2a5f720dfab36f0ee72fae \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index eb108138b5..d836e97058 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -4763,10 +4763,11 @@ sqlite3 *sqlite3_context_db_handle(sqlite3_context*); ** the compiled regular expression can be reused on multiple ** invocations of the same function. ** -** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata -** associated by the sqlite3_set_auxdata() function with the Nth argument -** value to the application-defined function. ^If there is no metadata -** associated with the function argument, this sqlite3_get_auxdata() interface +** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata +** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument +** value to the application-defined function. ^N is zero for the left-most +** function argument. ^If there is no metadata +** associated with the function argument, the sqlite3_get_auxdata(C,N) interface ** returns a NULL pointer. ** ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th @@ -4797,6 +4798,10 @@ sqlite3 *sqlite3_context_db_handle(sqlite3_context*); ** function parameters that are compile-time constants, including literal ** values and [parameters] and expressions composed from the same.)^ ** +** The value of the N parameter to these interfaces should be non-negative. +** Future enhancements may make use of negative N values to define new +** kinds of function caching behavior. +** ** These routines must be called from the same thread in which ** the SQL function is running. */ diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 214710e8f3..bdc5f0320d 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -804,6 +804,12 @@ void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){ /* ** Return the auxiliary data pointer, if any, for the iArg'th argument to ** the user-function defined by pCtx. +** +** The left-most argument is 0. +** +** Undocumented behavior: If iArg is negative then access a cache of +** auxiliary data pointers that is available to all functions within a +** single prepared statement. The iArg values must match. */ void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ AuxData *pAuxData; @@ -815,7 +821,7 @@ void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ assert( pCtx->pVdbe!=0 ); #endif for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){ - if( pAuxData->iAuxOp==pCtx->iOp && pAuxData->iAuxArg==iArg ){ + if( pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){ return pAuxData->pAux; } } @@ -826,6 +832,12 @@ void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ ** Set the auxiliary data pointer and delete function, for the iArg'th ** argument to the user-function defined by pCtx. Any previous value is ** deleted by calling the delete function specified when it was set. +** +** The left-most argument is 0. +** +** Undocumented behavior: If iArg is negative then make the data available +** to all functions within the current prepared statement using iArg as an +** access code. */ void sqlite3_set_auxdata( sqlite3_context *pCtx, @@ -837,7 +849,6 @@ void sqlite3_set_auxdata( Vdbe *pVdbe = pCtx->pVdbe; assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); - if( iArg<0 ) goto failed; #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 if( pVdbe==0 ) goto failed; #else @@ -845,7 +856,9 @@ void sqlite3_set_auxdata( #endif for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){ - if( pAuxData->iAuxOp==pCtx->iOp && pAuxData->iAuxArg==iArg ) break; + if( pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){ + break; + } } if( pAuxData==0 ){ pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData)); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 7d0e767897..c1b91a6d2c 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -2968,7 +2968,8 @@ void sqlite3VdbeDeleteAuxData(sqlite3 *db, AuxData **pp, int iOp, int mask){ while( *pp ){ AuxData *pAux = *pp; if( (iOp<0) - || (pAux->iAuxOp==iOp + || (pAux->iAuxOp==iOp + && pAux->iAuxArg>=0 && (pAux->iAuxArg>31 || !(mask & MASKBIT32(pAux->iAuxArg)))) ){ testcase( pAux->iAuxArg==31 ); From 3fb153cb297158830ce49edcbb0ccdd5a84179d5 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 11 May 2017 16:49:59 +0000 Subject: [PATCH 17/22] Cache the JSON parse used by json_extract(). FossilOrigin-Name: 44ca6c2c4639f3c50ae9233ee299ff0fc4566462c31f28d8676f8de7ffdcd7f0 --- ext/misc/json1.c | 81 +++++++++++++++++++++++++++++++++++++++--------- manifest | 15 ++++----- manifest.uuid | 2 +- 3 files changed, 74 insertions(+), 24 deletions(-) diff --git a/ext/misc/json1.c b/ext/misc/json1.c index 2ef6e128eb..c1d2334a13 100644 --- a/ext/misc/json1.c +++ b/ext/misc/json1.c @@ -171,6 +171,7 @@ struct JsonParse { u8 oom; /* Set to true if out of memory */ u8 nErr; /* Number of errors seen */ u16 iDepth; /* Nesting depth */ + int nJson; /* Length of the zJson string in bytes */ }; /* @@ -413,6 +414,14 @@ static void jsonParseReset(JsonParse *pParse){ pParse->aUp = 0; } +/* +** Free a JsonParse object that was obtained from sqlite3_malloc(). +*/ +static void jsonParseFree(JsonParse *pParse){ + jsonParseReset(pParse); + sqlite3_free(pParse); +} + /* ** Convert the JsonNode pNode into a pure JSON string and ** append to pOut. Subsubstructure is also included. Return @@ -964,6 +973,49 @@ static int jsonParseFindParents(JsonParse *pParse){ return SQLITE_OK; } +/* +** Magic number used for the JSON parse cache in sqlite3_get_auxdata() +*/ +#define JSON_CACHE_ID (-429938) + +/* +** Obtain a complete parse of the JSON found in the first argument +** of the argv array. Use the sqlite3_get_auxdata() cache for this +** parse if it is available. If the cache is not available or if it +** is no longer valid, parse the JSON again and return the new parse, +** and also register the new parse so that it will be available for +** future sqlite3_get_auxdata() calls. +*/ +static JsonParse *jsonParseCached( + sqlite3_context *pCtx, + sqlite3_value **argv +){ + const char *zJson = (const char*)sqlite3_value_text(argv[0]); + int nJson = sqlite3_value_bytes(argv[0]); + JsonParse *p; + if( zJson==0 ) return 0; + p = (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID); + if( p && p->nJson==nJson && memcmp(p->zJson,zJson,nJson)==0 ){ + p->nErr = 0; + return p; /* The cached entry matches, so return it */ + } + p = sqlite3_malloc( sizeof(*p) + nJson + 1 ); + if( p==0 ){ + sqlite3_result_error_nomem(pCtx); + return 0; + } + memset(p, 0, sizeof(*p)); + p->zJson = (char*)&p[1]; + memcpy((char*)p->zJson, zJson, nJson+1); + if( jsonParse(p, pCtx, p->zJson) ){ + sqlite3_free(p); + return 0; + } + p->nJson = nJson; + sqlite3_set_auxdata(pCtx, JSON_CACHE_ID, p, (void(*)(void*))jsonParseFree); + return (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID); +} + /* ** Compare the OBJECT label at pNode against zKey,nKey. Return true on ** a match. @@ -1329,29 +1381,30 @@ static void jsonArrayLengthFunc( int argc, sqlite3_value **argv ){ - JsonParse x; /* The parse */ + JsonParse *p; /* The parse */ sqlite3_int64 n = 0; u32 i; JsonNode *pNode; - if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; - assert( x.nNode ); + p = jsonParseCached(ctx, argv); + if( p==0 ) return; + assert( p->nNode ); if( argc==2 ){ const char *zPath = (const char*)sqlite3_value_text(argv[1]); - pNode = jsonLookup(&x, zPath, 0, ctx); + pNode = jsonLookup(p, zPath, 0, ctx); }else{ - pNode = x.aNode; + pNode = p->aNode; } if( pNode==0 ){ - x.nErr = 1; - }else if( pNode->eType==JSON_ARRAY ){ + return; + } + if( pNode->eType==JSON_ARRAY ){ assert( (pNode->jnFlags & JNODE_APPEND)==0 ); for(i=1; i<=pNode->n; n++){ i += jsonNodeSize(&pNode[i]); } } - if( x.nErr==0 ) sqlite3_result_int64(ctx, n); - jsonParseReset(&x); + sqlite3_result_int64(ctx, n); } /* @@ -1367,20 +1420,21 @@ static void jsonExtractFunc( int argc, sqlite3_value **argv ){ - JsonParse x; /* The parse */ + JsonParse *p; /* The parse */ JsonNode *pNode; const char *zPath; JsonString jx; int i; if( argc<2 ) return; - if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; + p = jsonParseCached(ctx, argv); + if( p==0 ) return; jsonInit(&jx, ctx); jsonAppendChar(&jx, '['); for(i=1; inErr ) break; if( argc>2 ){ jsonAppendSeparator(&jx); if( pNode ){ @@ -1398,7 +1452,6 @@ static void jsonExtractFunc( sqlite3_result_subtype(ctx, JSON_SUBTYPE); } jsonReset(&jx); - jsonParseReset(&x); } /* This is the RFC 7396 MergePatch algorithm. diff --git a/manifest b/manifest index 1276b9e334..9d3c8a8085 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Negative\sN\svalues\sin\ssqlite3_get_auxdata()\sand\ssqlite3_set_auxdata()\scan\sbe\nused\sto\saccess\san\sauxiliary\sdata\scache\sover\sall\sfunctions\sin\sa\ssingle\sprepared\s\nstatement. -D 2017-05-11T15:20:18.112 +C Cache\sthe\sJSON\sparse\sused\sby\sjson_extract(). +D 2017-05-11T16:49:59.245 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -219,7 +219,7 @@ F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c -F ext/misc/json1.c bd3bbdefb6024c5e40287d61cdf876587c18a6e60fbe8cd6bcdde10eefd14bb1 +F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 F ext/misc/memvfs.c e5225bc22e79dde6b28380f3a068ddf600683a33 F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/percentile.c 92699c8cd7d517ff610e6037e56506f8904dae2e @@ -1579,10 +1579,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 3980ea0911b3ad3f86d7a7bdc6503f233315c274f473e18831e13eda2c238eeb -R dd46ebd5214a15a152d68d903a52e3e5 -T *branch * auxdata-cache -T *sym-auxdata-cache * -T -sym-trunk * +P ff5306752e83e760255a10f20168c0f090929a4fee2a5f720dfab36f0ee72fae +R cae1848a63e8e13e207beadd6dc14b62 U drh -Z 41e6a797cec545b1cb4bc140fa542902 +Z e9ec1c79d7987d6b2eda6f4466e2dc4b diff --git a/manifest.uuid b/manifest.uuid index 5ff8b63dbf..a0274addc8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ff5306752e83e760255a10f20168c0f090929a4fee2a5f720dfab36f0ee72fae \ No newline at end of file +44ca6c2c4639f3c50ae9233ee299ff0fc4566462c31f28d8676f8de7ffdcd7f0 \ No newline at end of file From 6b4fbabd6a61933a230d4707c3c14d6f12d03d30 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 11 May 2017 18:14:06 +0000 Subject: [PATCH 18/22] Do not save the state of an fts5 merge operation mid-way through an input term, even if no previous entry for that term has caused any output. Doing so may corrupt the FTS index. FossilOrigin-Name: 9a2de4f05fabf7e725666fb8824ae1adad56834d7ae4f2e118375bb6f9c0ae77 --- ext/fts5/fts5_index.c | 13 ++++++--- ext/fts5/test/fts5delete.test | 54 +++++++++++++++++++++++++++++++++++ manifest | 15 +++++----- manifest.uuid | 2 +- 4 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 ext/fts5/test/fts5delete.test diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 3d6616bd91..6dc9f8470e 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4192,6 +4192,7 @@ static void fts5IndexMergeLevel( int bOldest; /* True if the output segment is the oldest */ int eDetail = p->pConfig->eDetail; const int flags = FTS5INDEX_QUERY_NOOUTPUT; + int bTermWritten = 0; /* True if current term already output */ assert( iLvlnLevel ); assert( pLvl->nMerge<=pLvl->nSeg ); @@ -4245,18 +4246,22 @@ static void fts5IndexMergeLevel( int nTerm; const u8 *pTerm; - /* Check for key annihilation. */ - if( pSegIter->nPos==0 && (bOldest || pSegIter->bDel==0) ) continue; - pTerm = fts5MultiIterTerm(pIter, &nTerm); if( nTerm!=term.n || memcmp(pTerm, term.p, nTerm) ){ if( pnRem && writer.nLeafWritten>nRem ){ break; } + fts5BufferSet(&p->rc, &term, nTerm, pTerm); + bTermWritten =0; + } + /* Check for key annihilation. */ + if( pSegIter->nPos==0 && (bOldest || pSegIter->bDel==0) ) continue; + + if( p->rc==SQLITE_OK && bTermWritten==0 ){ /* This is a new term. Append a term to the output segment. */ fts5WriteAppendTerm(p, &writer, nTerm, pTerm); - fts5BufferSet(&p->rc, &term, nTerm, pTerm); + bTermWritten = 1; } /* Append the rowid to the output */ diff --git a/ext/fts5/test/fts5delete.test b/ext/fts5/test/fts5delete.test new file mode 100644 index 0000000000..15d62c552d --- /dev/null +++ b/ext/fts5/test/fts5delete.test @@ -0,0 +1,54 @@ +# 2017 May 12 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# This 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 fts5delete + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} +fts5_aux_test_functions db + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(x); + WITH s(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<5000 + ) + INSERT INTO t1(rowid, x) SELECT i, (i/2)*2 FROM s; +} + +do_test 1.1 { + execsql BEGIN + for {set i 1} {$i<=5000} {incr i} { + if {$i % 2} { + execsql { INSERT INTO t1 VALUES($i) } + } else { + execsql { DELETE FROM t1 WHERE rowid = $i } + } + } + execsql COMMIT +} {} + +do_test 1.2 { + execsql { INSERT INTO t1(t1, rank) VALUES('usermerge', 2); } + for {set i 0} {$i < 5} {incr i} { + execsql { INSERT INTO t1(t1, rank) VALUES('merge', 1) } + execsql { INSERT INTO t1(t1) VALUES('integrity-check') } + } +} {} + +finish_test + diff --git a/manifest b/manifest index de491ca0b8..d5d926e205 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C New\srequirements\smarks\sand\sdocumentation\sfor\sthe\sauthorizer. -D 2017-05-11T13:43:57.931 +C Do\snot\ssave\sthe\sstate\sof\san\sfts5\smerge\soperation\smid-way\sthrough\san\sinput\nterm,\seven\sif\sno\sprevious\sentry\sfor\sthat\sterm\shas\scaused\sany\soutput.\sDoing\sso\nmay\scorrupt\sthe\sFTS\sindex. +D 2017-05-11T18:14:06.985 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -105,7 +105,7 @@ F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 F ext/fts5/fts5_expr.c f2825f714d91bbe62ab5820aee9ad12e0c94205b2a01725eaa9072415ae9ff1c F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 -F ext/fts5/fts5_index.c dc25123df20c60492857de491a194dab4b46ace217b8483bda305d357bf6431d +F ext/fts5/fts5_index.c 9ce10106f42f8b84278a8ea859940224e2af5f0cc882f909364469f6f52769cb F ext/fts5/fts5_main.c 1ba0e7806886c1bc16e20d0dde1c2b535d1aeb98cbbb937c4c3e064af5ac6f03 F ext/fts5/fts5_storage.c 7750986004f3f0c94619a85ecb5dd6cbef53e5e3853488e8a906c269d4d11db6 F ext/fts5/fts5_tcl.c 4a901f00c8553740dba63511603f5527d741c26a @@ -144,6 +144,7 @@ F ext/fts5/test/fts5content.test 9a952c95518a14182dc3b59e3c8fa71cda82a4e1 F ext/fts5/test/fts5corrupt.test c2ad090192708150d50d961278df10ae7a4b8b62 F ext/fts5/test/fts5corrupt2.test 128eb6e2d26b09f4da339e581f424b3321e0fdaa F ext/fts5/test/fts5corrupt3.test f77f65e386231daf62902466b40ff998b2c8ce4f +F ext/fts5/test/fts5delete.test 0585395660889090a6a04b0cac0e70b16801da44ee321534d6169da49af8167f F ext/fts5/test/fts5detail.test ef5c690535a797413acaf5ad9b8ab5d49972df69 F ext/fts5/test/fts5determin.test 10648edb75ef1e196b10978fd21a9be0c31e09c3 F ext/fts5/test/fts5dlidx.test 007e9390c94638760797dbec2990c97c3fa08dfe @@ -1579,7 +1580,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 47629b1911e52445aad8ea969137bddf0019c55b4a4f0de8e77decb6a434c8a2 -R 0c6451e367b2cefc9e69fa0621b4d931 -U drh -Z 18c2f8082a296f2f15ab41c2498f7cb3 +P 3980ea0911b3ad3f86d7a7bdc6503f233315c274f473e18831e13eda2c238eeb +R e8ce1902ba436a257e96b01caa3cadb9 +U dan +Z c1b8197d958a390da1753ec3ab7dee72 diff --git a/manifest.uuid b/manifest.uuid index 4e27390c06..8a1a73a65b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3980ea0911b3ad3f86d7a7bdc6503f233315c274f473e18831e13eda2c238eeb \ No newline at end of file +9a2de4f05fabf7e725666fb8824ae1adad56834d7ae4f2e118375bb6f9c0ae77 \ No newline at end of file From ee3333b202a527a26113fdd87a602be99f8038fe Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 11 May 2017 19:09:19 +0000 Subject: [PATCH 19/22] Add another test case for the new authorizer functionality. FossilOrigin-Name: 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- test/auth.test | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 5f2de8a3da..8fae8cd507 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\sjson_extract()\sfunction\sto\sreuse\sparses\sof\sthe\ssame\sJSON\swhen\nthe\sfunction\sappears\smultiple\stimes\sin\sthe\ssame\squery. -D 2017-05-11T18:42:19.585 +C Add\sanother\stest\scase\sfor\sthe\snew\sauthorizer\sfunctionality. +D 2017-05-11T19:09:19.861 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -527,7 +527,7 @@ F test/attach2.test 0ec5defa340363de6cd50fd595046465e9aaba2d F test/attach3.test c59d92791070c59272e00183b7353eeb94915976 F test/attach4.test 53bf502f17647c6d6c5add46dda6bac8b6f4665c F test/attachmalloc.test 3a4bfca9545bfe906a8d2e622de10fbac5b711b0 -F test/auth.test 32ee0e98593c9ea73870d9b0c8e50c2f43371d9fede388c09e9477c6bf5f8aab +F test/auth.test 3d6cd8f3978ba55b1202574e6ecd79c6e00914ca44b9bfd6c1fe6fb873fcac88 F test/auth2.test 9eb7fce9f34bf1f50d3f366fb3e606be5a2000a1 F test/auth3.test db21405b95257c24d29273b6b31d0efc59e1d337e3d5804ba2d1fd4897b1ae49 F test/autoanalyze1.test b9cc3f32a990fa56669b668d237c6d53e983554ae80c0604992e18869a0b2dec @@ -1580,8 +1580,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 9a2de4f05fabf7e725666fb8824ae1adad56834d7ae4f2e118375bb6f9c0ae77 44ca6c2c4639f3c50ae9233ee299ff0fc4566462c31f28d8676f8de7ffdcd7f0 -R 206babf55062a938db66e913be51f858 -T +closed 44ca6c2c4639f3c50ae9233ee299ff0fc4566462c31f28d8676f8de7ffdcd7f0 -U drh -Z 601ecb610822b99db3531b28190b1d48 +P 3ba9e7ab79e32090a71c7aa152da9bd5951940ae5e2cf433bceadeb6bfca193f +R c23ba6742d143bcb8e56ef743f752f47 +U dan +Z 8927c159ee024c66492c5adfd8a38c92 diff --git a/manifest.uuid b/manifest.uuid index 1ad89a97cc..492af23975 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3ba9e7ab79e32090a71c7aa152da9bd5951940ae5e2cf433bceadeb6bfca193f \ No newline at end of file +339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736 \ No newline at end of file diff --git a/test/auth.test b/test/auth.test index 40a92e74e1..2487e568b2 100644 --- a/test/auth.test +++ b/test/auth.test @@ -2525,6 +2525,28 @@ do_test auth-8.2 { SQLITE_READ t7 {} {} {} \ ] +# Test also that if SQLITE_DENY is returned from an SQLITE_READ authorizer +# invocation with no column name specified, compilation fails. +# +set ::authargs [list] +proc auth {op a b c d} { + lappend ::authargs $op $a $b $c $d + if {$op == "SQLITE_READ"} { return "SQLITE_DENY" } + return "SQLITE_OK" +} +set ::authargs [list] +do_catchsql_test auth-8.3 { + SELECT count(*) FROM t7 +} {1 {not authorized}} +do_test auth-8.4 { + set ::authargs +} [list \ + SQLITE_SELECT {} {} {} {} \ + SQLITE_FUNCTION {} count {} {} \ + SQLITE_READ t7 {} {} {} \ +] + + rename proc {} rename proc_real proc finish_test From c8d3e836cafb3b1d3a7a242027215feccccd052c Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 12 May 2017 14:05:11 +0000 Subject: [PATCH 20/22] Make sure the 'sqlite3changegroup_*' functions are included in the SQLITE_APICALL handling. FossilOrigin-Name: a123cb93307a6c48bd711d6af9828c87a1365e023f6fe4ca6eae264c8ec5e0c0 --- Makefile.msc | 2 +- autoconf/Makefile.msc | 4 ++-- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- tool/mkmsvcmin.tcl | 2 +- tool/mksqlite3h.tcl | 6 +++++- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 5ef8decc38..8b8d28d1f2 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1562,7 +1562,7 @@ $(SQLITE3DLL): $(LIBOBJ) $(LIBRESOBJS) $(CORE_LINK_DEP) sqlite3.def: libsqlite3.lib echo EXPORTS > sqlite3.def dumpbin /all libsqlite3.lib \ - | $(TCLSH_CMD) $(TOP)\tool\replace.tcl include "^\s+1 _?(sqlite3(?:session|changeset)?_[^@]*)(?:@\d+)?$$" \1 \ + | $(TCLSH_CMD) $(TOP)\tool\replace.tcl include "^\s+1 _?(sqlite3(?:session|changeset|changegroup)?_[^@]*)(?:@\d+)?$$" \1 \ | sort >> sqlite3.def # <> diff --git a/autoconf/Makefile.msc b/autoconf/Makefile.msc index ad88504be8..9f867986d7 100644 --- a/autoconf/Makefile.msc +++ b/autoconf/Makefile.msc @@ -21,7 +21,7 @@ TOP = . # Set this non-0 to enable full warnings (-W4, etc) when compiling. # !IFNDEF USE_FULLWARN -USE_FULLWARN = 0 +USE_FULLWARN = 1 !ENDIF # Set this non-0 to enable treating warnings as errors (-WX, etc) when @@ -954,7 +954,7 @@ Replace.exe: sqlite3.def: Replace.exe $(LIBOBJ) echo EXPORTS > sqlite3.def dumpbin /all $(LIBOBJ) \ - | .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \ + | .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset|changegroup)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \ | sort >> sqlite3.def $(SQLITE3EXE): $(TOP)\shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLITE3H) diff --git a/manifest b/manifest index 8fae8cd507..83ef433b5f 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Add\sanother\stest\scase\sfor\sthe\snew\sauthorizer\sfunctionality. -D 2017-05-11T19:09:19.861 +C Make\ssure\sthe\s'sqlite3changegroup_*'\sfunctions\sare\sincluded\sin\sthe\sSQLITE_APICALL\shandling. +D 2017-05-12T14:05:11.958 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 +F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc F README.md 2b15fae33852f2f53996774c21fb41e1d94181c4401a0e43ac93e11f2cc901b9 F VERSION 0a0e02e16b44ea735b40118fc844311b2ab0d35b25fbeda5120aee62f973f663 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -11,7 +11,7 @@ F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am 1a47d071e3d5435f8f7ebff7eb6703848bbd65d4 -F autoconf/Makefile.msc 1fba0d762d115509d4fce7e333305cee172d521aaacec8bbf7aad5503605d3fb +F autoconf/Makefile.msc 1014be616b420a5f48611d21b62ca2f50ec97ee795087ecb8a4d6bf6375ba11d F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1 F autoconf/configure.ac 2893b823ecc86cea13739f6c8109a41392254d1db08235c5615e0af5722c8578 @@ -1514,7 +1514,7 @@ F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca F tool/max-limits.c cbb635fbb37ae4d05f240bfb5b5270bb63c54439 F tool/mkautoconfamal.sh e855df211ecbcc7131dee817110ff386cfb112f7 F tool/mkkeywordhash.c f7f3b342211ac6a14258b9726d5b97cf4f548f22 -F tool/mkmsvcmin.tcl 95b37e202cbed873aa8ffdbb493b9db45927be2b +F tool/mkmsvcmin.tcl cbd93f1cfa3a0a9ae56fc958510aa3fc3ac65e29cb111716199e3d0e66eefaa4 F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c F tool/mkopcodeh.tcl a01d2c1d8a6205b03fc635adf3735b4c523befd3 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e @@ -1522,7 +1522,7 @@ F tool/mkpragmatab.tcl 32bb40741df11bddc8451de9ea4d130e7b4476d8064794b1cf402ac11 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl fef88397668ae83166735c41af99d79f56afaabb F tool/mksqlite3c.tcl 06b2e6a0f21cc0a5d70fbbd136b3e0a96470645e -F tool/mksqlite3h.tcl b9836752c3d08f9fab2dfc0017ca9fd5d90ac863 +F tool/mksqlite3h.tcl 51bd5e7e840a920388a5966c9f2ccc618f434c57bd68c1bab4085b2553e1e237 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 @@ -1580,7 +1580,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 3ba9e7ab79e32090a71c7aa152da9bd5951940ae5e2cf433bceadeb6bfca193f -R c23ba6742d143bcb8e56ef743f752f47 -U dan -Z 8927c159ee024c66492c5adfd8a38c92 +P 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736 +R f32069ec3ca4ccef1057ce7127947f8c +U mistachkin +Z 1ae8fc54b0b13feeb3ff5e35a3c2108d diff --git a/manifest.uuid b/manifest.uuid index 492af23975..286d3ef96e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736 \ No newline at end of file +a123cb93307a6c48bd711d6af9828c87a1365e023f6fe4ca6eae264c8ec5e0c0 \ No newline at end of file diff --git a/tool/mkmsvcmin.tcl b/tool/mkmsvcmin.tcl index bdd02be1fb..8d5729865c 100644 --- a/tool/mkmsvcmin.tcl +++ b/tool/mkmsvcmin.tcl @@ -83,7 +83,7 @@ Replace.exe: sqlite3.def: Replace.exe $(LIBOBJ) echo EXPORTS > sqlite3.def dumpbin /all $(LIBOBJ) \\ - | .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \\ + | .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset|changegroup)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \\ | sort >> sqlite3.def }]] diff --git a/tool/mksqlite3h.tcl b/tool/mksqlite3h.tcl index 9d307d1b1e..5106a83857 100644 --- a/tool/mksqlite3h.tcl +++ b/tool/mksqlite3h.tcl @@ -81,6 +81,9 @@ set declpattern2 \ set declpattern3 \ {^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3changeset_[_a-zA-Z0-9]+)(\(.*)$} +set declpattern4 \ + {^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3changegroup_[_a-zA-Z0-9]+)(\(.*)$} + # Force the output to use unix line endings, even on Windows. fconfigure stdout -translation lf @@ -129,7 +132,8 @@ foreach file $filelist { } else { if {[regexp $declpattern1 $line all rettype funcname rest] || \ [regexp $declpattern2 $line all rettype funcname rest] || \ - [regexp $declpattern3 $line all rettype funcname rest]} { + [regexp $declpattern3 $line all rettype funcname rest] || \ + [regexp $declpattern4 $line all rettype funcname rest]} { set line SQLITE_API append line " " [string trim $rettype] if {[string index $rettype end] ne "*"} { From 96a27f4cbb9a71e3f117029af91e7cc29bf9ce3a Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 15 May 2017 15:05:48 +0000 Subject: [PATCH 21/22] Improvements to the omittest.tcl script. FossilOrigin-Name: 0f05d7e93a73bbeac0a09bbd614287507355a7d75fc7b98729bcf7607fc8e125 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/omittest.tcl | 24 ++++++++++++++++-------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 83ef433b5f..c6d7e1f95e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthe\s'sqlite3changegroup_*'\sfunctions\sare\sincluded\sin\sthe\sSQLITE_APICALL\shandling. -D 2017-05-12T14:05:11.958 +C Improvements\sto\sthe\somittest.tcl\sscript. +D 2017-05-15T15:05:48.869 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -1526,7 +1526,7 @@ F tool/mksqlite3h.tcl 51bd5e7e840a920388a5966c9f2ccc618f434c57bd68c1bab4085b2553 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 -F tool/omittest.tcl 34d7ac01fe4fd18e3637f64abe12c40eca0f6b97 +F tool/omittest.tcl dfc8b18a23e9e5289104145b712cdb887c2d840c2d70dc09ce5dbeba8ed8d47c F tool/opcodesum.tcl 740ed206ba8c5040018988129abbf3089a0ccf4a F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b F tool/replace.tcl 60f91e8dd06ab81f74d213ecbd9c9945f32ac048 @@ -1580,7 +1580,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 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736 -R f32069ec3ca4ccef1057ce7127947f8c -U mistachkin -Z 1ae8fc54b0b13feeb3ff5e35a3c2108d +P a123cb93307a6c48bd711d6af9828c87a1365e023f6fe4ca6eae264c8ec5e0c0 +R 72b16ccdef50cad498e60404ed6c0e91 +U drh +Z 62d2ddcfe5df879e17f37c06a1755a54 diff --git a/manifest.uuid b/manifest.uuid index 286d3ef96e..b1887b0e01 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a123cb93307a6c48bd711d6af9828c87a1365e023f6fe4ca6eae264c8ec5e0c0 \ No newline at end of file +0f05d7e93a73bbeac0a09bbd614287507355a7d75fc7b98729bcf7607fc8e125 \ No newline at end of file diff --git a/tool/omittest.tcl b/tool/omittest.tcl index 5437f2eb01..c42519dd8c 100644 --- a/tool/omittest.tcl +++ b/tool/omittest.tcl @@ -1,6 +1,3 @@ - -set rcsid {$Id: omittest.tcl,v 1.8 2008/10/13 15:35:09 drh Exp $} - # Documentation for this script. This may be output to stderr # if the script is invoked incorrectly. set ::USAGE_MESSAGE { @@ -134,26 +131,37 @@ proc process_options {argv} { set ::TARGET testfixture ;# Default thing to build for {set i 0} {$i < [llength $argv]} {incr i} { - switch -- [lindex $argv $i] { - -makefile { + switch -regexp -- [lindex $argv $i] { + -{1,2}makefile { incr i set ::MAKEFILE [lindex $argv $i] } - -nmake { + -{1,2}nmake { set ::MAKEBIN nmake set ::MAKEFILE ./Makefile.msc } - -target { + -{1,2}target { incr i set ::TARGET [lindex $argv $i] } - -skip_run { + -{1,2}skip_run { set ::SKIP_RUN 1 } + -{1,2}help { + puts $::USAGE_MESSAGE + exit + } + + -.* { + puts stderr "Unknown option: [lindex $argv i]" + puts stderr $::USAGE_MESSAGE + exit 1 + } + default { if {[info exists ::SYMBOL]} { puts stderr [string trim $::USAGE_MESSAGE] From dd1bb43ab53cc8ab624988ec78157e7e6d0e73ff Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 15 May 2017 15:12:24 +0000 Subject: [PATCH 22/22] Fix the build so that it works again with SQLITE_OMIT_SUBQUERY. FossilOrigin-Name: bb0d9281588b8cc24bf2f1f10d0c56277004226adaa2ce5037782503b283b45d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/expr.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index c6d7e1f95e..954fc9afcc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\somittest.tcl\sscript. -D 2017-05-15T15:05:48.869 +C Fix\sthe\sbuild\sso\sthat\sit\sworks\sagain\swith\sSQLITE_OMIT_SUBQUERY. +D 2017-05-15T15:12:24.562 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -356,7 +356,7 @@ F src/ctime.c 47d91a25ad8f199a71a5b1b7b169d6dd0d6e98c5719eca801568798743d1161c F src/date.c cc42a41c7422389860d40419a5e3bce5eaf6e7835c3ba2677751dc653550a5c7 F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c 665e705641e5815c3f32d05820d1a5aa630274e568af73f377fdbc614fcf40b4 -F src/expr.c c980b2c9291a12a0f1de1e1e1aaa72c4579ded716e1e3a3ac1c3d898ba0df0a1 +F src/expr.c c83f799f3e5e3f3863bd0716119383e4a062d00a1e34e7273a78555918840a7c F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c db65492ae549c3b548c9ef1f279ce1684f1c473b116e1c56a90878cd5dcf968d F src/func.c 9d52522cc8ae7f5cdadfe14594262f1618bc1f86083c4cd6da861b4cf5af6174 @@ -1580,7 +1580,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 a123cb93307a6c48bd711d6af9828c87a1365e023f6fe4ca6eae264c8ec5e0c0 -R 72b16ccdef50cad498e60404ed6c0e91 +P 0f05d7e93a73bbeac0a09bbd614287507355a7d75fc7b98729bcf7607fc8e125 +R a9e25308f45891c9b24063503aeca595 U drh -Z 62d2ddcfe5df879e17f37c06a1755a54 +Z 8c1e0c69d71e5343091b9dc46bca8976 diff --git a/manifest.uuid b/manifest.uuid index b1887b0e01..de1332e1c2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0f05d7e93a73bbeac0a09bbd614287507355a7d75fc7b98729bcf7607fc8e125 \ No newline at end of file +bb0d9281588b8cc24bf2f1f10d0c56277004226adaa2ce5037782503b283b45d \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index b5d4ed1f96..8fc727fcd5 100644 --- a/src/expr.c +++ b/src/expr.c @@ -352,7 +352,6 @@ int sqlite3ExprVectorSize(Expr *pExpr){ } } -#ifndef SQLITE_OMIT_SUBQUERY /* ** Return a pointer to a subexpression of pVector that is the i-th ** column of the vector (numbered starting with 0). The caller must @@ -380,9 +379,7 @@ Expr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){ } return pVector; } -#endif /* !defined(SQLITE_OMIT_SUBQUERY) */ -#ifndef SQLITE_OMIT_SUBQUERY /* ** Compute and return a new Expr object which when passed to ** sqlite3ExprCode() will generate all necessary code to compute @@ -440,7 +437,6 @@ Expr *sqlite3ExprForVectorField( } return pRet; } -#endif /* !define(SQLITE_OMIT_SUBQUERY) */ /* ** If expression pExpr is of type TK_SELECT, generate code to evaluate @@ -3411,7 +3407,11 @@ static int exprCodeVector(Parse *pParse, Expr *p, int *piFreeable){ }else{ *piFreeable = 0; if( p->op==TK_SELECT ){ +#if SQLITE_OMIT_SUBQUERY + iResult = 0; +#else iResult = sqlite3CodeSubselect(pParse, p, 0, 0); +#endif }else{ int i; iResult = pParse->nMem+1;