drh [Wed, 18 Dec 2019 20:51:58 +0000 (20:51 +0000)]
Continue to back away from the LEFT JOIN optimization of check-in [41c27bc0ff1d3135]
by disallowing query flattening if the outer query is DISTINCT. Without this fix,
if an index scan is run on the table within the view on the right-hand side of the
LEFT JOIN, stale result registers might be accessed yielding incorrect results,
and/or an OP_IfNullRow opcode might be invoked on the un-opened table, resulting
in a NULL-pointer dereference. This problem was found by the Yongheng and Rui fuzzer.
drh [Wed, 18 Dec 2019 01:31:21 +0000 (01:31 +0000)]
Remove an assert() in the code generator that can fail due to an invalid
INSERT statement. The same assert() appears again in the VDBE and will fire
there if the problem persists in an SQL statement that does not contain
errors. Gramfuzz find.
drh [Wed, 18 Dec 2019 00:05:50 +0000 (00:05 +0000)]
When processing constant integer values in ORDER BY clauses of window
definitions (see check-in [7e4809eadfe99ebf]) be sure to fully disable
the constant value to avoid an invalid pointer dereference if the expression
is ever duplicated. This fixes a crash report from Yongheng and Rui.
drh [Mon, 16 Dec 2019 16:52:22 +0000 (16:52 +0000)]
When a table is part of a LEFT JOIN and should be a completely NULL row due to
the semantics of a LEFT JOIN, make sure any generated columns on that row
evaluate to NULL. Ticket [3b84b42943644d6f]
drh [Sun, 15 Dec 2019 02:49:32 +0000 (02:49 +0000)]
Ensure that all ON CONFLICT REPLACE indexes are sorted to the end of the list
of indexes for a table, even for weird cases where the same UNIQUE constraint
occurs twice with the ON CONFLICT REPLACE clause only on the second one. This
avoids an out-of-order contraint processing problem that can arise due
to the optimization of check-in [469a62ca33081854].
drh [Sat, 14 Dec 2019 19:55:31 +0000 (19:55 +0000)]
When a generated column expression is initially parsed, if it contains errors
convert the expression to a simple NULL. This prevents additional pieces of
the expression tree that are allocated from lookaside from leaking into the
schema, where lookaside allocations are not allowed.
drh [Sat, 14 Dec 2019 18:08:22 +0000 (18:08 +0000)]
Due to the previous change, the p5 parameter to OP_VColumn no longer ever
contains extraneous bits, so change a testcase() into an assert() to show
as much.
drh [Sat, 14 Dec 2019 17:43:37 +0000 (17:43 +0000)]
Do not set OP_Column flags on the instructions generated by
sqlite3ExprCodeGetColumn() if the opcode generated is not really an
OP_Column, which might happen if the column is virtual.
Fix for ticket [b439bfcfb7deedc6]
drh [Fri, 13 Dec 2019 21:24:46 +0000 (21:24 +0000)]
Patch to the page cache to avoid harmless pointer arithmetic that due to bugs
in the STD-C spec is technically UB. This is to fix a harmless UBSAN
complaint that OSSFuzz is hitting.
drh [Thu, 12 Dec 2019 15:19:18 +0000 (15:19 +0000)]
Factor out the conditional (which is only true for rare errors) from the
notValid() function in resolve.c, for a performance improvement and size
reduction. Also cause failures to set the Expr node to a NULL operator so
that it does not cause problems later in case PRAGMA writable_schema=ON has
been set. Test cases in TH3.
drh [Wed, 11 Dec 2019 16:22:53 +0000 (16:22 +0000)]
Strengthen check-in [83da4d4104ee1870] by ignoring *all* WHERE-clause
constraints for a virtual table that is the right table of a LEFT JOIN,
as such constraints are never useful.
This fixes an issue discovered by Manuel Rigger.
drh [Tue, 10 Dec 2019 20:41:48 +0000 (20:41 +0000)]
Enhance LEMON to provide the ability to mark a rules as one that will never
reduce due to intervention of actions. Use this new capability to designate
the EXPLAIN rule as NEVER-REDUCES.
drh [Mon, 9 Dec 2019 17:14:48 +0000 (17:14 +0000)]
Ensure that the SrcList_item.colUsed field is set correctly (set to have a
1 for all columns of the table) when a generated column appears in the USING
clause of a join.
drh [Mon, 9 Dec 2019 15:52:07 +0000 (15:52 +0000)]
Fix the NOT NULL verification logic in PRAGMA integrity_check so that it
works for generated columns whose value is the result of a comparison operator.
Ticket [bd8c280671ba44a7]
drh [Mon, 9 Dec 2019 14:34:37 +0000 (14:34 +0000)]
Fix a gramfuzz find. If a partial index that does not reference any column
of its table is used by an UPDATE statement in one-pass mode, then avoid the
use of OP_DeferredSeek since the seek might not be resolved prior to the
OP_Delete and OP_Insert that implement the UPDATE.
drh [Sat, 7 Dec 2019 12:13:54 +0000 (12:13 +0000)]
Ignore type affinity for auxiliary columns in RTREE as it is too error-prone
to try to parse out the type from other constraints.
Ticket [8bf76328ac940d52]
drh [Fri, 6 Dec 2019 11:48:27 +0000 (11:48 +0000)]
The check-in [b7810062ec2489e1] was not quite right in that it allowed an
oversized shift operation (which is UB in C) on some obscure inputs. OSSFuzz
found the problem for us overnight.
drh [Fri, 6 Dec 2019 01:38:24 +0000 (01:38 +0000)]
Further enhancements to RTREE, following up to check-in [f898d04cf272ef01]
so that constraints are allowed to be compared to strings that look like
numbers. Ticket [aa573a787b8f1fdf]
drh [Thu, 5 Dec 2019 21:46:23 +0000 (21:46 +0000)]
Fix to the rowvalue logic that avoids disabling rowvalue inequality
contraints on a virtual table when the virtual table sets the omit flag.
The logic has been incorrect since row-values were added. However, this
does not come up often as very few virtual tables implement inequality
constraints using the omit flag. Ticket [f096d191b6641daa]
drh [Thu, 5 Dec 2019 18:29:52 +0000 (18:29 +0000)]
Documentation update: Clarify that the sqlite3_index_info.aConstraintUsage.omit
flag is a hint only and that the code generator is not obligated to follow
the hint.
dan [Thu, 5 Dec 2019 14:31:43 +0000 (14:31 +0000)]
Fix a problem in ALTER TABLE that could occur if an index, view or trigger in the schema features an expression of the form ((SELECT ...) IN ()) where the SELECT statement uses a CTE.
dan [Sat, 23 Nov 2019 15:10:28 +0000 (15:10 +0000)]
Avoid evaluating PARTITION BY or ORDER BY expressions multiple times for window function queries that use multiple window functions with the same window-definition.
drh [Fri, 22 Nov 2019 00:42:01 +0000 (00:42 +0000)]
Revise the SQLITE_OPEN_NOFOLLOW so that it actually uses O_NOFOLLOW in the
open() system call. This backs out the SQLITE_ACCESS_SYMLINK value but adds
the new SQLITE_OK_SYMLINK return code from the xFullPathname method of
sqlite3_vfs when that routine resolves symbolic links. O_NOFOLLOW is always
included in open() system calls for journal files.
drh [Tue, 19 Nov 2019 21:22:16 +0000 (21:22 +0000)]
Enhancements to DBSTAT: (1) Make name=? queries efficient. (2) Add the
ability to aggregate results across each individual btree using the
aggregate=TRUE constraint in the WHERE clause.