1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Fix the IN-early-out optimization so that it works even for the corner case

where the NULL bypass fires before the affinity of the LHS operator has been
set.  Fix for the problem described in
[forum:/forumpost/6a3ec138e9|forum post 6a3ec138e9].

FossilOrigin-Name: eb40248ce606b792a02e4e0b7dd826a82891c5f4c9793f3ca5d332e593109525
This commit is contained in:
drh
2021-04-29 15:49:34 +00:00
parent 7bfccfe73c
commit 81f5ef05a9
4 changed files with 34 additions and 8 deletions

View File

@ -97,4 +97,23 @@ do_execsql_test in6-3.110 {
SELECT quote(v5) FROM v0 LEFT JOIN v3 ON v4 = NULL AND v5 IN(0);
} {NULL}
# 2021-04-29 forum https://sqlite.org/forum/forumpost/6a3ec138e9
# An early OP_IsNull bypass might skip over the OP_Affinity and
# cause the OP_IfNoHope to jump on a false-positive, resulting in
# incomplete output.
#
reset_db
do_execsql_test in6-3.120 {
CREATE TABLE t1(a TEXT, b TEXT);
INSERT INTO t1 VALUES(null,10),(0,10),(10,10);
CREATE INDEX t1ab ON t1(a,b);
SELECT quote(a), quote(b), '|' FROM t1 WHERE b in (SELECT a FROM t1) AND a=0;
} {'0' '10' |}
do_execsql_test in6-3.130 {
CREATE TABLE t2(x TEXT);
INSERT INTO t2(x) VALUES(NULL),(0),(10);
SELECT quote(x), quote(a), quote(b), 'x'
FROM t2 LEFT JOIN t1 ON a=x AND b in (null,0,10);
} {NULL NULL NULL x '0' '0' '10' x '10' '10' '10' x}
finish_test