1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

The NOT NULL strength reduction optimization from [de9c86c9e4cdb34f] should

be applied to the WHERE clause only.  Otherwise, the operand of the IS NULL
or IS NOT NULL operator might be a reference to a bare column of an
aggregate table, and we can't tell if it is NULL or not based only on its
NOT NULL attribute.  [forum:/forumpost/440f2a2f17|Forum post 440f2a2f17].

FossilOrigin-Name: 51704feae224eff601db5607f8651da11b3c2ed8a58ffe5b6ee8260cab50695b
This commit is contained in:
drh
2024-03-08 21:37:18 +00:00
parent 96f5ae6bd7
commit 61b77a6fe1
5 changed files with 67 additions and 25 deletions

View File

@ -59,14 +59,14 @@ do_vmstep_test 1.4.2 {
do_vmstep_test 1.5.1 {
SELECT count(*) FROM t2 WHERE EXISTS(
SELECT t2.d IS NULL FROM t1 WHERE t1.a=450
SELECT 1 FROM t1 WHERE t1.a=450 AND t2.d IS NULL
)
} 10000 {1000}
} 7000 {0}
do_vmstep_test 1.5.2 {
SELECT count(*) FROM t2 WHERE EXISTS(
SELECT t2.c IS NULL FROM t1 WHERE t1.a=450
SELECT 1 FROM t1 WHERE t1.a=450 AND t2.c IS NULL
)
} +100000 {1000}
} +8000 {0}
#-------------------------------------------------------------------------
reset_db
@ -111,4 +111,12 @@ do_execsql_test 4.1 {
SELECT * FROM (SELECT 3 AS c FROM t1) AS t3 LEFT JOIN t2 ON c IS NULL;
} {3 {}}
# 2024-03-08 https://sqlite.org/forum/forumpost/440f2a2f17
#
reset_db
do_execsql_test 5.0 {
CREATE TABLE t1(a INT NOT NULL);
SELECT a IS NULL, a IS NOT NULL, count(*) FROM t1;
} {1 0 0}
finish_test