mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-08 03:22:21 +03:00
Use of the CROSS keyword in a join prevents table reordering. Ticket #1414. (CVS 2683)
FossilOrigin-Name: 415b8b24629aa12756d8285c094b5f85d8a8e532
This commit is contained in:
16
manifest
16
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Enhanced\sdisk-full\stests.\s(CVS\s2682)
|
C Use\sof\sthe\sCROSS\skeyword\sin\sa\sjoin\sprevents\stable\sreordering.\s\sTicket\s#1414.\s(CVS\s2683)
|
||||||
D 2005-09-09T10:46:19
|
D 2005-09-10T15:28:09
|
||||||
F Makefile.in 12784cdce5ffc8dfb707300c34e4f1eb3b8a14f1
|
F Makefile.in 12784cdce5ffc8dfb707300c34e4f1eb3b8a14f1
|
||||||
F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
|
F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@@ -63,10 +63,10 @@ F src/pragma.c 69413fbdc0c6aaa493a776ea52c1b3e6cf35dfb2
|
|||||||
F src/prepare.c 86f0d8e744b8d956eff6bc40e29049efee017610
|
F src/prepare.c 86f0d8e744b8d956eff6bc40e29049efee017610
|
||||||
F src/printf.c c01e9ad473d79463fb1f483b1eca5c3cbed2a4e5
|
F src/printf.c c01e9ad473d79463fb1f483b1eca5c3cbed2a4e5
|
||||||
F src/random.c 90adff4e73a3b249eb4f1fc2a6ff9cf78c7233a4
|
F src/random.c 90adff4e73a3b249eb4f1fc2a6ff9cf78c7233a4
|
||||||
F src/select.c 2bba89bb64cd41991e5843617e2851c29661638d
|
F src/select.c a255ca7eddd14c68d966b6323234dd94fcc7a31f
|
||||||
F src/shell.c b21daba017b8feef2fdc65ecde57f70209494217
|
F src/shell.c b21daba017b8feef2fdc65ecde57f70209494217
|
||||||
F src/sqlite.h.in 461b2535550cf77aedfd44385da11ef7d63e57a2
|
F src/sqlite.h.in 461b2535550cf77aedfd44385da11ef7d63e57a2
|
||||||
F src/sqliteInt.h f5d20d26b71a3a3e7672c1363545df2015647361
|
F src/sqliteInt.h 0d38d50ebe15a16a1253c9a6f9ce4ad188e097fe
|
||||||
F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9
|
F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9
|
||||||
F src/tclsqlite.c ac94682f9e601dd373912c46414a5a842db2089a
|
F src/tclsqlite.c ac94682f9e601dd373912c46414a5a842db2089a
|
||||||
F src/test1.c b569b60e35f0e3ea20e5ebfaf6e522a01c08d481
|
F src/test1.c b569b60e35f0e3ea20e5ebfaf6e522a01c08d481
|
||||||
@@ -87,7 +87,7 @@ F src/vdbeapi.c 72213ce0c1ab8b215b2ae0ed342511bf769c1e60
|
|||||||
F src/vdbeaux.c a0aaf135c39825027366b5129f85191226d8b333
|
F src/vdbeaux.c a0aaf135c39825027366b5129f85191226d8b333
|
||||||
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
|
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
|
||||||
F src/vdbemem.c fea0744936008831daa17cdc75056c3ca1469690
|
F src/vdbemem.c fea0744936008831daa17cdc75056c3ca1469690
|
||||||
F src/where.c d69b304e506a78a1cf6b31e7a58408703a166dc2
|
F src/where.c d032cca1b983ad14fb0361f1f7a2706c5e7a9720
|
||||||
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
|
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
|
||||||
F test/all.test 7f0988442ab811dfa41793b5b550f5828ce316f3
|
F test/all.test 7f0988442ab811dfa41793b5b550f5828ce316f3
|
||||||
F test/alter.test 9d6837a3d946b73df692b7cef2a7644d2e2f6bc6
|
F test/alter.test 9d6837a3d946b73df692b7cef2a7644d2e2f6bc6
|
||||||
@@ -306,7 +306,7 @@ F www/tclsqlite.tcl 3df553505b6efcad08f91e9b975deb2e6c9bb955
|
|||||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||||
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
|
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
|
||||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||||
P bc8c33f94ce069f7bcfc32a59d5c40e034e023b5
|
P 0288fa5d25886f6fbef0be782f12285d62bebd68
|
||||||
R c6a7e93fc86868d935afb82bce6d24ba
|
R f8eceac70392349128d8b83ed9d12654
|
||||||
U drh
|
U drh
|
||||||
Z c2fef43dee5a47c4ebfb5ba1092b2569
|
Z 461ac5bc1124c76e7cb4172bfe8587a8
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
0288fa5d25886f6fbef0be782f12285d62bebd68
|
415b8b24629aa12756d8285c094b5f85d8a8e532
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
** This file contains C code routines that are called by the parser
|
** This file contains C code routines that are called by the parser
|
||||||
** to handle SELECT statements in SQLite.
|
** 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"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -73,6 +73,7 @@ Select *sqlite3SelectNew(
|
|||||||
** in terms of the following bit values:
|
** in terms of the following bit values:
|
||||||
**
|
**
|
||||||
** JT_INNER
|
** JT_INNER
|
||||||
|
** JT_CROSS
|
||||||
** JT_OUTER
|
** JT_OUTER
|
||||||
** JT_NATURAL
|
** JT_NATURAL
|
||||||
** JT_LEFT
|
** JT_LEFT
|
||||||
@@ -98,7 +99,7 @@ int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){
|
|||||||
{ "full", 4, JT_LEFT|JT_RIGHT|JT_OUTER },
|
{ "full", 4, JT_LEFT|JT_RIGHT|JT_OUTER },
|
||||||
{ "outer", 5, JT_OUTER },
|
{ "outer", 5, JT_OUTER },
|
||||||
{ "inner", 5, JT_INNER },
|
{ "inner", 5, JT_INNER },
|
||||||
{ "cross", 5, JT_INNER },
|
{ "cross", 5, JT_INNER|JT_CROSS },
|
||||||
};
|
};
|
||||||
int i, j;
|
int i, j;
|
||||||
apAll[0] = pA;
|
apAll[0] = pA;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** Internal interface definitions for SQLite.
|
** 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_
|
#ifndef _SQLITEINT_H_
|
||||||
#define _SQLITEINT_H_
|
#define _SQLITEINT_H_
|
||||||
@@ -999,11 +999,12 @@ struct SrcList {
|
|||||||
** Permitted values of the SrcList.a.jointype field
|
** Permitted values of the SrcList.a.jointype field
|
||||||
*/
|
*/
|
||||||
#define JT_INNER 0x0001 /* Any kind of inner or cross join */
|
#define JT_INNER 0x0001 /* Any kind of inner or cross join */
|
||||||
#define JT_NATURAL 0x0002 /* True for a "natural" join */
|
#define JT_CROSS 0x0002 /* Explicit use of the CROSS keyword */
|
||||||
#define JT_LEFT 0x0004 /* Left outer join */
|
#define JT_NATURAL 0x0004 /* True for a "natural" join */
|
||||||
#define JT_RIGHT 0x0008 /* Right outer join */
|
#define JT_LEFT 0x0008 /* Left outer join */
|
||||||
#define JT_OUTER 0x0010 /* The "OUTER" keyword is present */
|
#define JT_RIGHT 0x0010 /* Right outer join */
|
||||||
#define JT_ERROR 0x0020 /* unknown or unsupported join type */
|
#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
|
** For each nested loop in a WHERE clause implementation, the WhereInfo
|
||||||
|
|||||||
10
src/where.c
10
src/where.c
@@ -16,7 +16,7 @@
|
|||||||
** so is applicable. Because this module is responsible for selecting
|
** so is applicable. Because this module is responsible for selecting
|
||||||
** indices, you might also think of this module as the "query optimizer".
|
** 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"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -1425,6 +1425,7 @@ WhereInfo *sqlite3WhereBegin(
|
|||||||
pTabItem = pTabList->a;
|
pTabItem = pTabList->a;
|
||||||
pLevel = pWInfo->a;
|
pLevel = pWInfo->a;
|
||||||
andFlags = ~0;
|
andFlags = ~0;
|
||||||
|
TRACE(("*** Optimizer Start ***\n"));
|
||||||
for(i=iFrom=0, pLevel=pWInfo->a; i<pTabList->nSrc; i++, pLevel++){
|
for(i=iFrom=0, pLevel=pWInfo->a; i<pTabList->nSrc; i++, pLevel++){
|
||||||
Index *pIdx; /* Index for FROM table at pTabItem */
|
Index *pIdx; /* Index for FROM table at pTabItem */
|
||||||
int flags; /* Flags asssociated with pIdx */
|
int flags; /* Flags asssociated with pIdx */
|
||||||
@@ -1454,12 +1455,14 @@ WhereInfo *sqlite3WhereBegin(
|
|||||||
bestNEq = nEq;
|
bestNEq = nEq;
|
||||||
bestJ = j;
|
bestJ = j;
|
||||||
}
|
}
|
||||||
if( (pTabItem->jointype & JT_LEFT)!=0
|
if( (pTabItem->jointype & (JT_LEFT|JT_CROSS))!=0
|
||||||
|| (j>0 && (pTabItem[-1].jointype & JT_LEFT)!=0)
|
|| (j>0 && (pTabItem[-1].jointype & (JT_LEFT|JT_CROSS))!=0)
|
||||||
){
|
){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TRACE(("*** Optimizer choose table %d for loop %d\n", bestJ,
|
||||||
|
pLevel-pWInfo->a));
|
||||||
if( (bestFlags & WHERE_ORDERBY)!=0 ){
|
if( (bestFlags & WHERE_ORDERBY)!=0 ){
|
||||||
*ppOrderBy = 0;
|
*ppOrderBy = 0;
|
||||||
}
|
}
|
||||||
@@ -1477,6 +1480,7 @@ WhereInfo *sqlite3WhereBegin(
|
|||||||
notReady &= ~getMask(&maskSet, pTabList->a[bestJ].iCursor);
|
notReady &= ~getMask(&maskSet, pTabList->a[bestJ].iCursor);
|
||||||
pLevel->iFrom = bestJ;
|
pLevel->iFrom = bestJ;
|
||||||
}
|
}
|
||||||
|
TRACE(("*** Optimizer Finished ***\n"));
|
||||||
|
|
||||||
/* If the total query only selects a single row, then the ORDER BY
|
/* If the total query only selects a single row, then the ORDER BY
|
||||||
** clause is irrelevant.
|
** clause is irrelevant.
|
||||||
|
|||||||
Reference in New Issue
Block a user