From: drh Date: Tue, 2 Aug 2005 17:48:22 +0000 (+0000) Subject: Minor refactoring of the new optimizer code. (CVS 2576) X-Git-Tag: version-3.6.10~3583 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=45b1ee44a4371439a707b050de3d9f1cbd37c0be;p=thirdparty%2Fsqlite.git Minor refactoring of the new optimizer code. (CVS 2576) FossilOrigin-Name: 868322f7b7176486dfb4b54d99cf6662b79e639d --- diff --git a/manifest b/manifest index bee6c9787f..7cddbc7bb5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sdocumentation\sfor\sthe\snew\stransaction\smethod\son\sthe\sTCL\sinterface.\s(CVS\s2575) -D 2005-08-02T17:38:19 +C Minor\srefactoring\sof\sthe\snew\soptimizer\scode.\s(CVS\s2576) +D 2005-08-02T17:48:22 F Makefile.in 22ea9c0fe748f591712d8fe3c6d972c6c173a165 F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -85,7 +85,7 @@ F src/vdbeapi.c 7f392f0792d1258c958083d7de9eae7c3530c9a6 F src/vdbeaux.c 3732a86566a6be4da4c606e9334baf3fd98667af F src/vdbefifo.c b8805850afe13b43f1de78d58088cb5d66f88e1e F src/vdbemem.c da8e8d6f29dd1323f782f000d7cd120027c9ff03 -F src/where.c 7f59d0ed3b0b647b24f4cdce4a0623d2303dbbd9 +F src/where.c 72f68f996a1fd0139ef0ca77f407406c97b15d0a F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42 F test/all.test 7f0988442ab811dfa41793b5b550f5828ce316f3 F test/alter.test 9d6837a3d946b73df692b7cef2a7644d2e2f6bc6 @@ -290,7 +290,7 @@ F www/tclsqlite.tcl 3df553505b6efcad08f91e9b975deb2e6c9bb955 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b -P 68dd0ed5e312ecd5e98ee0fa1c21b70ff330f711 -R c779077438fd96a7272a0d01820472a0 +P 3dc823a0ac12f640a3c54fe1eb7be878d2738529 +R c9921c0f0ed27b22b2b2216c858185fd U drh -Z 0387ea2fe83c9838d106b4554dcce416 +Z 8627ed9e9eb875486f17896d9b8483fe diff --git a/manifest.uuid b/manifest.uuid index 662e02175c..040ba2a63a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3dc823a0ac12f640a3c54fe1eb7be878d2738529 \ No newline at end of file +868322f7b7176486dfb4b54d99cf6662b79e639d \ No newline at end of file diff --git a/src/where.c b/src/where.c index 6d4db13f6f..4a8ee2461e 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.158 2005/07/29 19:43:58 drh Exp $ +** $Id: where.c,v 1.159 2005/08/02 17:48:22 drh Exp $ */ #include "sqliteInt.h" @@ -81,12 +81,12 @@ typedef struct WhereTerm WhereTerm; struct WhereTerm { Expr *pExpr; /* Pointer to the subexpression */ u16 idx; /* Index of this term in pWC->a[] */ - i16 iPartner; /* Disable pWC->a[iPartner] when this term disabled */ + i16 iParent; /* Disable pWC->a[iParent] when this term disabled */ i16 leftCursor; /* Cursor number of X in "X " */ i16 leftColumn; /* Column number of X in "X " */ u16 operator; /* A WO_xx value describing */ u8 flags; /* Bit flags. See below */ - u8 nPartner; /* Number of partners that must disable us */ + u8 nChild; /* Number of children that must disable us */ WhereClause *pWC; /* The clause this term is part of */ Bitmask prereqRight; /* Bitmask of tables used by pRight */ Bitmask prereqAll; /* Bitmask of tables referenced by p */ @@ -98,7 +98,7 @@ struct WhereTerm { #define TERM_DYNAMIC 0x01 /* Need to call sqlite3ExprDelete(pExpr) */ #define TERM_VIRTUAL 0x02 /* Added by the optimizer. Do not code */ #define TERM_CODED 0x04 /* This term is already coded */ -#define TERM_PARTNERED 0x08 /* Has a virtual partner */ +#define TERM_COPIED 0x08 /* Has a child */ #define TERM_OR_OK 0x10 /* Used during OR-clause processing */ /* @@ -222,7 +222,7 @@ static WhereTerm *whereClauseInsert(WhereClause *pWC, Expr *p, int flags){ pTerm->pExpr = p; pTerm->flags = flags; pTerm->pWC = pWC; - pTerm->iPartner = -1; + pTerm->iParent = -1; return pTerm; } @@ -483,7 +483,7 @@ static void exprAnalyze( pTerm->prereqRight = exprTableUsage(pMaskSet, pExpr->pRight); pTerm->prereqAll = prereqAll = exprTableUsage(pMaskSet, pExpr); pTerm->leftCursor = -1; - pTerm->iPartner = -1; + pTerm->iParent = -1; pTerm->operator = 0; idxRight = -1; if( allowedOp(pExpr->op) && (pTerm->prereqRight & prereqLeft)==0 ){ @@ -501,9 +501,9 @@ static void exprAnalyze( pDup = sqlite3ExprDup(pExpr); pNew = whereClauseInsert(pTerm->pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC); if( pNew==0 ) return; - pNew->iPartner = pTerm->idx; - pTerm->nPartner = 1; - pTerm->flags |= TERM_PARTNERED; + pNew->iParent = pTerm->idx; + pTerm->nChild = 1; + pTerm->flags |= TERM_COPIED; }else{ pDup = pExpr; pNew = pTerm; @@ -535,9 +535,9 @@ static void exprAnalyze( pNewTerm = whereClauseInsert(pTerm->pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC); exprAnalyze(pSrc, pMaskSet, pNewTerm); - pNewTerm->iPartner = pTerm->idx; + pNewTerm->iParent = pTerm->idx; } - pTerm->nPartner = 2; + pTerm->nChild = 2; } /* Attempt to convert OR-connected terms into an IN operator so that @@ -566,15 +566,15 @@ static void exprAnalyze( } if( pOrTerm->leftCursor==iCursor && pOrTerm->leftColumn==iColumn ){ pOrTerm->flags |= TERM_OR_OK; - }else if( (pOrTerm->flags & TERM_PARTNERED)!=0 || + }else if( (pOrTerm->flags & TERM_COPIED)!=0 || ((pOrTerm->flags & TERM_VIRTUAL)!=0 && - (sOr.a[pOrTerm->iPartner].flags & TERM_OR_OK)!=0) ){ + (sOr.a[pOrTerm->iParent].flags & TERM_OR_OK)!=0) ){ pOrTerm->flags &= ~TERM_OR_OK; }else{ ok = 0; } } - }while( !ok && (sOr.a[j++].flags & TERM_PARTNERED)!=0 && jiLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin)) ){ pTerm->flags |= TERM_CODED; - if( pTerm->iPartner>=0 ){ - WhereTerm *pOther = &pTerm->pWC->a[pTerm->iPartner]; - if( (--pOther->nPartner)<=0 ){ + if( pTerm->iParent>=0 ){ + WhereTerm *pOther = &pTerm->pWC->a[pTerm->iParent]; + if( (--pOther->nChild)==0 ){ disableTerm(pLevel, pOther); } }