diff --git a/VERSION b/VERSION index 1eeac129c5..3f67e25cea 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.16.0 +3.17.0 diff --git a/configure b/configure index 598b0dd7d9..be7c89143b 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sqlite 3.16.0. +# Generated by GNU Autoconf 2.69 for sqlite 3.17.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -726,8 +726,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.16.0' -PACKAGE_STRING='sqlite 3.16.0' +PACKAGE_VERSION='3.17.0' +PACKAGE_STRING='sqlite 3.17.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1463,7 +1463,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.16.0 to adapt to many kinds of systems. +\`configure' configures sqlite 3.17.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1528,7 +1528,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.16.0:";; + short | recursive ) echo "Configuration of sqlite 3.17.0:";; esac cat <<\_ACEOF @@ -1652,7 +1652,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.16.0 +sqlite configure 3.17.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2071,7 +2071,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.16.0, which was +It was created by sqlite $as_me 3.17.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -12151,7 +12151,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.16.0, which was +This file was extended by sqlite $as_me 3.17.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -12217,7 +12217,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sqlite config.status 3.16.0 +sqlite config.status 3.17.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -13829,3 +13829,4 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi + diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index 70ca840dae..50793df0a0 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -374,9 +374,7 @@ static int sessionSerializeValue( if( aBuf ){ sessionVarintPut(&aBuf[1], n); - memcpy(&aBuf[nVarint + 1], eType==SQLITE_TEXT ? - sqlite3_value_text(pValue) : sqlite3_value_blob(pValue), n - ); + if( n ) memcpy(&aBuf[nVarint + 1], z, n); } nByte = 1 + nVarint + n; @@ -1792,7 +1790,7 @@ static void sessionAppendBlob( int nBlob, int *pRc ){ - if( 0==sessionBufferGrow(p, nBlob, pRc) ){ + if( nBlob>0 && 0==sessionBufferGrow(p, nBlob, pRc) ){ memcpy(&p->aBuf[p->nBuf], aBlob, nBlob); p->nBuf += nBlob; } @@ -1978,13 +1976,13 @@ static int sessionAppendUpdate( } default: { - int nByte; - int nHdr = 1 + sessionVarintGet(&pCsr[1], &nByte); + int n; + int nHdr = 1 + sessionVarintGet(&pCsr[1], &n); assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); - nAdvance = nHdr + nByte; + nAdvance = nHdr + n; if( eType==sqlite3_column_type(pStmt, i) - && nByte==sqlite3_column_bytes(pStmt, i) - && 0==memcmp(&pCsr[nHdr], sqlite3_column_blob(pStmt, i), nByte) + && n==sqlite3_column_bytes(pStmt, i) + && (n==0 || 0==memcmp(&pCsr[nHdr], sqlite3_column_blob(pStmt, i), n)) ){ break; } diff --git a/manifest b/manifest index 7d07fb38d6..4333aa5ff1 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Add\sthe\sbuilt-in\saffinity()\sSQL\sfunction. -D 2016-12-26T00:18:36.252 +C Merge\sall\sthe\slatest\schanges\sfrom\strunk. +D 2017-01-03T14:30:28.465 F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 -F VERSION 661b3e6a778cfbfd7bdce8bbb1545b22f4b6f09e +F VERSION cddd8d88dc8202afa0ebc96da61fc4acbd1e96a5 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 @@ -30,7 +30,7 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure adbf03e758431e886bba5ab04b5adfbd496d7b24 x +F configure fcfa56d5d66668c9263dc007724f62acff06dc83 x F configure.ac 605173e829ab64514ed89f9b53d0da1739d7b0a0 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html b5a3c07d33ecb8e019ce8f7660fe2dbbad9d7977 @@ -303,7 +303,7 @@ F ext/session/sessionG.test 01ef705096a9d3984eebdcca79807a211dee1b60 F ext/session/session_common.tcl 9b696a341cf1d3744823715ed92bb19749b6c3d4 F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 -F ext/session/sqlite3session.c 37485891b4add26cf61495df193c419f36556a32 +F ext/session/sqlite3session.c c61a43396368ec00dc127f7bc647e9bd6a4ee5fb F ext/session/sqlite3session.h 9345166bd8f80562145586cf817f707de5ecada2 F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386 F ext/userauth/sqlite3userauth.h 19cb6f0e31316d0ee4afdfb7a85ef9da3333a220 @@ -325,27 +325,27 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 3b23977620ce9662ac54443f65b87ba996e36121 -F src/analyze.c 8b62b2cf4da85451534ac0af82cafc418d837f68 -F src/attach.c f6725410c184a80d8141b294fdf98a854c8a52b5 +F src/analyze.c 3c4a63ff7a55faefecf6eb1589932fdbc06b2415 +F src/attach.c 8c476f8bd5d2afe11d925f890d30e527e5b0ce43 F src/auth.c 930b376a9c56998557367e6f7f8aaeac82a2a792 F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 -F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c 2e07a5a6d705c1439392460f4044ea4179d9cd40 +F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca +F src/btree.c d2c100618784bd89c089fcef03ff6e789768ecae F src/btree.h 2349a588abcd7e0c04f984e15c5c777b61637583 F src/btreeInt.h 10c4b77c2fb399580babbcc7cf652ac10dba796e F src/build.c 9e799f1edd910dfa8a0bc29bd390d35d310596af F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 9f2296a4e5d26ebf0e0d95a0af4628f1ea694e7a -F src/date.c b48378aeac68fa20c811404955a9b62108df47d8 +F src/date.c dc3f1391d9297f8c748132813aaffcb117090d6e F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c c8bc10d145c9666a34ae906250326fdaa8d58fa5 -F src/expr.c dfde7bf6d3293c34b975aef24a7b9e4f6dbe89da +F src/expr.c 3cf3bb3b5de2494d0f7b30c999984fd2918b4ef5 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 2e9aabe1aee76273aff8a84ee92c464e095400ae -F src/func.c 18193418066b4a46df0678167a61e2ecb532449e -F src/global.c dcdb89f30b7aa531c5660030af106bc5bc48ef2e +F src/func.c 04350956b6e45800f71e02e0ffeae2a35aff2634 +F src/global.c 4a34512d82fc5aa13c802db06bcfff5e1d3de955 F src/hash.c 63d0ee752a3b92d4695b2b1f5259c4621b2cfebd F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da @@ -353,8 +353,8 @@ F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 91ba5d0143e66479081536ebbaff1850ec9f57d9 F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/loadext.c 5d6642d141c07d366e43d359e94ec9de47add41d -F src/main.c ec789a410860bcdc5d8f7a82090043f482482aec -F src/malloc.c 5ee7c2d3dcb1b0a902c9c6d0115deef54736bdfa +F src/main.c e207b81542d13b9f13d61e78ca441f9781f055b0 +F src/malloc.c f3fad34cd570022abca558c573f1761fb09a8212 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 @@ -375,7 +375,7 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c 30e2c43e4955db990e5b5a81e901f8aa74cc8820 F src/os_win.c cf90abd4e50d9f56d2c20ce8e005aff55d7bd8e9 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c 81fe2bb847df537694ec39e28e8b3dc221c64a7d +F src/pager.c 9dc72d23eebbdf992bd69f2ab954d0d3a27c7340 F src/pager.h d1e944291030351f362a0a7da9b5c3e34e603e39 F src/parse.y 29153738a7322054359320eb00b5a4cd44389f20 F src/pcache.c 51070ec9b8251bbf9c6ea3d35fd96a458752929e @@ -384,16 +384,16 @@ F src/pcache1.c e3967219b2a92b9edcb9324a4ba75009090d3953 F src/pragma.c 5a23557e490e7ac5afef097efc4b59dce5b482c2 F src/pragma.h f9b221b2c8949ea941dbee49934299e4ed5af41c F src/prepare.c b1140c3d0cf59bc85ace00ce363153041b424b7a -F src/printf.c f94da4935d1dd25420ac50c6745db1deb35e07c1 +F src/printf.c 0c8579432f47948d9be5077eb590e8c4a01be667 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bb070cf5f23611c44ab7e4788803684e385fc3fb F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c dfb6cadc3dcfba1b1bdbfba62ebba2b4b673413e -F src/shell.c 48ab675e5526903d2b7bea8c9736cafa345544e1 +F src/shell.c 6095531aa900decdaa765e0f3993fba7153c92c1 F src/sqlite.h.in e8e2d108d82647f0a812fdb74accf91c1ec08ddc F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae -F src/sqliteInt.h 5a4ac95a34d9d323b2276ae1ed2b3eaafce6c97e +F src/sqliteInt.h 2c22eae7a29f17e0dfee9737d4844d7c08cc38cd F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -455,7 +455,7 @@ F src/update.c 1da7c462110bffed442a42884cb0d528c1db46d8 F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 1534060bc034cdc51381c040c8bd6252dbcb64c9 F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16 -F src/vdbe.c 73ded9a61658c82cf726cb7feb070836cb4f8a87 +F src/vdbe.c 88bd6c32b333580d2661ac3afe33369757fb1522 F src/vdbe.h 50ee139f9c68fff91be1d717ed3a6abbd496919c F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e F src/vdbeapi.c d6ebaa465f070eb1af8ba4e7b34583ece87bdd24 @@ -600,7 +600,7 @@ F test/corrupt8.test 2399dfe40d2c0c63af86706e30f3e6302a8d0516 F test/corrupt9.test 730a3db08d4ab9aa43392ea30d9c2b4879cbff85 F test/corruptA.test 53e56dafd180addcdadb402244b8cb9771d2ba26 F test/corruptB.test 73a8d6c0b9833697ecf16b63e3c5c05c945b5dec -F test/corruptC.test 0c46574f8d4f27ecc799b1b5c4cbf9b1817bce9a +F test/corruptC.test 4ef10844eba5213bd262f4d96784d7fcda114afe F test/corruptD.test b3c205fac7952b1de645ce44bb02335cd9e3e040 F test/corruptE.test 82ccf4f8f543fdbedd4aa42c709cb077f7374c62 F test/corruptF.test be9fde98e4c93648f1ba52b74e5318edc8f59fe4 @@ -816,7 +816,7 @@ F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1 F test/fuzz3.test b47377143f0c80f91ed29d722861077ff34415d5 F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26 -F test/fuzzcheck.c b5a3e54b100e65b008452a2d29193c7132af0b05 +F test/fuzzcheck.c a87e6067a8d19844bade916841cb76150ecf24a2 F test/fuzzdata1.db 7ee3227bad0e7ccdeb08a9e6822916777073c664 F test/fuzzdata2.db f03a420d3b822cc82e4f894ca957618fbe9c4973 F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba @@ -825,6 +825,7 @@ F test/fuzzdata5.db 9f0cdcc5c6e83b90cf9ae343bd07f684d2da2de7 F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8 F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14 F test/fuzzerfault.test 8792cd77fd5bce765b05d0c8e01b9edcf8af8536 +F test/gcfault.test dd28c228a38976d6336a3fc42d7e5f1ad060cb8c F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 F test/hexlit.test 4a6a5f46e3c65c4bf1fa06f5dd5a9507a5627751 F test/hidden.test 23c1393a79e846d68fd902d72c85d5e5dcf98711 @@ -865,11 +866,11 @@ F test/insert2.test 4d14b8f1b810a41995f6286b64a6943215d52208 F test/insert3.test 1b7db95a03ad9c5013fdf7d6722b6cd66ee55e30 F test/insert4.test a20432f1c0fbbcff8f11d0e6ab4acb8c9db58023 F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6 -F test/instr.test 737bbf80685232033f3abedc6ae92f75860b5dd2 -F test/instrfault.test aa90b7c3486a069151b28384ae525644a1f79d51 +F test/instr.test 9a8802f28437d8ade53fedfc47b2ca599b4e48ba +F test/instrfault.test 0f870b218ea17cd477bb19ed330eecdb460dd53a F test/intarray.test 46d95b457916638c5d8b1af21fb174804b3acf8b F test/interrupt.test 16ea879ec728cb76414c148c5f24afd5d1f91054 -F test/interrupt2.test 829b06f9e20a6c378d8bd121b26c337f4dfa36e5 +F test/interrupt2.test e4408ca770a6feafbadb0801e54a0dcd1a8d108d F test/intpkey.test ac71107a49a06492b69b82aafaf225400598d3c8 F test/io.test f95bca1783b01ea7761671560d023360d2dfa4cc F test/ioerr.test 2a24bd6ed5a8b062e64bfe1f6cf94fb25e92210d @@ -894,6 +895,7 @@ F test/json101.test c0897616f32d95431f37fd291cb78742181980ac F test/json102.test bf3fe7a706d30936a76a0f7a0375e1e8e73aff5a F test/json103.test c5f6b85e69de05f6b3195f9f9d5ce9cd179099a0 F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff +F test/kvtest.c 2c66ddefcd03c2caa337f6dd79e6c82368af83df F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 F test/like.test 0603f4fa0dad50987f70032c05800cbfa8985302 @@ -967,7 +969,7 @@ F test/multiplex4.test e8ae4c4bd70606a5727743241f13b5701990abe4 F test/mutex1.test ea2cc74d97f077b9e74c84cbd024f14d79a8126f F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660 F test/nan.test dacc57f80859c06a433d30839336fe227d2038b3 -F test/nockpt.test c65fc1c921d48805dcfca2dca5d1302839a5a1de +F test/nockpt.test 9a436a7213ba5ef7a32304998d386d3ea3f76c9d F test/nolock.test f196cf8b8fbea4e2ca345140a2b3f3b0da45c76e F test/notify1.test 669b2b743618efdc18ca4b02f45423d5d2304abf F test/notify2.test 2ecabaa1305083856b7c39cf32816b612740c161 @@ -988,7 +990,7 @@ F test/orderby7.test 3d1383d52ade5b9eb3a173b3147fdd296f0202da F test/orderby8.test 23ef1a5d72bd3adcc2f65561c654295d1b8047bd F test/orderby9.test 87fb9548debcc2cd141c5299002dd94672fa76a3 F test/oserror.test b32dc34f2363ef18532e3a0a7358e3e7e321974f -F test/ossfuzz.c ad79e867fb504338d324b08e0696db65a0c44d68 +F test/ossfuzz.c e469138f4be3e92df6173b79b3b216ab6e17b407 F test/ossshell.c d9f1a6f43e7bab45d6be857a5800f5d4a1861db3 F test/ovfl.test 199c482696defceacee8c8e0e0ef36da62726b2f F test/pager1.test 841868017e9dd3cb459b8d78862091a7d9cff21d @@ -1033,7 +1035,7 @@ F test/rollbackfault.test 0e646aeab8840c399cfbfa43daab46fd609cf04a F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 F test/rowid.test 5b7509f384f4f6fae1af3c8c104c8ca299fea18d -F test/rowvalue.test cacc565ed7e3ac467866af6705dd99020fdf2ee2 +F test/rowvalue.test 44f3492f415cc9f374e8388a5eb61503eaca5230 F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b F test/rowvalue3.test 3068f508753af69884b12125995f023da0dbb256 F test/rowvalue4.test 4b556d7de161a0dd8cff095c336e913986398bea @@ -1090,12 +1092,12 @@ F test/sharedA.test 0cdf1a76dfa00e6beee66af5b534b1e8df2720f5 F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e F test/shared_err.test 2f2aee20db294b9924e81f6ccbe60f19e21e8506 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell1.test 8ff47a4821570b99cc340c4da0ac4efe2ba06627 +F test/shell1.test 52ac23a345772ab0d6d3241a21a633fdaa3ed581 F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b F test/shell3.test 9b95ba643eaa228376f06a898fb410ee9b6e57c1 F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 50a732c1c2158b1cd62cf53975ce1ea7ce6b9dc9 -F test/shell6.test 87b47bf2f5c47a4e44f07dd119ea88ae303a8247 +F test/shell6.test cff624fadf71bdb5e3a9b0f86eaf59a43c0622b1 F test/shell7.test 07751911b294698e0c5df67bcbd29e7d2f0f2907 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 @@ -1125,7 +1127,7 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b -F test/speedtest1.c 0c92fd0db4cb778e3b6968db0ea859e28f077823 +F test/speedtest1.c 4e8ea6165046f02e1cfe0f4700256e91c981ec10 F test/spellfix.test f9c1f431e2c096c8775fec032952320c0e4700db F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -1447,7 +1449,7 @@ F test/without_rowid3.test 2724c787a51a5dce09d078453a758117b4b728f1 F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a F test/without_rowid5.test 89b1c587bd92a0590e440da33e7666bf4891572a F test/without_rowid6.test 1f99644e6508447fb050f73697350c7ceca3392e -F test/wordcount.c 97856eec21fd00d77da720007b1888c383f63dcf +F test/wordcount.c 06efb84b7c48a4973c2c24ea06c93d00bce24389 F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 @@ -1466,7 +1468,7 @@ F tool/fuzzershell.c dbf6c26eef936ec78cb0707570de3a4308b2507e F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c e4fb7d888873ac88f20a41c84a7d1e61f5209a6d +F tool/lemon.c 5ccba178a8e8a4b21e1c9232944d23973da38ad7 F tool/lempar.c 320d630b44da693407684c64d9fa91a163419dac F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 @@ -1539,10 +1541,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 8c5187f69d719b69aa6eaf2dc8f89243e5979222 -R b3d06bee0b628897cfc6aea60fc78deb -T *branch * affinity-sql-func -T *sym-affinity-sql-func * -T -sym-trunk * +P 57e40e1cb1bcd3dd8473d2fdeecc9c7ff3d6192b 36944be6be5c42096f5da84187ff203af26b08ae +R e122a5b19a6af1a9b03b2065c0a3a3fe U drh -Z 89d8ee615380053a8bde91353136b95e +Z 5f2d809963b79f73c941be08881302f0 diff --git a/manifest.uuid b/manifest.uuid index aa72dce7c8..34459e334c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -57e40e1cb1bcd3dd8473d2fdeecc9c7ff3d6192b \ No newline at end of file +c27cd8a8127b81d3176f6a5b9915c9b3c69574fb \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index e3955f3022..c480a0c507 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -1766,7 +1766,9 @@ static int loadStatTbl( sqlite3_finalize(pStmt); return SQLITE_NOMEM_BKPT; } - memcpy(pSample->p, sqlite3_column_blob(pStmt, 4), pSample->n); + if( pSample->n ){ + memcpy(pSample->p, sqlite3_column_blob(pStmt, 4), pSample->n); + } pIdx->nSample++; } rc = sqlite3_finalize(pStmt); diff --git a/src/attach.c b/src/attach.c index 4fe97bacea..393c46ccb6 100644 --- a/src/attach.c +++ b/src/attach.c @@ -137,6 +137,7 @@ static void attachFunc( rc = sqlite3BtreeOpen(pVfs, zPath, db, &aNew->pBt, 0, flags); sqlite3_free( zPath ); db->nDb++; + db->skipBtreeMutex = 0; if( rc==SQLITE_CONSTRAINT ){ rc = SQLITE_ERROR; zErrDyn = sqlite3MPrintf(db, "database is already attached"); diff --git a/src/btmutex.c b/src/btmutex.c index c1ebff9604..ddffb67fa4 100644 --- a/src/btmutex.c +++ b/src/btmutex.c @@ -183,16 +183,24 @@ int sqlite3BtreeHoldsMutex(Btree *p){ ** two or more btrees in common both try to lock all their btrees ** at the same instant. */ -void sqlite3BtreeEnterAll(sqlite3 *db){ +static void SQLITE_NOINLINE btreeEnterAll(sqlite3 *db){ int i; + int skipOk = 1; Btree *p; assert( sqlite3_mutex_held(db->mutex) ); for(i=0; inDb; i++){ p = db->aDb[i].pBt; - if( p ) sqlite3BtreeEnter(p); + if( p && p->sharable ){ + sqlite3BtreeEnter(p); + skipOk = 0; + } } + db->skipBtreeMutex = skipOk; } -void sqlite3BtreeLeaveAll(sqlite3 *db){ +void sqlite3BtreeEnterAll(sqlite3 *db){ + if( db->skipBtreeMutex==0 ) btreeEnterAll(db); +} +static void SQLITE_NOINLINE btreeLeaveAll(sqlite3 *db){ int i; Btree *p; assert( sqlite3_mutex_held(db->mutex) ); @@ -201,6 +209,9 @@ void sqlite3BtreeLeaveAll(sqlite3 *db){ if( p ) sqlite3BtreeLeave(p); } } +void sqlite3BtreeLeaveAll(sqlite3 *db){ + if( db->skipBtreeMutex==0 ) btreeLeaveAll(db); +} #ifndef NDEBUG /* diff --git a/src/btree.c b/src/btree.c index d2fd448f68..f869761625 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7077,7 +7077,7 @@ static int balance_nonroot( nMaxCells += 1+apOld[i]->nCell+apOld[i]->nOverflow; if( (i--)==0 ) break; - if( pParent->nOverflow && ALWAYS(i+nxDiv==pParent->aiOvfl[0]) ){ + if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){ apDiv[i] = pParent->apOvfl[0]; pgno = get4byte(apDiv[i]); szNew[i] = pParent->xCellSize(pParent, apDiv[i]); diff --git a/src/date.c b/src/date.c index 4326919601..a08248ce2f 100644 --- a/src/date.c +++ b/src/date.c @@ -395,13 +395,22 @@ static int parseDateOrTime( return 1; } +/* The julian day number for 9999-12-31 23:59:59.999 is 5373484.4999999. +** Multiplying this by 86400000 gives 464269060799999 as the maximum value +** for DateTime.iJD. +** +** But some older compilers (ex: gcc 4.2.1 on older Macs) cannot deal with +** such a large integer literal, so we have to encode it. +*/ +#define INT_464269060799999 ((((i64)0x1a640)<<32)|0x1072fdff) + /* ** Return TRUE if the given julian day number is within range. ** ** The input is the JulianDay times 86400000. */ static int validJulianDay(sqlite3_int64 iJD){ - return iJD>=0 && iJD<=464269060799999; + return iJD>=0 && iJD<=INT_464269060799999; } /* diff --git a/src/expr.c b/src/expr.c index 883273b3bc..6497d39cf9 100644 --- a/src/expr.c +++ b/src/expr.c @@ -414,9 +414,10 @@ Expr *sqlite3ExprForVectorField( assert( pVector->flags & EP_xIsSelect ); /* The TK_SELECT_COLUMN Expr node: ** - ** pLeft: pVector containing TK_SELECT + ** pLeft: pVector containing TK_SELECT. Not deleted. ** pRight: not used. But recursively deleted. ** iColumn: Index of a column in pVector + ** iTable: 0 or the number of columns on the LHS of an assignment ** pLeft->iTable: First in an array of register holding result, or 0 ** if the result is not yet computed. ** @@ -527,7 +528,10 @@ static void codeVectorCompare( u8 opx = op; int addrDone = sqlite3VdbeMakeLabel(v); - assert( nLeft==sqlite3ExprVectorSize(pRight) ); + if( nLeft!=sqlite3ExprVectorSize(pRight) ){ + sqlite3ErrorMsg(pParse, "row value misused"); + return; + } assert( pExpr->op==TK_EQ || pExpr->op==TK_NE || pExpr->op==TK_IS || pExpr->op==TK_ISNOT || pExpr->op==TK_LT || pExpr->op==TK_GT @@ -1085,7 +1089,7 @@ static int dupedExprStructSize(Expr *p, int flags){ assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */ assert( EXPR_FULLSIZE<=0xfff ); assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 ); - if( 0==flags ){ + if( 0==flags || p->op==TK_SELECT_COLUMN ){ nSize = EXPR_FULLSIZE; }else{ assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); @@ -1228,6 +1232,8 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){ if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){ if( pNew->op==TK_SELECT_COLUMN ){ pNew->pLeft = p->pLeft; + assert( p->iColumn==0 || p->pRight==0 ); + assert( p->pRight==0 || p->pRight==p->pLeft ); }else{ pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0); } @@ -1290,6 +1296,7 @@ ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags){ ExprList *pNew; struct ExprList_item *pItem, *pOldItem; int i; + Expr *pPriorSelectCol = 0; assert( db!=0 ); if( p==0 ) return 0; pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew) ); @@ -1304,7 +1311,24 @@ ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags){ pOldItem = p->a; for(i=0; inExpr; i++, pItem++, pOldItem++){ Expr *pOldExpr = pOldItem->pExpr; + Expr *pNewExpr; pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags); + if( pOldExpr + && pOldExpr->op==TK_SELECT_COLUMN + && (pNewExpr = pItem->pExpr)!=0 + ){ + assert( pNewExpr->iColumn==0 || i>0 ); + if( pNewExpr->iColumn==0 ){ + assert( pOldExpr->pLeft==pOldExpr->pRight ); + pPriorSelectCol = pNewExpr->pLeft = pNewExpr->pRight; + }else{ + assert( i>0 ); + assert( pItem[-1].pExpr!=0 ); + assert( pNewExpr->iColumn==pItem[-1].pExpr->iColumn+1 ); + assert( pPriorSelectCol==pItem[-1].pExpr->pLeft ); + pNewExpr->pLeft = pPriorSelectCol; + } + } pItem->zName = sqlite3DbStrDup(db, pOldItem->zName); pItem->zSpan = sqlite3DbStrDup(db, pOldItem->zSpan); pItem->sortOrder = pOldItem->sortOrder; @@ -1479,7 +1503,7 @@ no_mem: ** Or: (a,b,c) = (SELECT x,y,z FROM ....) ** ** For each term of the vector assignment, append new entries to the -** expression list pList. In the case of a subquery on the LHS, append +** expression list pList. In the case of a subquery on the RHS, append ** TK_SELECT_COLUMN expressions. */ ExprList *sqlite3ExprListAppendVector( @@ -1496,13 +1520,19 @@ ExprList *sqlite3ExprListAppendVector( ** exit prior to this routine being invoked */ if( NEVER(pColumns==0) ) goto vector_append_error; if( pExpr==0 ) goto vector_append_error; - n = sqlite3ExprVectorSize(pExpr); - if( pColumns->nId!=n ){ + + /* If the RHS is a vector, then we can immediately check to see that + ** the size of the RHS and LHS match. But if the RHS is a SELECT, + ** wildcards ("*") in the result set of the SELECT must be expanded before + ** we can do the size check, so defer the size check until code generation. + */ + if( pExpr->op!=TK_SELECT && pColumns->nId!=(n=sqlite3ExprVectorSize(pExpr)) ){ sqlite3ErrorMsg(pParse, "%d columns assigned %d values", pColumns->nId, n); goto vector_append_error; } - for(i=0; inId; i++){ Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i); pList = sqlite3ExprListAppend(pParse, pList, pSubExpr); if( pList ){ @@ -1511,11 +1541,20 @@ ExprList *sqlite3ExprListAppendVector( pColumns->a[i].zName = 0; } } + if( pExpr->op==TK_SELECT ){ if( pList && pList->a[iFirst].pExpr ){ - assert( pList->a[iFirst].pExpr->op==TK_SELECT_COLUMN ); - pList->a[iFirst].pExpr->pRight = pExpr; + Expr *pFirst = pList->a[iFirst].pExpr; + assert( pFirst->op==TK_SELECT_COLUMN ); + + /* Store the SELECT statement in pRight so it will be deleted when + ** sqlite3ExprListDelete() is called */ + pFirst->pRight = pExpr; pExpr = 0; + + /* Remember the size of the LHS in iTable so that we can check that + ** the RHS and LHS sizes match during code generation. */ + pFirst->iTable = pColumns->nId; } } @@ -3723,9 +3762,17 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ break; } case TK_SELECT_COLUMN: { + int n; if( pExpr->pLeft->iTable==0 ){ pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft, 0, 0); } + assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT ); + if( pExpr->iTable + && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft)) + ){ + sqlite3ErrorMsg(pParse, "%d columns assigned %d values", + pExpr->iTable, n); + } return pExpr->pLeft->iTable + pExpr->iColumn; } case TK_IN: { diff --git a/src/func.c b/src/func.c index ec50d97af0..e156e2c9d3 100644 --- a/src/func.c +++ b/src/func.c @@ -200,25 +200,28 @@ static void instrFunc( if( typeHaystack==SQLITE_NULL || typeNeedle==SQLITE_NULL ) return; nHaystack = sqlite3_value_bytes(argv[0]); nNeedle = sqlite3_value_bytes(argv[1]); - if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){ - zHaystack = sqlite3_value_blob(argv[0]); - zNeedle = sqlite3_value_blob(argv[1]); - isText = 0; - }else{ - zHaystack = sqlite3_value_text(argv[0]); - zNeedle = sqlite3_value_text(argv[1]); - isText = 1; - if( zNeedle==0 ) return; - assert( zHaystack ); + if( nNeedle>0 ){ + if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){ + zHaystack = sqlite3_value_blob(argv[0]); + zNeedle = sqlite3_value_blob(argv[1]); + assert( zNeedle!=0 ); + assert( zHaystack!=0 || nHaystack==0 ); + isText = 0; + }else{ + zHaystack = sqlite3_value_text(argv[0]); + zNeedle = sqlite3_value_text(argv[1]); + isText = 1; + if( zHaystack==0 || zNeedle==0 ) return; + } + while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){ + N++; + do{ + nHaystack--; + zHaystack++; + }while( isText && (zHaystack[0]&0xc0)==0x80 ); + } + if( nNeedle>nHaystack ) N = 0; } - while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){ - N++; - do{ - nHaystack--; - zHaystack++; - }while( isText && (zHaystack[0]&0xc0)==0x80 ); - } - if( nNeedle>nHaystack ) N = 0; sqlite3_result_int(context, N); } @@ -1631,7 +1634,7 @@ static void groupConcatStep( zSep = ","; nSep = 1; } - if( nSep ) sqlite3StrAccumAppend(pAccum, zSep, nSep); + if( zSep ) sqlite3StrAccumAppend(pAccum, zSep, nSep); } zVal = (char*)sqlite3_value_text(argv[0]); nVal = sqlite3_value_bytes(argv[0]); diff --git a/src/global.c b/src/global.c index ff6c7dba52..a105135561 100644 --- a/src/global.c +++ b/src/global.c @@ -169,6 +169,19 @@ const unsigned char sqlite3CtypeMap[256] = { # define SQLITE_STMTJRNL_SPILL (64*1024) #endif +/* +** The default lookaside-configuration, the format "SZ,N". SZ is the +** number of bytes in each lookaside slot (should be a multiple of 8) +** and N is the number of slots. The lookaside-configuration can be +** changed as start-time using sqlite3_config(SQLITE_CONFIG_LOOKASIDE) +** or at run-time for an individual database connection using +** sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE); +*/ +#ifndef SQLITE_DEFAULT_LOOKASIDE +# define SQLITE_DEFAULT_LOOKASIDE 1200,100 +#endif + + /* ** The following singleton contains the global configuration for ** the SQLite library. @@ -181,8 +194,7 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = { SQLITE_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */ 0x7ffffffe, /* mxStrlen */ 0, /* neverCorrupt */ - 512, /* szLookaside */ - 125, /* nLookaside */ + SQLITE_DEFAULT_LOOKASIDE, /* szLookaside, nLookaside */ SQLITE_STMTJRNL_SPILL, /* nStmtSpill */ {0,0,0,0,0,0,0,0}, /* m */ {0,0,0,0,0,0,0,0,0}, /* mutex */ diff --git a/src/main.c b/src/main.c index 244ac0f0fc..9aad8fdd4c 100644 --- a/src/main.c +++ b/src/main.c @@ -1568,7 +1568,7 @@ int sqlite3_busy_timeout(sqlite3 *db, int ms){ */ void sqlite3_interrupt(sqlite3 *db){ #ifdef SQLITE_ENABLE_API_ARMOR - if( !sqlite3SafetyCheckOk(db) ){ + if( !sqlite3SafetyCheckOk(db) && (db==0 || db->magic!=SQLITE_MAGIC_ZOMBIE) ){ (void)SQLITE_MISUSE_BKPT; return; } @@ -2739,7 +2739,9 @@ int sqlite3ParseUri( }else{ zFile = sqlite3_malloc64(nUri+2); if( !zFile ) return SQLITE_NOMEM_BKPT; - memcpy(zFile, zUri, nUri); + if( nUri ){ + memcpy(zFile, zUri, nUri); + } zFile[nUri] = '\0'; zFile[nUri+1] = '\0'; flags &= ~SQLITE_OPEN_URI; diff --git a/src/malloc.c b/src/malloc.c index 4ec1bca57c..84191c78a1 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -519,7 +519,7 @@ void *sqlite3Realloc(void *pOld, u64 nBytes){ sqlite3_mutex_enter(mem0.mutex); sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, (int)nBytes); nDiff = nNew - nOld; - if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= + if( nDiff>0 && sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= mem0.alarmThreshold-nDiff ){ sqlite3MallocAlarm(nDiff); } diff --git a/src/pager.c b/src/pager.c index 5bcb9247e8..5813b4db47 100644 --- a/src/pager.c +++ b/src/pager.c @@ -3964,6 +3964,7 @@ static int pagerSyncHotJournal(Pager *pPager){ return rc; } +#if SQLITE_MAX_MMAP_SIZE>0 /* ** Obtain a reference to a memory mapped page object for page number pgno. ** The new object will use the pointer pData, obtained from xFetch(). @@ -4012,6 +4013,7 @@ static int pagerAcquireMapPage( return SQLITE_OK; } +#endif /* ** Release a reference to page pPg. pPg must have been returned by an @@ -5371,6 +5373,7 @@ static int getPageNormal( assert( assert_pager_state(pPager) ); assert( pPager->hasHeldSharedLock==1 ); + if( pgno==0 ) return SQLITE_CORRUPT_BKPT; pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3); if( pBase==0 ){ pPg = 0; @@ -5398,11 +5401,10 @@ static int getPageNormal( /* The pager cache has created a new page. Its content needs to ** be initialized. But first some error checks: ** - ** (1) Minimum page number is 1 - ** (2) The maximum page number is 2^31 - ** (3) Never try to fetch the locking page + ** (1) The maximum page number is 2^31 + ** (2) Never try to fetch the locking page */ - if( pgno==0 || pgno>PAGER_MAX_PGNO || pgno==PAGER_MJ_PGNO(pPager) ){ + if( pgno>PAGER_MAX_PGNO || pgno==PAGER_MJ_PGNO(pPager) ){ rc = SQLITE_CORRUPT_BKPT; goto pager_acquire_err; } diff --git a/src/printf.c b/src/printf.c index 8de0a924ae..91b753e04f 100644 --- a/src/printf.c +++ b/src/printf.c @@ -841,7 +841,7 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){ assert( p->accError==0 || p->nAlloc==0 ); if( p->nChar+N >= p->nAlloc ){ enlargeAndAppend(p,z,N); - }else{ + }else if( N ){ assert( p->zText ); p->nChar += N; memcpy(&p->zText[p->nChar-N], z, N); diff --git a/src/shell.c b/src/shell.c index ae833d767a..b0928ce792 100644 --- a/src/shell.c +++ b/src/shell.c @@ -3292,7 +3292,7 @@ static void shellFkeyCollateClause( const char *zParentSeq; const char *zChild; const char *zChildCol; - const char *zChildSeq; + const char *zChildSeq = 0; /* Initialize to avoid false-positive warning */ int rc; assert( nVal==4 ); @@ -3500,7 +3500,7 @@ static int lintDotCommand( int nArg /* Number of entries in azArg[] */ ){ int n; - n = (nArg>=2 ? strlen(azArg[1]) : 0); + n = (nArg>=2 ? (int)strlen(azArg[1]) : 0); if( n<1 || sqlite3_strnicmp(azArg[1], "fkey-indexes", n) ) goto usage; return lintFkeyIndexes(pState, azArg, nArg); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index c4aaf39244..31cedf40e7 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -587,9 +587,12 @@ ** pagecaches for each database connection. A positive number is the ** number of pages. A negative number N translations means that a buffer ** of -1024*N bytes is allocated and used for as many pages as it will hold. +** +** The default value of "20" was choosen to minimize the run-time of the +** speedtest1 test program with options: --shrink-memory --reprepare */ #ifndef SQLITE_DEFAULT_PCACHE_INITSZ -# define SQLITE_DEFAULT_PCACHE_INITSZ 100 +# define SQLITE_DEFAULT_PCACHE_INITSZ 20 #endif /* @@ -1296,6 +1299,7 @@ struct sqlite3 { u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */ u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ u8 mTrace; /* zero or more SQLITE_TRACE flags */ + u8 skipBtreeMutex; /* True if no shared-cache backends */ int nextPagesize; /* Pagesize after VACUUM if >0 */ u32 magic; /* Magic number for detect library misuse */ int nChange; /* Value returned by sqlite3_changes() */ diff --git a/src/vdbe.c b/src/vdbe.c index ec722691f1..5e707a6232 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -977,7 +977,7 @@ case OP_Halt: { p->rc = pOp->p1; p->errorAction = (u8)pOp->p2; p->pc = pcx; - assert( pOp->p5>=0 && pOp->p5<=4 ); + assert( pOp->p5<=4 ); if( p->rc ){ if( pOp->p5 ){ static const char * const azType[] = { "NOT NULL", "UNIQUE", "CHECK", @@ -3783,7 +3783,8 @@ case OP_SeekGT: { /* jump, in3 */ if( pC->isTable ){ /* The BTREE_SEEK_EQ flag is only set on index cursors */ - assert( sqlite3BtreeCursorHasHint(pC->uc.pCursor, BTREE_SEEK_EQ)==0 ); + assert( sqlite3BtreeCursorHasHint(pC->uc.pCursor, BTREE_SEEK_EQ)==0 + || CORRUPT_DB ); /* The input value in P3 might be of any type: integer, real, string, ** blob, or NULL. But it needs to be an integer before we can do diff --git a/test/corruptC.test b/test/corruptC.test index 80c3c09f61..e2fb1f33c4 100644 --- a/test/corruptC.test +++ b/test/corruptC.test @@ -100,6 +100,12 @@ do_test corruptC-2.1 { } {1 {database disk image is malformed}} # test that a corrupt content offset size is handled (seed 5649) +# +# Update 2016-12-27: As of check-in [0b86fbca66] "In sqlite3BtreeInsert() when +# replacing a re-existing row, try to overwrite the cell directly rather than +# deallocate and reallocate the cell" on 2016-12-09, this test case no longer +# detects the offset size problem during the UPDATE. We have to run a subsequent +# integrity_check to see it. do_test corruptC-2.2 { db close forcecopy test.bu test.db @@ -117,8 +123,9 @@ do_test corruptC-2.2 { hexio_write test.db 3746 [format %02x 0x9a] sqlite3 db test.db - catchsql {UPDATE t1 SET y=1} -} {1 {database disk image is malformed}} + db eval {UPDATE t1 SET y=1} + db eval {PRAGMA integrity_check} +} {/Offset .* out of range/} # test that a corrupt free cell size is handled (seed 13329) do_test corruptC-2.3 { diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c index 90765ffc8d..75d519566f 100644 --- a/test/fuzzcheck.c +++ b/test/fuzzcheck.c @@ -70,7 +70,6 @@ #include #include #include "sqlite3.h" -#include #define ISSPACE(X) isspace((unsigned char)(X)) #define ISDIGIT(X) isdigit((unsigned char)(X)) @@ -636,14 +635,12 @@ static void inmemVfsRegister(int makeDefault){ */ static void runSql(sqlite3 *db, const char *zSql, unsigned runFlags){ const char *zMore; - const char *zEnd = &zSql[strlen(zSql)]; sqlite3_stmt *pStmt; while( zSql && zSql[0] ){ zMore = 0; pStmt = 0; sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zMore); - assert( zMore<=zEnd ); if( zMore==zSql ) break; if( runFlags & SQL_TRACE ){ const char *z = zSql; @@ -1195,6 +1192,8 @@ int main(int argc, char **argv){ } rc = sqlite3_open_v2("main.db", &db, openFlags, zVfs); if( rc ) fatalError("cannot open inmem database"); + sqlite3_limit(db, SQLITE_LIMIT_LENGTH, 100000000); + sqlite3_limit(db, SQLITE_LIMIT_LIKE_PATTERN_LENGTH, 50); if( cellSzCkFlag ) runSql(db, "PRAGMA cell_size_check=ON", runFlags); setAlarm(iTimeout); #ifndef SQLITE_OMIT_PROGRESS_CALLBACK diff --git a/test/gcfault.test b/test/gcfault.test new file mode 100644 index 0000000000..d54b78fafc --- /dev/null +++ b/test/gcfault.test @@ -0,0 +1,56 @@ +# 2016 December 30 +# +# 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 file is testing OOM error handling within the built-in +# group_concat() function. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix gcfault + + +foreach {enc} { + utf16 + utf8 +} { + reset_db + sqlite3_db_config_lookaside db 0 0 0 + execsql "PRAGMA encoding = $enc" + + do_execsql_test 1.$enc.1 { + CREATE TABLE s(i, s); + INSERT INTO s VALUES(1, ',0123456789,'); + INSERT INTO s VALUES(2, X'2c303132333435363738392c'); + + CREATE TABLE e(e); + INSERT INTO e VALUES('v1'), ('v2'); + } {} + + do_faultsim_test 1.$enc.1 -faults oom* -body { + execsql { SELECT group_concat(e, (SELECT s FROM s WHERE i=1)) FROM e } + } + + do_faultsim_test 1.$enc.2 -faults oom-t* -body { + execsql { SELECT group_concat(e, (SELECT s FROM s WHERE i=2)) FROM e } + } + + do_faultsim_test 1.$enc.3 -faults oom-t* -prep { + set ::STMT [sqlite3_prepare db {SELECT group_concat(e, ?) FROM e} -1 dummy] + sqlite3_bind_text $::STMT 1 ",0123456789," 12 + } -body { + while { "SQLITE_ROW"==[sqlite3_step $::STMT] } { } + } -test { + sqlite3_finalize $::STMT + } +} + +finish_test diff --git a/test/instr.test b/test/instr.test index c8be4862b9..2caf3bce3b 100644 --- a/test/instr.test +++ b/test/instr.test @@ -248,4 +248,13 @@ do_execsql_test instr-1.62 { SELECT coalesce(instr(NULL,NULL), 999); } {999} +do_execsql_test instr-1.63 { + SELECT instr(X'', 'abc') +} 0 +do_execsql_test instr-1.64 { + CREATE TABLE x1(a, b); + INSERT INTO x1 VALUES(X'', 'abc'); + SELECT instr(a, b) FROM x1; +} 0 + finish_test diff --git a/test/instrfault.test b/test/instrfault.test index e2d93e742d..0ddb12c84b 100644 --- a/test/instrfault.test +++ b/test/instrfault.test @@ -29,6 +29,8 @@ foreach {enc} { utf16 } { reset_db + sqlite3_db_config_lookaside db 0 0 0 + execsql "PRAGMA encoding = $enc" do_execsql_test 1.$enc.1 { CREATE TABLE t1(n, h); @@ -63,6 +65,28 @@ foreach {enc} { faultsim_test_result {0 31} sqlite3_finalize $::stmt } + + do_faultsim_test 1.$enc.4 -faults oom-t* -prep { + set ::stmt [sqlite3_prepare_v2 db "SELECT instr(?, ?)" -1 dummy] + sqlite3_bind_blob $::stmt 1 $::HAYSTACK [string length $::HAYSTACK] + sqlite3_bind_text $::stmt 2 $::NEEDLE [string length $::NEEDLE] + } -body { + set rc [sqlite3_step $::stmt] + if {$rc=="SQLITE_NOMEM"} { error "out of memory" } + sqlite3_column_int $::stmt 0 + } -test { + faultsim_test_result {0 31} + sqlite3_finalize $::stmt + } + + do_execsql_test 1.$enc.5.0 { + CREATE TABLE h1(a, b); + INSERT INTO h1 VALUES('abcdefg%200hijkl', randomblob(200)); + INSERT INTO h1 SELECT b, a FROM h1; + } + do_faultsim_test 1.$enc.5 -faults oom-t* -body { + execsql { SELECT rowid FROM h1 WHERE instr(a,b) } + } -test {} } finish_test diff --git a/test/interrupt2.test b/test/interrupt2.test index 59ad7b3893..b9c66bd1f4 100644 --- a/test/interrupt2.test +++ b/test/interrupt2.test @@ -18,6 +18,11 @@ source $testdir/tester.tcl source $testdir/wal_common.tcl set testprefix interrupt2 +if {[permutation]=="journaltest" || [permutation]=="inmemory_journal"} { + finish_test + return +} + db close testvfs tvfs -default 1 diff --git a/test/kvtest.c b/test/kvtest.c new file mode 100644 index 0000000000..877605aced --- /dev/null +++ b/test/kvtest.c @@ -0,0 +1,583 @@ +/* +** 2016-12-28 +** +** 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 "key-value" performance test for SQLite. The +** purpose is to compare the speed of SQLite for accessing large BLOBs +** versus reading those same BLOB values out of individual files in the +** filesystem. +** +** Run "kvtest" with no arguments for on-line help, or see comments below. +** +** HOW TO COMPILE: +** +** (1) Gather this source file and a recent SQLite3 amalgamation with its +** header into the working directory. You should have: +** +** kvtest.c >--- this file +** sqlite3.c \___ SQLite +** sqlite3.h / amlagamation & header +** +** (2) Run you compiler against the two C source code files. +** +** (a) On linux or mac: +** +** OPTS="-DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION" +** gcc -Os -I. $OPTS kvtest.c sqlite3.c -o kvtest +** +** The $OPTS options can be omitted. The $OPTS merely omit +** the need to link against -ldl and -lpthread, or whatever +** the equivalent libraries are called on your system. +** +** (b) Windows with MSVC: +** +** cl -I. kvtest.c sqlite3.c +** +** USAGE: +** +** (1) Create a test database by running "kvtest init" with appropriate +** options. See the help message for available options. +** +** (2) Construct the corresponding pile-of-files database on disk using +** the "kvtest export" command. +** +** (3) Run tests using "kvtest run" against either the SQLite database or +** the pile-of-files database and with appropriate options. +** +** For example: +** +** ./kvtest init x1.db --count 100000 --size 10000 +** mkdir x1 +** ./kvtest export x1.db x1 +** ./kvtest run x1.db --count 10000 --max-id 1000000 +** ./kvtest run x1 --count 10000 --max-id 1000000 +*/ +static const char zHelp[] = +"Usage: kvhelp COMMAND ARGS...\n" +"\n" +" kvhelp init DBFILE --count N --size M --pagesize X\n" +"\n" +" Generate a new test database file named DBFILE containing N\n" +" BLOBs each of size M bytes. The page size of the new database\n" +" file will be X\n" +"\n" +" kvhelp export DBFILE DIRECTORY\n" +"\n" +" Export all the blobs in the kv table of DBFILE into separate\n" +" files in DIRECTORY.\n" +"\n" +" kvhelp run DBFILE [options]\n" +"\n" +" Run a performance test. DBFILE can be either the name of a\n" +" database or a directory containing sample files. Options:\n" +"\n" +" --asc Read blobs in ascending order\n" +" --blob-api Use the BLOB API\n" +" --cache-size N Database cache size\n" +" --count N Read N blobs\n" +" --desc Read blobs in descending order\n" +" --max-id N Maximum blob key to use\n" +" --random Read blobs in a random order\n" +" --start N Start reading with this blob key\n" +; + +/* Reference resources used */ +#include +#include +#include +#include +#include +#include +#include "sqlite3.h" + +#ifndef _WIN32 +# include +#else + /* Provide Windows equivalent for the needed parts of unistd.h */ +# include +# define R_OK 2 +# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +# define access _access +#endif + + +/* +** Show thqe help text and quit. +*/ +static void showHelp(void){ + fprintf(stdout, "%s", zHelp); + exit(1); +} + +/* +** Show an error message an quit. +*/ +static void fatalError(const char *zFormat, ...){ + va_list ap; + fprintf(stdout, "ERROR: "); + va_start(ap, zFormat); + vfprintf(stdout, zFormat, ap); + va_end(ap); + fprintf(stdout, "\n"); + exit(1); +} + +/* +** Check the filesystem object zPath. Determine what it is: +** +** PATH_DIR A directory +** PATH_DB An SQLite database +** PATH_NEXIST Does not exist +** PATH_OTHER Something else +*/ +#define PATH_DIR 1 +#define PATH_DB 2 +#define PATH_NEXIST 0 +#define PATH_OTHER 99 +static int pathType(const char *zPath){ + struct stat x; + int rc; + if( access(zPath,R_OK) ) return PATH_NEXIST; + memset(&x, 0, sizeof(x)); + rc = stat(zPath, &x); + if( rc<0 ) return PATH_OTHER; + if( S_ISDIR(x.st_mode) ) return PATH_DIR; + if( (x.st_size%512)==0 ) return PATH_DB; + return PATH_OTHER; +} + +/* +** Return the size of a file in bytes. Or return -1 if the +** named object is not a regular file or does not exist. +*/ +static sqlite3_int64 fileSize(const char *zPath){ + struct stat x; + int rc; + memset(&x, 0, sizeof(x)); + rc = stat(zPath, &x); + if( rc<0 ) return -1; + if( !S_ISREG(x.st_mode) ) return -1; + return x.st_size; +} + +/* +** A Pseudo-random number generator with a fixed seed. Use this so +** that the same sequence of "random" numbers are generated on each +** run, for repeatability. +*/ +static unsigned int randInt(void){ + static unsigned int x = 0x333a13cd; + static unsigned int y = 0xecb2adea; + x = (x>>1) ^ ((1+~(x&1)) & 0xd0000001); + y = y*1103515245 + 12345; + return x^y; +} + +/* +** Do database initialization. +*/ +static int initMain(int argc, char **argv){ + char *zDb; + int i, rc; + int nCount = 1000; + int sz = 10000; + int pgsz = 4096; + sqlite3 *db; + char *zSql; + char *zErrMsg = 0; + + assert( strcmp(argv[1],"init")==0 ); + assert( argc>=3 ); + zDb = argv[2]; + for(i=3; i65536 || ((pgsz-1)&pgsz)!=0 ){ + fatalError("the --pagesize must be power of 2 between 512 and 65536"); + } + continue; + } + fatalError("unknown option: \"%s\"", argv[i]); + } + rc = sqlite3_open(zDb, &db); + if( rc ){ + fatalError("cannot open database \"%s\": %s", zDb, sqlite3_errmsg(db)); + } + zSql = sqlite3_mprintf( + "DROP TABLE IF EXISTS kv;\n" + "PRAGMA page_size=%d;\n" + "VACUUM;\n" + "BEGIN;\n" + "CREATE TABLE kv(k INTEGER PRIMARY KEY, v BLOB);\n" + "WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<%d)" + " INSERT INTO kv(k,v) SELECT x, randomblob(%d) FROM c;\n" + "COMMIT;\n", + pgsz, nCount, sz + ); + rc = sqlite3_exec(db, zSql, 0, 0, &zErrMsg); + if( rc ) fatalError("database create failed: %s", zErrMsg); + sqlite3_free(zSql); + sqlite3_close(db); + return 0; +} + +/* +** Implementation of the "writefile(X,Y)" SQL function. The argument Y +** is written into file X. The number of bytes written is returned. Or +** NULL is returned if something goes wrong, such as being unable to open +** file X for writing. +*/ +static void writefileFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + FILE *out; + const char *z; + sqlite3_int64 rc; + const char *zFile; + + zFile = (const char*)sqlite3_value_text(argv[0]); + if( zFile==0 ) return; + out = fopen(zFile, "wb"); + if( out==0 ) return; + z = (const char*)sqlite3_value_blob(argv[1]); + if( z==0 ){ + rc = 0; + }else{ + rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out); + } + fclose(out); + printf("\r%s ", zFile); fflush(stdout); + sqlite3_result_int64(context, rc); +} + +/* +** Export the kv table to individual files in the filesystem +*/ +static int exportMain(int argc, char **argv){ + char *zDb; + char *zDir; + sqlite3 *db; + char *zSql; + int rc; + char *zErrMsg = 0; + + assert( strcmp(argv[1],"export")==0 ); + assert( argc>=3 ); + zDb = argv[2]; + if( argc!=4 ) fatalError("Usage: kvtest export DATABASE DIRECTORY"); + zDir = argv[3]; + if( pathType(zDir)!=PATH_DIR ){ + fatalError("object \"%s\" is not a directory", zDir); + } + rc = sqlite3_open(zDb, &db); + if( rc ){ + fatalError("cannot open database \"%s\": %s", zDb, sqlite3_errmsg(db)); + } + sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0, + writefileFunc, 0, 0); + zSql = sqlite3_mprintf( + "SELECT writefile(printf('%s/%%06d',k),v) FROM kv;", + zDir + ); + rc = sqlite3_exec(db, zSql, 0, 0, &zErrMsg); + if( rc ) fatalError("database create failed: %s", zErrMsg); + sqlite3_free(zSql); + sqlite3_close(db); + printf("\n"); + return 0; +} + +/* +** Read the content of file zName into memory obtained from sqlite3_malloc64() +** and return a pointer to the buffer. The caller is responsible for freeing +** the memory. +** +** If parameter pnByte is not NULL, (*pnByte) is set to the number of bytes +** read. +** +** For convenience, a nul-terminator byte is always appended to the data read +** from the file before the buffer is returned. This byte is not included in +** the final value of (*pnByte), if applicable. +** +** NULL is returned if any error is encountered. The final value of *pnByte +** is undefined in this case. +*/ +static unsigned char *readFile(const char *zName, int *pnByte){ + FILE *in; /* FILE from which to read content of zName */ + sqlite3_int64 nIn; /* Size of zName in bytes */ + size_t nRead; /* Number of bytes actually read */ + unsigned char *pBuf; /* Content read from disk */ + + nIn = fileSize(zName); + if( nIn<0 ) return 0; + in = fopen(zName, "rb"); + if( in==0 ) return 0; + pBuf = sqlite3_malloc64( nIn ); + if( pBuf==0 ) return 0; + nRead = fread(pBuf, nIn, 1, in); + fclose(in); + if( nRead!=1 ){ + sqlite3_free(pBuf); + return 0; + } + if( pnByte ) *pnByte = nIn; + return pBuf; +} + +/* +** Return the current time in milliseconds since the beginning of +** the Julian epoch. +*/ +static sqlite3_int64 timeOfDay(void){ + static sqlite3_vfs *clockVfs = 0; + sqlite3_int64 t; + if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0); + if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){ + clockVfs->xCurrentTimeInt64(clockVfs, &t); + }else{ + double r; + clockVfs->xCurrentTime(clockVfs, &r); + t = (sqlite3_int64)(r*86400000.0); + } + return t; +} + +/* Blob access order */ +#define ORDER_ASC 1 +#define ORDER_DESC 2 +#define ORDER_RANDOM 3 + +/* +** Run a performance test +*/ +static int runMain(int argc, char **argv){ + int eType; /* Is zDb a database or a directory? */ + char *zDb; /* Database or directory name */ + int i; /* Loop counter */ + int rc; /* Return code from SQLite calls */ + int nCount = 1000; /* Number of blob fetch operations */ + int nExtra = 0; /* Extra cycles */ + int iKey = 1; /* Next blob key */ + int iMax = 1000; /* Largest allowed key */ + int iPagesize = 0; /* Database page size */ + int iCache = 1000; /* Database cache size in kibibytes */ + int bBlobApi = 0; /* Use the incremental blob I/O API */ + int eOrder = ORDER_ASC; /* Access order */ + sqlite3 *db = 0; /* Database connection */ + sqlite3_stmt *pStmt = 0; /* Prepared statement for SQL access */ + sqlite3_blob *pBlob = 0; /* Handle for incremental Blob I/O */ + sqlite3_int64 tmStart; /* Start time */ + sqlite3_int64 tmElapsed; /* Elapsed time */ + int nData = 0; /* Bytes of data */ + sqlite3_int64 nTotal = 0; /* Total data read */ + unsigned char *pData; /* Content of the blob */ + + + assert( strcmp(argv[1],"run")==0 ); + assert( argc>=3 ); + zDb = argv[2]; + eType = pathType(zDb); + if( eType==PATH_OTHER ) fatalError("unknown object type: \"%s\"", zDb); + if( eType==PATH_NEXIST ) fatalError("object does not exist: \"%s\"", zDb); + for(i=3; iiMax ) iKey = 1; + }else if( eOrder==ORDER_DESC ){ + iKey--; + if( iKey<=0 ) iKey = iMax; + }else{ + iKey = (randInt()%iMax)+1; + } + nTotal += nData; + if( nData==0 ){ nCount++; nExtra++; } + } + if( pStmt ) sqlite3_finalize(pStmt); + if( pBlob ) sqlite3_blob_close(pBlob); + if( db ) sqlite3_close(db); + tmElapsed = timeOfDay() - tmStart; + if( nExtra ){ + printf("%d cycles due to %d misses\n", nCount, nExtra); + } + if( eType==PATH_DB ){ + printf("SQLite version: %s\n", sqlite3_libversion()); + } + printf("--count %d --max-id %d", nCount-nExtra, iMax); + if( eType==PATH_DB ){ + printf(" --cache-size %d", iCache); + } + switch( eOrder ){ + case ORDER_RANDOM: printf(" --random\n"); break; + case ORDER_DESC: printf(" --desc\n"); break; + default: printf(" --asc\n"); break; + } + if( iPagesize ) printf("Database page size: %d\n", iPagesize); + printf("Total elapsed time: %.3f\n", tmElapsed/1000.0); + printf("Microseconds per BLOB read: %.3f\n", tmElapsed*1000.0/nCount); + printf("Content read rate: %.1f MB/s\n", nTotal/(1000.0*tmElapsed)); + return 0; +} + + +int main(int argc, char **argv){ + if( argc<3 ) showHelp(); + if( strcmp(argv[1],"init")==0 ){ + return initMain(argc, argv); + } + if( strcmp(argv[1],"export")==0 ){ + return exportMain(argc, argv); + } + if( strcmp(argv[1],"run")==0 ){ + return runMain(argc, argv); + } + showHelp(); + return 0; +} diff --git a/test/nockpt.test b/test/nockpt.test index cf350c3e1b..bd3953f1ee 100644 --- a/test/nockpt.test +++ b/test/nockpt.test @@ -19,10 +19,15 @@ source $testdir/lock_common.tcl source $testdir/malloc_common.tcl source $testdir/wal_common.tcl ifcapable !wal {finish_test ; return } +if {[permutation]=="journaltest" || [permutation]=="inmemory_journal"} { + finish_test + return +} set testprefix nockpt do_execsql_test 1.0 { + PRAGMA auto_vacuum=OFF; PRAGMA page_size = 1024; PRAGMA journal_mode = wal; CREATE TABLE c1(x, y, z); diff --git a/test/ossfuzz.c b/test/ossfuzz.c index 4bf0eb5e41..3a3e852c34 100644 --- a/test/ossfuzz.c +++ b/test/ossfuzz.c @@ -6,12 +6,14 @@ #include #include "sqlite3.h" +#ifndef SQLITE_OMIT_PROGRESS_CALLBACK /* ** Progress handler callback */ static int progress_handler(void *pReturn) { return *(int*)pReturn; } +#endif /* ** Callback for sqlite3_exec(). @@ -53,11 +55,13 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY, 0); if( rc ) return 0; +#ifndef SQLITE_OMIT_PROGRESS_CALLBACK /* Bit 0 of the selector enables progress callbacks. Bit 1 is the ** return code from progress callbacks */ if( uSelector & 1 ){ sqlite3_progress_handler(db, 4, progress_handler, (void*)&progressArg); } +#endif uSelector >>= 1; progressArg = uSelector & 1; uSelector >>= 1; diff --git a/test/rowvalue.test b/test/rowvalue.test index 1e59bb5df9..5f2701c733 100644 --- a/test/rowvalue.test +++ b/test/rowvalue.test @@ -315,5 +315,83 @@ foreach {tn n sql} { do_catchsql_test 14.2.$tn $sql [list 1 $err] } +#-------------------------------------------------------------------------- +# Test for vector size mismatches concealed by unexpanded subqueries. +# +do_catchsql_test 15.1 { + DETACH (SELECT * FROM (SELECT 1,2))<3; +} {1 {row value misused}} +do_catchsql_test 15.2 { + UPDATE x1 SET a=(SELECT * FROM (SELECT b,2))<3; +} {1 {row value misused}} +do_catchsql_test 15.3 { + UPDATE x1 SET a=NULL WHERE a<(SELECT * FROM (SELECT b,2)); +} {1 {sub-select returns 2 columns - expected 1}} +do_catchsql_test 15.4 { + DELETE FROM x1 WHERE a<(SELECT * FROM (SELECT b,2)); +} {1 {sub-select returns 2 columns - expected 1}} +do_catchsql_test 15.5 { + INSERT INTO x1(a,b) VALUES(1,(SELECT * FROM (SELECT 1,2))<3); +} {1 {row value misused}} + +#------------------------------------------------------------------------- +# Row-values used in UPDATE statements within TRIGGERs +# +# Ticket https://www.sqlite.org/src/info/8c9458e703666e1a +# +do_execsql_test 16.1 { + CREATE TABLE t16a(a,b,c); + INSERT INTO t16a VALUES(1,2,3); + CREATE TABLE t16b(x); + INSERT INTO t16b(x) VALUES(1); + CREATE TRIGGER t16r AFTER UPDATE ON t16b BEGIN + UPDATE t16a SET (a,b,c)=(SELECT new.x,new.x+1,new.x+2); + END; + UPDATE t16b SET x=7; + SELECT * FROM t16a; +} {7 8 9} +do_execsql_test 16.2 { + UPDATE t16b SET x=97; + SELECT * FROM t16a; +} {97 98 99} + +do_execsql_test 16.3 { + CREATE TABLE t16c(a, b, c, d, e); + INSERT INTO t16c VALUES(1, 'a', 'b', 'c', 'd'); + CREATE TRIGGER t16c1 AFTER INSERT ON t16c BEGIN + UPDATE t16c SET (c, d) = (SELECT 'A', 'B'), (e, b) = (SELECT 'C', 'D') + WHERE a = new.a-1; + END; + + SELECT * FROM t16c; +} {1 a b c d} + +do_execsql_test 16.4 { + INSERT INTO t16c VALUES(2, 'w', 'x', 'y', 'z'); + SELECT * FROM t16c; +} { + 1 D A B C + 2 w x y z +} + +do_execsql_test 16.5 { + DROP TRIGGER t16c1; + PRAGMA recursive_triggers = 1; + INSERT INTO t16c VALUES(3, 'i', 'ii', 'iii', 'iv'); + CREATE TRIGGER t16c1 AFTER UPDATE ON t16c WHEN new.a>1 BEGIN + UPDATE t16c SET (e, d) = ( + SELECT b, c FROM t16c WHERE a = new.a-1 + ), (c, b) = ( + SELECT d, e FROM t16c WHERE a = new.a-1 + ) WHERE a = new.a-1; + END; + + UPDATE t16c SET a=a WHERE a=3; + SELECT * FROM t16c; +} { + 1 C B A D + 2 z y x w + 3 i ii iii iv +} finish_test diff --git a/test/shell1.test b/test/shell1.test index 9400d75296..95c3130bdd 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -273,6 +273,7 @@ do_test shell1-3.2.4 { catchcmd "test.db" ".bail OFF BAD" } {1 {Usage: .bail on|off}} +ifcapable vtab { # .databases List names and files of attached databases do_test shell1-3.3.1 { catchcmd "-csv test.db" ".databases" @@ -281,6 +282,7 @@ do_test shell1-3.3.2 { # extra arguments ignored catchcmd "test.db" ".databases BAD" } "/0.+main.+[string map {/ ".{1,2}"} [string range [get_pwd] 0 10]].*/" +} # .dump ?TABLE? ... Dump the database in an SQL text format # If TABLE specified, only dump tables matching diff --git a/test/shell6.test b/test/shell6.test index 028ac5efe9..a70c4b4298 100644 --- a/test/shell6.test +++ b/test/shell6.test @@ -14,6 +14,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +ifcapable !vtab {finish_test; return} set testprefix shell6 set CLI [test_find_cli] db close @@ -98,5 +99,3 @@ foreach {tn schema output} { } finish_test - - diff --git a/test/speedtest1.c b/test/speedtest1.c index d568aada0a..02d55d5974 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -50,7 +50,11 @@ static const char zHelp[] = #include #include #include -#include +#ifndef _WIN32 +# include +#else +# include +#endif #define ISSPACE(X) isspace((unsigned char)(X)) #define ISDIGIT(X) isdigit((unsigned char)(X)) @@ -1374,7 +1378,7 @@ int main(int argc, char **argv){ int doIncrvac = 0; /* True for --incrvacuum */ const char *zJMode = 0; /* Journal mode */ const char *zKey = 0; /* Encryption key */ - int nLook = 0, szLook = 0; /* --lookaside configuration */ + int nLook = -1, szLook = 0; /* --lookaside configuration */ int noSync = 0; /* True for --nosync */ int pageSize = 0; /* Desired page size. 0 means default */ int nPCache = 0, szPCache = 0;/* --pcache configuration */ @@ -1558,7 +1562,7 @@ int main(int argc, char **argv){ rc = sqlite3_config(SQLITE_CONFIG_SCRATCH, pScratch, szScratch, nScratch); if( rc ) fatal_error("scratch configuration failed: %d\n", rc); } - if( nLook>0 ){ + if( nLook>=0 ){ sqlite3_config(SQLITE_CONFIG_LOOKASIDE, 0, 0); } #endif diff --git a/test/wordcount.c b/test/wordcount.c index 5002918c5e..bc1d499f15 100644 --- a/test/wordcount.c +++ b/test/wordcount.c @@ -13,24 +13,6 @@ ** ** Option: ** -** --without-rowid Use a WITHOUT ROWID table to store the words. -** --insert Use INSERT mode (the default) -** --replace Use REPLACE mode -** --select Use SELECT mode -** --update Use UPDATE mode -** --delete Use DELETE mode -** --query Use QUERY mode -** --nocase Add the NOCASE collating sequence to the words. -** --trace Enable sqlite3_trace() output. -** --summary Show summary information on the collected data. -** --stats Show sqlite3_status() results at the end. -** --pagesize NNN Use a page size of NNN -** --cachesize NNN Use a cache size of NNN -** --commit NNN Commit after every NNN operations -** --nosync Use PRAGMA synchronous=OFF -** --journal MMMM Use PRAGMA journal_mode=MMMM -** --timer Time the operation of this program -** --tag NAME Tag all output using NAME. Use only stdout. ** ** Modes: ** @@ -81,8 +63,36 @@ #include #include #include "sqlite3.h" +#ifndef _WIN32 +# include +#else +# include +#endif #define ISALPHA(X) isalpha((unsigned char)(X)) +const char zHelp[] = +"Usage: wordcount [OPTIONS] DATABASE [INPUT]\n" +" --all Repeat the test for all test modes\n" +" --cachesize NNN Use a cache size of NNN\n" +" --commit NNN Commit after every NNN operations\n" +" --delete Use DELETE mode\n" +" --insert Use INSERT mode (the default)\n" +" --journal MMMM Use PRAGMA journal_mode=MMMM\n" +" --nocase Add the NOCASE collating sequence to the words.\n" +" --nosync Use PRAGMA synchronous=OFF\n" +" --pagesize NNN Use a page size of NNN\n" +" --query Use QUERY mode\n" +" --replace Use REPLACE mode\n" +" --select Use SELECT mode\n" +" --stats Show sqlite3_status() results at the end.\n" +" --summary Show summary information on the collected data.\n" +" --tag NAME Tag all output using NAME. Use only stdout.\n" +" --timer Time the operation of this program\n" +" --trace Enable sqlite3_trace() output.\n" +" --update Use UPDATE mode\n" +" --without-rowid Use a WITHOUT ROWID table to store the words.\n" +; + /* Output tag */ char *zTag = "--"; @@ -110,6 +120,12 @@ static void fatal_error(const char *zMsg, ...){ exit(1); } +/* Print a usage message and quit */ +static void usage(void){ + printf("%s",zHelp); + exit(0); +} + /* The sqlite3_trace() callback function */ static void traceCallback(void *NotUsed, const char *zSql){ printf("%s;\n", zSql); @@ -189,7 +205,6 @@ static void checksumFinalize(sqlite3_context *context){ } } - /* Define operating modes */ #define MODE_INSERT 0 #define MODE_REPLACE 1 @@ -197,12 +212,50 @@ static void checksumFinalize(sqlite3_context *context){ #define MODE_UPDATE 3 #define MODE_DELETE 4 #define MODE_QUERY 5 +#define MODE_COUNT 6 +#define MODE_ALL (-1) + +/* Mode names */ +static const char *azMode[] = { + "--insert", + "--replace", + "--select", + "--update", + "--delete", + "--query" +}; + +/* +** Determine if another iteration of the test is required. Return true +** if so. Return zero if all iterations have finished. +*/ +static int allLoop( + int iMode, /* The selected test mode */ + int *piLoopCnt, /* Iteration loop counter */ + int *piMode2, /* The test mode to use on the next iteration */ + int *pUseWithoutRowid /* Whether or not to use --without-rowid */ +){ + int i; + if( iMode!=MODE_ALL ){ + if( *piLoopCnt ) return 0; + *piMode2 = iMode; + *piLoopCnt = 1; + return 1; + } + if( (*piLoopCnt)>=MODE_COUNT*2 ) return 0; + i = (*piLoopCnt)++; + *pUseWithoutRowid = i&1; + *piMode2 = i>>1; + return 1; +} int main(int argc, char **argv){ const char *zFileToRead = 0; /* Input file. NULL for stdin */ const char *zDbName = 0; /* Name of the database file to create */ int useWithoutRowid = 0; /* True for --without-rowid */ int iMode = MODE_INSERT; /* One of MODE_xxxxx */ + int iMode2; /* Mode to use for current --all iteration */ + int iLoopCnt = 0; /* Which iteration when running --all */ int useNocase = 0; /* True for --nocase */ int doTrace = 0; /* True for --trace */ int showStats = 0; /* True for --stats */ @@ -226,7 +279,8 @@ int main(int argc, char **argv){ int iCur, iHiwtr; /* Statistics values, current and "highwater" */ FILE *pTimer = stderr; /* Output channel for the timer */ sqlite3_int64 sumCnt = 0; /* Sum in QUERY mode */ - sqlite3_int64 startTime; + sqlite3_int64 startTime; /* Time of start */ + sqlite3_int64 totalTime = 0; /* Total time */ char zInput[2000]; /* A single line of input */ /* Process command-line arguments */ @@ -248,6 +302,9 @@ int main(int argc, char **argv){ iMode = MODE_DELETE; }else if( strcmp(z,"query")==0 ){ iMode = MODE_QUERY; + }else if( strcmp(z,"all")==0 ){ + iMode = MODE_ALL; + showTimer = -99; }else if( strcmp(z,"nocase")==0 ){ useNocase = 1; }else if( strcmp(z,"trace")==0 ){ @@ -274,23 +331,30 @@ int main(int argc, char **argv){ }else if( strcmp(z,"tag")==0 && i0 && (nOp%commitInterval)==0 ){ + sqlite3_exec(db, "COMMIT; BEGIN IMMEDIATE", 0, 0, 0); } } - i = j-1; - - /* Increment the operation counter. Do a COMMIT if it is time. */ - nOp++; - if( commitInterval>0 && (nOp%commitInterval)==0 ){ - sqlite3_exec(db, "COMMIT; BEGIN IMMEDIATE", 0, 0, 0); + } + sqlite3_exec(db, "COMMIT", 0, 0, 0); + sqlite3_finalize(pInsert); pInsert = 0; + sqlite3_finalize(pUpdate); pUpdate = 0; + sqlite3_finalize(pSelect); pSelect = 0; + sqlite3_finalize(pDelete); pDelete = 0; + + if( iMode2==MODE_QUERY && iMode!=MODE_ALL ){ + printf("%s sum of cnt: %lld\n", zTag, sumCnt); + rc = sqlite3_prepare_v2(db,"SELECT sum(cnt*cnt) FROM wordcount", -1, + &pSelect, 0); + if( rc==SQLITE_OK && sqlite3_step(pSelect)==SQLITE_ROW ){ + printf("%s double-check: %lld\n", zTag,sqlite3_column_int64(pSelect,0)); + } + sqlite3_finalize(pSelect); + } + + + if( showTimer ){ + sqlite3_int64 elapseTime = realTime() - startTime; + totalTime += elapseTime; + fprintf(pTimer, "%3d.%03d wordcount", (int)(elapseTime/1000), + (int)(elapseTime%1000)); + if( iMode==MODE_ALL ){ + fprintf(pTimer, " %s%s\n", azMode[iMode2], + useWithoutRowid? " --without-rowid" : ""); + }else{ + for(i=1; irule; rp; rp=rp->next) rp->doesReduce = LEMON_FALSE; for(i=0; inxstate; i++){ - struct action *ap; for(ap=lemp->sorted[i]->ap; ap; ap=ap->next){ if( ap->type==REDUCE || ap->type==SHIFTREDUCE ){ ap->x.rp->doesReduce = i;