]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Use of the CROSS keyword in a join prevents table reordering. Ticket #1414. (CVS...
authordrh <drh@noemail.net>
Sat, 10 Sep 2005 15:28:09 +0000 (15:28 +0000)
committerdrh <drh@noemail.net>
Sat, 10 Sep 2005 15:28:09 +0000 (15:28 +0000)
FossilOrigin-Name: 415b8b24629aa12756d8285c094b5f85d8a8e532

manifest
manifest.uuid
src/select.c
src/sqliteInt.h
src/where.c

index baeab5c5174179114eebbe3368a3b400e10adb62..6f5ee78d0b3c7acce52914c633c604d45c55df66 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Enhanced\sdisk-full\stests.\s(CVS\s2682)
-D 2005-09-09T10:46:19
+C Use\sof\sthe\sCROSS\skeyword\sin\sa\sjoin\sprevents\stable\sreordering.\s\sTicket\s#1414.\s(CVS\s2683)
+D 2005-09-10T15:28:09
 F Makefile.in 12784cdce5ffc8dfb707300c34e4f1eb3b8a14f1
 F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -63,10 +63,10 @@ F src/pragma.c 69413fbdc0c6aaa493a776ea52c1b3e6cf35dfb2
 F src/prepare.c 86f0d8e744b8d956eff6bc40e29049efee017610
 F src/printf.c c01e9ad473d79463fb1f483b1eca5c3cbed2a4e5
 F src/random.c 90adff4e73a3b249eb4f1fc2a6ff9cf78c7233a4
-F src/select.c 2bba89bb64cd41991e5843617e2851c29661638d
+F src/select.c a255ca7eddd14c68d966b6323234dd94fcc7a31f
 F src/shell.c b21daba017b8feef2fdc65ecde57f70209494217
 F src/sqlite.h.in 461b2535550cf77aedfd44385da11ef7d63e57a2
-F src/sqliteInt.h f5d20d26b71a3a3e7672c1363545df2015647361
+F src/sqliteInt.h 0d38d50ebe15a16a1253c9a6f9ce4ad188e097fe
 F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9
 F src/tclsqlite.c ac94682f9e601dd373912c46414a5a842db2089a
 F src/test1.c b569b60e35f0e3ea20e5ebfaf6e522a01c08d481
@@ -87,7 +87,7 @@ F src/vdbeapi.c 72213ce0c1ab8b215b2ae0ed342511bf769c1e60
 F src/vdbeaux.c a0aaf135c39825027366b5129f85191226d8b333
 F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
 F src/vdbemem.c fea0744936008831daa17cdc75056c3ca1469690
-F src/where.c d69b304e506a78a1cf6b31e7a58408703a166dc2
+F src/where.c d032cca1b983ad14fb0361f1f7a2706c5e7a9720
 F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
 F test/all.test 7f0988442ab811dfa41793b5b550f5828ce316f3
 F test/alter.test 9d6837a3d946b73df692b7cef2a7644d2e2f6bc6
@@ -306,7 +306,7 @@ F www/tclsqlite.tcl 3df553505b6efcad08f91e9b975deb2e6c9bb955
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P bc8c33f94ce069f7bcfc32a59d5c40e034e023b5
-R c6a7e93fc86868d935afb82bce6d24ba
+P 0288fa5d25886f6fbef0be782f12285d62bebd68
+R f8eceac70392349128d8b83ed9d12654
 U drh
-Z c2fef43dee5a47c4ebfb5ba1092b2569
+Z 461ac5bc1124c76e7cb4172bfe8587a8
index d316030a2f8b59f226b1d23bb48b9c863bf80eeb..063d7e351f9e4a19b848cbfd2e40ce6774fcd90c 100644 (file)
@@ -1 +1 @@
-0288fa5d25886f6fbef0be782f12285d62bebd68
\ No newline at end of file
+415b8b24629aa12756d8285c094b5f85d8a8e532
\ No newline at end of file
index c43f1aa3e3c98591cd48bd19f937c131c4a23970..da7c2ab4c060f1af69d546382d1139c2dca24ba7 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle SELECT statements in SQLite.
 **
-** $Id: select.c,v 1.266 2005/09/08 12:57:28 drh Exp $
+** $Id: select.c,v 1.267 2005/09/10 15:28:09 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -73,6 +73,7 @@ Select *sqlite3SelectNew(
 ** in terms of the following bit values:
 **
 **     JT_INNER
+**     JT_CROSS
 **     JT_OUTER
 **     JT_NATURAL
 **     JT_LEFT
@@ -98,7 +99,7 @@ int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){
     { "full",    4, JT_LEFT|JT_RIGHT|JT_OUTER },
     { "outer",   5, JT_OUTER },
     { "inner",   5, JT_INNER },
-    { "cross",   5, JT_INNER },
+    { "cross",   5, JT_INNER|JT_CROSS },
   };
   int i, j;
   apAll[0] = pA;
index b212f24b2d2694b7481d60002d14ffeb82a6bb9c..e33d115f95f216474ade9e56be8d6afb3a22b007 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.413 2005/09/09 01:33:19 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.414 2005/09/10 15:28:09 drh Exp $
 */
 #ifndef _SQLITEINT_H_
 #define _SQLITEINT_H_
@@ -999,11 +999,12 @@ struct SrcList {
 ** Permitted values of the SrcList.a.jointype field
 */
 #define JT_INNER     0x0001    /* Any kind of inner or cross join */
-#define JT_NATURAL   0x0002    /* True for a "natural" join */
-#define JT_LEFT      0x0004    /* Left outer join */
-#define JT_RIGHT     0x0008    /* Right outer join */
-#define JT_OUTER     0x0010    /* The "OUTER" keyword is present */
-#define JT_ERROR     0x0020    /* unknown or unsupported join type */
+#define JT_CROSS     0x0002    /* Explicit use of the CROSS keyword */
+#define JT_NATURAL   0x0004    /* True for a "natural" join */
+#define JT_LEFT      0x0008    /* Left outer join */
+#define JT_RIGHT     0x0010    /* Right outer join */
+#define JT_OUTER     0x0020    /* The "OUTER" keyword is present */
+#define JT_ERROR     0x0040    /* unknown or unsupported join type */
 
 /*
 ** For each nested loop in a WHERE clause implementation, the WhereInfo
index 1c2007b6556ba3035a038652f0d2b4df76d5dd9c..50ef5d6d9f306cc0559f157dda1c14eb5ed94cd1 100644 (file)
@@ -16,7 +16,7 @@
 ** 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.169 2005/09/08 14:17:20 drh Exp $
+** $Id: where.c,v 1.170 2005/09/10 15:28:09 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -1425,6 +1425,7 @@ WhereInfo *sqlite3WhereBegin(
   pTabItem = pTabList->a;
   pLevel = pWInfo->a;
   andFlags = ~0;
+  TRACE(("*** Optimizer Start ***\n"));
   for(i=iFrom=0, pLevel=pWInfo->a; i<pTabList->nSrc; i++, pLevel++){
     Index *pIdx;                /* Index for FROM table at pTabItem */
     int flags;                  /* Flags asssociated with pIdx */
@@ -1454,12 +1455,14 @@ WhereInfo *sqlite3WhereBegin(
         bestNEq = nEq;
         bestJ = j;
       }
-      if( (pTabItem->jointype & JT_LEFT)!=0
-         || (j>0 && (pTabItem[-1].jointype & JT_LEFT)!=0)
+      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));
     if( (bestFlags & WHERE_ORDERBY)!=0 ){
       *ppOrderBy = 0;
     }
@@ -1477,6 +1480,7 @@ WhereInfo *sqlite3WhereBegin(
     notReady &= ~getMask(&maskSet, pTabList->a[bestJ].iCursor);
     pLevel->iFrom = bestJ;
   }
+  TRACE(("*** Optimizer Finished ***\n"));
 
   /* If the total query only selects a single row, then the ORDER BY
   ** clause is irrelevant.