Do not allow a WHERE clause constraint to be used to drive an index for

the right operand of a RIGHT JOIN, since this can cause problem if the
constraint implies a not-NULL value for one of the columns for the left
operand of the same join.  See
[forum:/forumpost/206d99a16dd9212f|forum post 206d99a16dd9212f].

FossilOrigin-Name: 4a31b7942a15c9c4363477365784d6d4ac5b1bbe8ff8aeaf2dd3d6532bf8bc96
This commit is contained in:
drh
2022-06-06 15:27:42 +00:00
parent 8a4d2bc34f
commit c18fc6134e
4 changed files with 36 additions and 15 deletions
+15
View File
@@ -572,4 +572,19 @@ do_execsql_test join8-17091 {
SELECT t3.a FROM t4 RIGHT JOIN t3 ON (x=a) WHERE (b, 4) IS (SELECT 3, 4);
} {1}
# 2022-06-06
# https://sqlite.org/forum/forumpost/206d99a16dd9212f
# tag-20191211-001
#
reset_db
do_execsql_test join8-18000 {
CREATE TABLE t1(a BOOLEAN); INSERT INTO t1 VALUES (false);
CREATE TABLE t2(x INT); INSERT INTO t2 VALUES (0);
SELECT *, x NOTNULL, (x NOTNULL)=a FROM t2 RIGHT JOIN t1 ON true WHERE (x NOTNULL)=a;
} {}
do_execsql_test join8-18010 {
CREATE INDEX t1a ON t1(a);
SELECT *, x NOTNULL, (x NOTNULL)=a FROM t2 RIGHT JOIN t1 ON true WHERE (x NOTNULL)=a;
} {}
finish_test