diff options
author | drh <drh@noemail.net> | 2013-06-11 13:30:04 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-06-11 13:30:04 +0000 |
commit | 8e23daf372c57084e7921e48c1b7968b631bb94d (patch) | |
tree | ca19add163193236f59050dcafe186f8e7f1e7e7 /src | |
parent | 8b76656ad4cf13b4a716fa208bbc1433b21fd606 (diff) | |
download | sqlite-8e23daf372c57084e7921e48c1b7968b631bb94d.tar.gz sqlite-8e23daf372c57084e7921e48c1b7968b631bb94d.zip |
Fix the Parse.nQueryLoop state variable to work with NGQP.
FossilOrigin-Name: f1cac24f06b9c71cfa472fdcf2da4cd8689a7cc3
Diffstat (limited to 'src')
-rw-r--r-- | src/expr.c | 6 | ||||
-rw-r--r-- | src/prepare.c | 4 | ||||
-rw-r--r-- | src/sqliteInt.h | 2 | ||||
-rw-r--r-- | src/where.c | 9 |
4 files changed, 11 insertions, 10 deletions
diff --git a/src/expr.c b/src/expr.c index c1a27ebf8..4e834ffe8 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1596,15 +1596,15 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){ /* Could not found an existing table or index to use as the RHS b-tree. ** We will have to generate an ephemeral table to do the job. */ - double savedNQueryLoop = pParse->nQueryLoop; + u32 savedNQueryLoop = pParse->nQueryLoop; int rMayHaveNull = 0; eType = IN_INDEX_EPH; if( prNotFound ){ *prNotFound = rMayHaveNull = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_Null, 0, *prNotFound); }else{ - testcase( pParse->nQueryLoop>(double)1 ); - pParse->nQueryLoop = (double)1; + testcase( pParse->nQueryLoop>1 ); + pParse->nQueryLoop = 1; if( pX->pLeft->iColumn<0 && !ExprHasAnyProperty(pX, EP_xIsSelect) ){ eType = IN_INDEX_ROWID; } diff --git a/src/prepare.c b/src/prepare.c index d78d83cbd..319bb5012 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -592,7 +592,7 @@ static int sqlite3Prepare( sqlite3VtabUnlockList(db); pParse->db = db; - pParse->nQueryLoop = (double)1; + pParse->nQueryLoop = 1; if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){ char *zSqlCopy; int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH]; @@ -614,7 +614,7 @@ static int sqlite3Prepare( }else{ sqlite3RunParser(pParse, zSql, &zErrMsg); } - assert( 1==(int)pParse->nQueryLoop ); + assert( 1==pParse->nQueryLoop ); if( db->mallocFailed ){ pParse->rc = SQLITE_NOMEM; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index aa1ea5101..d3d6fcf70 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2226,7 +2226,7 @@ struct Parse { /* Information used while coding trigger programs. */ Parse *pToplevel; /* Parse structure for main program (or NULL) */ Table *pTriggerTab; /* Table triggers are being coded for */ - u32 nQueryLoop; /* Estimated number of iterations of a query */ + u32 grep nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */ u32 oldmask; /* Mask of old.* columns referenced */ u32 newmask; /* Mask of new.* columns referenced */ u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ diff --git a/src/where.c b/src/where.c index 330faf771..d493dba46 100644 --- a/src/where.c +++ b/src/where.c @@ -358,7 +358,7 @@ struct WhereInfo { WhereMaskSet sMaskSet; /* Map cursor numbers to bitmasks */ WhereClause sWC; /* Decomposition of the WHERE clause */ WhereLoop *pLoops; /* List of all WhereLoop objects */ - WhereCost savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ + int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ WhereCost nRowOut; /* Estimated number of output rows */ WhereLevel a[1]; /* Information about each nest loop in WHERE */ }; @@ -3099,7 +3099,7 @@ static void explainOneScan( }else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){ zMsg = sqlite3MAppendf(db, zMsg, "%s USING INTEGER PRIMARY KEY", zMsg); - if( flags&WHERE_COLUMN_EQ ){ + if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){ zMsg = sqlite3MAppendf(db, zMsg, "%s (rowid=?)", zMsg); }else if( (flags&WHERE_BOTH_LIMIT)==WHERE_BOTH_LIMIT ){ zMsg = sqlite3MAppendf(db, zMsg, "%s (rowid>? AND rowid<?)", zMsg); @@ -4432,7 +4432,7 @@ static int whereLoopAddBtree( /* Automatic indexes */ if( !pBuilder->pBest - && pTabList->nSrc>1 +// && pTabList->nSrc>1 && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0 && !pSrc->viaCoroutine && !pSrc->notIndexed @@ -5074,7 +5074,7 @@ static int wherePathSolver(WhereInfo *pWInfo, WhereCost nRowEst){ } /* Seed the search with a single WherePath containing zero WhereLoops */ - aFrom[0].nRow = 0; + aFrom[0].nRow = pWInfo->pParse->nQueryLoop; nFrom = 1; /* Precompute the cost of sorting the final result set, if the caller @@ -5615,6 +5615,7 @@ WhereInfo *sqlite3WhereBegin( } #endif WHERETRACE(("*** Optimizer Finished ***\n")); + pWInfo->pParse->nQueryLoop += pWInfo->nRowOut; #if 0 /* FIXME: Add this back in? */ /* If the caller is an UPDATE or DELETE statement that is requesting |