diff options
author | drh <drh@noemail.net> | 2007-09-12 15:41:01 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2007-09-12 15:41:01 +0000 |
commit | a430ae8e54bc0f61b3398f81139f188fcfda915a (patch) | |
tree | cd6b2569260e1588b22f7dab4c4fc65ca68f92e6 /src | |
parent | 076f1c0d63ce5a170f374df2239e309c70fcb14a (diff) | |
download | sqlite-a430ae8e54bc0f61b3398f81139f188fcfda915a.tar.gz sqlite-a430ae8e54bc0f61b3398f81139f188fcfda915a.zip |
In the query optimizer, make sure table dependencies from all terms
of a compound SELECT statement are recognized so that subqueries in
a WHERE clause are not evaluated too early. Fix for ticket #2640. (CVS 4422)
FossilOrigin-Name: 9c9c2a1da2b6235b3b0541d1f55a02a1f350567f
Diffstat (limited to 'src')
-rw-r--r-- | src/where.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/where.c b/src/where.c index a9a3c7594..126b0847c 100644 --- a/src/where.c +++ b/src/where.c @@ -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.259 2007/08/29 14:06:23 danielk1977 Exp $ +** $Id: where.c,v 1.260 2007/09/12 15:41:01 drh Exp $ */ #include "sqliteInt.h" @@ -350,15 +350,14 @@ static Bitmask exprListTableUsage(ExprMaskSet *pMaskSet, ExprList *pList){ return mask; } static Bitmask exprSelectTableUsage(ExprMaskSet *pMaskSet, Select *pS){ - Bitmask mask; - if( pS==0 ){ - mask = 0; - }else{ - mask = exprListTableUsage(pMaskSet, pS->pEList); + Bitmask mask = 0; + while( pS ){ + mask |= exprListTableUsage(pMaskSet, pS->pEList); mask |= exprListTableUsage(pMaskSet, pS->pGroupBy); mask |= exprListTableUsage(pMaskSet, pS->pOrderBy); mask |= exprTableUsage(pMaskSet, pS->pWhere); mask |= exprTableUsage(pMaskSet, pS->pHaving); + pS = pS->pPrior; } return mask; } |