1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-18 10:21:03 +03:00

If a query contains "FROM t1 LEFT JOIN t2, t3, t4", ensure that tables t3 and t4 are not scanned before t2. The trunk already does this.

FossilOrigin-Name: 0d9edfab9fb61322620f188b48ae2a1798a07581
This commit is contained in:
dan
2015-06-08 18:48:29 +00:00
parent 4f20cd402b
commit 35175bf7ab
4 changed files with 37 additions and 12 deletions

View File

@@ -2997,6 +2997,7 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){
sqlite3 *db = pWInfo->pParse->db;
int rc = SQLITE_OK;
WhereLoop *pNew;
u8 priorJointype = 0;
pNew = pBuilder->pNew;
whereLoopInit(pNew);
@@ -3008,11 +3009,12 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){
Bitmask mUnusable = 0;
pNew->iTab = iTab;
pNew->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, pItem->iCursor);
if( (pItem->jointype & (JT_LEFT|JT_CROSS))!=0 ){
if( ((pItem->jointype|priorJointype) & (JT_LEFT|JT_CROSS))!=0 ){
/* This condition is true when pItem is the FROM clause term on the
** right-hand-side of a LEFT or CROSS JOIN. */
mExtra = mPrior;
}
priorJointype = pItem->jointype;
if( IsVirtual(pItem->pTab) ){
struct SrcList_item *p;
for(p=&pItem[1]; p<pEnd; p++){