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.
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.
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.
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.
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.
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.
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].
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.
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.
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.
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.
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.
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.
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.
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.
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]
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.
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().
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.
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.
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.
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.
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.
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.
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]
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.
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.
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].
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.
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]
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.