drh [Sat, 25 Aug 2018 19:51:49 +0000 (19:51 +0000)]
Provide the two-argument geopoly_within(P1,P2) routine that determines if
polygon P2 is contained within polygon P1. Make this function available to
the query planner for optimized rtree lookups. Update the visual01.txt
script to verify that the new functionality actually works.
drh [Tue, 14 Aug 2018 15:12:52 +0000 (15:12 +0000)]
Fix UPSERT so that it checks the target-constraint first and fires the
DO UPDATE if that constraint is violated regardless of whether or not
other constraints are in violation. This aligns SQLite behavior with
what PostgreSQL does. Fix for ticket [908f001483982c43cdb476dfb590a1a].
drh [Thu, 9 Aug 2018 21:45:45 +0000 (21:45 +0000)]
Fix the isLikeOrGlob() routine in the WHERE clause processing logic so that
it avoids signed/unsigned character comparisons, as that can lead to an
incorrect answer if the ESCAPE clause is an invalid UTF8 string. Problem
found by OSSFuzz.
drh [Sat, 4 Aug 2018 20:30:55 +0000 (20:30 +0000)]
Remove the column-cache from the code generator. The column-cache has been
a persistent source of bugs for years and with recent improvements
in the performance of OP_Column, it no longer provides a benefit. After
the column cache is removed, the binary is almost 2KB smaller and the
speed-check.sh performance test is over 3 million cycles faster.
drh [Sat, 4 Aug 2018 15:16:20 +0000 (15:16 +0000)]
Ensure that all expressions that are to be evaluated once at the start of
a prepared statement (the Parse.pConstExpr expressions) pass the
sqlite3ExprIsConstantNotJoin() test. It is not sufficient to pass just the
sqlite3ExprIsConstant() test as that would allow through column references
that are bound to constants by the WHERE clause in the constant propagation
optimization. This fixes a problem discovered by OSSFuzz.
drh [Fri, 3 Aug 2018 23:04:16 +0000 (23:04 +0000)]
Completely remove the column cache logic, which has been a persistent source
of bugs for many years. We recent enhancements to the performance of the
OP_Column opcode, the removing the column cache actually makes speed-check.sh
run faster. It also saves about 1,800 bytes of code space.
drh [Fri, 3 Aug 2018 15:58:07 +0000 (15:58 +0000)]
Fix the OP_SeekRowid opcode so that it has no type-change side-effects on the
key register in P3. This fixes an obcure problem that arises when doing
equi-joins between a table with a TEXT column against another table with
an INTEGER PRIMARY KEY. The original problem was discovered when OSSFuzz
created such a query and hit an assert() in OP_VerifyTabCol that was
specifically designed to catch these kinds of errors at run-time.
Do not allow a column reference that is converted into a constant by the
WHERE-clause constant propagation optimization to be moved to the init-time
constant expression list, as the table reference will not work there.
This fixes a problem found by OSSFuzz.
Improvements to the parser to increase coverage. Fix the parser so that
at least one expresssion is required after PARTITION BY and within the
list of expressions on VALUES().
The WHERE-clause constant propagation optimization attempts to use
transitive laws to replace column values with constants in the WHERE
clause in order to help to query planner make more aggressive optimizations.
Only run the constant propagation optimization on joins since that is the
only scenario where it is useful. This saves prepare time for the common
case of a simple query.
Constant propagation is now restricted to just the WHERE clause. The
mechanism is changed to take affinity and collation into account. This
seems to give correct answers. But the search for constant propagation
costs 4 million cycles in the speed test.
Generalize the constant propagation optimization so that it applies on every
WHERE close, not just those that contain a subquery. This then demonstrates
that the current implementation is inadequate since it does not take into
account collating sequences.
In the unix VFS, give every unixInodeInfo object its own mutex, rather
than using the global VFS mutex, to improve concurrency in cases where there
are many threads operating on separate database files.
Do not abort running queries due to a CREATE INDEX statement. Allow them
to run to completion before being reprepared. Fix for ticket
[c694113e50321afdf9].
dan [Mon, 23 Jul 2018 10:57:53 +0000 (10:57 +0000)]
Fix the macros used to generate the output of "PRAGMA compile_options" so that
they handle valid values for the SQLITE_DEFAULT_LOOKASIDE macro (which
contain a "," character).
Change the SQLITE_Stat34 bit of the optimization test-control so that it
prevents STAT4 data from being used but allows it to be loaded into the
Index objects. This permits STAT4 to be turned on and off on a per-statement
basis.
Allow the VACUUM following SQLITE_DBCONFIG_RESET_DATABASE to proceed even
if the write-version in the header indicates that the database file is not
writable.
On an UPSERT when the order of constraint checks is rearranged, make sure
that the affinity transformations on the inserted content occur before
any of the constraint checks. Fix for ticket [79cad5e4b2e219dd197242e9e5f4e].
Identify Select objects within a single statement using small sequential
integers rather than "0x%p". This is more readable and yields the same result
on successive runs.
Further improvements to bytecode branch testing. Fix cases where the
macros said a branch could not be taken when in fact it could be. Alter
some window function branch coverage macros to indicate that comparison
operands cannot be NULL.
Enhancements and improved documentation to the byte-code branch coverage
testing logic. Provide new macros that allow the code to specify that
some branch instructions can never take the NULL path and that the OP_Jump
opcode is only interested in equal/not-equal. The
SQLITE_TESTCTRL_VDBE_COVERAGE file control callback now works slightly
differently (it provides the callback with a bitmask of the branch action,
rather than an integer).
Fix a harmless warning about comment formatting in the previous
check-in. Simplify the ORDER BY dereferencing logic so that it avoids
unreachable branches.
Assert that if two functions compare equal in every other way, then they
must both have OVER clauses, or neither has an OVER clause. Use this fact
to simplify expression comparison.