drh [Mon, 31 Dec 2018 20:39:37 +0000 (20:39 +0000)]
Additional steps to help ensure that scalar subqueries are only evaluated
once even if they are used in multiple places within the query. This fixes
a performance regression reported on the mailing list and caused by
check-in [531eca6104e41e43] which was a fix for ticket
[787fa716be3a7f650c]. Think of this check-in as an improved fix for
that ticket.
drh [Mon, 31 Dec 2018 20:13:12 +0000 (20:13 +0000)]
Remove an optimization that can no longer occur, being superceded by the
subquery-reuse optimization. Put an assert in place of the optimization
to detect if the need for this optimization ever returns.
drh [Mon, 31 Dec 2018 16:36:42 +0000 (16:36 +0000)]
Fix the OP_OpenEphemeral opcode in the bytecode engine so that if it is called
a second or subsequent time, it merely clears the existing table rather than
creating a new one. Proposed fix for ticket [d0866b26f83e9c55e30de0821f5d].
drh [Sat, 29 Dec 2018 02:26:59 +0000 (02:26 +0000)]
A new implementation of sqlite3VdbeMakeLabel() is faster and makes fewer
memory allocations by deferring memory allocation until
sqlite3VdbeResolveLabel() is called, at which point the code generator has
a better idea of how big the relocation table needs to be.
The sqlite3VdbeMakeLabel() routine now takes a Parse* parameter instead of
Vdbe*.
dan [Fri, 28 Dec 2018 17:45:08 +0000 (17:45 +0000)]
Fix a problem causing the sqlite_master entry corresponding to a virtual table
to be removed by a DROP TABLE even if the call to the vtabs xDestroy() method
failed.
drh [Thu, 27 Dec 2018 02:16:01 +0000 (02:16 +0000)]
Fix a problem in which nested CTEs with the same table name trick the
code generator into thinking they are the same CTE, which then tries to
use the manifest them both into the same transient table.
drh [Tue, 25 Dec 2018 00:15:37 +0000 (00:15 +0000)]
Increase the number of parameters to sqlite3WhereCodeOneLoopStart() to
encourage the compiler to inline that routine within sqlite3WhereBegin().
This gives a performance improvement.
drh [Mon, 24 Dec 2018 20:21:06 +0000 (20:21 +0000)]
Improvements to EXPLAIN QUERY PLAN formatting. The MULTI-INDEX OR now shows
a separate "INDEX" subtree for each index. SCALAR SUBQUERY entries provide
a subquery number that is related back to the .selecttrace output.
drh [Mon, 24 Dec 2018 12:09:47 +0000 (12:09 +0000)]
Do not generate subroutines for non-static SELECT and EXISTS expressions.
Fix up some test cases to account for the minor changes in EXPLAIN QUERY PLAN
output.
drh [Mon, 24 Dec 2018 02:34:49 +0000 (02:34 +0000)]
Experimental code that tries to put the computation of subqueries inside a
subroutine, and reuse that subroutine if the same subquery is evaluated more
than once. Current code does not work for CHECK constraints.
drh [Sun, 23 Dec 2018 21:27:29 +0000 (21:27 +0000)]
Split the code generation for the RHS of IN operators and for SELECT and
EXISTS expressions into two separate subroutines, because there is now little
commonality between those to functions. This is intended to help make the
code easier to read and maintain.
drh [Sat, 22 Dec 2018 01:13:25 +0000 (01:13 +0000)]
Do not all REPLACE to sneak a NULL value into a NOT NULL column. Detect that
situation and ABORT instead. Fix for ticket [e6f1f2e34dceeb1ed61531c7e98].
drh [Sat, 22 Dec 2018 00:34:30 +0000 (00:34 +0000)]
The OP_Eq and OP_Ne operators have a special P5 value SQLITE_NOTNULL that
asserts that the values are not null. Except that is not always true for
a corrupt database. Adjust the assert() and add a testcase() to make this
point clear.
drh [Fri, 21 Dec 2018 22:11:37 +0000 (22:11 +0000)]
Update the dbtotxt utility program so that it does not output characters that
are special to TCL, thus making the output of dbtotxt easier to insert into
test scripts.
dan [Fri, 21 Dec 2018 20:18:06 +0000 (20:18 +0000)]
Add new sqlite3_prepare_v3() flag SQLITE_PREPARE_NO_VTAB, for
preparing statements that are not allowed to use any virtual tables.
Use this to prevent circular references in triggers on virtual table
shadow tables from causing resource leaks.
dan [Fri, 21 Dec 2018 19:29:11 +0000 (19:29 +0000)]
Add new sqlite3_prepare_v3() flag SQLITE_PREPARE_NO_VTAB, for preparing
statements that are not allowed to use any virtual tables. Use this to prevent
circular references in triggers on virtual table shadow tables from causing
resource leaks.
drh [Fri, 14 Dec 2018 13:35:48 +0000 (13:35 +0000)]
Expand the size of the temporary page used during btree rebalancing by a
few bytes, to avoid problems with small buffer overreads that can occur
on corrupted database files.
dan [Fri, 14 Dec 2018 13:18:35 +0000 (13:18 +0000)]
When saving the position of a cursor at the b-tree layer, allocate a few extra
bytes at the end of the buffer used to save the key. Otherwise, if the key is
corrupt, the code that restores the cursor position may overread the buffer by a
little.
drh [Fri, 14 Dec 2018 02:29:56 +0000 (02:29 +0000)]
Fix a bug in the custom in-memory VFS used by fuzzcheck. This bug masks
other bugs that should have caused some existing fuzzdata7.db entries to
fail, and so this fix is initially on a branch until those other bugs can
be repaired.
drh [Thu, 13 Dec 2018 21:11:22 +0000 (21:11 +0000)]
Add extra tests for database corruption inside the defragmentPage() routine,
as dbfuzz2 has found ways for corruption to leak into that point. Add test
cases in fuzzdata7.db.
drh [Thu, 13 Dec 2018 20:49:43 +0000 (20:49 +0000)]
Add the "decode_hexdb" TCL command to testfixture. Add the dbfuzz001.test
module to demonstration how to use decode_hexdb to deserialize a dbtotxt
database description for use in a corruption test.
drh [Thu, 13 Dec 2018 18:59:30 +0000 (18:59 +0000)]
Fix the CLI to keep proper track of input line numbers for use in error
messages, even after processing in-line hex database inputs using
".open --hexdb".
drh [Thu, 13 Dec 2018 15:06:26 +0000 (15:06 +0000)]
Add the "dbtotxt" utility program and the ability to read "dbtotxt" output
as a deserialized input database in the CLI, using the --hexdb option to
the ".open" command.