]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Relax the restrictions on reordering tables in vtab queries that occur to the right... vtab-outer-joins
authordan <Dan Kennedy>
Wed, 15 Jul 2026 19:19:03 +0000 (19:19 +0000)
committerdan <Dan Kennedy>
Wed, 15 Jul 2026 19:19:03 +0000 (19:19 +0000)
FossilOrigin-Name: 7df34b446edb2e6826f504a9fed13631817ac03e1423539fc4c28efe7ec485e0

manifest
manifest.tags
manifest.uuid
src/where.c
test/bestindexG.test [new file with mode: 0644]

index 0598b7a4cf3c0af58c581fc302ffa796834c74e7..051beca8fbf68dfdf8ab1296ca4f9b687fccae6b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Adjust\sQRF\sto\sgenerate\slower-case\sHTML\soutput\swith\sthe\sSQLITE_STYLE_Html\nstyle\ssetting.
-D 2026-07-14T17:02:47.865
+C Relax\sthe\srestrictions\son\sreordering\stables\sin\svtab\squeries\sthat\soccur\sto\sthe\sright\sof\sa\sLEFT\sor\sCROSS\sJOIN\sbut\sare\snot\sactually\sthe\sRHS\sof\ssaid\sjoin.
+D 2026-07-15T19:19:03.835
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -824,7 +824,7 @@ F src/vxworks.h 9d18819c5235b49c2340a8a4d48195ec5d5afb637b152406de95a9436beeaeab
 F src/wal.c abfd99239725a258af4f733681b24dd7a9ee298babe389a36d29c197e2443ebf
 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452
 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014
-F src/where.c e76636ee3a58a3fc84e6a0362c69dd61234c24a77cfc9219b8db8cc2278ae5b7
+F src/where.c 18943748b107b94f35c9170a68b583d0fdea3a2107ce5300f502ae9b954fab31
 F src/whereInt.h 8d94cb116c9e06205c3d5ac87af065fc044f8cf08bfdccd94b6ea1c1308e65da
 F src/wherecode.c bc39ccbe3648f01157038b16cc55bdbff128590972b7185521b5526dc2815765
 F src/whereexpr.c b48dd990a15d36173e12acbcf961b81b2ea9917adeda01b2fdb9821e2cea08f8
@@ -927,6 +927,7 @@ F test/bestindexC.test f44eb3d77359e9487222a2dde27f8ecf11a8e4932803c0dd9477f75e1
 F test/bestindexD.test 6a8f6f84990bcf17dfa59652a1f935beddb7afd96f8302830fbc86b0a13df3c3
 F test/bestindexE.test 297f3ea8500a8f3c17d6f78e55bdfee089064c6144ee84a110bd005a03338f49
 F test/bestindexF.test 4e53d606cbde40a2254aa016d500c5b71766a4065b8541202d195a3d9fe11b1c
+F test/bestindexG.test 973d68bb680db9045c8b24bf672f38eb05997eaa65338c64ba8400bdb01aa063
 F test/between.test e7587149796101cbe8d5f8abae8d2a7b87f04d8226610aa1091615005dcf4d54
 F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59
 F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc
@@ -2214,8 +2215,11 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P 5a4b0b81de1abf9c1b73f026b416b29b9bdddc7a1b73ae5b9aa02f3dde131731
-R 5ca5451ceba84a0338aad30cb6fcd699
-U drh
-Z c5c16572b72ca5414518d30654f89f2d
+P 4be8630e053de91fb03c960d792960e837cf6360d5d24fbae4fc97b8fcaef062
+R 96cb8d87026f44ed7e5edbb91b716f2b
+T *branch * vtab-outer-joins
+T *sym-vtab-outer-joins *
+T -sym-trunk *
+U dan
+Z 8f4635e8239e55ade09fb573e77c7c4b
 # Remove this line to create a well-formed Fossil manifest.
index bec971799ff1b8ee641c166c7aeb22d12c785393..1b94131618506b804a29ded3a9dc630256566c4d 100644 (file)
@@ -1,2 +1,2 @@
-branch trunk
-tag trunk
+branch vtab-outer-joins
+tag vtab-outer-joins
index bb3401bd614705939b34c67baff447414e0ccc23..f447948149d2f8720eab71b3fa6304154c47a823 100644 (file)
@@ -1 +1 @@
-4be8630e053de91fb03c960d792960e837cf6360d5d24fbae4fc97b8fcaef062
+7df34b446edb2e6826f504a9fed13631817ac03e1423539fc4c28efe7ec485e0
index 9083d04f9b81322d1434a2e79bb6b2efc7a237f1..d1c63ff8c01394f4d11b1feab993e82629e24ce2 100644 (file)
@@ -5008,7 +5008,7 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){
     if( IsVirtual(pItem->pSTab) ){
       SrcItem *p;
       for(p=&pItem[1]; p<pEnd; p++){
-        if( mUnusable || (p->fg.jointype & (JT_OUTER|JT_CROSS)) ){
+        if( (p->fg.jointype & (JT_OUTER|JT_CROSS)) ){
           mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor);
         }
       }
diff --git a/test/bestindexG.test b/test/bestindexG.test
new file mode 100644 (file)
index 0000000..4958a36
--- /dev/null
@@ -0,0 +1,101 @@
+# 2025-07-14
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# 
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix bestindexF
+
+ifcapable !vtab {
+  finish_test
+  return
+}
+
+
+proc vtab_command {method args} {
+  switch -- $method {
+    xConnect {
+      return "CREATE TABLE tt(id, k)"
+    }
+
+    xBestIndex {
+      set hdl [lindex $args 0]
+      set conslist [$hdl constraints]
+
+      set ret [list]
+      set idxnum 0
+      set iCons 0
+      foreach cons $conslist {
+        array set c $cons
+        if {$c(usable) && $c(op)=="eq" && $c(column)==0} {
+          lappend ret use $iCons
+          set idxnum 1
+          break
+        }
+        incr iCons
+      }
+
+      return [concat idxnum $idxnum $ret]
+    }
+
+    xFilter {
+      set idxnum [lindex $args 0]
+      if {$idxnum==0} {
+        return [list sql "SELECT * FROM t1"]
+      }
+
+      return [list sql "SELECT * FROM t1 WHERE id=[lindex $args 2 0]"]
+    }
+  }
+
+  return {}
+}
+
+register_tcl_module db
+
+do_execsql_test 1.0 {
+  CREATE TABLE t1(rowid INTEGER PRIMARY KEY, id, k);
+  INSERT INTO t1 VALUES(1, 1, 1);
+  INSERT INTO t1 VALUES(2, 2, 2);
+  INSERT INTO t1 VALUES(3, 3, 3);
+  INSERT INTO t1 VALUES(4, 4, 4);
+
+  INSERT INTO t1 VALUES(5, 1, 11);
+  INSERT INTO t1 VALUES(6, 2, 22);
+  INSERT INTO t1 VALUES(7, 3, 33);
+  INSERT INTO t1 VALUES(8, 4, 44);
+
+  CREATE VIRTUAL TABLE tt USING tcl(vtab_command)
+}
+
+do_execsql_test 1.1 {
+  CREATE TABLE probe(id);
+  CREATE TABLE pr(id, k);
+  CREATE TABLE sl(id, dk);
+
+  INSERT INTO probe VALUES(3), (44);
+
+  INSERT INTO pr VALUES(3, 3);
+  INSERT INTO sl VALUES(3, 3);
+} {}
+
+do_execsql_test 1.2 {
+  with v as (
+      select sl.id as id
+      from tt
+      left join pr on pr.k = tt.k
+      join sl on sl.dk = tt.id
+  )
+  select count(*) from probe join v on v.id = probe.id;
+} {2}
+
+finish_test
+