]> git.ipfire.org Git - thirdparty/sqlite.git/log
thirdparty/sqlite.git
7 years agoThe BtCursor.info fields are only valid if info.nSize!=0.
drh [Thu, 3 May 2018 14:07:18 +0000 (14:07 +0000)] 
The BtCursor.info fields are only valid if info.nSize!=0.

FossilOrigin-Name: 54c537eead5b08104cfaf0d5b1e2706e53d6f74be2ca02e06229024fd889fc94

7 years agoAdd more corruption checking to the cell overwrite logic.
drh [Thu, 3 May 2018 13:56:23 +0000 (13:56 +0000)] 
Add more corruption checking to the cell overwrite logic.

FossilOrigin-Name: 58d14afe1e1288d114ea213458b3121e0a95670887861928858b7f143c76f789

7 years agoBug fixes in the overwrite optimization.
drh [Thu, 3 May 2018 12:57:48 +0000 (12:57 +0000)] 
Bug fixes in the overwrite optimization.

FossilOrigin-Name: 0cb6cd2a6a596afaa1cca6c5f5abc2ea75d04f254c7debaf36ecd6a90b66aed6

7 years agoThe sqlite3BtreeInsert() routine tries to overwrite an existing cell with
drh [Thu, 3 May 2018 03:59:02 +0000 (03:59 +0000)] 
The sqlite3BtreeInsert() routine tries to overwrite an existing cell with
modified content if the new content is the same size.  Pages are only dirtied
if they change.  This prototype works some, but still has issues.

FossilOrigin-Name: 489451b378819621537231c1c8a07704437e11c1f5384fd53b09f3977d2213a4

7 years agoPrevent VACUUM from running any commands in sqlite_master.sql other than
drh [Wed, 2 May 2018 15:00:26 +0000 (15:00 +0000)] 
Prevent VACUUM from running any commands in sqlite_master.sql other than
CREATE statements.  That is all that should be there anyhow.  This fixes
a problem discovered by OSSFuzz.  Test cases in TH3.

FossilOrigin-Name: ab0d99d0b5edece4c639baa47ce1ca2c02774cb2515e5b7f36d9bd312ccd3310

7 years agoFix a problem in the xBestIndex method of the closure extension causing it to
dan [Wed, 2 May 2018 08:12:22 +0000 (08:12 +0000)] 
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

7 years agoAdd sqlite3_win32_set_directory8() and sqlite3_win32_set_directory16() functions.
mistachkin [Wed, 2 May 2018 03:01:50 +0000 (03:01 +0000)] 
Add sqlite3_win32_set_directory8() and sqlite3_win32_set_directory16() functions.

FossilOrigin-Name: 22089ea2bbea93eb1da7f08344789a5455077169443e40025f053d2a117f1c08

7 years agoThe SQLITE_ALLOW_SQLITE_MASTER_INDEX compile-time option allows a CREATE INDEX
drh [Tue, 1 May 2018 18:39:31 +0000 (18:39 +0000)] 
The SQLITE_ALLOW_SQLITE_MASTER_INDEX compile-time option allows a CREATE INDEX
statement against the sqlite_master table.  Once created, the index works, and
is usable by legacy instances of SQLite.

FossilOrigin-Name: 853f3163597b9946c0cbeb808ea6fd33a0cf48ae6b8f4459c4165db377f33a9e

7 years agoTest cases added for SQLITE_DBCONFIG_RESET_DATABASE.
drh [Sat, 28 Apr 2018 19:08:02 +0000 (19:08 +0000)] 
Test cases added for SQLITE_DBCONFIG_RESET_DATABASE.

FossilOrigin-Name: 08665a9e2e50a0a1e62529884cf65f8090debe89a306a3904b53268729ab5ad5

7 years agoFix an RBU problem causing spurious SQLITE_CONSTRAINT errors when restarting
dan [Sat, 28 Apr 2018 18:20:01 +0000 (18:20 +0000)] 
Fix an RBU problem causing spurious SQLITE_CONSTRAINT errors when restarting
an RBU update in which more than one source table writes to a single target
database table.

FossilOrigin-Name: 564ae8297d417ba4b7978e430d41f125007177673163f6ed9adc3a3974f73d24

7 years agoAdd the SQLITE_DBCONFIG_RESET_DATABASE control for resetting a corrupt
drh [Sat, 28 Apr 2018 13:21:00 +0000 (13:21 +0000)] 
Add the SQLITE_DBCONFIG_RESET_DATABASE control for resetting a corrupt
database file without closing any database connections.  Added the
".dbconfig" command to the CLI.

FossilOrigin-Name: a200a49edeaca5a787a3036070f7ced3cb6e9495f8afe7b74d5cde02c79b20dc

7 years agoAdd the SQLITE_DBCONFIG_RESET_DATABASE control as a replacement for
drh [Sat, 28 Apr 2018 12:43:16 +0000 (12:43 +0000)] 
Add the SQLITE_DBCONFIG_RESET_DATABASE control as a replacement for
the reset_database pragma.  Resetting the database should be hard enough
to do that it cannot be done by accident.

FossilOrigin-Name: ff836cb8b0377c5970ecb2b797702e2b5d208eda443ecbd55f4c238a3094b28a

7 years agoMerge updates from trunk.
drh [Sat, 28 Apr 2018 11:22:53 +0000 (11:22 +0000)] 
Merge updates from trunk.

FossilOrigin-Name: 94877e495c563f101b51cd8891ca7665c7aab87ff526157f1dc1781e0a2a5d87

7 years agoPrevent deep recursions on nested COLLATE operators.
drh [Sat, 28 Apr 2018 04:16:43 +0000 (04:16 +0000)] 
Prevent deep recursions on nested COLLATE operators.

FossilOrigin-Name: 6e098ee415f1a530e17a942c9ba51d67c25a3ebff6b97377b7858d0b10bcec92

7 years agoFix compiler warnings in FTS3.
drh [Sat, 28 Apr 2018 04:10:55 +0000 (04:10 +0000)] 
Fix compiler warnings in FTS3.

FossilOrigin-Name: de508e831a43f02c3b354a24ea34798da03c163bae5521c852c9ddd252723739

7 years agoDocument and expose sqlite3_win32_set_directory() function for use on Win32.
mistachkin [Sat, 28 Apr 2018 01:46:22 +0000 (01:46 +0000)] 
Document and expose sqlite3_win32_set_directory() function for use on Win32.

FossilOrigin-Name: 7626b593405ca720e371b9f698b72b499b7c829bfe00f758140bc542cf970689

7 years agoAdd comments about the intended use of the sqlite3_data_directory variable as it... win32dir
mistachkin [Sat, 28 Apr 2018 01:44:27 +0000 (01:44 +0000)] 
Add comments about the intended use of the sqlite3_data_directory variable as it pertains to the sqlite3_win32_set_directory function.

FossilOrigin-Name: d11c419756ce28fcc1f58df6bbe59a3d8d19d0441970aa7bfa216ba915ceddf5

7 years agoAdd the "PRAGMA reset_database=ON|OFF" command. When on, it causes the
drh [Sat, 28 Apr 2018 01:27:09 +0000 (01:27 +0000)] 
Add the "PRAGMA reset_database=ON|OFF" command.  When on, it causes the
database to appear to be empty, causing the next transaction to reset it to
an empty database.

FossilOrigin-Name: 02e1a13c1f04bb72599b98f51240c78d0d050de264fef5808fd97db3f4c16dac

7 years agoDocument and expose sqlite3_win32_set_directory() function for use on Win32.
mistachkin [Fri, 27 Apr 2018 22:42:37 +0000 (22:42 +0000)] 
Document and expose sqlite3_win32_set_directory() function for use on Win32.

FossilOrigin-Name: cbce7180ee664367ee8fc1f8af703eb7845bb58ade6870cc3b7608dcbe5952b3

7 years agoUpdate test script fts3expr4.test so that it always creates fts3 tokenizers in
dan [Fri, 27 Apr 2018 18:05:01 +0000 (18:05 +0000)] 
Update test script fts3expr4.test so that it always creates fts3 tokenizers in
the "en_US" locality.

FossilOrigin-Name: 576a8f69ae25883f752e58953624e9f7126db998bebaa1f07f7c2ec47aaecabe

7 years agoFix a test script error causing tests to fail in soak.test.
dan [Fri, 27 Apr 2018 16:35:44 +0000 (16:35 +0000)] 
Fix a test script error causing tests to fail in soak.test.

FossilOrigin-Name: 462b52b121c1882e0eca819bc30c0f6e94d7fdd60047d2c32adeff3a1eb70546

7 years agoEnhance the comments in the templatevtab.c implementation.
drh [Fri, 27 Apr 2018 15:17:08 +0000 (15:17 +0000)] 
Enhance the comments in the templatevtab.c implementation.

FossilOrigin-Name: 05f6278a02e5cde89f76ced5af7d508e26576d7291dad7ee9e06b1a3be516cb0

7 years agoThe previous fix for ticket [d85fffd6ffe856092ed8da] in check-in
drh [Thu, 26 Apr 2018 18:34:26 +0000 (18:34 +0000)] 
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

7 years agoWhen processing an "ORDER BY ... LIMIT" that does not use an index, check
dan [Thu, 26 Apr 2018 17:43:35 +0000 (17:43 +0000)] 
When processing an "ORDER BY ... LIMIT" that does not use an index, check
whether or not a record may appear in the final result set before adding it to
the temp b-tree used for sorting.

FossilOrigin-Name: 0fcfc36ceb820fc70136b799a0405fe92e50646e697be2872bbe9a53a05ed5a9

7 years agoWhen processing an "ORDER BY ... LIMIT" that does not use an index, check sorter-limit-opt
dan [Thu, 26 Apr 2018 16:13:47 +0000 (16:13 +0000)] 
When processing an "ORDER BY ... LIMIT" that does not use an index, check
whether or not a record may appear in the final result set before adding it to
the sorter.

FossilOrigin-Name: 71bf91c218334381b1b4bdba6a093e623b62e17f3e8550e154a11f0cb0b404f3

7 years agoEnsure that new.* values of an UPDATE do not get clobbered after the
drh [Thu, 26 Apr 2018 15:50:10 +0000 (15:50 +0000)] 
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

7 years agoClarification of the behavior of a BEFORE UPDATE trigger when the trigger
drh [Thu, 26 Apr 2018 15:04:18 +0000 (15:04 +0000)] 
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

7 years agoImproved VDBE comment on the OP_Param opcode. No substantial changes.
drh [Thu, 26 Apr 2018 12:27:03 +0000 (12:27 +0000)] 
Improved VDBE comment on the OP_Param opcode.  No substantial changes.

FossilOrigin-Name: 368c14da868a843767344f6cc17c499fddd83244c0510337ed9a918e64ee2413

7 years agoUpdate the "fuzz_malloc.test" script to print SQL statements in which OOM
dan [Thu, 26 Apr 2018 08:56:40 +0000 (08:56 +0000)] 
Update the "fuzz_malloc.test" script to print SQL statements in which OOM
handling problems are found to stdout.

FossilOrigin-Name: a956363cf6881be590120c7718976b54b12c4bd0d9228d8142b45e0fe1826f7e

7 years agoAdd new interfaces for accessing the list of SQL keywords:
drh [Wed, 25 Apr 2018 19:02:48 +0000 (19:02 +0000)] 
Add new interfaces for accessing the list of SQL keywords:
sqlite3_keyword_count(), sqlite3_keyword_name(), sqlite3_keyword_check().

FossilOrigin-Name: 7dd34e3776fed90a49344d54a1b68bb59f7957b5a8a1a367087b7cafb63111c1

7 years agoAdd the new DO and NOTHING keywords to the keyword lists maintained
drh [Wed, 25 Apr 2018 17:10:30 +0000 (17:10 +0000)] 
Add the new DO and NOTHING keywords to the keyword lists maintained
by various extensions and auxiliary programs.

FossilOrigin-Name: 77a98a0781cd8450e2100111e70526db6a51d7e58e3c505ea87f685388099e82

7 years agoAdd the new SQLITE_SHELL_INIT_PROC compile-time entry point to the CLI. This
drh [Wed, 25 Apr 2018 13:27:07 +0000 (13:27 +0000)] 
Add the new SQLITE_SHELL_INIT_PROC compile-time entry point to the CLI.  This
is needed to work around the tighter sqlite3_config() constraints now in the
CLI.

FossilOrigin-Name: 3bcdbccf530e2a5aab7b91f4b9e5535cced91f242c49ff69b05a75d643b8b4a3

7 years agoAvoid many unnecessary calls to sqlite3ReadSchema() and sqlite3Init() when
drh [Wed, 25 Apr 2018 12:01:45 +0000 (12:01 +0000)] 
Avoid many unnecessary calls to sqlite3ReadSchema() and sqlite3Init() when
the schema is known to be valid already.

FossilOrigin-Name: 58cf812fd81329e82b3fdd61b7ad2040c9b90d2d80f592b9231e0e1902c8d577

7 years agoAdd an assert() to ensure that schema mutexes are held prior to accessing
drh [Wed, 25 Apr 2018 10:30:46 +0000 (10:30 +0000)] 
Add an assert() to ensure that schema mutexes are held prior to accessing
the DB_SchemaLoaded flag inside of sqlite3Init().

FossilOrigin-Name: d8b46290bb75c695dac523cf9a50d1b43e773802e3b95fd722feca16162ab7c5

7 years agoRemove a recently added NEVER() macro from a branch that can be taken in
dan [Tue, 24 Apr 2018 18:59:18 +0000 (18:59 +0000)] 
Remove a recently added NEVER() macro from a branch that can be taken in
obscure circumstances.

FossilOrigin-Name: 2aa210030ae414782adab9291cc43a149a780f39bd3d306dc2892a8c20422a51

7 years agoFix a problem with processing "LEFT JOIN tbl ON tbl.a = ? AND (tbl.b=? OR
dan [Tue, 24 Apr 2018 18:53:24 +0000 (18:53 +0000)] 
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

7 years agoDo not attempt to use terms from the WHERE clause to drive indexes on the
drh [Tue, 24 Apr 2018 17:34:03 +0000 (17:34 +0000)] 
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

7 years agoUpdate the expert extension test cases to account for the fact that
drh [Tue, 24 Apr 2018 16:51:38 +0000 (16:51 +0000)] 
Update the expert extension test cases to account for the fact that
EXPLAIN QUERY PLAN now shows the start of each trigger in its output.

FossilOrigin-Name: 8acb42f48929d908fe67a8536e240ca252a9ab780dce79eaa85b8fba35d52250

7 years agoAll the OR optimization to proceed even if the OR is also converted into
drh [Tue, 24 Apr 2018 16:41:37 +0000 (16:41 +0000)] 
All the OR optimization to proceed even if the OR is also converted into
an IN operator.

FossilOrigin-Name: e252c6540db266b93beeb47a8f7dbf3b275f8c782cd2d36ba4c00648c382f63f

7 years agoAdd a hyperlink to the ticket on the code comment for the fix to
drh [Tue, 24 Apr 2018 14:18:49 +0000 (14:18 +0000)] 
Add a hyperlink to the ticket on the code comment for the fix to
ticket [7fa8049685b50b5aeb0c2].

FossilOrigin-Name: 45247c7f291bc0cc42600a4aa4ff7cdcd0a703fdfadcb0e12174c5250e70d503

7 years agoDo not attempt to read values from indexes-on-expressions if the index is on
dan [Tue, 24 Apr 2018 14:05:14 +0000 (14:05 +0000)] 
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

7 years agoEnhance the CLI to render EXPLAIN QUERY PLAN using an ASCII-art graph.
drh [Tue, 24 Apr 2018 13:07:40 +0000 (13:07 +0000)] 
Enhance the CLI to render EXPLAIN QUERY PLAN using an ASCII-art graph.
This works with ".eqp" modes and when the query begins with exactly
"EXPLAIN QUERY PLAN".  To see the original output format, add extra space
characters in between words of the initial "EXPLAIN QUERY PLAN".

FossilOrigin-Name: f53716ee2ab5a6d47a5551529aae526bb39058f4a8e11e6243b32c1ddc25a19e

7 years agoFix a memory leak following failure to open an external CSV file in the
drh [Tue, 24 Apr 2018 10:57:10 +0000 (10:57 +0000)] 
Fix a memory leak following failure to open an external CSV file in the
csv.c extension.

FossilOrigin-Name: 526ee07d19dbc8fd1af3a02a8da12b337020a4be40e045da9a19d0a7c2b6ab54

7 years agoIn EXPLAIN QUERY PLAN output, do not show an EXECUTE LIST SUBQUERY line for
drh [Tue, 24 Apr 2018 01:10:12 +0000 (01:10 +0000)] 
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

7 years agoFix to check-in [ca34c2dd20ee071e] - avoid a NULL pointer dereference
drh [Tue, 24 Apr 2018 00:08:09 +0000 (00:08 +0000)] 
Fix to check-in [ca34c2dd20ee071e] - avoid a NULL pointer dereference
following an OOM.

FossilOrigin-Name: c7e6e848fa91f61bc980a031a17d4cd4784f93a1c9ffee35665efa1a59f2982a

7 years agoFix a problem in sqlite3ExprCompare() associated with UPSERT.
drh [Mon, 23 Apr 2018 20:38:40 +0000 (20:38 +0000)] 
Fix a problem in sqlite3ExprCompare() associated with UPSERT.

FossilOrigin-Name: 67d0b2c15299dd20bca7254ecb33e71b5eee6024e2709bfdc36f877bf2a5679f

7 years agoFix a formatting issue in the TreeView output for bare expression lists.
drh [Mon, 23 Apr 2018 20:04:38 +0000 (20:04 +0000)] 
Fix a formatting issue in the TreeView output for bare expression lists.

FossilOrigin-Name: a6356817815fe986c4d89475194e0537ebd46582d6df1034482bf08521182bdf

7 years agoAdd the ".imposter off" variant of the ".imposter" dot-command in the CLI.
drh [Mon, 23 Apr 2018 18:38:48 +0000 (18:38 +0000)] 
Add the ".imposter off" variant of the ".imposter" dot-command in the CLI.

FossilOrigin-Name: d3dad06ff1b163040c54dd215f30d6669cc2bc339001a362605f26f06eddf98c

7 years agoThe ".selecttrace 0x2000" command causes just the top-level parse tree to
drh [Mon, 23 Apr 2018 17:43:35 +0000 (17:43 +0000)] 
The ".selecttrace 0x2000" command causes just the top-level parse tree to
be displayed, after all transformations, and showing the EQP iSelectId at
each level.

FossilOrigin-Name: ca34c2dd20ee071e6f8d60f91dbf474515a688ba57949143483da1641246cb25

7 years agoThe ".selecttrace 4" command now shows only a single parse tree after
drh [Mon, 23 Apr 2018 17:18:03 +0000 (17:18 +0000)] 
The ".selecttrace 4" command now shows only a single parse tree after
name resolution.

FossilOrigin-Name: 5682146e8a4ebb4edc1e1b53fbf3daf77f8cb9cd9bc2aa32acb34fa5824bd518

7 years agoDo not restore the iSelectId value until after the last SELECTTRACE when
drh [Mon, 23 Apr 2018 17:09:58 +0000 (17:09 +0000)] 
Do not restore the iSelectId value until after the last SELECTTRACE when
debugging Select processing.

FossilOrigin-Name: 8088d8cac317adb96e357a8f4a196d7c1e0115af9c2335f167b4d7e7154299b0

7 years agoIn the ".selecttrace" output, include the EXPLAIN QUERY PLAN iSelectId as
drh [Mon, 23 Apr 2018 17:02:14 +0000 (17:02 +0000)] 
In the ".selecttrace" output, include the EXPLAIN QUERY PLAN iSelectId as
part of each Select identifier.

FossilOrigin-Name: 5c6339f955eaa550c7d112488d7830e67ceacba4fbba12e1c5ce2970980159e0

7 years agoEnsure that there are no bind-parameters or incorrect schema references in
drh [Mon, 23 Apr 2018 13:28:55 +0000 (13:28 +0000)] 
Ensure that there are no bind-parameters or incorrect schema references in
the UPSERT portions of an INSERT within a TRIGGER.

FossilOrigin-Name: d47a6bdda0ce967a7b70bc6eb56278c8b79525622381ff4adcf04525eafc1461

7 years agoFix an unreachable branch associated with stack overflow in the
drh [Mon, 23 Apr 2018 00:25:31 +0000 (00:25 +0000)] 
Fix an unreachable branch associated with stack overflow in the
LEMON-generated parser.

FossilOrigin-Name: e3064ba3b68ca2a1c54561756e8c898866a19ef6e785d315171cd47827a50c85

7 years agoPerformance improvements on the main loop of the LEMON-generated parser.
drh [Sat, 21 Apr 2018 22:40:08 +0000 (22:40 +0000)] 
Performance improvements on the main loop of the LEMON-generated parser.

FossilOrigin-Name: fec1ebadeb9d6b55b19a1c159c543fd7ae67b3307c4caee4d2541bd783630e23

7 years agoEnhance LEMON to track which symbols actually carry semantic content.
drh [Sat, 21 Apr 2018 20:24:19 +0000 (20:24 +0000)] 
Enhance LEMON to track which symbols actually carry semantic content.
Output the list of symbols that do not carry content at the end of the
report, but do not (yet) do anything else with the information.

FossilOrigin-Name: dcf2bafc159179859b91ffea3a4ebd70b5ca6de9e1d515eaf9afde8cfff26c6c

7 years agoA few more tests for upsert.
dan [Sat, 21 Apr 2018 14:11:18 +0000 (14:11 +0000)] 
A few more tests for upsert.

FossilOrigin-Name: b78005b6d41640203c163ffde4faf9336f11f47f42e8b7fe10b95415bbaed028

7 years agoAdd the %extra_context directive to lemon, as an alternative to %extra_argument.
drh [Sat, 21 Apr 2018 13:51:42 +0000 (13:51 +0000)] 
Add the %extra_context directive to lemon, as an alternative to %extra_argument.
Use this to improve the performance of the parser.

FossilOrigin-Name: be47a6f5262a43f477700579512fe7112a0872faedcbbe5c3383d13a08af6440

7 years agoFix UPSERT so that it plays nicely with AUTOINCREMENT.
drh [Sat, 21 Apr 2018 03:06:29 +0000 (03:06 +0000)] 
Fix UPSERT so that it plays nicely with AUTOINCREMENT.

FossilOrigin-Name: 359725ab36339b443b7745e84f6d27991038ceb063c653805dde17f3eb5a03c5

7 years agoAdd the -dDIRECTORY command-line option to LEMON.
drh [Fri, 20 Apr 2018 20:47:49 +0000 (20:47 +0000)] 
Add the -dDIRECTORY command-line option to LEMON.

FossilOrigin-Name: 9cd20475ff3b2ca1a58e441194c921780d25bdb9b9c744a6b4541b888194efb8

7 years agoEnhance the "rbu" command line utility a bit.
dan [Fri, 20 Apr 2018 20:37:25 +0000 (20:37 +0000)] 
Enhance the "rbu" command line utility a bit.

FossilOrigin-Name: 61eb516f83d1a7fe44f72bebe2a2745ab904a02e06e38fb6d932348c49607976

7 years agoFix a harmless compiler warning.
drh [Fri, 20 Apr 2018 20:09:22 +0000 (20:09 +0000)] 
Fix a harmless compiler warning.

FossilOrigin-Name: d2ab24f59d92527fe503fa7dc2128078fbc4dd2d2c1148effa9ea1957ab19940

7 years agoAvoid the use of statement journals on DELETEs of a single row without
drh [Fri, 20 Apr 2018 19:46:52 +0000 (19:46 +0000)] 
Avoid the use of statement journals on DELETEs of a single row without
triggers or foreign keys.

FossilOrigin-Name: 20bf5800808ea02b2aa4bf01a380926784c0e7514a2c73ca303cac1f5c732ae0

7 years agoAvoid opening a statement journal on single-row UPDATEs without triggers or
drh [Fri, 20 Apr 2018 19:32:35 +0000 (19:32 +0000)] 
Avoid opening a statement journal on single-row UPDATEs without triggers or
FK constraints.

FossilOrigin-Name: 2772404b8c570caf3c31d2b0530cf347a24f6f60e220e726c086537b38ebfa85

7 years agoFix a VDBE comment on upsert. Provide an error message when upsert detects
drh [Fri, 20 Apr 2018 18:01:31 +0000 (18:01 +0000)] 
Fix a VDBE comment on upsert.  Provide an error message when upsert detects
index corruption.

FossilOrigin-Name: 279c48f6061f766f5437edd6964c0dd1e10399314eb17b6e5ee34df925a776ed

7 years agoAdd tests for name resolution in ON CONFLICT clauses.
dan [Fri, 20 Apr 2018 17:50:49 +0000 (17:50 +0000)] 
Add tests for name resolution in ON CONFLICT clauses.

FossilOrigin-Name: cf253584ecf7aed04406b4bae78b536818fadfb3fb96c05f2c99954b841db85f

7 years agoAvoid unnecessary cursor seeking when performing an UPSERT.
drh [Fri, 20 Apr 2018 17:02:16 +0000 (17:02 +0000)] 
Avoid unnecessary cursor seeking when performing an UPSERT.

FossilOrigin-Name: 693a3dcbdd8fb2d516c0f46fdbb478838cde675afc1026740e942705aac3c07f

7 years agoImproved VDBE comment on UPSERT code. upsert-opt2
drh [Fri, 20 Apr 2018 16:49:51 +0000 (16:49 +0000)] 
Improved VDBE comment on UPSERT code.

FossilOrigin-Name: 131ed95e1452a5b0d92341c48a5d3915b328ccfce2cf605f702428ae7ee3e21b

7 years agoMinor simplification of the previous checkin.
drh [Fri, 20 Apr 2018 16:27:57 +0000 (16:27 +0000)] 
Minor simplification of the previous checkin.

FossilOrigin-Name: d1906689abdb685f78aa97bca4bf301204d12846016d27bc86dcc9ce2b024d24

7 years agoAvoid unnecessary cursor seeks during upsert processing.
drh [Fri, 20 Apr 2018 15:56:24 +0000 (15:56 +0000)] 
Avoid unnecessary cursor seeks during upsert processing.

FossilOrigin-Name: 7c4b6d5475092a3e205f01a6972366e27a404568e8e7ba327f2feefac2ce2c7c

7 years agoAdd test cases for UPSERT. And a fix for a "REPLACE INTO ... ON CONFLICT"
dan [Fri, 20 Apr 2018 15:34:08 +0000 (15:34 +0000)] 
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

7 years agoEnhance UPSERT so that the UPDATE uses the same set of cursors as the INSERT.
drh [Fri, 20 Apr 2018 13:18:51 +0000 (13:18 +0000)] 
Enhance UPSERT so that the UPDATE uses the same set of cursors as the INSERT.

FossilOrigin-Name: c37f39d18d41ae5ba6c4561d87cbbf71f3b6896b86cc5cff9cdf046b02dc521a

7 years agoMinor simplification of the cursor allocation logic for update.
drh [Fri, 20 Apr 2018 00:40:19 +0000 (00:40 +0000)] 
Minor simplification of the cursor allocation logic for update.

FossilOrigin-Name: fdf71be65835e7e8915d16dd64114de35c4754ef5b94a2af6cac88a94817fb75

7 years agoFix the handling of "PRAGMA count_changes=ON" with UPSERT. Also improved
drh [Thu, 19 Apr 2018 23:52:39 +0000 (23:52 +0000)] 
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

7 years agoMinor simplification to the upsert logic.
drh [Thu, 19 Apr 2018 21:29:52 +0000 (21:29 +0000)] 
Minor simplification to the upsert logic.

FossilOrigin-Name: e657c1d60f5fca9464e9bcab24bc328855bec9986e0a029877f639355da4b201

7 years agoModify a test case in zipfile2.test to take into account that with some
dan [Thu, 19 Apr 2018 20:06:10 +0000 (20:06 +0000)] 
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

7 years agoAdd the --upsert option to the wordcount test program.
drh [Thu, 19 Apr 2018 16:52:37 +0000 (16:52 +0000)] 
Add the --upsert option to the wordcount test program.

FossilOrigin-Name: ee1e750baaf4c66b4e1f103d8b80362f57e711ac601e57f99ed6a33913f443d2

7 years agoAdd the ext/misc/tmeplatevtab.c template for virtual tables. This is a
drh [Thu, 19 Apr 2018 16:14:59 +0000 (16:14 +0000)] 
Add the ext/misc/tmeplatevtab.c template for virtual tables.  This is a
work-in-progress as it still needs improvements to the comments in order to
be useful as a template.

FossilOrigin-Name: 22358fb5495c727a4dde129128fe409a7b929a5ffa143b1e2879f84d7680ec3c

7 years agoFix a problem in the new upsert implemention, discovered by OSSFuzz.
drh [Thu, 19 Apr 2018 13:52:39 +0000 (13:52 +0000)] 
Fix a problem in the new upsert implemention, discovered by OSSFuzz.

FossilOrigin-Name: b6d5ea59fe83716f464e408b7eef0310c6d30b3493e3f966362db2e30b36e821

7 years agoFix the table name aliasing on INSERT so that it occurs before the column list
drh [Thu, 19 Apr 2018 11:45:16 +0000 (11:45 +0000)] 
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

7 years agoAdd the "sorter-reference" optimization, allowing SQLite to be configured so
dan [Wed, 18 Apr 2018 19:56:14 +0000 (19:56 +0000)] 
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

7 years agoMinor changes to test script upsert4.test.
dan [Wed, 18 Apr 2018 19:45:14 +0000 (19:45 +0000)] 
Minor changes to test script upsert4.test.

FossilOrigin-Name: 0cb83c84d10b89ef7a5504862566a609307c63e7571dd711d8b9f995d29e5a8c

7 years agoAvoid a NULL-pointer deref following OOM. sorter-reference
drh [Wed, 18 Apr 2018 19:08:44 +0000 (19:08 +0000)] 
Avoid a NULL-pointer deref following OOM.

FossilOrigin-Name: 413015c029d850d4ce7e66be1f59b57f291254240a958856378a62f5ac4a5092

7 years agoFix a test case inside distinct.test.
drh [Wed, 18 Apr 2018 18:19:25 +0000 (18:19 +0000)] 
Fix a test case inside distinct.test.

FossilOrigin-Name: 61cb8a391a0c709340ac60ffd0c58f950567892a8404c2bec7b9b1f64b3cc5cf

7 years agoImproved matching of COLLATE clauses within the ON CONFLICT conflict-target.
drh [Wed, 18 Apr 2018 18:18:12 +0000 (18:18 +0000)] 
Improved matching of COLLATE clauses within the ON CONFLICT conflict-target.

FossilOrigin-Name: 8f4376e52b6124986937a3837ad83a18863c3144ef3b438a0d5e9231bf6c8980

7 years agoAdd extra test cases for UPSERT.
dan [Wed, 18 Apr 2018 17:56:37 +0000 (17:56 +0000)] 
Add extra test cases for UPSERT.

FossilOrigin-Name: 7ea08d0750dd9e07d2ffea336127034800db14aa23e60adec384d338871bf53a

7 years agoFix a problem in the sqlite3ExprCompare() function that caused two
drh [Wed, 18 Apr 2018 17:52:28 +0000 (17:52 +0000)] 
Fix a problem in the sqlite3ExprCompare() function that caused two
dissimilar expressions to match if they have the same "COLLATE name" at
the outer layer.

FossilOrigin-Name: fb16348a5bd52752098c9aeacc3281c4e1e8eb5a868d131ea6c3271dc4226b40

7 years agoAdd support for PostgreSQL UPSERT syntax and functionality.
drh [Wed, 18 Apr 2018 16:03:36 +0000 (16:03 +0000)] 
Add support for PostgreSQL UPSERT syntax and functionality.

FossilOrigin-Name: fba24aec235dd6f124c1ece66cdac485c9d96e0578c4fbacd8f49d7b767a5b4a

7 years agoFix the build for SQLITE_OMIT_UPSERT upsert
drh [Wed, 18 Apr 2018 15:33:21 +0000 (15:33 +0000)] 
Fix the build for SQLITE_OMIT_UPSERT

FossilOrigin-Name: 32956519173ee49ec9dd9aa7952278eb4effe567493c6cb304e16f887df6bafa

7 years agoAdd the --sorterref N option to the CLI.
drh [Wed, 18 Apr 2018 15:21:13 +0000 (15:21 +0000)] 
Add the --sorterref N option to the CLI.

FossilOrigin-Name: 902a40897f74ac8a3bc72ef84c2161ab308b5601381cc9eea18147bfefa978ce

7 years agoOmit some code not used without SQLITE_ENABLE_SORTER_REFERENCES. Improvements
drh [Wed, 18 Apr 2018 14:48:08 +0000 (14:48 +0000)] 
Omit some code not used without SQLITE_ENABLE_SORTER_REFERENCES.  Improvements
to comments used for documentation.

FossilOrigin-Name: f3596ab9eb1168dc75202e6f79e12c67d518b3a0659a0a629c707f43990fa7cf

7 years agoRemove an unused local variable.
drh [Wed, 18 Apr 2018 14:04:19 +0000 (14:04 +0000)] 
Remove an unused local variable.

FossilOrigin-Name: 9afeb0c88b211e3ad90697778ec8ebb80f216fe7078c3a2f51651c35d3828746

7 years agoEnhance ALTER TABLE ADD COLUMN to support "DEFAULT true" and "DEFAULT false".
drh [Wed, 18 Apr 2018 11:35:35 +0000 (11:35 +0000)] 
Enhance ALTER TABLE ADD COLUMN to support "DEFAULT true" and "DEFAULT false".

FossilOrigin-Name: 594ebc69557095c9262db39129dd50a3dbf038556a3d2a3ea69b82ed4c61e2b9

7 years agoAdd checks to the CLI that issue a warning if SQLite gets initialized prior
drh [Wed, 18 Apr 2018 10:44:58 +0000 (10:44 +0000)] 
Add checks to the CLI that issue a warning if SQLite gets initialized prior
to the last sqlite3_config() call.

FossilOrigin-Name: 40b117347763ef67f6621d3665ca7f287eebfd7435e3178055a8c624eb06b2c5

7 years agoFix a problem in the shell preventing it from working with
dan [Wed, 18 Apr 2018 09:16:11 +0000 (09:16 +0000)] 
Fix a problem in the shell preventing it from working with
SQLITE_OMIT_AUTOINIT builds.

FossilOrigin-Name: 89209000a205c685bb6bd941376ef16e507919d192d606c1be110ccf2921d9bd

7 years agoAdd new testcase() macros and fix a bug that was revealed when trying to
drh [Wed, 18 Apr 2018 01:34:39 +0000 (01:34 +0000)] 
Add new testcase() macros and fix a bug that was revealed when trying to
cover all the new test cases.

FossilOrigin-Name: 266a99f7c068aadbd08157d1d495a428109ad7a32d872f8026e8db0f89c40f91

7 years agoRemove unreachable branches. 100% MC/DC in TH3 now.
drh [Tue, 17 Apr 2018 21:59:34 +0000 (21:59 +0000)] 
Remove unreachable branches.  100% MC/DC in TH3 now.

FossilOrigin-Name: 558865d5c3c297155e1be5ea73effb46a995ea146bd745b23330c94782c6c45b

7 years agoAdded a comment on the assert() added to the previous check-in.
drh [Tue, 17 Apr 2018 20:09:27 +0000 (20:09 +0000)] 
Added a comment on the assert() added to the previous check-in.

FossilOrigin-Name: 542547c1ce770a1427d3023d8c8fdcb2db7b1e017bc111e3484641f97e42381a

7 years agoFixes to the logic for constraint check reordering during upsert.
drh [Tue, 17 Apr 2018 20:06:24 +0000 (20:06 +0000)] 
Fixes to the logic for constraint check reordering during upsert.
Improved comments on constraint check bytecode.  Add an assert that
prevents the same label from being resolved more than once.

FossilOrigin-Name: 1ddbb0ff5586ef5ca987e4309979f24f95eea883ed68937094a2db2d61e75657

7 years agoDuring PRAGMA vdbe_addoptrace=ON, show calls to sqlite3VdbeResolveLabel()
drh [Tue, 17 Apr 2018 19:29:58 +0000 (19:29 +0000)] 
During PRAGMA vdbe_addoptrace=ON, show calls to sqlite3VdbeResolveLabel()
in the debugging output.

FossilOrigin-Name: 9ff07a06cef6e04777d2d5b81f96e8626e835382e62320ecf17b3ff73573e23e