Commit Graph

6857 Commits

Author SHA1 Message Date
drh 98b677f2cb Overhaul of EXPLAIN QUERY PLAN. The output is now in the form of a tree.
More details of the query plan are shown, and what is shown is truer to what
actually happens.

FossilOrigin-Name: ff01bbdabc4b9db3db8b928979442c91b32d72082158e4f5fe62ae51a73649d2
2018-05-03 19:56:50 +00:00
drh fa16f5d9d6 Enhance EXPLAIN QUERY PLAN to report the generation of constant rows using
VALUES or just a SELECT without FROM.

FossilOrigin-Name: c75eee69fa8a9b56ee58a4cc539e80cc982f43390dc3a357344d58479dd89a41
2018-05-03 01:37:13 +00:00
drh cdf88760da More test case updates. Tests are all running now.
FossilOrigin-Name: dab5e5294813891469660cceb211ac1a1e526715bb57dcdbb1ab90321e6a4dad
2018-05-02 19:42:33 +00:00
drh b3f0276b9e Fix test cases so that they work with the new EXPLAIN QUERY PLAN output
format.  Only some of the cases have been fixed.  This is an incremental
check-in.

FossilOrigin-Name: 5f0e803e33aa557865d5fc830d9202d628de9a94c9757058ca48f1a560702cd3
2018-05-02 18:00:17 +00:00
drh 03c3905f94 Fix a dangling-else problem that was causing recursive CTEs to malfunction.
Begin fixing test cases to work with the new EQP output.

FossilOrigin-Name: 82ca44b82fed6814c84440ba8bfaa019488ab956e84ac165180e2fcece6facb2
2018-05-02 14:24:34 +00:00
dan fa5c69f5cb Fix a problem in the xBestIndex method of the closure extension causing it to
allocate non-contiguous argvIndex values in some cases (an "xBestIndex
malfunction" error).

FossilOrigin-Name: 0c67150749cb3d067e14b2dcac9c3489e0f14bd18c0387f1d9bc93d21fc96fe5
2018-05-02 08:12:22 +00:00
drh b57e3ec5d8 Test cases added for SQLITE_DBCONFIG_RESET_DATABASE.
FossilOrigin-Name: 08665a9e2e50a0a1e62529884cf65f8090debe89a306a3904b53268729ab5ad5
2018-04-28 19:08:02 +00:00
drh 6bfd973ce6 Fix compiler warnings in FTS3.
FossilOrigin-Name: de508e831a43f02c3b354a24ea34798da03c163bae5521c852c9ddd252723739
2018-04-28 04:10:55 +00:00
dan 03db962ab5 Update test script fts3expr4.test so that it always creates fts3 tokenizers in
the "en_US" locality.

FossilOrigin-Name: 576a8f69ae25883f752e58953624e9f7126db998bebaa1f07f7c2ec47aaecabe
2018-04-27 18:05:01 +00:00
dan 0ef54fa6e8 Fix a test script error causing tests to fail in soak.test.
FossilOrigin-Name: 462b52b121c1882e0eca819bc30c0f6e94d7fdd60047d2c32adeff3a1eb70546
2018-04-27 16:35:44 +00:00
drh 6876dccbfe The previous fix for ticket [d85fffd6ffe856092ed8da] in check-in
[0a514e62ad1ebe5c12da8dae] did not completely address the
probably in that it only worked for cases where the OP_SCopy that loaded
the register was the last instruction in the sequence for the expression, which
is not necessarily the case for expressions like CASE...END.  This revision
prevents the registered that will be recomputed from being cached in the first
place.

FossilOrigin-Name: 9fd0faf517993587d2f54212638545fc85fbbc84a031bcfae8c1e5894825d83b
2018-04-26 18:34:26 +00:00
drh 909066bba0 Ensure that new.* values of an UPDATE do not get clobbered after the
BEFORE triggers run when unmodified columns of the row being updated are
reloaded.  Fix for ticket [d85fffd6ffe856092ed8da]

FossilOrigin-Name: 0a514e62ad1ebe5c12da8daed429ae2f9d9910471d3c5cef3b6870bdadfefca1
2018-04-26 15:50:10 +00:00
drh de7ca50dac Clarification of the behavior of a BEFORE UPDATE trigger when the trigger
changes the values of some of the columns used to compute new columns in
the UPDATE.

FossilOrigin-Name: 7bb23c2a3d37f0d5e5515b917860818906819d54a0066e1ba8e9792a82f7d279
2018-04-26 15:04:18 +00:00
dan 1e08074906 Update the "fuzz_malloc.test" script to print SQL statements in which OOM
handling problems are found to stdout.

FossilOrigin-Name: a956363cf6881be590120c7718976b54b12c4bd0d9228d8142b45e0fe1826f7e
2018-04-26 08:56:40 +00:00
dan ccb9eb782c Remove a recently added NEVER() macro from a branch that can be taken in
obscure circumstances.

FossilOrigin-Name: 2aa210030ae414782adab9291cc43a149a780f39bd3d306dc2892a8c20422a51
2018-04-24 18:59:18 +00:00
dan 820fcd2ce9 Fix a problem with processing "LEFT JOIN tbl ON tbl.a = ? AND (tbl.b=? OR
tbl.c=?)" in cases where there are indexes on both tbl(a, b) and tbl(a, c).

FossilOrigin-Name: ce35e39c5cc2b00dd6b4a9ffaa9d5eb7d9b862759e87d5f053729de7643eee9c
2018-04-24 18:53:24 +00:00
drh c447595df5 Do not attempt to use terms from the WHERE clause to drive indexes on the
right table of a LEFT JOIN.  Fix for ticket [4ba5abf65c5b0f9a96a7a40cd18b]

FossilOrigin-Name: aeb694e3f787f1f8b55650c17f90c197eee3f7f9b890a88f458c33e43009a082
2018-04-24 17:34:03 +00:00
drh cb23e5d5d1 All the OR optimization to proceed even if the OR is also converted into
an IN operator.

FossilOrigin-Name: e252c6540db266b93beeb47a8f7dbf3b275f8c782cd2d36ba4c00648c382f63f
2018-04-24 16:41:37 +00:00
dan 4da04f784f Do not attempt to read values from indexes-on-expressions if the index is on
the RHS of a LEFT JOIN. This won't work if the index cursor points at a
null-row. Fix for [7fa80496].

FossilOrigin-Name: b8ef967ab1bebf2846c06c4f7200d6fa1c60e52e55711ea171c25ef1331f8a24
2018-04-24 14:05:14 +00:00
drh 4d3e61403a Fix a memory leak following failure to open an external CSV file in the
csv.c extension.

FossilOrigin-Name: 526ee07d19dbc8fd1af3a02a8da12b337020a4be40e045da9a19d0a7c2b6ab54
2018-04-24 10:57:10 +00:00
drh 8349c11d02 In EXPLAIN QUERY PLAN output, do not show an EXECUTE LIST SUBQUERY line for
IN operators where the RHS is a list and not a subquery, since in that case
there is no SUBQUERY to execute.

FossilOrigin-Name: 8bc0207abdeeb3ffac003703e78826759f07994698f6cdf40c89c3443ba22a47
2018-04-24 01:10:12 +00:00
drh f49ff6ffb3 Fix a problem in sqlite3ExprCompare() associated with UPSERT.
FossilOrigin-Name: 67d0b2c15299dd20bca7254ecb33e71b5eee6024e2709bfdc36f877bf2a5679f
2018-04-23 20:38:40 +00:00
dan 42d181604c A few more tests for upsert.
FossilOrigin-Name: b78005b6d41640203c163ffde4faf9336f11f47f42e8b7fe10b95415bbaed028
2018-04-21 14:11:18 +00:00
drh f3d7bbb767 Fix UPSERT so that it plays nicely with AUTOINCREMENT.
FossilOrigin-Name: 359725ab36339b443b7745e84f6d27991038ceb063c653805dde17f3eb5a03c5
2018-04-21 03:06:29 +00:00
dan 224d92c8c0 Add tests for name resolution in ON CONFLICT clauses.
FossilOrigin-Name: cf253584ecf7aed04406b4bae78b536818fadfb3fb96c05f2c99954b841db85f
2018-04-20 17:50:49 +00:00
dan a46838cb13 Add test cases for UPSERT. And a fix for a "REPLACE INTO ... ON CONFLICT"
statement where the new row conflicts with both the IPK and the ON CONFLICT
indexes.

FossilOrigin-Name: d8eb9f8d9b61400c7e12f01ef5c233257b03532221f7c7a8386f7ac2db439626
2018-04-20 15:34:08 +00:00
drh 7963691314 Fix the handling of "PRAGMA count_changes=ON" with UPSERT. Also improved
the implementation of count_changes in other places, without changing the
behavior.

FossilOrigin-Name: c6f71115eb933c2aee295bc31e5139112463c28e15a3b3ea242fd9bac168aed9
2018-04-19 23:52:39 +00:00
dan a67d02f509 Modify a test case in zipfile2.test to take into account that with some
platform/file-system combinations it is possible to fopen() and fread() (but
not fwrite()) a directory.

FossilOrigin-Name: 893e6089c875e947ddadb23f031a81bc36da8b060d2212363098992ddb90378b
2018-04-19 20:06:10 +00:00
drh 482dc64505 Add the --upsert option to the wordcount test program.
FossilOrigin-Name: ee1e750baaf4c66b4e1f103d8b80362f57e711ac601e57f99ed6a33913f443d2
2018-04-19 16:52:37 +00:00
drh bb6b1ca73d Fix a problem in the new upsert implemention, discovered by OSSFuzz.
FossilOrigin-Name: b6d5ea59fe83716f464e408b7eef0310c6d30b3493e3f966362db2e30b36e821
2018-04-19 13:52:39 +00:00
drh 5e3a6ebf34 Fix the table name aliasing on INSERT so that it occurs before the column list
rather than afterwards, just as it does for PostgreSQL.  Add table name
aliasing to UPDATE and DELETE.

FossilOrigin-Name: 861a2e2a4895f96a5d8e1730e744983b2ac4311d0c2cf201c0e59f409030d5d7
2018-04-19 11:45:16 +00:00
dan dedff6be8a Add the "sorter-reference" optimization, allowing SQLite to be configured so
that some required values may be loaded from the database after external
sorting occurs for SELECT statements with ORDER BY clauses that are not
satisfied by database indexes.

FossilOrigin-Name: ef74090a40ceaef2fd93a7613ec99a191ce986811c852e96f4a19719f18af4f0
2018-04-18 19:56:14 +00:00
dan 52b3e340cc Minor changes to test script upsert4.test.
FossilOrigin-Name: 0cb83c84d10b89ef7a5504862566a609307c63e7571dd711d8b9f995d29e5a8c
2018-04-18 19:45:14 +00:00
drh 4e8b9925bf Fix a test case inside distinct.test.
FossilOrigin-Name: 61cb8a391a0c709340ac60ffd0c58f950567892a8404c2bec7b9b1f64b3cc5cf
2018-04-18 18:19:25 +00:00
dan 370c32628f Add extra test cases for UPSERT.
FossilOrigin-Name: 7ea08d0750dd9e07d2ffea336127034800db14aa23e60adec384d338871bf53a
2018-04-18 17:56:37 +00:00
drh 6651e10ee7 Add support for PostgreSQL UPSERT syntax and functionality.
FossilOrigin-Name: fba24aec235dd6f124c1ece66cdac485c9d96e0578c4fbacd8f49d7b767a5b4a
2018-04-18 16:03:36 +00:00
drh 3bc431550a Enhance ALTER TABLE ADD COLUMN to support "DEFAULT true" and "DEFAULT false".
FossilOrigin-Name: 594ebc69557095c9262db39129dd50a3dbf038556a3d2a3ea69b82ed4c61e2b9
2018-04-18 11:35:35 +00:00
dan 2cc00423a0 Add some more simple test cases for UPSERT. And a minor fix.
FossilOrigin-Name: 27cd3b2fb2ad0cf2b36741bd1057cb7973954d40456e9db158261a38b049d2b5
2018-04-17 18:16:10 +00:00
drh 5015c9b50e New test cases for upsert.
FossilOrigin-Name: 907b5a37c539ea67c285c87399b494c7fe15014389a2ea3d49e90640b58946ae
2018-04-17 16:16:40 +00:00
dan 2e3a5a810a Add SQLITE_CONFIG_SORTERREF_SIZE configuration option.
FossilOrigin-Name: b25a7bb769b8397a00736bd922bd24b1200b2f82d36d42ecb4c3eb17efb4b84d
2018-04-16 21:12:42 +00:00
dan 24e25d32ce Experimental change to "SELECT * FROM ... ORDER BY" processing to load some
column values from the db after sorting.

FossilOrigin-Name: 9719cb46bbf501ce80f185159d594f593dd0b2639b9ef5a71a6c7b70046cb08d
2018-04-14 18:46:20 +00:00
drh c8a0c90b62 Get the ON CONFLICT DO NOTHING form of upsert working by mapping it
into INSERT OR IGNORE.

FossilOrigin-Name: d07f05e98bb9ce0f9b46db159d9df161b7499d6face6a5299ecd2d00a94fb8d0
2018-04-13 15:14:33 +00:00
drh d5af54207d Get the conflict-target clause parsing working correctly, with test
cases.  This change involves an enhancement to sqlite3ExprCompare() which
needs to be reviewed on trunk prior to merging.

FossilOrigin-Name: 5bf704256206f84b3db7a5d8523215604eeb218ef8db86316d1e43ecd7248d6a
2018-04-13 14:27:01 +00:00
drh 3b45d8bfb7 Improved conflict-target matching logic.
FossilOrigin-Name: 98d32ba661f4ba662b639994b74352b695d53a33bc8a498bd09b9e02f794c81e
2018-04-13 13:44:48 +00:00
drh e9c2e772f1 Back off of the extended upsert syntax that allows multiple ON CONFLICT
clauses.  The syntax now is exactly as in PostgreSQL and MySQL.  Add support
for WHERE clauses on the conflict-target phrase, for partial indexes.

FossilOrigin-Name: 2c1b1987d8de1efa8ed7e1f199710e32ff20edf8ceec570514fc63bb1ef264e0
2018-04-13 13:06:45 +00:00
drh 788d55aa77 Begin adding upsert logic. This is an incremental check-in.
FossilOrigin-Name: 809696434097e62e8ef486c7478b5eb62c0cf1342522a5584939fade82821410
2018-04-13 01:15:09 +00:00
drh 84fbff18d0 Prohibit bound parameters in the arguments to table-valued functions within
a trigger.  Problem discovered by OSSFuzz.

FossilOrigin-Name: b7178209152452e82f5908513385018524472640d67547927d6b4c0aa0c15a46
2018-04-11 16:04:01 +00:00
dan 0493222ff8 Fix a problem causing the LEFT JOIN strength reduction optimization to be
incorrectly applied in some cases where the WHERE clause of the query contains
a filter expression of the form "lhs.x IS NOT ?".

FossilOrigin-Name: 1fdaf2c34431adcac1c7ff29aae0623c4cbaa6a7f38e843c786bd407d8b3e730
2018-04-10 15:31:56 +00:00
dan a1054dcc3f Fix a problem causing the LEFT JOIN strength reduction optimization to be
incorrectly applied in some cases where the WHERE clause of the query contains
a filter expression of the form NOT(x AND y). Ticket [1e39b966].

FossilOrigin-Name: 38d319c153641ea4138fab2d5a47c31a86f57a071a1e1c299ca54c980cfb2b60
2018-04-10 12:10:01 +00:00
dan 9a3c375fce Fix an instance where an uninitialized VM register might be accessed. Fix for
[093420fc0]. This problem was found by OSSFuzz.

FossilOrigin-Name: a3b02db74681a215996c5ed110eb0ece5ed24f71a1b131c10e9f33e666af0256
2018-04-05 16:26:39 +00:00