| 11256 | } |
| 11257 | |
| 11258 | static int idxCreateFromWhere( |
| 11259 | sqlite3expert *p, |
| 11260 | IdxScan *pScan, /* Create indexes for this scan */ |
| 11261 | IdxConstraint *pTail /* range/ORDER BY constraints for inclusion */ |
| 11262 | ){ |
| 11263 | IdxConstraint *p1 = 0; |
| 11264 | IdxConstraint *pCon; |
| 11265 | int rc; |
| 11266 | |
| 11267 | /* Gather up all the == constraints. */ |
| 11268 | for(pCon=pScan->pEq; pCon; pCon=pCon->pNext){ |
| 11269 | if( !idxFindConstraint(p1, pCon) && !idxFindConstraint(pTail, pCon) ){ |
| 11270 | pCon->pLink = p1; |
| 11271 | p1 = pCon; |
| 11272 | } |
| 11273 | } |
| 11274 | |
| 11275 | /* Create an index using the == constraints collected above. And the |
| 11276 | ** range constraint/ORDER BY terms passed in by the caller, if any. */ |
| 11277 | rc = idxCreateFromCons(p, pScan, p1, pTail); |
| 11278 | |
| 11279 | /* If no range/ORDER BY passed by the caller, create a version of the |
| 11280 | ** index for each range constraint. */ |
| 11281 | if( pTail==0 ){ |
| 11282 | for(pCon=pScan->pRange; rc==SQLITE_OK && pCon; pCon=pCon->pNext){ |
| 11283 | assert( pCon->pLink==0 ); |
| 11284 | if( !idxFindConstraint(p1, pCon) && !idxFindConstraint(pTail, pCon) ){ |
| 11285 | rc = idxCreateFromCons(p, pScan, p1, pCon); |
| 11286 | } |
| 11287 | } |
| 11288 | } |
| 11289 | |
| 11290 | return rc; |
| 11291 | } |
| 11292 | |
| 11293 | /* |
| 11294 | ** Create candidate indexes in database [dbm] based on the data in |
no test coverage detected