Commit Graph

21678 Commits

Author SHA1 Message Date
drh
cdfadc7948 Minor changes for consistency between sqlite3_filename_wal() and
sqlite3_filename_journal().

FossilOrigin-Name: 9a70ff43a7b6848a71d5049f5a4ae24e3eb8a83d5c6651f5a9937abf03b3eccf
2020-01-11 20:27:02 +00:00
drh
8080403e44 Redesign for better legacy compatibility. Add the sqlite3_uri_key() interface.
FossilOrigin-Name: bcb43d11c4d0be36888c9e968ccdf85e7d7fccd72a29866f85c014e0562d4b93
2020-01-11 16:08:31 +00:00
drh
8875b9e7b5 Rearchitect the way in which filenames are stored in the Pager object so that
the sqlite3_uri_parameter() interface will work from journal and WAL filenames
too.  This check-in implements the central idea, and compile and runs somewhat,
but crashes on an extended test.

FossilOrigin-Name: 2ae77bd2335708343bce4541b4d2cf16edfe3fd5bc2dfb93757238c926aa960b
2020-01-10 18:05:55 +00:00
drh
b2fe5a7c35 Fix to the register validity tracking logic in debug builds. No impact
on release builds.

FossilOrigin-Name: 0a500da6aa659a8e73206e6d22ddbf2da5e4f1d1d551eeb66433163a3e13109d
2020-01-10 01:05:49 +00:00
drh
e5f8801044 Documentation updates on newer APIs. No changes to code.
FossilOrigin-Name: 8845a8c22a4ceabee130ce2addbe07e13b0496eeb542c89850f8658d21a48f89
2020-01-10 00:00:18 +00:00
drh
2e22579dea Fix the fossildelta.c extension so that it will compile on mingw.
FossilOrigin-Name: 20237d5dc4451f142b511e50a4acef4574cef17b9222c87dcebfe1ed1bab0ad9
2020-01-09 23:07:21 +00:00
drh
bebce86cde Merge in the untrusted-schema enhancements.
See [/doc/87aea3ab1cdda453/doc/trusted-schema.md|doc/trusted-schema.md]
for details.

FossilOrigin-Name: 5720924cb07766cd54fb042da58f4b4acf12b60029fba86a23a606ad0d0f7c68
2020-01-09 20:44:37 +00:00
drh
32d184e049 Only register the fts3_tokenizer() function using a single text encoding.
FossilOrigin-Name: 966964af1021feebc56cfda7b08bc787be7f447d682299f7958463aca30a73af
2020-01-09 20:33:36 +00:00
drh
7be5e3dd4c Fix a harmless compiler warning.
FossilOrigin-Name: edbf911fdeda14bd63cd752f6237896400eb5a65ef486abe7b91433621d21b5c
2020-01-09 20:33:13 +00:00
dan
fbb6e9ff48 Fix an assert() in window.c that could fail with some obscure SELECT statements that use window functions.
FossilOrigin-Name: 83dc55679a91bf5d1d13706088ce58eed02b9aad1ad0ae237966e78e0d769663
2020-01-09 20:11:29 +00:00
drh
b84fda37ef Fix a problem in the encoding display in the updated PRAGMA function_list.
FossilOrigin-Name: 318ff7720bc60c30c0826becce424226e9cec25c1d59cb2cdb75793739322760
2020-01-09 16:28:50 +00:00
drh
51ebd5fa14 Fix minor typos in the trusted-schema.md document.
FossilOrigin-Name: 87aea3ab1cdda4533e6fed605d1295e83bae0bbb9e1b238d239ce158a0d42954
2020-01-09 16:00:08 +00:00
drh
3858be3e59 Minor formatting changes in the trusted-schema.md document.
FossilOrigin-Name: 55553b5e5ece8282f6a56a6f5c71024eaaef3c86ec42203af3da708b0de3643b
2020-01-09 15:18:08 +00:00
drh
b0c4ef711f Design notes for the new-security-options branch.
FossilOrigin-Name: af7c1ed4f8a7293d0ecacca3cfbe9414e0de5ec40b418ce7831b8dc724feb747
2020-01-09 14:51:47 +00:00
drh
32266a1072 Simplified error message for the unsafe use of a virtual table.
FossilOrigin-Name: d662129a601e05e8fca5717a890b5bc920b80a750d061f3c2494788d32b917a5
2020-01-09 13:08:28 +00:00
drh
05b32ee3c0 Fix a problem that restricted edgy functions in TEMP tables.
New test cases added.

FossilOrigin-Name: 8878c40753566a8c4ccd1d413019cabde7569b947f730527d13bfc3db384e97d
2020-01-09 01:20:03 +00:00
drh
014fff20ad Block edgy functions used in DEFAULT constraints.
FossilOrigin-Name: da434dc149786e4b1cd80b3b2b25f8b614d0dec62d5439f839a66b536999e398
2020-01-08 22:22:36 +00:00
drh
2eeca2046e Performance improvements and test cases added. Allow "PRAGMA trusted_schema=ON"
FossilOrigin-Name: 30882ca80f6c51f6bb7b2692c1ac3f19a7c61a23aa8730be79aec0ae3ef08d54
2020-01-08 20:37:45 +00:00
drh
0dfa5255bc Check for whether or not it is safe to use non-innocuous functions as the
function is being coded, not when its name is resolved.

FossilOrigin-Name: 1da802d54b689a462e1fe899c6ffa08ef14d34f36728b14b055b5a76b1edc274
2020-01-08 17:28:19 +00:00
drh
15f3eacfc0 Provide the -innocuous option to the "db func" method in the TCL interface.
FossilOrigin-Name: 0138652b6c2f21fd67e59a23a396a5b9d6a16ee9b44701cddfc49b23fddfce5b
2020-01-08 15:44:10 +00:00
drh
6d35956c86 Fix the rot13.c extension to be deterministic. Add the noop.c extension.
FossilOrigin-Name: a679122ca8ec95d5c8afba3a1a50170db9dd519a3810e56877b8f56e858d0175
2020-01-08 15:43:29 +00:00
drh
b7e519956a In the TreeView debugging output, show a "DDL" mark on SrcList and Expr nodes
that derive from a non-TEMP schema.

FossilOrigin-Name: fe7472fd2a70b4df6cb62041b72ed1638ba27ed1e6ceb8aaf56d1c8a82d91889
2020-01-08 14:39:57 +00:00
drh
19ca76af38 Merge recent changes from trunk.
FossilOrigin-Name: 5962921fceaf2ec645379a5f1d18e2c2c13abbf92cf64606caee69f45a21c500
2020-01-08 13:08:52 +00:00
drh
87969b2a11 When doing a test-to-double conversion on a BLOB with an odd number of bytes
and assuming a UTF16 encoding, ignore the last byte.
Ticket [9eda2697f5cc1aba].

FossilOrigin-Name: 1c76f1d8ec0937a2d2e4ce75f98494c953e9621db31945d7e44f45d90d1c3892
2020-01-08 12:17:46 +00:00
drh
ded33ccea4 Fix a minor formatting error in the display of BLOB values during VDBE
tracing.

FossilOrigin-Name: 295442887a3cd5868df26c5be244649ffb3bae8367f5cf02fe513424a1c9f6a7
2020-01-08 11:36:30 +00:00
drh
4a62581b32 Improvements to the documentation of sqlite3_create_collation().
FossilOrigin-Name: fa866aec56deca8cc1b70814215bbdc683f41bc0826da0f8804d952de429820c
2020-01-08 10:57:27 +00:00
drh
f8f76d672b Simplification of the logic in the constant-propagation optimization.
FossilOrigin-Name: 1c3e5c20a9e6f501befa2bf6241a1b5190872bd83b765dac67065d252d04ea4f
2020-01-08 04:36:01 +00:00
drh
c9301e6e7c Fix the constant propagation optimization so that it does not try to
propagate constant expressions that have affinity.  Ticket [82ac75ba0093e5dc]

FossilOrigin-Name: 6db1c3498f6bfa01bb460e62b802b63ec4bf43577a17a94e1e2fa0ecc1e64960
2020-01-08 01:43:47 +00:00
drh
97bffe674f Fix a misworded comment. No code changes.
FossilOrigin-Name: ee0bc7ede0fbf3e54bb934c0d580c62d7393c984cbc374ece6d57fe9211dac26
2020-01-08 00:39:37 +00:00
drh
2b1c2aad9f Create the "trusted_schema" pragma. Add sqlite3_vtab_config() calls to set
the risk rank for many virtual tables.

FossilOrigin-Name: 4c21373c21c9b17b222ae65297a039a035e6ec6b505c00c33704e3c03f94f834
2020-01-07 19:45:40 +00:00
drh
3f68142b82 Enforce SQLITE_VTABRISK restrictions.
FossilOrigin-Name: 3d87ff312e617a26846d482b423163cad9c222513f33e128f0fe348dda27c7c9
2020-01-07 18:10:56 +00:00
drh
406dfcb843 Fix a performance regression caused by the previous check-in.
FossilOrigin-Name: d7d98d3dff2f0e0cfa5bb8be8e5fd2af5ab470be399eafe3d77b23ee1262f70d
2020-01-07 18:10:01 +00:00
drh
b77da374ab Invert the UNTRUSTED_SCHEMA setting to be TRUSTED_SCHEMA.
FossilOrigin-Name: f5fcf1fbc6473f8e91315b14d67745f2748010641b7463d1f4ca51e6fdf97462
2020-01-07 16:09:11 +00:00
drh
46d987405c Merge recent fixes from trunk.
FossilOrigin-Name: 5dfa33a09e608d26549e46c58a5563754688af68fa99415f9a548e91f81aca7c
2020-01-07 15:44:22 +00:00
drh
42925d1f1a Add an "|| CORRUPT_DB" term to an assert() statement inside of btree.
FossilOrigin-Name: 03c1d75ddc063469fc856114595bd12d21759fe0979ce1ba1cf52e48e6b0d4a1
2020-01-07 13:32:15 +00:00
dan
262efe4a43 Fix an instance of an undefined behaviour (a left-shift of a 64-bit unsigned integer by a value greater than 64) that could occur in fts3.
FossilOrigin-Name: e1f12978b53683114ab0ef0e84a14dd4fabc72750b214aac19cd9da22a582a27
2020-01-07 09:06:43 +00:00
drh
cbae3f8c7d In the typeof() optimization in OP_Column, expand the size of the bogus buffer
provided for data so that it is big enough to cover the increased number of
bytes displayed during register tracing from check-in [54553bf16fabd72d].
This is the correct fix for ticket [bbd55a97e66ff50d], though the earlier one
does not hurt and is useful to retain.

FossilOrigin-Name: e1154c39ba0f8caec70d330e6d5bec745c93ec9a7eafedb3e3730fadc8b8277c
2020-01-06 20:48:45 +00:00
drh
1402b8e5b6 Merge enhancements from trunk.
FossilOrigin-Name: 9c50f6c28a4cadb2c33954c066a8e94f8aaf4c31b6c0309db35efc472cb0bcaa
2020-01-06 19:30:36 +00:00
drh
5ca06329c9 Rewrite the (debugging use only) sqlite3VdbeMemPrettyPrint() function to use
the safer StrAccum interface rather than writing directly into a static string
buffer.  Perhaps this will address ticket [bbd55a97e66ff50d], which we are
unable to reproduce.

FossilOrigin-Name: 69f6a7e42f42116d29514239575ee1dc381b5b673da012cb5f3e8cf17922d493
2020-01-06 19:23:41 +00:00
drh
2e26a602a3 Backout change [4d0b9109f7a5312d4e1] because the conditional it added is
no longer reachable due to check-in [1409758f72c0206c].

FossilOrigin-Name: b3f2696705cc3e7b038f156423f808432a4680ea7e313dc15e34bdf6b1845655
2020-01-06 18:59:46 +00:00
mistachkin
65cdae00ec Move variable declaration to start-of-block for MSVC.
FossilOrigin-Name: 55c136ef61f23a04be1bf351ab7f6bdfa033653c32557a04916cc9770453f261
2020-01-06 18:44:56 +00:00
drh
b592d47a81 Do not attempt to use the skip-scan optimization if prior terms of the
index are already used for non-equality constraints.
Ticket [304017f5f04a0035]

FossilOrigin-Name: d7126a9ced86cb0934d5bde2bf535e6b529c361444c99e723f29dd3eb36e7044
2020-01-06 17:33:09 +00:00
dan
9e10f9ab05 Ensure the SF_Aggregate flag on a SELECT statement is set if a DISTINCT is transformed to a GROUP BY. Ticket [9c944882].
FossilOrigin-Name: 1409758f72c0206cc48f9f7e789382472949523b7056ea46f8dcb93fd3ea60c6
2020-01-06 17:06:12 +00:00
drh
2928a15b3c Refactor names of flags for improved legibility.
FossilOrigin-Name: 411e8ec2219bb4181aaf2209fb1e7baf5e8df8b8c8adb82a69b48cf7e8e7e7d4
2020-01-06 15:25:41 +00:00
drh
628b1a3f9e Remove a NEVER in btree due to a new test case from dbsqlfuzz.
FossilOrigin-Name: 46f8ef70fb8b3ae00cc081b280f3dff38b1d0f1b52a8f4477ec89dec32e4d813
2020-01-05 21:53:15 +00:00
drh
67c826536f Refactor the names of the new controls for restricting what actions the schema
can take behind the application's back.

FossilOrigin-Name: 65d7d39a858c51ffd781f5a6335e029895e597aeb1e1ccdadea8ce79c8ad412f
2020-01-04 20:58:41 +00:00
drh
337ca519e1 Enhance PRAGMA function_list to show internal functions if the direct use
of internal functions is enabled via the SQLITE_TESTCTRL_INTERNAL_FUNCTIONS
test control.

FossilOrigin-Name: 7a8d7ca726666f4384925f959df0d58f7622229e06f1b5e643a3caccd539bb6e
2020-01-04 19:58:28 +00:00
drh
0ad4f792a9 Merge all fixes and enhancements from trunk.
FossilOrigin-Name: b878c30f03e895bbc5c4c99c0f727d49093bb78bdc275593cf4852148579ae69
2020-01-04 19:19:54 +00:00
drh
2e5beddb34 Fix DBSTAT so that it returns now rows, rather than an error when the
WHERE clause is "schema=NULL".

FossilOrigin-Name: 5b246b47aeadc25dbec0956e2d6edcd49fbe874a01734fdf15b770507648222d
2020-01-04 19:14:48 +00:00
drh
17aceebab7 Fix harmless compiler warnings.
FossilOrigin-Name: 8452fe03430d34abecab618d6136b863630f91d68d69ebbc115f808bc81c3817
2020-01-04 19:12:13 +00:00
dan
664d80bbf7 Omit the omit flat from eq constraints on column "name" of dbstat virtual tables. Fix for [74a4c386].
FossilOrigin-Name: cfff5cb2279088aa66f435bd0d627b2c74c9a99ad9addfd44a4df8ba770b795a
2020-01-04 18:38:58 +00:00
drh
56ea69bf0e Record when the OP_IfNotOpen branch is and is not taken.
FossilOrigin-Name: 182a898b14d585edd5fcfdcd6584c957911f0d81773d2868f16b5762dec031ca
2020-01-04 18:33:20 +00:00
drh
64f7ee0219 Remove another NEVER added by check-in [7b62555e285f32d3].
Dbsqlfuzz found another test case.

FossilOrigin-Name: 481f4956aff52797880930752693a8c0b10d7fdd71d86919fe8ee13c90ad5b81
2020-01-04 17:55:01 +00:00
drh
6f2180d21a New test cases in test/in4.test require rtree, so disable those tests on
builds that lack the rtree extension.

FossilOrigin-Name: b5900914f7f34caf1a97c87233781d55467329b0ac4366354df13c6fd72a99c7
2020-01-04 17:42:27 +00:00
dan
74ebaadcdd Fix a problem where the loop for the RHS of a LEFT JOIN uses values from an IN() clause as the second or subsequent field of an index.
FossilOrigin-Name: 95ef68966c50f311830cba8c9257a4085c93011d205e0e31867c2917fa62a48e
2020-01-04 16:55:57 +00:00
drh
af23236660 Merge the latest fixes from trunk.
FossilOrigin-Name: 26ef709a47294c512a70aecd37d29caecec2af261977d9fb2c4d78d09b12f77a
2020-01-04 15:37:57 +00:00
drh
f6ea97ea3d Fix a false-positive in the register validity tracking logic by moving the
temporary register release call before the jump that uses that temporary
register.

FossilOrigin-Name: 9da48a5ca66dc67c8f7fb2d2471dac7ea696e35ecba5ddf65747d08d452436c1
2020-01-04 15:21:47 +00:00
drh
4549a3b8cb Improve a testcase in test/fuzzdata8.db to make it more resilient.
FossilOrigin-Name: 139aefe60097e06b43df35652e6b2183b7a4b03341d1bde23deada3fa3358fee
2020-01-04 14:57:26 +00:00
drh
b2b61bb61f Back out another NEVER added by check-in [7b62555e285f32d3] - the test case
was already in test/fuzzdata3.db, but it only occurs if compiled without
SQLITE_ENABLE_PREUPDATE_HOOK.

FossilOrigin-Name: 61f873b14c2c835f3d10b018b357cb8b1f041e97e05709d7ab5a8055e5e05349
2020-01-04 14:50:06 +00:00
dan
6fe63b4ee7 Omit the omit flag from eq constraints on column "aggregate" of dbstat virtual tables. Fix for [727074e2].
FossilOrigin-Name: 74ef6f2b6d9f50ff1d455e2263ba77707c1e8394b25b3f8a3a2a7b6e7f2c481e
2020-01-04 14:00:56 +00:00
drh
e5cf3e990a Restore a NEVER and an assert in btree that was removed by
check-in [7b62555e285f32d3].  Dbsqlfuzz found test cases.

FossilOrigin-Name: 04a05c83f58784df438dc6614f7920f782bf7c1ed4f6d101c03b6573cfde06ee
2020-01-04 12:34:44 +00:00
drh
79d5bc80c7 Enhance PRAGMA function_list so that it shows all instances of each FuncDef,
the number of arguments, the encoding, the type, and the flags.  Use this
capability to locate and fix incorrect function flags in the standard build.

FossilOrigin-Name: 9ca906d24a2e88eddb2fd067783512b66cfc49dce1596d816a1c38a09d128218
2020-01-04 01:43:02 +00:00
drh
4be621e1ba Invert the SQLITE_FUNC_SAFE bit to be SQLITE_FUNC_UNSAFE. The external
bit is still SQLITE_INNOCUOUS.  It gets inverted as the appdef function
is registered.

FossilOrigin-Name: 1c266cb3be46d26e640752a99979acb1a1809361ba70ca3fca981c42383c360e
2020-01-03 21:57:53 +00:00
drh
c4ad849921 When UNSAFE_IN_VIEW is disabled, only allow functions in views that are
tagged with SQLITE_INNOCUOUS.

FossilOrigin-Name: 9ee79b254e4c51a2a41f7ed49ad389d8d7105e649483adb79772052fa0ade3c0
2020-01-03 20:57:38 +00:00
dan
e455e3acf0 In fts3, avoid making a very large memory allocation if the merge-hint record is corrupt.
FossilOrigin-Name: 9add58fe9688d5c1f675736e7f1c6ff7831d2ff6fdeb884a2e62c1bf9536ee50
2020-01-03 20:16:32 +00:00
drh
3b76c45a7f Add NEVER macros to error-detection branches that were made unreachable
(as far as I can tell) by check-in [ceacc28b03580334].

FossilOrigin-Name: 7b62555e285f32d354df7746ef8dce16856c6d9d53a02d895b74ba02362d2968
2020-01-03 17:40:30 +00:00
drh
0d21eae099 Improvement to check-in [7405e98225761180] so that missing or null filenames
given to the zipfile extension throw an immediate error.

FossilOrigin-Name: 523e09bd228750fb7be1d4e68d18f6c1bf9db19293d66fbf30b86409321e9814
2020-01-03 16:38:54 +00:00
dan
9a20ea9b5b Improve a specific case of early database corruption dectecion in the b-tree layer.
FossilOrigin-Name: ceacc28b035803342764f9b696c1e80edcd259b87ea4fb46f92963d6cb33de3e
2020-01-03 15:51:23 +00:00
drh
9ee00200ef Merge fixes from trunk.
FossilOrigin-Name: 002406df22995880d002be2e4cebb4d560283d4e0d7a4b5a34edcb110802b543
2020-01-03 15:22:54 +00:00
drh
4c983b2f86 Remove an over-zealous ALWAYS() macro and add a test case that shows that
the conditional can sometimes be false.

FossilOrigin-Name: 536e9a9d1bd514056ecbc8172ed58f2656a86f791a15e526ae2e5f2c93687b6a
2020-01-03 14:34:04 +00:00
dan
607dd6e608 Fix a possible NULL pointer dereference caused by using a "VALUES(...)" as a component of a compound SELECT with non-integer ORDER BY clause terms.
FossilOrigin-Name: 9d791116420f4e3f613775569e0a0cba2fc22da568b2fb2df920bcf9c9002938
2020-01-03 14:27:08 +00:00
drh
90996885fc Fix the OP_Copy-coalesce optimization so that if the previous row happens
to end with OP_Copy but is not a candidate for the optimization due to jumps,
then the optimization is correctly bypassed.

FossilOrigin-Name: b36126c1889e323c9a8f04b4f4884576993c845e7d393e5e73aaa6ab5158c1f9
2020-01-03 14:16:43 +00:00
dan
aa328b6ab1 Ensure that when a Select object is reset a new, empty, SrcList is allocated.
FossilOrigin-Name: 4889cbf898d7ec54f061b21b6d3621b22fc482cbeaa7115d40995a4cc30e41db
2020-01-03 13:55:14 +00:00
drh
0cbec59c8b When generating the name of a view (or common table expression) because the
SQL does not specify a name, avoid the names "true" and "false" which might
be confused for the boolean literals of the same name, leading to an
inconsistent abstract syntax tree.

FossilOrigin-Name: ff9492d3ff733c222ea67f23d478df1547641b5e2e6dd870b0b29e25c13f3739
2020-01-03 02:20:37 +00:00
drh
e1f49b8850 Fix a problem in sqlite3TreeViewBareExprList() in which the routine was
not interpreting the new ExprList format correctly.

FossilOrigin-Name: cd56872afbb4edeff2e8c1cb1c8d47c7a9b333b3fc416c20183250807291fae8
2020-01-03 00:28:14 +00:00
drh
618ee33614 Merge enhancements from trunk.
FossilOrigin-Name: 091403a6705f5f1352c76eacbfdca75fe0bab12ab9b156842641de07c38d3f66
2020-01-02 23:50:50 +00:00
drh
24d35e409c Add the two-size lookaside memory allocator. Also, reduce the per-entry
size of the ExprList object.

FossilOrigin-Name: 51665bf0f975fb248964a4be205a4f3285d3f3f8cc697977d264efefbbe20dd8
2020-01-02 22:28:47 +00:00
drh
9fc1b9af36 NEVER() and ALWAYS() macros tagging unreachable branches.
FossilOrigin-Name: 34b877742ef78e9bb3f16815180f4ad9cd722beb1d610f713400a3b25d68aa9b
2020-01-02 22:23:01 +00:00
drh
378ca1eab3 Merge the latest enhancements from trunk.
FossilOrigin-Name: bd57e6d923d3b04f0a07aaf18bf389d2b2b7efc7c57e8cb37e6ef910662d8397
2020-01-02 21:41:59 +00:00
drh
0c4f82051c Do not allow the zipfile virtual table to start a transaction if no
filename has been specified.

FossilOrigin-Name: 7405e982257611803792617f5d8142c54f9831b4a030f4de8607888c525e6289
2020-01-02 21:30:13 +00:00
drh
6b559f3033 Fix some test logic in the OP_Delete opcode so that it works after a
cursor-trip.

FossilOrigin-Name: 28900e5cab73f9edb9383d64a37e14fed0602966cb704ddffa60c0281698fd52
2020-01-02 19:50:50 +00:00
drh
1b39aab08d Ifdef-out code that is only possible with the sessions extension.
FossilOrigin-Name: 4fcf07f79672d203efbc90ad21d97f6a131c3885306f8e0bab015d5ac44b8644
2020-01-02 18:37:04 +00:00
drh
3aef2fb1b4 Have the OP_ReleaseReg opcode also invalidate the registers if P5 is non-zero.
FossilOrigin-Name: 937be22106f7e3f08712febd342d6cb81d129f2d5ab24ce80b3a5c3f9bbde54e
2020-01-02 17:46:02 +00:00
dan
9f3e6fadde Handle blobs that are the return values of functions being cast to text in utf16 databases in the same way as blobs read directly from the database. Fix for [771fe617].
FossilOrigin-Name: e782096aa06fcf410c3a0a6ee26a9e4f44333da39b28b2efe675814a8652911a
2020-01-02 16:24:22 +00:00
drh
4cbd847a91 Fix the OP_Move opcode so that it correctly manages dependency tracking.
This change impacts debugging builds only.

FossilOrigin-Name: 5377add4b8af8c52d0a32f5273835ac6bdc42cfb2a95ffcb335b987437a91aa6
2020-01-02 15:02:08 +00:00
drh
22e95fbd74 Enhancements to aid testing and debugging:
In PRAGMA vdbe_trace=on output, show pScopyFrom dependencies on register
values.  Add the sqlite3VdbeRegisterDump() procedure, callable from a
debugger, that shows the values of all registers.  Pass the VDBE pointer
into test_trace_breakpoint() so that sqlite3VdbeRegisterDump() is callable
from the breakpoint.

FossilOrigin-Name: 9886cb4b7987f720aa9d701222ab0987caa0ab8c5d216cb6e523c4a45366dfe5
2020-01-02 14:42:42 +00:00
drh
52f11b885a Add the test_trace_breakpoint() subroutine that is invoked after each
instruction is printed while running PRAGMA vdbe_trace=on.  Only works for
SQLITE_DEBUG builds.  Also add parameters "pc" and "pOp" to 
test_addop_breakpoint() to make it easier to set conditionals.

FossilOrigin-Name: 49a6368c384178653cb3ccb58cc8eff93327c16929bf79eeefeb13a4ce897153
2020-01-02 13:26:49 +00:00
drh
629b88c683 Use OP_Copy instead of OP_SCopy to move the results of a scalar subquery.
FossilOrigin-Name: 435c272dcf6ed5f3acb564b8f959557145f117b869547b670258cf5a1908ab6b
2020-01-02 02:50:45 +00:00
drh
36e678bc39 The sqlite3WhereEnd() call now unwinds all Expr modifications made by the
sqlite3WhereBegin().

FossilOrigin-Name: 7bfd42f1dc0c94f9bb74516e62fec8e39c20f4749f4e0972f66c2886d3c64f73
2020-01-02 00:45:38 +00:00
drh
2a83c10072 Provide the -DSQLITE_ENABLE_INTERNAL_FUNCTIONS=1 compile-time option. Fix
the ".testctrl internal_function" command in the CLI so that it does not
signal an error on a valid input.

FossilOrigin-Name: 8ee2ce92c082771675d0e8be597043cf9f0fd4f8a73d6a1498bf8743d6b3904a
2020-01-01 23:02:35 +00:00
drh
fc705da15d When generating code for a subquery, make a copy of the Select object and
generate the code out of the copy, in case the code generator makes
modifications to expression and the Select object needs to be reused.

FossilOrigin-Name: 4edddcc0bc8d71e9b8abac67bc3766f1d9143dddd1f59264859ce65e5aa9b8c6
2020-01-01 21:14:30 +00:00
dan
4ea562ee70 Ensure that when code for a scalar SELECT featuring window functions is generated more than once by the planner, separate ephemeral tables are opened for each instance.
FossilOrigin-Name: ce1417325273aba866767349b55d9bbfb61a08e716bebda2122918a9657ee38c
2020-01-01 20:17:15 +00:00
drh
aef8167421 Fix the sqlite3ExprImpliesNonNullRow() routine so that it correctly
handles a numeric comparison of two AND subexpressions.

FossilOrigin-Name: 07e504d5174a1a8b1aa05ec5b44ac81ab3ea706c5a098caa88deb3d489cec8fb
2020-01-01 16:43:41 +00:00
drh
171c50ec38 New test-only SQL functions: implies_nonnull_row(), expr_compare(), and
expr_implies_expr().  The SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control
is modified to toggle internal function access on and off for a single
database connection.

FossilOrigin-Name: 473892a8eceacf24d57fd0c72ff2a0b8be4e0d75e0af7a30bdb24fbc3b453601
2020-01-01 15:43:30 +00:00
drh
25c4296bd9 Factor out code generation for in-line SQL functions into a separate routine
inside of expr.c.

FossilOrigin-Name: 586a65a28fc6cac77309612abc32a2e1017c65e0387f9f438f5d8ac8406da8eb
2020-01-01 13:55:08 +00:00
drh
6d67aff0e3 Issue OP_ReleaseReg opcodes against the array of registers used to compute
index records after the index record has been computed.

FossilOrigin-Name: e3330861b4deab7c7cc09ad8b936d633c600b9fb4e274801efeaaf94e5c860b4
2020-01-01 01:26:05 +00:00
drh
51676fab72 Remove an incorrect assert() statement. Ticket [46fcd700b855e6d1]
FossilOrigin-Name: eca7ec9cda4606c4104bcb8da315070b615713db9f3444579c6a3e96b0aad02f
2019-12-31 23:17:35 +00:00
drh
b945bcdaf1 Experimental branch with new sqlite3_db_config() options that could possible
enhance security for applications reading potentially compromised database
files.

FossilOrigin-Name: 96a2db2612f2e47bbec0e374a242820c88f03c42ccbf8467abccaef41469bae2
2019-12-31 22:52:10 +00:00
drh
64de2a5f7b Also set the SQLITE_DIRECTONLY flag on the load_extension() function.
FossilOrigin-Name: 3bd095a53119c368fe30e539983588b27957203344cf427405b9a64784b8eba7
2019-12-31 18:39:23 +00:00
drh
1e732787da Set the SQLITE_DIRECTONLY flag on the fts3_tokenizer() function of FTS3,
thus preventing that function from being called from within a trigger or
view.

FossilOrigin-Name: f3171dc22e4d3a40ca17fe609391d92fc6a997b775bfefa5947aec69c889aa73
2019-12-31 18:12:36 +00:00
drh
cf014f6cbd Refactor names. Use "small" instead of "mini" to describe the smaller
of the two lookaside memory allocation sizes.

FossilOrigin-Name: 88d244983854cdc1a369c5df09ae00f1098784db768ba4e17b963d187dcb1009
2019-12-31 15:12:34 +00:00
drh
5f6a2ed7f2 Merge recent enhancements from trunk.
FossilOrigin-Name: 39d55579376906f212271ce9b2d367e3ad029fb173f22c7253312b467970208a
2019-12-31 14:49:10 +00:00
drh
02ff747bc0 The OP_ResultRow opcode releases the SCopy dependences on all its registers,
as the values in those registers will not be reused.

FossilOrigin-Name: 1dc83c5d54ca2890112e735e336c209adb8d067d2f647e9f8ae5d58f84a52461
2019-12-31 12:18:24 +00:00
drh
70d6b8327a Back out the NEVER() from check-in [40d10e7aad5b8992] because it is reachable
after all. Ticket [892575cdba4e1e36]

FossilOrigin-Name: f481636f1a0333c6e98906e5d4433bf1d046380bc29c760e8e7e2c2b3530b956
2019-12-30 23:50:19 +00:00
drh
0b973c8bff Add an ALWAYS() to a conditional which is apparently always true.
FossilOrigin-Name: ea44c607b8038999a6bda4d761d95056aa4058d6c2891b7eee0715a50e703490
2019-12-30 23:41:59 +00:00
drh
2b173b93fc Put a NEVER() on a defensive branch.
FossilOrigin-Name: 40d10e7aad5b899206e45d1f8606470a90a07049e15d94c3811cfe695f3a402e
2019-12-30 20:42:53 +00:00
drh
8d95ed789e Fix a typo in a comment. No changes to code.
FossilOrigin-Name: d4813a8d813f234e819f8ebefbd3ff96d3d69593cc7d716cf0ad6c1a126da827
2019-12-30 20:42:17 +00:00
dan
9d41af23a4 Do not use HIDDEN columns for NATURAL joins. Fix for [7c0e06b16].
FossilOrigin-Name: ab09ef427181130be09a087b7e572ad4cfb6b3e1b459769ee5ebf046b3ead682
2019-12-30 14:32:27 +00:00
dan
2b6e670f73 In ALTER TABLE, rename columns and tables in expressions that are optimized out by the "AND 0" optimization. Doing this also fixes an otherwise harmless assert() failure.
FossilOrigin-Name: a9e0354c992b0287608ddd18fd35fe7e6102a8f293d6e6e1b3488644bcda8168
2019-12-30 06:55:31 +00:00
drh
7b14b65d20 Do not allow triggers that run as part of REPLACE conflict resolution
during an UPDATE to modify the the table being updated.  Otherwise, those
triggers might delete content out from under the update operation, leading
to all kinds of problems.  Ticket [314cc133e5ada126]

FossilOrigin-Name: db4b7e1dc399c1f16b827ac087aa37c0815f4b2f41f1ffad59963eead2ab5562
2019-12-29 22:08:20 +00:00
drh
be3da24134 Add the OP_FinishSeek opcode which completes an OP_DeferredSeek if the seek
has not already completed.  Also add the sqlite3WhereUsesDeferredSeek()
interface to the query planner.  The UPDATE implementation adds an
OP_FinishSeek before running the final OP_Insert if one is needed.
Ticket [ec8abb025e78f40c] and also an assertion fault reported by Yongheng.

FossilOrigin-Name: 21ef6e99331210b80fa7c71b4f02e8f768a748d01aef884368af2f6b51a067e0
2019-12-29 00:52:41 +00:00
dan
997d7434b7 Do not attempt to flatten compound sub-queries in a FROM clause into the parent if any component of the sub-query uses a window function.
FossilOrigin-Name: eeb76f621de2f930a548db0fbb9fe25b4479b73581826b8dfa2e63cd1f1ab783
2019-12-28 18:25:51 +00:00
dan
4adb1d0000 Change an assert() in where.c to a testcase() macro, since the condition may be false. This was a problem with the assert() only, there is no bug in release builds that omit assert().
FossilOrigin-Name: 82be135dee7ccfde5f8a67f3621b7ced449dce89bae9cadf025154a4de848c11
2019-12-28 18:08:39 +00:00
drh
a4b2df5ce2 Disable early coding of transitive constraints at the end of each loop in
the WHERE clause processing if the loop being coded is for a LEFT JOIN,
even if the loop is part of an OR-clause optimization for virtual tables.
Test cases in TH3.

FossilOrigin-Name: 9421b442cad9858ec21050c106aa935a1c0723ab08ef9a867a79638b040b6e68
2019-12-28 16:20:23 +00:00
dan
51f2b1719c Fix an instance where the planner might choose to use the OR-optimization when it adds no benefit. The same quirk causes an assert() to fail. This is not a bug in released versions - without the assert() the library still gets the right answer, it just does so less efficiently than it should.
FossilOrigin-Name: f4bed1d7af8a94c6facd567dec5afae8865a5ad76b8834493099e5e30bed1132
2019-12-28 15:24:02 +00:00
drh
f1bb31e219 Further improvements to .wheretrace during loop code generation.
FossilOrigin-Name: c4d5b75c9381255ec8d9a284eedb6b27be46ca868cae5985cf8a5769b15290c3
2019-12-28 14:33:26 +00:00
drh
118efd1626 New enhancements to .wheretrace. The 0x20000 flag shows the WHERE clause
before and after coding each loop.  The 0x800 flag shows status at the start
and at the end of each loop.  An extra "C" tag is shown on coded terms.

FossilOrigin-Name: 59cc46e5a6d8dbb030f27716ad5446ecccf81cf0cfff95338b9133777f2059e7
2019-12-28 14:07:22 +00:00
drh
cacdf20771 Expose some of the Where data structure debug printing routines to the
entire WHERE-clause processing module.

FossilOrigin-Name: 85e76887761b5d7e290fb2bac7f9121648f79d67fdd92f624d81632f28620518
2019-12-28 13:39:47 +00:00
drh
29368eabc5 Add the --enable-all option to the main configure script as a short-hand
to enable FTS4, FTS5, Geopoly/Rtree, JSON, and Sessions.  In the
amalgamation-autoconf, the --enable-rtree option (which is enabled by
default) also now activates Geopoly.

FossilOrigin-Name: 52ea0672d7494346c636cd7b05ca42161eb3b07d9378fa9959be9a11de87dbbb
2019-12-28 13:17:11 +00:00
drh
cfcf4de4a6 Simplifications to the initialization of the sqlite3_index_info structure
that is used to communicate with virtual table modules.  Avoid adding
unused constraints to the sqlite3_index_info structure.  Extra constraints
are harmless, but might be confusing to people trying to understand the code.

FossilOrigin-Name: 5e6357fc953a955d8ebb5c1fcd72e04e4ae5e8bf5941810015c2fbc50de70535
2019-12-28 13:01:52 +00:00
drh
6411d656aa If the ".wheretrace 0x10000" bit is set, print WhereTerm.prereqAll
and .prereqRight fields in the WhereTerm trace output.

FossilOrigin-Name: a4f330b133a36356681dce7d2a65d8ab792620494d6cd4ef4934a97cf3a8e6fc
2019-12-28 12:33:35 +00:00
drh
7505123fe5 Two new test cases added to test/fuzzdata8.db.
FossilOrigin-Name: 1be2c18f4021e1d0b8412ecb68a599475c717dd97c7db209fc4203358957fd70
2019-12-28 11:55:44 +00:00
dan
409f3370af Second attempt to fix a problem with unwinding the WITH stack of the Parse object following an error.
FossilOrigin-Name: 315d1f1a503e8c186739658c85b92fa3d12514e5baaa26925c85664b5e85d1c0
2019-12-28 09:08:27 +00:00
dan
43526f4ada Merge latest trunk changes with this branch.
FossilOrigin-Name: d693be375380fbfca426999a77eeecb8453fa77b77f608bfe266945dee1da41d
2019-12-28 08:33:46 +00:00
dan
5d59102a91 Fix an assert() failure in altertable3-22.4.
FossilOrigin-Name: c566a91d5c4290b0a491a01e85bf8f9fbebf2910e0d478bafc2d22da7f749cae
2019-12-28 08:26:47 +00:00
drh
9a1f2e4853 Fix a faulty assert() associated with query search limiting query plans.
FossilOrigin-Name: 0d743585c242ebd898b232f42937a2306752aaed0a6756705e3ef1cf7593aa97
2019-12-28 03:55:50 +00:00
drh
b97f3532f5 Convert an assert() back into a conditional. The conditional was converted
into an assert() by check-in [6ae4ad6ebee4db88] (2009-05-28) because we were
unable to find a test case for it.  Yongheng's fuzzer just now
found that test case.

FossilOrigin-Name: 4d0b9109f7a5312d4e136395e08b11dad64d746bc106ad44d47675e5b1dcb4ef
2019-12-28 02:40:49 +00:00
drh
d9670abb58 When an INSERT is receiving content from a SELECT, run an OP_ReleaseReg opcode
at the top of each iteration of the loop in order to prevent spurious
OP_SCopy misuse complaints.  Ticket [de4b04149b9fdeae]

FossilOrigin-Name: 6afadd3b3a40b0ef29fd14fb24c2a4b9479483e5f8b9125ce02d8daae662207f
2019-12-28 01:52:46 +00:00
drh
ad5f157791 Recompute the values for all generated columns after
NOT NULL ON CONFLICT REPLACE constraints fire.
Tickets [37823501c68a09f9] and [5fbc159eeb092130].

FossilOrigin-Name: 4cc12c18860bc4801a407cf45e88e23d3d40391f01a461fbac2cac5f102100e1
2019-12-28 00:36:51 +00:00
dan
a6c1a71cde Do not attempt to unwind the WITH stack in the Parse object following an error. This fixes a separate case to [de6e6d68].
FossilOrigin-Name: d29edef93451cc67a5d69c1cce1b1832d9ca8fff1f600afdd51338b74d077b92
2019-12-27 20:54:42 +00:00
dan
b4b3630657 Remove a NEVER() that is no longer true. Fix for [36ffedcb9].
FossilOrigin-Name: 597896ed0ae9e2960a8f39576bd7f77a11dccc1da84b6a44ebb5c38d90ebc330
2019-12-27 20:06:32 +00:00
dan
e3735bf466 Fix a problem involving window function aliases being referenced from sub-selects.
FossilOrigin-Name: e3b5fc05c00fc58be7a7c94ce1d97a5b05113f39aba03df64aab08364f85616b
2019-12-27 19:46:07 +00:00
drh
6473ba95a0 Add a missing "ifcapable rtree {...}" line to the window1.test test module.
FossilOrigin-Name: 4e6fbb1a5100fe29209bcf668fbecf3a733034b84925265d8a15b0a84baf6cf0
2019-12-27 18:15:04 +00:00
dan
431704375e Fix a problem with window functions in aggregate queries that do not have GROUP BY clauses.
FossilOrigin-Name: 99609786f485653464d1caef1d207ae299d28c925bff3e8e94891759b4765dcc
2019-12-27 16:25:56 +00:00
dan
d8d2fb9222 Do not mistake constant integers in a PARTITION BY expression for references to ORDER BY style references to values returned by the SELECT statement.
FossilOrigin-Name: 45c64d39d5afed7fdc6b1de19408559740d1fba1f5e0269ab68b132366a289e4
2019-12-27 15:31:47 +00:00
drh
09bee5743d Follow-up to check-in [c8c6dd0e6582ec91] - change the xAccess() method to
return true if the file exists and it is anything other than a regular file,
or if it is a regular file with a non-zero file size.

FossilOrigin-Name: 8a39803ef8db4d8cb0d231e66299525fad4e61266ca29b3704aebb88df1c745b
2019-12-27 13:30:46 +00:00
dan
5e484cb3eb When determining if an aggregate within a sub-query should be processed as part of the sub-query or an outer query, consider any FILTER clause in the same way as the arguments to the aggregate.
FossilOrigin-Name: 1ffc045d2bbeeda9c13a3a3585538ff6434fc852b0ae6679d3c8b9f606bf92e6
2019-12-27 08:57:08 +00:00
drh
fce8165ec6 Ensure that the Pager.changeCountDone flag is cleared whenever dropping
the write lock, even when transitioning from EXCLUSIVE locking mode into
NORMAL locking mode while in WAL mode.  Ticket [fb3b3024ea238d5c].

FossilOrigin-Name: 846b1de6e5a9e418f225273dc033234c64c116fcd89c8261522b4902c248451f
2019-12-27 01:50:46 +00:00
drh
8d7f44c03a Fix buffer underflows in the zipfile extension associated with zero-length
or NULL filename in the ZIP archive.  But report on the mailing list by
Yongheng and Rui.

FossilOrigin-Name: 465a15c5c2077011befa854a77f9d295bb751ef20b7d2937ac0ba47cc84587c9
2019-12-27 00:19:53 +00:00
drh
fe2a3f1d24 If an UPSERT can cause an Abort due to a constraint failure, make sure
the query planner knows this.  Ticket [7c13db5c3bf74001].

FossilOrigin-Name: f14ce948662f3445a06d84d4f32d9b81143e0cffaf773d8aa4d3a609bfb9682b
2019-12-26 23:40:33 +00:00
drh
d3ee3ad12f An UPDATE of a table that is indexed by a constant virtual column that uses
the one-pass optimization might cause the table seek to be omitted before
reaching row DELETE/INSERT.  Fix this by coding an extra OP_Column in that
circumstance.  Ticket [ec8abb025e78f40c]

FossilOrigin-Name: e54560495926fbb8a2ce829c677a2dd0066e46b7a8d4ada9d8a34a3426959836
2019-12-26 23:16:18 +00:00
dan
e752040c09 Fix an assert() in fts5 that could fail if an xSavepoint() call on another vtab fails.
FossilOrigin-Name: a5d7f5d24a239f729de0b8aa5becf5af35ba87160565ee0713c335b8d1bbf12d
2019-12-26 14:36:31 +00:00
drh
fa53284777 Makefile.in fix so that it works on systems that require a .EXE suffix
on executables.

FossilOrigin-Name: f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1bef22f3
2019-12-26 01:10:17 +00:00
drh
0bb7af44a3 Add two new fuzzer test cases from dbsqlfuzz.
FossilOrigin-Name: f8d5586a8ceca985dcb2d63d0fbad9e271e9e1664720ee698d4947acd5dcc543
2019-12-26 01:02:02 +00:00
drh
96e8eebf96 In the xAccess() method of the unix VFS, return true if the named object
is a directory, regardless of what stat() reports as the st_size for the
object.  Different filesystems report st_size differently for directories.
Problem reported on the mailing list by Stefan Brüns.

FossilOrigin-Name: c8c6dd0e6582ec9103d007b294c42bb1820be1fa7dab85d873b04e0b90571626
2019-12-26 00:56:50 +00:00
drh
0b12613a00 Fix an FTS3 test case that depends on the ICU extension so that it only
runs if SQLite is compiled with ICU.

FossilOrigin-Name: 19c6240bdbb022b2af463e59d873280d0f2385bf30e22b9aad5fc9677a99f251
2019-12-26 00:54:39 +00:00
drh
aaa5ba0609 Fix an incorrect assert() added by check-in [fa58aad48a788802].
Problem found by dbsqlfuzz.

FossilOrigin-Name: a17b29f08c888301911c35096899f10d24192c8ecec467cddde5401b6bd1903f
2019-12-26 00:53:43 +00:00
drh
e86f3402ac Disables the optimization that tries to pull the value of an expression
from an index on that expression if the expression is a constant.

FossilOrigin-Name: e5fd8b50500f9225e435ef5afee98e3c2cccd22785f99c718d7e6c9b5b653c56
2019-12-26 00:20:56 +00:00
drh
a9ebfe2030 When the sqlite3WindowRewrite() routine detects and error, have it convert
the SELECT statement into just "SELECT null" so that it does not leave the
parse tree in a goofy state that can cause problems with subsequent code
before the stack has a chance to unwind and report the error.
Ticket [d87336c81c7d0873]

FossilOrigin-Name: fa58aad48a788802b13a819e49f9b8787f713bbe395c46c7295e821c52c81738
2019-12-25 23:54:21 +00:00
drh
b44fec68a5 Fix a minor performance regression from check-in [401c9d30e06191d9]
FossilOrigin-Name: 76f54ee86777cbf530654323c953388ef64d0608516722d2522be6c859fa1382
2019-12-24 21:42:22 +00:00
drh
c7a5ff45b9 Backout the early VTable cursor close change from yesterday, as Yongheng and
Rui have found a test case for which it fails.  The new test case is added
to fuzzcheck.

FossilOrigin-Name: ddb10f0374e66886d0681937b14cf0b4f100f03d3955b45b6c508dc6d9e36976
2019-12-24 21:01:37 +00:00
dan
4fcce747e2 Fix a problem causing fts5 integrity-check failures if numeric values are inserted into a table within a utf-16 database. Fix for [752fdbf6].
FossilOrigin-Name: bae060f382e4386c0793db4aa280fe9cd4893307d17a1801a17218ae4dc031c2
2019-12-24 20:51:01 +00:00
drh
a194d3152c Make the zipfile() extension function more robust against zero-length filenames.
FossilOrigin-Name: b9c2005f0291d58d7f3bfd4a2286eb6563e9c9433519c3329035f325fc723445
2019-12-24 18:53:13 +00:00
dan
3fee9de239 Fix another case where malformed utf-8 was being mishandled in fts5. Fix for [df46a6f3].
FossilOrigin-Name: 1c0a05b09a97e6e2e9b11c31ed6ec7e6484686614b587ebfd0cfe27d973ba461
2019-12-24 16:20:05 +00:00
dan
84d17bdaa7 Fix an assert() added as part of commit [a11b393dc] that can fail if fts5 database records are corrupt.
FossilOrigin-Name: 4630c1ec013a4c2e54a34c9a64b2c803ac3912450de660497eb34ee21c91f426
2019-12-24 15:35:53 +00:00
drh
4eac5f04ab Extra defense against problems following an OOM. dbsqlfuzz find. Also
import the latest dbsqlfuzz test cases.

FossilOrigin-Name: 0a70f5ddaf3567f335cc0fd0fcd5303e2afb5e38a6388faddf5cab1f2a74e3dd
2019-12-24 15:01:17 +00:00
dan
c26e78d275 Fix a spurious report of corruption that could be made by the fts5 integrity-check in SQLITE_DEBUG builds if the fts5 index contains malformed utf text.
FossilOrigin-Name: a11b393dc2c882cf0b3c47c3405bf43ca1d6459605bd39cccce4d32da653a72d
2019-12-24 14:27:03 +00:00
drh
34da2a4806 Convert an ALWAYS() into an assert() with an extra error term.
Dbsqlfuzz find, with test case in TH3.

FossilOrigin-Name: b473ad35c5ce355853e1805a5c0658bda1500775f22f59c6b6759ae990e65aca
2019-12-24 13:41:33 +00:00
drh
22c04f8199 Allow comparison operators of a register against itself.
Ticket [188f912b51cd802a],

FossilOrigin-Name: 401c9d30e06191d938503aae024bc453d960fa64dc812ed86c661f94533247fd
2019-12-24 01:53:05 +00:00
drh
1e490c4ca6 Test case for the zipfile-extension bug fix of the previous check-in.
FossilOrigin-Name: bc8bfc7fcdf33f6855584e10e9260073430517ff3268cf0c7988dcc4cd785391
2019-12-23 21:11:15 +00:00
drh
d8f2d46cbc Fix the zipfile() function in the zipfile extension so that it is able to
deal with goofy filenames that contain embedded zeros.

FossilOrigin-Name: cc0fb00a128fd0773db5ff7891f7aa577a3671d570166d2cbb30df922344adcf
2019-12-23 21:04:33 +00:00
drh
5f0dfc00de Thoroughly reset the rtree cursor at the start of each VFilter operation,
including clearing its cache.  This prevents left over pages in the cache
which can cause problems on shutdown after a LEFT JOIN.
Ticket [5eadca17c4dde90c]

FossilOrigin-Name: 4c50afafce8416369f89477ba7fe7d9b047399a5ee5754c73d0e67bbea8d877c
2019-12-23 20:41:39 +00:00
drh
192cf36de6 Remove an extra deflateInit2() call accidently left in
check-in [f5ee30426e8876e7]

FossilOrigin-Name: 953e6aa6d9ca09e549c88bc728c322fabdcef581f3b4a7763d95488dddbbd6a5
2019-12-23 20:07:28 +00:00
drh
e2478dfa43 Do an early close of virtual table cursors to avoid unnecessary cursor
contention in UPDATE for some virtual table implementations.
Ticket [56a74875be799b85]

FossilOrigin-Name: eb95dac7f6482c36853a23234c5ce7af37c7beed8e3675d6a49c4d3a8307e076
2019-12-23 19:28:34 +00:00
drh
a2d50283db Early detection of database corruption in balance_deeper().
FossilOrigin-Name: 61c2233654158e65a3d3baeea947903a919a569fcc4a5b342b2e9a68cec1b6f3
2019-12-23 18:02:15 +00:00
dan
1d24a53125 Fix a case in which SQLite could fail to identify "x BETWEEN ? AND ?" being true as implying that x is not null. Ticket [dfd66334].
FossilOrigin-Name: 2f17974912ec5e99089dc0da803e7ff1bf033377a49762d2689a812c005f2641
2019-12-23 15:17:11 +00:00
dan
2811ea6be7 For expressions like (x, y) IN (SELECT ...) where the SELECT uses window-functions, require that all columns on the LHS be indexed before an index can be used. Fix for [d9ed4ebe].
FossilOrigin-Name: 0b1dbd60f5db3abe2097dbc0b6de9671685ca5eaf7d3fc8e3f87ff5065a9d114
2019-12-23 14:20:46 +00:00
drh
7edce5ecc0 Fix a shift-overflow problem in yesterday's check-in [36fdeb4f0a66970a]
that OSSFuzz helpfully discovered overnight.  Thanks Google.

FossilOrigin-Name: bff38e2b5318ed032aaf1d350903c3494b4531f2dc59a6997144ec8e23defef4
2019-12-23 13:24:34 +00:00
drh
0af6ddd3ca Fix the OP_Cast operator so that when casting to TEXT, it always leaves
the result in the encoding of the database.  Ticket [0911b5d161b039c6].
Test cases in TH3.

FossilOrigin-Name: f347744e0d576f0250c29259cca755e57afded8956224114c01603c1bca5b3a4
2019-12-23 03:37:46 +00:00
drh
3d8e7a2f97 Change the assert() back into a testcase(). See also check-ins
[9ab985a9c8160b90] and [ddb17d92df194337] and other check-ins that those
reference.  Fix for ticket [9d708e474201c001]

FossilOrigin-Name: 2c44c73499154bc57634a54cb743642d0aacc93a1336fbb8bb3eb5dbbf616357
2019-12-23 02:43:52 +00:00
drh
13d7950267 Enhance the sqlite3VdbeMemAboutToChange() shallow-copy validation mechanism
by adding the new OP_ReleaseReg opcode to tell MemAboutToChange() that a
range of registers is no longer needed so that the source register can be
freely changed.  This is a change to debugging and test builds only and
does not impact release builds.  Fix for ticket
[c62c5e58524b204d] and [5ad2aa6921faa1ee].  The previous fix to ticket
[5ad2aa6921faa1ee] is backed out by this change since this change is a better
fix.

FossilOrigin-Name: 36fdeb4f0a66970a35de688b617f90899c89cfdfab659f864df99aa7ebf854ea
2019-12-23 02:18:49 +00:00
drh
4799488e16 Change the code generator for the IN operator so that it avoids creating
OP_Eq and OP_Ne opcode with the same P1 and P3 arguments.  This enables us
to back out check-in [ddb17d92df194337] and also fix ticket [188f912b51cd802].

FossilOrigin-Name: 9ab985a9c8160b905730678f40ed440a246cdec549c798bafefaed5abbc0437f
2019-12-22 23:48:36 +00:00
drh
5d762b2d1d Make a hard copy of strings in constraint checks prior to applying
OP_RealAffinity, to avoid problems with a pointer accounting assert.
This change is not strictly necessary - the correct answer is obtained
without it and no UB occurs - however the pointer accounting asserts are
useful to prevent other problems so it is a simple matter to bring this
piece into compliance.  Ticket [5ad2aa6921faa1ee]

FossilOrigin-Name: 89a9dad6330270a4c3b962f86a208088d2ea9883c7d291351a77f058e0ed8b0c
2019-12-22 20:29:25 +00:00
drh
6e827fa27d When constructing the virtual MATCH term of the WHERE clause for a virtual
table that is in a LEFT JOIN, be sure to set the correct Expr.iRightJoinTable
value.  This value does not appear to ever be used, except inside of a single
assert().  But it is good to set it correctly, nevertheless.  This fixes
ticket [7929c1efb2d67e98], which as far as I can tell is completely harmless.

FossilOrigin-Name: ef604882a275d3d5ebd4d5a08e3fe43e148f169b7d5c3a81464fbe7f54f3582a
2019-12-22 20:03:29 +00:00
drh
d262c2db8f In the WHERE clause debugging output (the .wheretrace output) show the
parent index of any WhereTerm that is a child.

FossilOrigin-Name: 7fc733328c5914c747e048c830522ec13e433c0a86388bae47b198a3e220c6c2
2019-12-22 19:41:12 +00:00
drh
6c1c85ca48 Fix to the optimization of check-in [a47efb7c8520a011] that reads the values
of expressions used in an index-on-expression directly from the index rather
than recomputing the value.  If the expression has a top-level COLLATE or
unlikely() operator, be sure to clear the corresponding flags prior to
converting it into a TK_COLUMN expression.  Failure to do this is most likely
harmless in production, but might cause an assertion fault in debugging builds.
Ticket [b0cb8aff561a6dcd].  Test cases in TH3.

FossilOrigin-Name: 56539e1c132632c075efc217ad5951a35e4459605ac128914aec3a7be1e25718
2019-12-22 18:55:04 +00:00
drh
db1954be0a Back out the asserts of check-ins [a500893b6f64aced] and [d9c9fe9f5ad3fc91]
as ticket [1b06916e01c82b66] demonstrates a case that refutes them.

FossilOrigin-Name: ddb17d92df194337a103c561ef46ced00db5e67e4551e82de7cb5ad7f457dd5f
2019-12-22 18:23:30 +00:00
drh
9524a7ea9f When parsing a CREATE TABLE from the sqlite_master table, delete the CHECK
constraints if there are any errors, since there might otherwise be attempts
to use those CHECK constraints if PRAGMA writable_schema=ON is set.
This undoes the fix in check-in [ea721b34477ab8b4] for a more general
solution.

FossilOrigin-Name: a982e6434cd66bfbe94d455f538bcbc4360b91572062d92acae6b77e9560e65d
2019-12-22 18:06:49 +00:00
dan
69843342de Ensure sqlite3WindowRewrite() is called on a SELECT statement before any terms aremoved from it as part of IN() clause processing. Fix for [f00d096ca].
FossilOrigin-Name: 8c856404b4e98d295449a4e89a41495dc007319a8e9c35c1a763718d7c5f67e8
2019-12-22 17:32:25 +00:00
dan
7a1d7c3968 Fix "PRAGMA data_version" so that it works the same way with locking_mode=PERSIST and journal_mode=PERSIST configured. Fix for 7a458c2a5f.
FossilOrigin-Name: 45748e2db028ffbda5d3e747493721a5a89af3fbc06823081a2f27f570e40e73
2019-12-22 14:29:55 +00:00
dan
e88af0179e Fix a spurious report of corruption from the fts3/4 integrity-check triggered by using the languageid option.
FossilOrigin-Name: 70815e273f511481c310dc33b3b49079901d891078fad49b663fbce06c77ecc2
2019-12-21 20:43:34 +00:00
drh
f4f31df02d When creating a new virtual table, ensure that the OP_ParseSchema opcode
processes the correct entry in the sqlite_master table even if there is
a second entry with the same name and table values due to database corruption
and the use of writable_schema=ON.  Dbsqlfuzz find.

FossilOrigin-Name: 4dbb6e1cb094f3428c74ea8bdd86ab63341fecce978a062968ca01423f382e90
2019-12-21 19:37:09 +00:00
drh
b0cbcd0edf When a corrupt schema is loaded using writable_schema=ON, the CHECK constraints
(or other expressions in the table definition) might not be fully resolved.
Ensure that the code generator can deal with this if the table is subsequently
used in a DML statement.  dbsqlfuzz find.

FossilOrigin-Name: ea721b34477ab8b49d182352c4bc198245933b850e9b6248b4f97600e80bb44b
2019-12-21 14:09:30 +00:00
drh
ed0c34857a Do not try to access a generated column through an index if the collating
sequence for the generated column is non-standard.
Part 2 of ticket [e0a8120553f4b082]

FossilOrigin-Name: 056bb8dcbdc45989c5c6e86d2966200062e3c01c382ec52aae37c828104b4496
2019-12-20 22:46:41 +00:00
drh
67b9ba1732 Apply real affinity to generated columns of type REAL that are extract from
an index.  Ticket [e0a8120553f4b082]

FossilOrigin-Name: 728ad39e3bd07a2503a95c68ed5bbc3f28fd97551d59f12a5fab25dc68227e99
2019-12-20 20:45:02 +00:00
drh
a513e591ae Debugging enhancment: Show the Expr.y.pTab pointer on TK_COLUMN nodes of
an expression tree in the treeview.

FossilOrigin-Name: 64154ac450e4366d18e7e867841877a69c1f978d3ba9b8754cc133248966731d
2019-12-20 20:08:56 +00:00
dan
879f1a1ea6 Fix a bad interaction between RBU and [df51ae19].
FossilOrigin-Name: 0b9d8a1202c4220fd2ef299b6194533c1bf4018a0cd2d13da7e22c1a7de05ffa
2019-12-20 20:03:21 +00:00
dan
42ae633ab9 Fix two more cases in fts5 where sqlite3_value_bytes() was being called before sqlite3_value_text(). Fix for e431c355.
FossilOrigin-Name: a1ba9a37d7a68a6d31f8197c6350589ebe6a12f4e3c193a178dd7ead8bcd565a
2019-12-20 19:41:01 +00:00
mistachkin
e99cb2da5f Export the public RBU entry points from the Win32 DLL.
FossilOrigin-Name: e62d1791f428b7a9bb14a59483f12d8ee08afbf4061a5e3be8f64787444301e7
2019-12-20 17:41:15 +00:00
drh
5d73272340 Debugging improvement: when tracing the VDBE, output the register value for
OP_Cast after the cast is completed.

FossilOrigin-Name: dc5f1d282d1e75f8a3791b0c95cb8f143b2a956323cb6c889d76d20db7f89257
2019-12-20 17:25:10 +00:00
drh
8cc8feae7e When computing dependencies on WHERE-clause terms, be sure to take into
account the FILTER clause of aggregate functions.  Problem reported by
Manuel Rigger.

FossilOrigin-Name: 3cc2b5709e66ef605c3b85ed13ae6cc9c3090e864ebc18859db36284b8f715b6
2019-12-20 15:35:56 +00:00
drh
8c7715d1cc Improved assert() statements on the OP_Column opcode.
FossilOrigin-Name: c538601e4c979ee59f18d19e6eb6296cebfa580fb029a18d5a3f0dd9393acb75
2019-12-20 14:37:56 +00:00
drh
40e9c8328e Load new dbsqlfuzz test cases into test/fuzzdata8.db.
FossilOrigin-Name: 01aeeb5c4c70a0f19651448e94ad5c6810cab3d6957b5bc7a9b4b8e0b887f3de
2019-12-20 14:24:26 +00:00
dan
394aa710f2 Fix a potential problem with ALTER TABLE commands on schemas that contains a triggers or view featuring a sub-query that uses an ON clause with a join that is not a LEFT JOIN.
FossilOrigin-Name: 365dd8b663d5a28af33556b2b3820c6b5482114ef741a1d82b55c6e154f3043a
2019-12-20 14:18:29 +00:00
drh
b2ab3dcff0 Fix harmless compiler warnings.
FossilOrigin-Name: 2bbd014c900e0d71fd30ec647739b82c5dc3aa237a0203f5a1db50593dae199e
2019-12-20 14:08:34 +00:00
dan
73b21382d4 Ensure fts5 consistently calls sqlite3_value_text() before sqlite3_value_bytes(). This matters when storing blobs in fts5 tables within utf-16 databases. Fix for [cf36cb4e02].
FossilOrigin-Name: c16305eba0eb14368f2631b9a82b7eb4483c93f3b31257ee7c33f9b00c344379
2019-12-20 13:24:11 +00:00
drh
1548d5276f Do not continue an ALTER TABLE tree walk of a subquery if a prior error
is seen in the tree.  Report the problem immediately, without continuing.

FossilOrigin-Name: 01ca865f31c0c817ede7f357401ef76cf311ae662397908464f53e1c147f5b6b
2019-12-20 12:55:21 +00:00
drh
0e5ce8029d Fix an assert() in btree.c that can fail if an INSERT is attempted on
a corrupted database while in PRAGMA writable_schema=ON.

FossilOrigin-Name: 07beb3629e648e7feae4e786191514339ac1d8f6ba5bb6e7cc8a04bc1f1cd6ab
2019-12-20 12:33:17 +00:00
drh
8428b3b437 Continuation of [e2bddcd4c55ba3cb]: Add another spot where it is necessary
to abort early due to prior errors in sqlite3WindowRewrite().

FossilOrigin-Name: cba2a2a44cdf138a629109bb0ad088ed4ef67fc66bed3e0373554681a39615d2
2019-12-19 22:08:19 +00:00
drh
6ad0e25fa4 Fix the regexp extension so that it correctly translates all over-length
3-byte UTF8 sequences into 0xfffd.

FossilOrigin-Name: 3d4c0bf8904135fa68c75801bfa738715cacc3b19dc8ad6ef550b11798d4b121
2019-12-19 21:11:48 +00:00