Fix a bug in the multi-index OR cost estimator. Remove leftover "breakpoint"
commands from test scripts. (CVS 6086)
FossilOrigin-Name: b090d5736d7eaec17a39d3133e1587b1d2a42acb
diff --git a/src/where.c b/src/where.c
index 0261dea..ffe06a3 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.354 2008/12/30 16:18:48 drh Exp $
+** $Id: where.c,v 1.355 2008/12/30 17:55:00 drh Exp $
*/
#include "sqliteInt.h"
@@ -1840,7 +1840,6 @@
for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
WhereClause tempWC;
tempWC = *pWC;
- tempWC.nSlot = 1;
if( pTerm->eOperator==WO_OR
&& ((pTerm->prereqAll & ~maskSrc) & notReady)==0
&& (pTerm->u.pOrInfo->indexable & maskSrc)!=0 ){
@@ -1851,11 +1850,13 @@
double nRow = 0;
for(j=0, pOrTerm=pOrWC->a; j<pOrWC->nTerm; j++, pOrTerm++){
WhereCost sTermCost;
+ WHERETRACE(("... Multi-index OR testing for term %d of %d....\n", j,i));
if( pOrTerm->eOperator==WO_AND ){
WhereClause *pAndWC = &pOrTerm->u.pAndInfo->wc;
bestIndex(pParse, pAndWC, pSrc, notReady, 0, &sTermCost);
}else if( pOrTerm->leftCursor==iCur ){
tempWC.a = pOrTerm;
+ tempWC.nTerm = 1;
bestIndex(pParse, &tempWC, pSrc, notReady, 0, &sTermCost);
}else{
continue;
@@ -1867,6 +1868,8 @@
rTotal += sTermCost.rCost;
nRow += sTermCost.nRow;
}
+ WHERETRACE(("... multi-index OR cost=%.9g nrow=%.9g\n",
+ rTotal, nRow));
if( rTotal<pCost->rCost ){
pCost->rCost = rTotal;
pCost->nRow = nRow;