]> git.ipfire.org Git - thirdparty/sqlite.git/log
thirdparty/sqlite.git
5 years agoProvide the ability to tag an application-defined function as "testonly". testonly-functions
drh [Tue, 7 Jan 2020 14:51:54 +0000 (14:51 +0000)] 
Provide the ability to tag an application-defined function as "testonly".

FossilOrigin-Name: e6f5c0e0ac712176da75889401f415952abcbf5652bbf7124b362e37d950c275

5 years agoAdd an "|| CORRUPT_DB" term to an assert() statement inside of btree.
drh [Tue, 7 Jan 2020 13:32:15 +0000 (13:32 +0000)] 
Add an "|| CORRUPT_DB" term to an assert() statement inside of btree.

FossilOrigin-Name: 03c1d75ddc063469fc856114595bd12d21759fe0979ce1ba1cf52e48e6b0d4a1

5 years agoFix an instance of an undefined behaviour (a left-shift of a 64-bit unsigned integer...
dan [Tue, 7 Jan 2020 09:06:43 +0000 (09:06 +0000)] 
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

5 years agoIn the typeof() optimization in OP_Column, expand the size of the bogus buffer
drh [Mon, 6 Jan 2020 20:48:45 +0000 (20:48 +0000)] 
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

5 years agoRewrite the (debugging use only) sqlite3VdbeMemPrettyPrint() function to use
drh [Mon, 6 Jan 2020 19:23:41 +0000 (19:23 +0000)] 
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

5 years agoBackout change [4d0b9109f7a5312d4e1] because the conditional it added is
drh [Mon, 6 Jan 2020 18:59:46 +0000 (18:59 +0000)] 
Backout change [4d0b9109f7a5312d4e1] because the conditional it added is
no longer reachable due to check-in [1409758f72c0206c].

FossilOrigin-Name: b3f2696705cc3e7b038f156423f808432a4680ea7e313dc15e34bdf6b1845655

5 years agoMove variable declaration to start-of-block for MSVC.
mistachkin [Mon, 6 Jan 2020 18:44:56 +0000 (18:44 +0000)] 
Move variable declaration to start-of-block for MSVC.

FossilOrigin-Name: 55c136ef61f23a04be1bf351ab7f6bdfa033653c32557a04916cc9770453f261

5 years agoDo not attempt to use the skip-scan optimization if prior terms of the
drh [Mon, 6 Jan 2020 17:33:09 +0000 (17:33 +0000)] 
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

5 years agoEnsure the SF_Aggregate flag on a SELECT statement is set if a DISTINCT is transforme...
dan [Mon, 6 Jan 2020 17:06:12 +0000 (17:06 +0000)] 
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

5 years agoRemove a NEVER in btree due to a new test case from dbsqlfuzz.
drh [Sun, 5 Jan 2020 21:53:15 +0000 (21:53 +0000)] 
Remove a NEVER in btree due to a new test case from dbsqlfuzz.

FossilOrigin-Name: 46f8ef70fb8b3ae00cc081b280f3dff38b1d0f1b52a8f4477ec89dec32e4d813

5 years agoFix DBSTAT so that it returns now rows, rather than an error when the
drh [Sat, 4 Jan 2020 19:14:48 +0000 (19:14 +0000)] 
Fix DBSTAT so that it returns now rows, rather than an error when the
WHERE clause is "schema=NULL".

FossilOrigin-Name: 5b246b47aeadc25dbec0956e2d6edcd49fbe874a01734fdf15b770507648222d

5 years agoFix harmless compiler warnings.
drh [Sat, 4 Jan 2020 19:12:13 +0000 (19:12 +0000)] 
Fix harmless compiler warnings.

FossilOrigin-Name: 8452fe03430d34abecab618d6136b863630f91d68d69ebbc115f808bc81c3817

5 years agoOmit the omit flat from eq constraints on column "name" of dbstat virtual tables...
dan [Sat, 4 Jan 2020 18:38:58 +0000 (18:38 +0000)] 
Omit the omit flat from eq constraints on column "name" of dbstat virtual tables. Fix for [74a4c386].

FossilOrigin-Name: cfff5cb2279088aa66f435bd0d627b2c74c9a99ad9addfd44a4df8ba770b795a

5 years agoRecord when the OP_IfNotOpen branch is and is not taken.
drh [Sat, 4 Jan 2020 18:33:20 +0000 (18:33 +0000)] 
Record when the OP_IfNotOpen branch is and is not taken.

FossilOrigin-Name: 182a898b14d585edd5fcfdcd6584c957911f0d81773d2868f16b5762dec031ca

5 years agoRemove another NEVER added by check-in [7b62555e285f32d3].
drh [Sat, 4 Jan 2020 17:55:01 +0000 (17:55 +0000)] 
Remove another NEVER added by check-in [7b62555e285f32d3].
Dbsqlfuzz found another test case.

FossilOrigin-Name: 481f4956aff52797880930752693a8c0b10d7fdd71d86919fe8ee13c90ad5b81

5 years agoNew test cases in test/in4.test require rtree, so disable those tests on
drh [Sat, 4 Jan 2020 17:42:27 +0000 (17:42 +0000)] 
New test cases in test/in4.test require rtree, so disable those tests on
builds that lack the rtree extension.

FossilOrigin-Name: b5900914f7f34caf1a97c87233781d55467329b0ac4366354df13c6fd72a99c7

5 years agoFix a problem where the loop for the RHS of a LEFT JOIN uses values from an IN()...
dan [Sat, 4 Jan 2020 16:55:57 +0000 (16:55 +0000)] 
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

5 years agoFix a false-positive in the register validity tracking logic by moving the
drh [Sat, 4 Jan 2020 15:21:47 +0000 (15:21 +0000)] 
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

5 years agoImprove a testcase in test/fuzzdata8.db to make it more resilient.
drh [Sat, 4 Jan 2020 14:57:26 +0000 (14:57 +0000)] 
Improve a testcase in test/fuzzdata8.db to make it more resilient.

FossilOrigin-Name: 139aefe60097e06b43df35652e6b2183b7a4b03341d1bde23deada3fa3358fee

5 years agoBack out another NEVER added by check-in [7b62555e285f32d3] - the test case
drh [Sat, 4 Jan 2020 14:50:06 +0000 (14:50 +0000)] 
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

5 years agoOmit the omit flag from eq constraints on column "aggregate" of dbstat virtual tables...
dan [Sat, 4 Jan 2020 14:00:56 +0000 (14:00 +0000)] 
Omit the omit flag from eq constraints on column "aggregate" of dbstat virtual tables. Fix for [727074e2].

FossilOrigin-Name: 74ef6f2b6d9f50ff1d455e2263ba77707c1e8394b25b3f8a3a2a7b6e7f2c481e

5 years agoRestore a NEVER and an assert in btree that was removed by
drh [Sat, 4 Jan 2020 12:34:44 +0000 (12:34 +0000)] 
Restore a NEVER and an assert in btree that was removed by
check-in [7b62555e285f32d3].  Dbsqlfuzz found test cases.

FossilOrigin-Name: 04a05c83f58784df438dc6614f7920f782bf7c1ed4f6d101c03b6573cfde06ee

5 years agoIn fts3, avoid making a very large memory allocation if the merge-hint record is...
dan [Fri, 3 Jan 2020 20:16:32 +0000 (20:16 +0000)] 
In fts3, avoid making a very large memory allocation if the merge-hint record is corrupt.

FossilOrigin-Name: 9add58fe9688d5c1f675736e7f1c6ff7831d2ff6fdeb884a2e62c1bf9536ee50

5 years agoAdd NEVER macros to error-detection branches that were made unreachable
drh [Fri, 3 Jan 2020 17:40:30 +0000 (17:40 +0000)] 
Add NEVER macros to error-detection branches that were made unreachable
(as far as I can tell) by check-in [ceacc28b03580334].

FossilOrigin-Name: 7b62555e285f32d354df7746ef8dce16856c6d9d53a02d895b74ba02362d2968

5 years agoImprovement to check-in [7405e98225761180] so that missing or null filenames
drh [Fri, 3 Jan 2020 16:38:54 +0000 (16:38 +0000)] 
Improvement to check-in [7405e98225761180] so that missing or null filenames
given to the zipfile extension throw an immediate error.

FossilOrigin-Name: 523e09bd228750fb7be1d4e68d18f6c1bf9db19293d66fbf30b86409321e9814

5 years agoImprove a specific case of early database corruption dectecion in the b-tree layer.
dan [Fri, 3 Jan 2020 15:51:23 +0000 (15:51 +0000)] 
Improve a specific case of early database corruption dectecion in the b-tree layer.

FossilOrigin-Name: ceacc28b035803342764f9b696c1e80edcd259b87ea4fb46f92963d6cb33de3e

5 years agoRemove an over-zealous ALWAYS() macro and add a test case that shows that
drh [Fri, 3 Jan 2020 14:34:04 +0000 (14:34 +0000)] 
Remove an over-zealous ALWAYS() macro and add a test case that shows that
the conditional can sometimes be false.

FossilOrigin-Name: 536e9a9d1bd514056ecbc8172ed58f2656a86f791a15e526ae2e5f2c93687b6a

5 years agoFix a possible NULL pointer dereference caused by using a "VALUES(...)" as a componen...
dan [Fri, 3 Jan 2020 14:27:08 +0000 (14:27 +0000)] 
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

5 years agoFix the OP_Copy-coalesce optimization so that if the previous row happens
drh [Fri, 3 Jan 2020 14:16:43 +0000 (14:16 +0000)] 
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

5 years agoEnsure that when a Select object is reset a new, empty, SrcList is allocated.
dan [Fri, 3 Jan 2020 13:55:14 +0000 (13:55 +0000)] 
Ensure that when a Select object is reset a new, empty, SrcList is allocated.

FossilOrigin-Name: 4889cbf898d7ec54f061b21b6d3621b22fc482cbeaa7115d40995a4cc30e41db

5 years agoWhen generating the name of a view (or common table expression) because the
drh [Fri, 3 Jan 2020 02:20:37 +0000 (02:20 +0000)] 
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

5 years agoFix a problem in sqlite3TreeViewBareExprList() in which the routine was
drh [Fri, 3 Jan 2020 00:28:14 +0000 (00:28 +0000)] 
Fix a problem in sqlite3TreeViewBareExprList() in which the routine was
not interpreting the new ExprList format correctly.

FossilOrigin-Name: cd56872afbb4edeff2e8c1cb1c8d47c7a9b333b3fc416c20183250807291fae8

5 years agoAdd the two-size lookaside memory allocator. Also, reduce the per-entry
drh [Thu, 2 Jan 2020 22:28:47 +0000 (22:28 +0000)] 
Add the two-size lookaside memory allocator.  Also, reduce the per-entry
size of the ExprList object.

FossilOrigin-Name: 51665bf0f975fb248964a4be205a4f3285d3f3f8cc697977d264efefbbe20dd8

5 years agoNEVER() and ALWAYS() macros tagging unreachable branches. two-size-lookaside
drh [Thu, 2 Jan 2020 22:23:01 +0000 (22:23 +0000)] 
NEVER() and ALWAYS() macros tagging unreachable branches.

FossilOrigin-Name: 34b877742ef78e9bb3f16815180f4ad9cd722beb1d610f713400a3b25d68aa9b

5 years agoMerge the latest enhancements from trunk.
drh [Thu, 2 Jan 2020 21:41:59 +0000 (21:41 +0000)] 
Merge the latest enhancements from trunk.

FossilOrigin-Name: bd57e6d923d3b04f0a07aaf18bf389d2b2b7efc7c57e8cb37e6ef910662d8397

5 years agoDo not allow the zipfile virtual table to start a transaction if no
drh [Thu, 2 Jan 2020 21:30:13 +0000 (21:30 +0000)] 
Do not allow the zipfile virtual table to start a transaction if no
filename has been specified.

FossilOrigin-Name: 7405e982257611803792617f5d8142c54f9831b4a030f4de8607888c525e6289

5 years agoFix some test logic in the OP_Delete opcode so that it works after a
drh [Thu, 2 Jan 2020 19:50:50 +0000 (19:50 +0000)] 
Fix some test logic in the OP_Delete opcode so that it works after a
cursor-trip.

FossilOrigin-Name: 28900e5cab73f9edb9383d64a37e14fed0602966cb704ddffa60c0281698fd52

5 years agoIfdef-out code that is only possible with the sessions extension.
drh [Thu, 2 Jan 2020 18:37:04 +0000 (18:37 +0000)] 
Ifdef-out code that is only possible with the sessions extension.

FossilOrigin-Name: 4fcf07f79672d203efbc90ad21d97f6a131c3885306f8e0bab015d5ac44b8644

5 years agoHave the OP_ReleaseReg opcode also invalidate the registers if P5 is non-zero.
drh [Thu, 2 Jan 2020 17:46:02 +0000 (17:46 +0000)] 
Have the OP_ReleaseReg opcode also invalidate the registers if P5 is non-zero.

FossilOrigin-Name: 937be22106f7e3f08712febd342d6cb81d129f2d5ab24ce80b3a5c3f9bbde54e

5 years agoHandle blobs that are the return values of functions being cast to text in utf16...
dan [Thu, 2 Jan 2020 16:24:22 +0000 (16:24 +0000)] 
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

5 years agoFix the OP_Move opcode so that it correctly manages dependency tracking.
drh [Thu, 2 Jan 2020 15:02:08 +0000 (15:02 +0000)] 
Fix the OP_Move opcode so that it correctly manages dependency tracking.
This change impacts debugging builds only.

FossilOrigin-Name: 5377add4b8af8c52d0a32f5273835ac6bdc42cfb2a95ffcb335b987437a91aa6

5 years agoEnhancements to aid testing and debugging:
drh [Thu, 2 Jan 2020 14:42:42 +0000 (14:42 +0000)] 
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

5 years agoAdd the test_trace_breakpoint() subroutine that is invoked after each
drh [Thu, 2 Jan 2020 13:26:49 +0000 (13:26 +0000)] 
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

5 years agoUse OP_Copy instead of OP_SCopy to move the results of a scalar subquery.
drh [Thu, 2 Jan 2020 02:50:45 +0000 (02:50 +0000)] 
Use OP_Copy instead of OP_SCopy to move the results of a scalar subquery.

FossilOrigin-Name: 435c272dcf6ed5f3acb564b8f959557145f117b869547b670258cf5a1908ab6b

5 years agoThe sqlite3WhereEnd() call now unwinds all Expr modifications made by the
drh [Thu, 2 Jan 2020 00:45:38 +0000 (00:45 +0000)] 
The sqlite3WhereEnd() call now unwinds all Expr modifications made by the
sqlite3WhereBegin().

FossilOrigin-Name: 7bfd42f1dc0c94f9bb74516e62fec8e39c20f4749f4e0972f66c2886d3c64f73

5 years agoProvide the -DSQLITE_ENABLE_INTERNAL_FUNCTIONS=1 compile-time option. Fix
drh [Wed, 1 Jan 2020 23:02:35 +0000 (23:02 +0000)] 
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

5 years agoWhen generating code for a subquery, make a copy of the Select object and
drh [Wed, 1 Jan 2020 21:14:30 +0000 (21:14 +0000)] 
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

5 years agoEnsure that when code for a scalar SELECT featuring window functions is generated...
dan [Wed, 1 Jan 2020 20:17:15 +0000 (20:17 +0000)] 
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

5 years agoFix the sqlite3ExprImpliesNonNullRow() routine so that it correctly
drh [Wed, 1 Jan 2020 16:43:41 +0000 (16:43 +0000)] 
Fix the sqlite3ExprImpliesNonNullRow() routine so that it correctly
handles a numeric comparison of two AND subexpressions.

FossilOrigin-Name: 07e504d5174a1a8b1aa05ec5b44ac81ab3ea706c5a098caa88deb3d489cec8fb

5 years agoNew test-only SQL functions: implies_nonnull_row(), expr_compare(), and
drh [Wed, 1 Jan 2020 15:43:30 +0000 (15:43 +0000)] 
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

5 years agoFactor out code generation for in-line SQL functions into a separate routine
drh [Wed, 1 Jan 2020 13:55:08 +0000 (13:55 +0000)] 
Factor out code generation for in-line SQL functions into a separate routine
inside of expr.c.

FossilOrigin-Name: 586a65a28fc6cac77309612abc32a2e1017c65e0387f9f438f5d8ac8406da8eb

5 years agoIssue OP_ReleaseReg opcodes against the array of registers used to compute
drh [Wed, 1 Jan 2020 01:26:05 +0000 (01:26 +0000)] 
Issue OP_ReleaseReg opcodes against the array of registers used to compute
index records after the index record has been computed.

FossilOrigin-Name: e3330861b4deab7c7cc09ad8b936d633c600b9fb4e274801efeaaf94e5c860b4

5 years agoRemove an incorrect assert() statement. Ticket [46fcd700b855e6d1]
drh [Tue, 31 Dec 2019 23:17:35 +0000 (23:17 +0000)] 
Remove an incorrect assert() statement.  Ticket [46fcd700b855e6d1]

FossilOrigin-Name: eca7ec9cda4606c4104bcb8da315070b615713db9f3444579c6a3e96b0aad02f

5 years agoAlso set the SQLITE_DIRECTONLY flag on the load_extension() function.
drh [Tue, 31 Dec 2019 18:39:23 +0000 (18:39 +0000)] 
Also set the SQLITE_DIRECTONLY flag on the load_extension() function.

FossilOrigin-Name: 3bd095a53119c368fe30e539983588b27957203344cf427405b9a64784b8eba7

5 years agoSet the SQLITE_DIRECTONLY flag on the fts3_tokenizer() function of FTS3,
drh [Tue, 31 Dec 2019 18:12:36 +0000 (18:12 +0000)] 
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

5 years agoRefactor names. Use "small" instead of "mini" to describe the smaller mini-lookaside-take-2
drh [Tue, 31 Dec 2019 15:12:34 +0000 (15:12 +0000)] 
Refactor names.  Use "small" instead of "mini" to describe the smaller
of the two lookaside memory allocation sizes.

FossilOrigin-Name: 88d244983854cdc1a369c5df09ae00f1098784db768ba4e17b963d187dcb1009

5 years agoMerge recent enhancements from trunk.
drh [Tue, 31 Dec 2019 14:49:10 +0000 (14:49 +0000)] 
Merge recent enhancements from trunk.

FossilOrigin-Name: 39d55579376906f212271ce9b2d367e3ad029fb173f22c7253312b467970208a

5 years agoThe OP_ResultRow opcode releases the SCopy dependences on all its registers,
drh [Tue, 31 Dec 2019 12:18:24 +0000 (12:18 +0000)] 
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

5 years agoBack out the NEVER() from check-in [40d10e7aad5b8992] because it is reachable
drh [Mon, 30 Dec 2019 23:50:19 +0000 (23:50 +0000)] 
Back out the NEVER() from check-in [40d10e7aad5b8992] because it is reachable
after all. Ticket [892575cdba4e1e36]

FossilOrigin-Name: f481636f1a0333c6e98906e5d4433bf1d046380bc29c760e8e7e2c2b3530b956

5 years agoAdd an ALWAYS() to a conditional which is apparently always true.
drh [Mon, 30 Dec 2019 23:41:59 +0000 (23:41 +0000)] 
Add an ALWAYS() to a conditional which is apparently always true.

FossilOrigin-Name: ea44c607b8038999a6bda4d761d95056aa4058d6c2891b7eee0715a50e703490

5 years agoPut a NEVER() on a defensive branch.
drh [Mon, 30 Dec 2019 20:42:53 +0000 (20:42 +0000)] 
Put a NEVER() on a defensive branch.

FossilOrigin-Name: 40d10e7aad5b899206e45d1f8606470a90a07049e15d94c3811cfe695f3a402e

5 years agoFix a typo in a comment. No changes to code.
drh [Mon, 30 Dec 2019 20:42:17 +0000 (20:42 +0000)] 
Fix a typo in a comment.  No changes to code.

FossilOrigin-Name: d4813a8d813f234e819f8ebefbd3ff96d3d69593cc7d716cf0ad6c1a126da827

5 years agoDo not use HIDDEN columns for NATURAL joins. Fix for [7c0e06b16].
dan [Mon, 30 Dec 2019 14:32:27 +0000 (14:32 +0000)] 
Do not use HIDDEN columns for NATURAL joins. Fix for [7c0e06b16].

FossilOrigin-Name: ab09ef427181130be09a087b7e572ad4cfb6b3e1b459769ee5ebf046b3ead682

5 years agoIn ALTER TABLE, rename columns and tables in expressions that are optimized out by...
dan [Mon, 30 Dec 2019 06:55:31 +0000 (06:55 +0000)] 
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

5 years agoDo not allow triggers that run as part of REPLACE conflict resolution
drh [Sun, 29 Dec 2019 22:08:20 +0000 (22:08 +0000)] 
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

5 years agoAdd the OP_FinishSeek opcode which completes an OP_DeferredSeek if the seek
drh [Sun, 29 Dec 2019 00:52:41 +0000 (00:52 +0000)] 
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

5 years agoDo not attempt to flatten compound sub-queries in a FROM clause into the parent if...
dan [Sat, 28 Dec 2019 18:25:51 +0000 (18:25 +0000)] 
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

5 years agoChange an assert() in where.c to a testcase() macro, since the condition may be false...
dan [Sat, 28 Dec 2019 18:08:39 +0000 (18:08 +0000)] 
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

5 years agoDisable early coding of transitive constraints at the end of each loop in
drh [Sat, 28 Dec 2019 16:20:23 +0000 (16:20 +0000)] 
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

5 years agoFix an instance where the planner might choose to use the OR-optimization when it...
dan [Sat, 28 Dec 2019 15:24:02 +0000 (15:24 +0000)] 
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

5 years agoFurther improvements to .wheretrace during loop code generation.
drh [Sat, 28 Dec 2019 14:33:26 +0000 (14:33 +0000)] 
Further improvements to .wheretrace during loop code generation.

FossilOrigin-Name: c4d5b75c9381255ec8d9a284eedb6b27be46ca868cae5985cf8a5769b15290c3

5 years agoNew enhancements to .wheretrace. The 0x20000 flag shows the WHERE clause
drh [Sat, 28 Dec 2019 14:07:22 +0000 (14:07 +0000)] 
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

5 years agoExpose some of the Where data structure debug printing routines to the
drh [Sat, 28 Dec 2019 13:39:47 +0000 (13:39 +0000)] 
Expose some of the Where data structure debug printing routines to the
entire WHERE-clause processing module.

FossilOrigin-Name: 85e76887761b5d7e290fb2bac7f9121648f79d67fdd92f624d81632f28620518

5 years agoAdd the --enable-all option to the main configure script as a short-hand
drh [Sat, 28 Dec 2019 13:17:11 +0000 (13:17 +0000)] 
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

5 years agoSimplifications to the initialization of the sqlite3_index_info structure
drh [Sat, 28 Dec 2019 13:01:52 +0000 (13:01 +0000)] 
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

5 years agoIf the ".wheretrace 0x10000" bit is set, print WhereTerm.prereqAll
drh [Sat, 28 Dec 2019 12:33:35 +0000 (12:33 +0000)] 
If the ".wheretrace 0x10000" bit is set, print WhereTerm.prereqAll
and .prereqRight fields in the WhereTerm trace output.

FossilOrigin-Name: a4f330b133a36356681dce7d2a65d8ab792620494d6cd4ef4934a97cf3a8e6fc

5 years agoTwo new test cases added to test/fuzzdata8.db.
drh [Sat, 28 Dec 2019 11:55:44 +0000 (11:55 +0000)] 
Two new test cases added to test/fuzzdata8.db.

FossilOrigin-Name: 1be2c18f4021e1d0b8412ecb68a599475c717dd97c7db209fc4203358957fd70

5 years agoSecond attempt to fix a problem with unwinding the WITH stack of the Parse object...
dan [Sat, 28 Dec 2019 09:08:27 +0000 (09:08 +0000)] 
Second attempt to fix a problem with unwinding the WITH stack of the Parse object following an error.

FossilOrigin-Name: 315d1f1a503e8c186739658c85b92fa3d12514e5baaa26925c85664b5e85d1c0

5 years agoMerge latest trunk changes with this branch. better-error-handling-1
dan [Sat, 28 Dec 2019 08:33:46 +0000 (08:33 +0000)] 
Merge latest trunk changes with this branch.

FossilOrigin-Name: d693be375380fbfca426999a77eeecb8453fa77b77f608bfe266945dee1da41d

5 years agoFix an assert() failure in altertable3-22.4.
dan [Sat, 28 Dec 2019 08:26:47 +0000 (08:26 +0000)] 
Fix an assert() failure in altertable3-22.4.

FossilOrigin-Name: c566a91d5c4290b0a491a01e85bf8f9fbebf2910e0d478bafc2d22da7f749cae

5 years agoFix a faulty assert() associated with query search limiting query plans.
drh [Sat, 28 Dec 2019 03:55:50 +0000 (03:55 +0000)] 
Fix a faulty assert() associated with query search limiting query plans.

FossilOrigin-Name: 0d743585c242ebd898b232f42937a2306752aaed0a6756705e3ef1cf7593aa97

5 years agoConvert an assert() back into a conditional. The conditional was converted
drh [Sat, 28 Dec 2019 02:40:49 +0000 (02:40 +0000)] 
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

5 years agoWhen an INSERT is receiving content from a SELECT, run an OP_ReleaseReg opcode
drh [Sat, 28 Dec 2019 01:52:46 +0000 (01:52 +0000)] 
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

5 years agoRecompute the values for all generated columns after
drh [Sat, 28 Dec 2019 00:36:51 +0000 (00:36 +0000)] 
Recompute the values for all generated columns after
NOT NULL ON CONFLICT REPLACE constraints fire.
Tickets [37823501c68a09f9] and [5fbc159eeb092130].

FossilOrigin-Name: 4cc12c18860bc4801a407cf45e88e23d3d40391f01a461fbac2cac5f102100e1

5 years agoDo not attempt to unwind the WITH stack in the Parse object following an error. This...
dan [Fri, 27 Dec 2019 20:54:42 +0000 (20:54 +0000)] 
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

5 years agoRemove a NEVER() that is no longer true. Fix for [36ffedcb9].
dan [Fri, 27 Dec 2019 20:06:32 +0000 (20:06 +0000)] 
Remove a NEVER() that is no longer true. Fix for [36ffedcb9].

FossilOrigin-Name: 597896ed0ae9e2960a8f39576bd7f77a11dccc1da84b6a44ebb5c38d90ebc330

5 years agoFix a problem involving window function aliases being referenced from sub-selects.
dan [Fri, 27 Dec 2019 19:46:07 +0000 (19:46 +0000)] 
Fix a problem involving window function aliases being referenced from sub-selects.

FossilOrigin-Name: e3b5fc05c00fc58be7a7c94ce1d97a5b05113f39aba03df64aab08364f85616b

5 years agoAdd a missing "ifcapable rtree {...}" line to the window1.test test module.
drh [Fri, 27 Dec 2019 18:15:04 +0000 (18:15 +0000)] 
Add a missing "ifcapable rtree {...}" line to the window1.test test module.

FossilOrigin-Name: 4e6fbb1a5100fe29209bcf668fbecf3a733034b84925265d8a15b0a84baf6cf0

5 years agoFix a problem with window functions in aggregate queries that do not have GROUP BY...
dan [Fri, 27 Dec 2019 16:25:56 +0000 (16:25 +0000)] 
Fix a problem with window functions in aggregate queries that do not have GROUP BY clauses.

FossilOrigin-Name: 99609786f485653464d1caef1d207ae299d28c925bff3e8e94891759b4765dcc

5 years agoDo not mistake constant integers in a PARTITION BY expression for references to ORDER...
dan [Fri, 27 Dec 2019 15:31:47 +0000 (15:31 +0000)] 
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

5 years agoFollow-up to check-in [c8c6dd0e6582ec91] - change the xAccess() method to
drh [Fri, 27 Dec 2019 13:30:46 +0000 (13:30 +0000)] 
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

5 years agoWhen determining if an aggregate within a sub-query should be processed as part of...
dan [Fri, 27 Dec 2019 08:57:08 +0000 (08:57 +0000)] 
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

5 years agoEnsure that the Pager.changeCountDone flag is cleared whenever dropping
drh [Fri, 27 Dec 2019 01:50:46 +0000 (01:50 +0000)] 
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

5 years agoFix buffer underflows in the zipfile extension associated with zero-length
drh [Fri, 27 Dec 2019 00:19:53 +0000 (00:19 +0000)] 
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

5 years agoIf an UPSERT can cause an Abort due to a constraint failure, make sure
drh [Thu, 26 Dec 2019 23:40:33 +0000 (23:40 +0000)] 
If an UPSERT can cause an Abort due to a constraint failure, make sure
the query planner knows this.  Ticket [7c13db5c3bf74001].

FossilOrigin-Name: f14ce948662f3445a06d84d4f32d9b81143e0cffaf773d8aa4d3a609bfb9682b

5 years agoAn UPDATE of a table that is indexed by a constant virtual column that uses
drh [Thu, 26 Dec 2019 23:16:18 +0000 (23:16 +0000)] 
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

5 years agoFix an assert() in fts5 that could fail if an xSavepoint() call on another vtab fails.
dan [Thu, 26 Dec 2019 14:36:31 +0000 (14:36 +0000)] 
Fix an assert() in fts5 that could fail if an xSavepoint() call on another vtab fails.

FossilOrigin-Name: a5d7f5d24a239f729de0b8aa5becf5af35ba87160565ee0713c335b8d1bbf12d

5 years agoMakefile.in fix so that it works on systems that require a .EXE suffix
drh [Thu, 26 Dec 2019 01:10:17 +0000 (01:10 +0000)] 
Makefile.in fix so that it works on systems that require a .EXE suffix
on executables.

FossilOrigin-Name: f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1bef22f3

5 years agoAdd two new fuzzer test cases from dbsqlfuzz.
drh [Thu, 26 Dec 2019 01:02:02 +0000 (01:02 +0000)] 
Add two new fuzzer test cases from dbsqlfuzz.

FossilOrigin-Name: f8d5586a8ceca985dcb2d63d0fbad9e271e9e1664720ee698d4947acd5dcc543

5 years agoIn the xAccess() method of the unix VFS, return true if the named object
drh [Thu, 26 Dec 2019 00:56:50 +0000 (00:56 +0000)] 
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