Commit Graph

6828 Commits

Author SHA1 Message Date
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
mistachkin 33fc27790a Fix segfault in 'eval.c' extension when used with 'empty_result_callbacks'.
FossilOrigin-Name: e8b87bd4954437041139344d6d1ce3e4aace40ea6891b70f9c20cd95671270e7
2018-04-04 12:21:33 +00:00
drh b14e6de579 Fix an error message in speedtest1.c and make the "trigger" testset sensitive
to the --size parameter.

FossilOrigin-Name: 5a6fd9e0156a14e6509c4ea713c4b332b2d050432b49571c7a45a7ecc7cb5da4
2018-04-03 20:44:53 +00:00
dan b278c594f1 Update speedtest1.c with new testset "trigger" based on the tests in
speed4p.test.

FossilOrigin-Name: 7b7fa5fa0dd0dcef759ce1e22ade3a4e5fc8e8a244eac19b1abcc96d89c99721
2018-04-03 20:00:09 +00:00
dan 22f60b847c Fix a few small test script issues affecting SQLITE_TEMP_STORE=3 builds.
FossilOrigin-Name: e171f3722f78c58d2f20443e3bbcce2bd9701b8537f6e8d482ae804154d7a17f
2018-04-03 17:05:13 +00:00
dan 4f9a7e5cb7 Fix an assertion failure triggered by a SELECT with a compound sub-query that
contains an incorrectly placed ORDER BY clause. This problem is just an
assert() failure - non-DEBUG builds are not affected. Problem found by
OSSFuzz.

FossilOrigin-Name: 823779d31eb09cda5effe747d9adb35e600a52d4274226586437f674e7824d91
2018-03-31 16:31:51 +00:00
dan d99f49fcc9 Another change to test file zipfile.test to help it run on systems without "unzip".
FossilOrigin-Name: b6252feb125db16dabf6ce07568159f0002f9053df1b7b600e2614cc9da24873
2018-03-29 23:54:00 +00:00
dan a8728e7428 Fix a test script bug causing zipfile.test to fail on systems that do not have
the "unzip" program installed.

FossilOrigin-Name: d99022a5a8e4469a87a9fab8a976271e5785524da73ac1d2fae47d00d90fc07a
2018-03-29 16:39:09 +00:00
dan d88690bd10 Update memdb1.test so that it works with SQLITE_DEFAULT_AUTOVACUUM builds.
FossilOrigin-Name: d67f1c7d18d076b18e327ae4e3bccf6086b8f3fd370a7550d77753fc1f1ce07f
2018-03-29 11:02:19 +00:00
drh 928ba14904 Fix a harmless compiler warning in the kvtest.exe program.
FossilOrigin-Name: d48972cf873f8e2499f7c77f8062fde439e7426b616514c147810763469d7c6a
2018-03-28 22:08:44 +00:00
dan 3a95c65e37 Add -DSQLITE_ENABLE_DESERIALIZE to the "Device-Two" configuration in
releasetest.tcl.

FossilOrigin-Name: 765a014d8e91be18ac0f12f0fe94f4126bf8ce101f5c9d7f234376e2368f6db3
2018-03-28 20:29:04 +00:00
drh 6a9b9527fa The push-down optimization was being too aggressive such that it sometimes
generated incorrect results.  Reinstate the restriction (4) (with
qualifications) that was removed by check-ins
[b5d3dd8cb0b1e4] and [dd568c27b1d765].

FossilOrigin-Name: f08c1731b0b1dddcba190b094a35306a159713d3db939330f73075ff1d72c81e
2018-03-27 15:13:43 +00:00
dan b948948542 Fix a typo preventing test script avtrans.test from running in auto-vacuum
mode.

FossilOrigin-Name: c7473bdb1055df06dc6a93a39ba7f56116f6866292784c4938d843531500c368
2018-03-26 17:56:39 +00:00
drh e3eff266bc Yet another fault in the sqlite3ExprImpliesNotNull() routine, causing errors
in the LEFT JOIN strength reduction optimization of check-in
[dd568c27b1d76563].

FossilOrigin-Name: e88cf3d4df64097ebc19aae464b88d0faf9b7d4c30d057042b582d78327e7ad3
2018-03-24 15:47:31 +00:00
dan 07f119e470 Fix a test script problem causing shell1.test to fail with
-DSQLITE_OMIT_VIRTUAL_TABLE builds.

FossilOrigin-Name: 2e06906e0959e1256fc2feb9dc2c3a9d1e9c19c4ba59585fe52df9af174ab443
2018-03-24 15:08:48 +00:00
drh 2c492061ce Bug fix in the LEFT JOIN strength reduction optimization of
check-in [dd568c27b1d76563].  The sqlite3ExprImpliesNotNull() routine was
mistakenly assuming that a CASE expression must always be NULL if contained
any reference to a variable that was NULL.

FossilOrigin-Name: cf171abe954a5f25262161dd69f2e8cecdbf9446c3f6b298201507dbc743567e
2018-03-24 13:24:02 +00:00
mistachkin cf847d44ac Add some more tests for the IS TRUE / IS FALSE operators.
FossilOrigin-Name: 9fe5bebefe909288e583226b5dc32e0465f6b2d8eda850d01820e3f1f8091ddd
2018-03-23 14:56:05 +00:00
mistachkin 9d107262e4 Enhance .schema in shell to enable matching patterns with literal underscores.
FossilOrigin-Name: 98e3f5247a6012f58642a2fcdc9be062f7afe8f2e154d06007f4935a0fd87aac
2018-03-23 14:24:34 +00:00
drh cedfecf90a Fix the ANALYZE command so that it will process tables whose names begin
with "sqlite" as long as they do not being with "sqlite_".

FossilOrigin-Name: 0249d9aecf69948d9343feef9291273beef5fc98aa9a8f95b1e35cc2ce8e6cbd
2018-03-23 12:59:10 +00:00
drh c6c5ab80ee Add the left join strength reduction optimization. Enhance the push-down
optimization so that it works with many LEFT JOINs.

FossilOrigin-Name: dd568c27b1d7656388ea5b4132cc0265aedd7348d265d8e8c7412b00b28a31aa
2018-03-22 12:00:43 +00:00
drh 66651c2b4b Add the --valid-sql option to the optfuzz test program.
FossilOrigin-Name: a8dfeec73b069f2dd7371c2792b36f152945d32120843db5361ff7e04de177bc
2018-03-22 11:28:31 +00:00
drh 00f0375df7 Get the optfuzz program working.
FossilOrigin-Name: 21346bbce9fd161e8a2037834a6e8eb443a901109ddb3a52c1b7a29000ffeac8
2018-03-21 20:21:29 +00:00
drh 30f30133d7 Add the optfuzz.c program for verifying the query planner using a fuzzer.
This is an initial code check-in.

FossilOrigin-Name: 3fb21251b0c9c731513e8fb137867c2710a77d99411c99348d3ac45d3babffd7
2018-03-21 19:25:59 +00:00
drh efce69de37 Do a more thorough job of cleaning erasing traces of the strength-reduced
LEFT JOIN.

FossilOrigin-Name: 08833dda3a25965cc509d0244d7cd68bdb2306351ca52862f347e1efe5db4508
2018-03-20 22:52:27 +00:00
drh 2589787c5a If terms of the WHERE clause require that the right table in a LEFT JOIN
not be a null row, then simplify the LEFT JOIN into an ordinary JOIN.

FossilOrigin-Name: 5b7abecc7ab8ccbbb8cb5e0f672e67625c2555ad03442efbf34cb395f5bb71a8
2018-03-20 21:16:15 +00:00
drh f6e6f02308 Fix incorrect testcase labels on two cases in join5.test. No changes to code.
FossilOrigin-Name: 4661ac81c9589b06a07df8b7931fbd0a7f9a4e9ba1448192b70701dc85a29bd2
2018-03-20 19:02:03 +00:00
dan 93c803e960 Fix handling of "UPDATE OR REPLACE" statements run on zipfile virtual tables.
FossilOrigin-Name: 9a5ef341de2bd2fc4657a510f48159f7876f58d340b457b4272a71d389f88da3
2018-03-20 13:26:01 +00:00
dan d30830e42d Add a test case for the fix on this branch.
FossilOrigin-Name: 7834cf6c28c63f6ca0e29a508c0f6e3ec9c5c48715344c2db99a9866e92ef205
2018-03-20 12:12:06 +00:00
mistachkin 2cc8f4831e For 'zipfile', detect attempts to cause a duplicate entry via UPDATE.
FossilOrigin-Name: cf78a882799424610209e9ac5e76771db3f5e6704ffa181f9598eb0986d93eb8
2018-03-17 02:13:13 +00:00
mistachkin d42d8ae337 Another Win32 portability fix for the 'zipfile' tests.
FossilOrigin-Name: 9f604418ca21472d84d754f4c3b7f170e5c2bff05e8cee86640e45b43bc53a49
2018-03-17 00:44:29 +00:00