]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the Bloom filter pull-down optimization so that it jumps to the correct
authordrh <>
Tue, 3 May 2022 14:01:48 +0000 (14:01 +0000)
committerdrh <>
Tue, 3 May 2022 14:01:48 +0000 (14:01 +0000)
place if it encounters a NULL key.  Fix for the bug described by
[forum:/forumpost/2482b32700384a0f|forum thread 2482b32700384a0f].

FossilOrigin-Name: 6eda9b1a7784cf6d58c8876551f67ab98e78a08e726a0579d4def5ba881985bb

manifest
manifest.uuid
src/wherecode.c
test/join5.test

index 6f5ed17f428c9935c4c9a4c5bce30d9f4f9e9544..81a7fdb108e0c7d99bdd20f3d97de16252ca0e65 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sassert()s\sto\sshow\sthat\sjumps\salways\sland\san\san\sinstruction\sthat\sis\sbetween\n1\sand\sVdbe.nOp-1.\s\sHad\sthese\sassert()s\sbeen\sin\splace\sbefore,\sthey\swould\shave\ncaused\san\sassertion\sfault\sfor\sthe\sbyte-code\serror\sreported\sby\n[forum:/forumpost/2482b32700|forum\spost\s2482b32700].
-D 2022-05-03T12:11:16.206
+C Fix\sthe\sBloom\sfilter\spull-down\soptimization\sso\sthat\sit\sjumps\sto\sthe\scorrect\nplace\sif\sit\sencounters\sa\sNULL\skey.\s\sFix\sfor\sthe\sbug\sdescribed\sby\n[forum:/forumpost/2482b32700384a0f|forum\sthread\s2482b32700384a0f].
+D 2022-05-03T14:01:48.589
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -642,7 +642,7 @@ F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
 F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b
 F src/where.c 43085b3a4ce2e56315fabb0b240a56e76667d9e03c79f287695bcae7b76152d5
 F src/whereInt.h 4db5a877a9d1f38b5c928c1c84297c07f30b9a3bc1f5f66214cf1a8ef90a0556
-F src/wherecode.c dfc3fbb6b7cb14a5a8e022d22f4d2c6004807e458a7cd8278194fbef7c1670e1
+F src/wherecode.c cd9da760d391a51013f9ab8bc8ca7ad67f3b96e4857efe0d1dd85f538b3494a6
 F src/whereexpr.c 174d4ad5be165c610c907abb779ef4a97974d22b84e1ce7898d2d9f6947249e5
 F src/window.c 924e04fd6e0e113d4dba18b78d43fcb8e42b8ebffc8fc728da52cf3ab014cf3c
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
@@ -1145,7 +1145,7 @@ F test/join.test e5f165dfd84fd46406ddae6614b0122c3bfa23a26ef62966442e1503c40d96a
 F test/join2.test 466b07233820f5deee66a6c3bf6e4500c8bbf7b83649e67606f5f649c07928c0
 F test/join3.test 6f0c774ff1ba0489e6c88a3e77b9d3528fb4fda0
 F test/join4.test 1a352e4e267114444c29266ce79e941af5885916
-F test/join5.test c4df54e2e204d7f1417bfbdd21ca324b4b07415c647595cc47798eacfddc96d3
+F test/join5.test d22b6cba8fb59ab3f1c82701434c360705eb12d4ce200c449f37b018fc47681a
 F test/join6.test f809c025fa253f9e150c0e9afd4cef8813257bceeb6f46e04041228c9403cc2c
 F test/join7.test 8e72de4b45e5e930d18c305c7efe86015fb2552731e4e03ea226353036b0dab0
 F test/join8.test 9a4b2f53d5358abb29e6356e357c0cd40f4d8f282589300dcb76728dce050b51
@@ -1951,8 +1951,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 053cf45ecaa7eac8cc64c7b2672807f736a45575a84b426263b2e1feb060b401
-R ac9704868f7c1c02692fbf03e14bf6d3
+P 8f8a58feb7047d19522ca32efbe42fd9ddf49aaf9064f7373eb56a88982406a2
+R 48e95e8ad10915971573fc98c5fba3fb
 U drh
-Z 2799ccc42c2b61451a2da6d606baab94
+Z 4d1d0f66bed5171c72952a11ac9180b2
 # Remove this line to create a well-formed Fossil manifest.
index 039e77d8b3d33a0eaa1c9307109377f1fa6bfc8f..b5b28cd857c9fd1e34b3f2816820437027b5b78f 100644 (file)
@@ -1 +1 @@
-8f8a58feb7047d19522ca32efbe42fd9ddf49aaf9064f7373eb56a88982406a2
\ No newline at end of file
+6eda9b1a7784cf6d58c8876551f67ab98e78a08e726a0579d4def5ba881985bb
\ No newline at end of file
index 6f5a85386b2c7d100b2faff4a0b888bb9119be33..0a4a0019cf0b188e14de1a8672f99a952d3439e6 100644 (file)
@@ -1412,6 +1412,8 @@ static SQLITE_NOINLINE void filterPullDown(
     /*         ,--- Because sqlite3ConstructBloomFilter() has will not have set
     **  vvvvv--'    pLevel->regFilter if this were true. */
     if( NEVER(pLoop->prereq & notReady) ) continue;
+    assert( pLevel->addrBrk==0 );
+    pLevel->addrBrk = addrNxt;
     if( pLoop->wsFlags & WHERE_IPK ){
       WhereTerm *pTerm = pLoop->aLTerm[0];
       int regRowid;
@@ -1438,6 +1440,7 @@ static SQLITE_NOINLINE void filterPullDown(
       VdbeCoverage(pParse->pVdbe);
     }
     pLevel->regFilter = 0;
+    pLevel->addrBrk = 0;
   }
 }
 
index e4fd9cd871b8d5780ce83bebf45fd4e571b588d1..2ffe3f8ace871cabb7e0aba22a9d78c1f1be6193 100644 (file)
@@ -393,6 +393,38 @@ do_execsql_test 11.4 {
   SELECT count(*) FROM t1 LEFT JOIN t2 ON c=b WHERE d>=300;
 } {2}
 
+# 2022-05-03 https://sqlite.org/forum/forumpost/2482b32700384a0f
+# Bloom-filter pull-down does not handle NOT NULL constraints correctly.
+#
+reset_db
+do_execsql_test 12.1 {
+  CREATE TABLE t1(a INT, b INT, c INT);
+  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+    INSERT INTO t1(a,b,c) SELECT x, x*1000, x*1000000 FROM c;
+  CREATE TABLE t2(b INT, x INT);
+  INSERT INTO t2(b,x) SELECT b, a FROM t1 WHERE a%3==0;
+  CREATE INDEX t2b ON t2(b);
+  CREATE TABLE t3(c INT, y INT);
+  INSERT INTO t3(c,y) SELECT c, a FROM t1 WHERE a%4==0;
+  CREATE INDEX t3c ON t3(c);
+  INSERT INTO t1(a,b,c) VALUES(200, 200000, NULL);
+  ANALYZE;
+} {}
+do_execsql_test 12.2 {
+  SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN t3 WHERE x>0 AND y>0
+  ORDER BY +a;
+} {
+  12  12000  12000000  12  12
+  24  24000  24000000  24  24
+  36  36000  36000000  36  36
+  48  48000  48000000  48  48
+  60  60000  60000000  60  60
+  72  72000  72000000  72  72
+  84  84000  84000000  84  84
+  96  96000  96000000  96  96
+}
+
+
 
 
 finish_test