1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-16 23:02:26 +03:00

Query optimizer enhancement: In "FROM a,b,c left join d" allow the C table

to be reordered with A and B.  This used to be the case but the capability
was removed by (3203) and (3052) in response to ticket #1652.  This change
restores the capability. (CVS 3529)

FossilOrigin-Name: 7393c81b8cb9d4344ae744de9eabcb3af64f1db8
This commit is contained in:
drh
2006-12-16 16:25:15 +00:00
parent f0fa1c1b9f
commit 61dfc31d80
9 changed files with 212 additions and 86 deletions

View 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.232 2006/11/06 15:10:05 drh Exp $
** $Id: where.c,v 1.233 2006/12/16 16:25:16 drh Exp $
*/
#include "sqliteInt.h"
@@ -1854,8 +1854,7 @@ WhereInfo *sqlite3WhereBegin(
for(j=iFrom, pTabItem=&pTabList->a[j]; j<pTabList->nSrc; j++, pTabItem++){
int doNotReorder; /* True if this table should not be reordered */
doNotReorder = (pTabItem->jointype & (JT_LEFT|JT_CROSS))!=0
|| (j>0 && (pTabItem[-1].jointype & (JT_LEFT|JT_CROSS))!=0);
doNotReorder = (pTabItem->jointype & (JT_LEFT|JT_CROSS))!=0;
if( once && doNotReorder ) break;
m = getMask(&maskSet, pTabItem->iCursor);
if( (m & notReady)==0 ){
@@ -2031,7 +2030,7 @@ WhereInfo *sqlite3WhereBegin(
** initialize a memory cell that records if this table matches any
** row of the left table of the join.
*/
if( pLevel->iFrom>0 && (pTabItem[-1].jointype & JT_LEFT)!=0 ){
if( pLevel->iFrom>0 && (pTabItem[0].jointype & JT_LEFT)!=0 ){
if( !pParse->nMem ) pParse->nMem++;
pLevel->iLeftJoin = pParse->nMem++;
sqlite3VdbeAddOp(v, OP_MemInt, 0, pLevel->iLeftJoin);