-C Added\ssupport\sfor\sthe\s-enable-thread-override-lock\soption\son\sthe\nconfigure\sscript.\s(CVS\s3051)
-D 2006-02-01T01:55:17
+C In\sjoins\sof\sthe\sform:\s"A,\sB\sleft\sC"\smake\ssure\sthat\sthe\sreordering\soptimization\ndoes\snot\sput\stable\sA\safter\stable\sC.\s\sTicket\s#1652.\s(CVS\s3052)
+D 2006-02-01T02:45:02
F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b
F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/vdbeaux.c 9bf50cdb6a6c40b8c06ca9a8d87cf90120a16797
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
F src/vdbemem.c 2034e93b32c14bda6e306bb54e3a8e930b963027
-F src/where.c 8409e00fa2cb5fce873b4c911165cfed097e9c49
+F src/where.c c7d71d5e55c9c4c1e948089280fb0dec7c7d1ef6
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
F test/aggerror.test b854de90f530ae37be68fbfe6de40e111358cbb2
F test/all.test 5df90d015ca63fcef2a4b62c24f7316b66c4bfd4
F test/view.test 354bd0ceb363e88da8ce98fb47e18550d7594b13
F test/where.test ee7c9a6659b07e1ee61177f6e7ff71565ee2c9df
F test/where2.test fde821b9cb8e20d53ccd2e71482b063c5b1e222a
+F test/where3.test 6356013ce1c8ddc22a65c880dfff2b2c985634cb
F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
F tool/lemon.c 26d271a753ef87fe1e6194f53c594ab5e6783d85
F tool/lempar.c 424df14a48736bb961ed47acf30c26d66ed85a62
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P e83a19e8cb6d721b02502925b362f2e86b2de742
-R 8e940d36d3cad60499f251caa2aa3738
+P 82f558bd11ddb20792fbc9f579b40ad38d7f6af5
+R 2af434e8b15703eb7f034d5057b5c6a7
U drh
-Z cc40a051ac76c8707a4ca4b120503958
+Z 400ad0ae9ac8ef551d8c82316e3538c4
-82f558bd11ddb20792fbc9f579b40ad38d7f6af5
\ No newline at end of file
+248b9be93d9532e31c640432b75c3310e180acb3
\ No newline at end of file
** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
-** $Id: where.c,v 1.203 2006/01/24 12:09:20 danielk1977 Exp $
+** $Id: where.c,v 1.204 2006/02/01 02:45:02 drh Exp $
*/
#include "sqliteInt.h"
double lowestCost; /* Cost of the pBest */
int bestJ = 0; /* The value of j */
Bitmask m; /* Bitmask value for j or bestJ */
+ int once = 0; /* True when first table is seen */
lowestCost = SQLITE_BIG_DBL;
for(j=iFrom, pTabItem=&pTabList->a[j]; j<pTabList->nSrc; j++, pTabItem++){
+ if( once &&
+ ((pTabItem->jointype & (JT_LEFT|JT_CROSS))!=0
+ || (j>0 && (pTabItem[-1].jointype & (JT_LEFT|JT_CROSS))!=0))
+ ){
+ break;
+ }
m = getMask(&maskSet, pTabItem->iCursor);
if( (m & notReady)==0 ){
if( j==iFrom ) iFrom++;
(i==0 && ppOrderBy) ? *ppOrderBy : 0,
&pIdx, &flags, &nEq);
if( cost<lowestCost ){
+ once = 1;
lowestCost = cost;
pBest = pIdx;
bestFlags = flags;
bestNEq = nEq;
bestJ = j;
}
- if( (pTabItem->jointype & (JT_LEFT|JT_CROSS))!=0
- || (j>0 && (pTabItem[-1].jointype & (JT_LEFT|JT_CROSS))!=0)
- ){
- break;
- }
}
TRACE(("*** Optimizer choose table %d for loop %d\n", bestJ,
pLevel-pWInfo->a));
--- /dev/null
+# 2006 January 31
+#
+# 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.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the join reordering optimization
+# in cases that include a LEFT JOIN.
+#
+# $Id: where3.test,v 1.1 2006/02/01 02:45:02 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# The following is from ticket #1652.
+#
+# A comma join then a left outer join: A,B left join C.
+# Arrange indices so that the B table is chosen to go first.
+# Also put an index on C, but make sure that A is chosen before C.
+#
+do_test where3-1.1 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(p, q);
+ CREATE TABLE t3(x, y);
+
+ INSERT INTO t1 VALUES(111,'one');
+ INSERT INTO t1 VALUES(222,'two');
+ INSERT INTO t1 VALUES(333,'three');
+
+ INSERT INTO t2 VALUES(1,111);
+ INSERT INTO t2 VALUES(2,222);
+ INSERT INTO t2 VALUES(4,444);
+ CREATE INDEX t2i1 ON t2(p);
+
+ INSERT INTO t3 VALUES(999,'nine');
+ CREATE INDEX t3i1 ON t3(x);
+
+ SELECT * FROM t1, t2 LEFT JOIN t3 ON q=x WHERE p=2 AND a=q;
+ }
+} {222 two 2 222 {} {}}
+
+
+finish_test