drh [Wed, 26 Dec 2018 15:04:43 +0000 (15:04 +0000)]
Here is the beginnings of an effort to factor out the implementation of
scalar subqueries to be implemented as subroutines at the end of the main
body of bytecode, after the jump back to the OP_Init opcode. This is an
incremental check-in that contains only preliminary changes.
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.
drh [Thu, 13 Dec 2018 03:36:13 +0000 (03:36 +0000)]
New database corruption test cases discovered by dbfuzz2. The new cases
have been added to test/fuzzdata7.db, but have not yet all been fixed,
so tests will not currently pass.
drh [Fri, 7 Dec 2018 01:56:26 +0000 (01:56 +0000)]
Fix the sqlite3ExprDup() function so that it correctly duplicates the
Window object list on a Select that contains window functions. Fix
for ticket [f09fcd17810f65f717].
drh [Thu, 6 Dec 2018 22:12:18 +0000 (22:12 +0000)]
Performance improvement: Avoid using sqlite3WalkerSelectExpr()
and sqlite3WalkerSelectFrom() twice, so that the compiler will in-line their
implementation.
drh [Thu, 6 Dec 2018 19:56:20 +0000 (19:56 +0000)]
New test case that still hits an assertion fault, just to prove that the
previous checkin merely made the problem more obscure and did not completely
fix it.
drh [Thu, 6 Dec 2018 19:15:36 +0000 (19:15 +0000)]
Simplify the query flattener so that it does not duplicate the WHERE clause
of subquery that is being incorporated into the outer query - copies it
directly. This is more efficient. And it also fixes the specific test case
show for ticket [f09fcd17810f65f71789525] but it does not resolve the more
general problem that sqlite3ExprDup() does not correctly duplicate expressions
that contain subqueries with window functions.
drh [Thu, 6 Dec 2018 01:08:58 +0000 (01:08 +0000)]
Fix a missing mutex in the sqlite3_normalized_sql() interface when it is
called on a prepared statement that did not previously have a computed
normalization of the input SQL.
drh [Wed, 5 Dec 2018 23:45:46 +0000 (23:45 +0000)]
The sqlite3_normalized_sql() interface should not be transforming quoted
identifier names into wildcards. Fix this, and at the same time simplify
the code substantially.