drh [Sat, 14 May 2022 19:05:13 +0000 (19:05 +0000)]
Do not allow an index scan on an index-on-expression for a RIGHT JOIN because
the index might not be positioned on the correct row when running the
the right-join no-match loop.
dbsqlfuzz 39ee60004ff027a9e2846cf76e02cd5ac0953739
drh [Sat, 14 May 2022 15:59:42 +0000 (15:59 +0000)]
Improvements to the decision of when to check ON constraints for an inner
join that is an operand to a RIGHT JOIN. Fix for issue identify by
[forum:/forumpost/c06b10ad7e|forum post c06b10ad7e].
drh [Fri, 13 May 2022 19:50:29 +0000 (19:50 +0000)]
Walk back the optimization from check-in [cc458317bd77046c] that tries to
reuse the same ephemeral cursor of a list subquery when that subquery is
reused, as it does not work in cases where the list subquery is used both
for lookups and for scans.
drh [Fri, 13 May 2022 17:45:52 +0000 (17:45 +0000)]
Defer generating WHERE clause constraints for a RIGHT JOIN until after the
ON-clause processing for the RIGHT JOIN has done its own row elimination.
This fixes and incorrect output from some RIGHT JOINs that was identified
by [forum:/forumpost/41cc3851d864c5e6|forum post 41cc3851d864c5e6].
drh [Fri, 13 May 2022 15:31:30 +0000 (15:31 +0000)]
New test cases for outer joins. Case joinE-32 currently gets an incorrect
answer. See [forum:/forumpost/41cc3851d8|forum post 41cc3851d8] for the bug
report.
drh [Thu, 12 May 2022 11:45:20 +0000 (11:45 +0000)]
Add IS NOT DISTINCT FROM and IS DISTINCT FROM binary operators which are
equivalent to IS and IS NOT, respectively, for compatability with PostgreSQL
and hence standard SQL.
larrybr [Wed, 11 May 2022 19:59:31 +0000 (19:59 +0000)]
Change .echo on effect so that SQL is echoed before prepare. This slightly alters echoed output when multiple SQL statements are submitted at once. Also sync with trunk.
drh [Wed, 11 May 2022 16:46:27 +0000 (16:46 +0000)]
For the unix VFS, rewrite the xFullPathname method so that it automatically
resolves all symbolic links, rendering a canonical pathname that contains
no symlinks.
drh [Fri, 6 May 2022 00:43:06 +0000 (00:43 +0000)]
Prevent an infinite loop on SQLITE_ERROR_RETRY when trying to modify a
corrupt schema while PRAGMA writeable_schema=ON is active.
dbsqlfuzz ded83609f475cc989c7339d45efb5151c1495501
drh [Wed, 4 May 2022 17:43:59 +0000 (17:43 +0000)]
New test cases for RIGHT and FULL JOIN, focusing on cases that make use
of Bloom filters, and a bug fix related to when ON-clause constraints are
applied.
drh [Tue, 3 May 2022 14:01:48 +0000 (14:01 +0000)]
Fix the Bloom filter pull-down optimization so that it jumps to the correct
place if it encounters a NULL key. Fix for the bug described by
[forum:/forumpost/2482b32700384a0f|forum thread 2482b32700384a0f].
drh [Tue, 3 May 2022 12:11:16 +0000 (12:11 +0000)]
Add assert()s to show that jumps always land an an instruction that is between
1 and Vdbe.nOp-1. Had these assert()s been in place before, they would have
caused an assertion fault for the byte-code error reported by
[forum:/forumpost/2482b32700|forum post 2482b32700].
drh [Mon, 2 May 2022 20:49:30 +0000 (20:49 +0000)]
Organize the various flag bits of the ExprList_item object into a substructure
so that the whole lot can be copied all at once. Faster and smaller code.
drh [Mon, 2 May 2022 19:59:03 +0000 (19:59 +0000)]
Name resolution and "*" wildcard expansion for parenthesized FROM clauses
seems to work the same as PG. The code is chaos, however, and needs some
cleanup.
drh [Mon, 2 May 2022 14:32:56 +0000 (14:32 +0000)]
Improvement on check-in [a193749730d6cfba] so that the subroutine call to
the IN operator right-hand side generator from the RIGHT JOIN no-match logic
does not generate unreachable byte code.
Simplified fix to the problem with subroutine reuse in the RIGHT JOIN no-match
logic for a subquery on the right-hand side of an IN operator. The code still
needs simplification.
Preserve the COLLATE operator on an index on an expression when resolving
the use of that expression into a reference to the index. See
[forum:/info/7efabf4b03328e57|forum thread 7efabf4b03328e57] for details.
Further improvements to codeEqualityTerm() for cases when an IN operator with
a right-hand side subquery is used as a constraint that needs to be processed
by the RIGHT JOIN non-matched logic.
Enhance the codeEqualityTerm() routine inside the code generator so that it is
able to reuse an IN operator that has an invariant subquery on its right-hand
side while coding the non-matched loop of a RIGHT JOIN.
dbsqlfuzz 19f1102a70cf966ab249de56d944fc20dbebcfcf
When computing STAT1 values using ANALYZE, if a ratio comes out to be between
1.0 and 1.1, then round it down to 1 rather than the using the default rounding
rule of changing it to 2. The reduces the estimation error for the
case where a column value is very nearly, but not quite unique.
The pushDownWhereTerms() routine should be using
sqlite3ExprIsTableConstraint(), not sqlite3ExprIsTableConstant(). This fixes
many problems, but still an error persists in join7.test.
Remove NEVER() on branches formerly thought to unreachable
(see check-in [71272caff5874137]) in order to fix the first bug reported
by [forum:/forumpost/28821db852|forum post 28821db852].
For debug builds, if the RIGHT JOIN body subroutine contains a jump that
escapes the subroutine, then abort the prepared statement with a descriptive
error and SQLITE_INTERNAL. This extra sanity check causes many tests to
fail.
Add the ability to access the USING columns of the right or left tables
of an OUTER JOIN even if the OUTER JOIN is in parentheses. Prototype code
only.