-C Latest\sside-stream\sautosetup/proj.tcl\sfor\simproved\scompile-commands\sfeature\sdetection.
-D 2025-09-01T13:01:20.088
+C Add\stest\scase\sfor\spushing\sWHERE\sconstraints\sinto\sa\sUNION\ssub-query\sthat\suses\svirtual\stables.
+D 2025-09-02T14:59:16.366
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F test/bestindexB.test 328b97b69cd1a20928d5997f9ecb04d2e00f1d18e19ab27f9e9adb44d7bc51ce
F test/bestindexC.test 95b4a527b1a5d07951d731604a6d4cf7e5a806b39cea0e7819d4c9667e11c3fc
F test/bestindexD.test 6a8f6f84990bcf17dfa59652a1f935beddb7afd96f8302830fbc86b0a13df3c3
+F test/bestindexE.test f0c7105d1e7facaa8f5e6c498849cc6dcadd533b35ea9e5e1176e54a9a2d70f1
F test/between.test e7587149796101cbe8d5f8abae8d2a7b87f04d8226610aa1091615005dcf4d54
F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59
F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 321938063e2d6c579b992bbbed5210c8a051a8b2fe858bb88f95dbd8fb0f35dc
-R e267cd26b1b9022ad2ef2c0d79c6fc0b
-U stephan
-Z d017608f1f8f249c42675a4c86d9b660
+P 55744ca8b8f2f95ba8bd3e01ef89e21e26c8547912c9d5637afe772d17f34486
+R be5632311d45cdba9967fc14583b2918
+U dan
+Z 29bc2637cfcfc43e3bf668a29f18cbf3
# Remove this line to create a well-formed Fossil manifest.
--- /dev/null
+# 2025-09-02
+#
+# 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 bestindex1
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_tcl_module db
+
+proc pretty_constraint {lCol cons} {
+ array set C $cons
+
+ set ret ""
+ if {$C(usable)} {
+ set OP(eq) =
+ set ret "[lindex $lCol $C(column)]$OP($C(op))?"
+ }
+
+ return $ret
+}
+
+proc vtab_command {zName lCol method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE $zName ([join $lCol ,]) "
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set conslist [$hdl constraints]
+
+ set ret [list]
+ foreach cons $conslist {
+ set pretty [pretty_constraint $lCol $cons]
+ if {$pretty != ""} { lappend ret $pretty }
+ }
+
+ lappend ::xBestIndex "$zName: [join $ret { AND }]"
+
+ return "cost 1000 rows 1000 idxnum 555"
+ }
+ }
+
+ return {}
+}
+
+proc do_bestindex_test {tn sql lCons} {
+ set ::xBestIndex [list]
+ do_execsql_test $tn.1 $sql
+ uplevel [list do_test $tn.2 [list set ::xBestIndex] [list {*}$lCons]]
+}
+
+proc create_vtab {tname clist} {
+ set cmd [list vtab_command $tname $clist]
+ execsql "
+ CREATE VIRTUAL TABLE $tname USING tcl('$cmd')
+ "
+}
+
+do_test 1.0 {
+ create_vtab x1 {a b c}
+} {}
+
+do_bestindex_test 1.1 {
+ SELECT * FROM x1 WHERE a=?
+} {{x1: a=?}}
+
+do_bestindex_test 1.2 {
+ SELECT * FROM x1 WHERE a=? AND b=?
+} {{x1: a=? AND b=?}}
+
+#--------------------------------------------------------------------------
+reset_db
+register_tcl_module db
+
+do_test 2.0 {
+ create_vtab Delivery {id customer}
+ create_vtab ReturnDelivery {id customer}
+ create_vtab Customer {oid name}
+} {}
+
+do_bestindex_test 2.1 {
+ SELECT Delivery.ID, Customer.Name
+ FROM Delivery LEFT JOIN
+ Customer ON Delivery.Customer = Customer.OID
+} {
+ {Delivery: }
+ {Customer: oid=?}
+}
+
+do_bestindex_test 2.2 {
+ SELECT * FROM
+ (
+ SELECT Delivery.ID, Customer.Name
+ FROM Delivery LEFT JOIN
+ Customer ON Delivery.Customer = Customer.OID
+
+ UNION
+
+ SELECT ReturnDelivery.ID, Customer.Name
+ FROM ReturnDelivery LEFT JOIN
+ Customer ON ReturnDelivery.Customer = Customer.OID
+ )
+ WHERE ID = 1
+} {
+ {Delivery: id=?}
+ {Customer: oid=?}
+ {ReturnDelivery: id=?}
+ {Customer: oid=?}
+}
+
+
+
+
+finish_test