| 12152 | } |
| 12153 | |
| 12154 | int sqlite3_expert_analyze(sqlite3expert *p, char **pzErr){ |
| 12155 | int rc; |
| 12156 | IdxHashEntry *pEntry; |
| 12157 | |
| 12158 | /* Do trigger processing to collect any extra IdxScan structures */ |
| 12159 | rc = idxProcessTriggers(p, pzErr); |
| 12160 | |
| 12161 | /* Create candidate indexes within the in-memory database file */ |
| 12162 | if( rc==SQLITE_OK ){ |
| 12163 | rc = idxCreateCandidates(p); |
| 12164 | }else if ( rc==SQLITE_BUSY_TIMEOUT ){ |
| 12165 | if( pzErr ) |
| 12166 | *pzErr = sqlite3_mprintf("Cannot find a unique index name to propose."); |
| 12167 | return rc; |
| 12168 | } |
| 12169 | |
| 12170 | /* Generate the stat1 data */ |
| 12171 | if( rc==SQLITE_OK ){ |
| 12172 | rc = idxPopulateStat1(p, pzErr); |
| 12173 | } |
| 12174 | |
| 12175 | /* Formulate the EXPERT_REPORT_CANDIDATES text */ |
| 12176 | for(pEntry=p->hIdx.pFirst; pEntry; pEntry=pEntry->pNext){ |
| 12177 | p->zCandidates = idxAppendText(&rc, p->zCandidates, |
| 12178 | "%s;%s%s\n", pEntry->zVal, |
| 12179 | pEntry->zVal2 ? " -- stat1: " : "", pEntry->zVal2 |
| 12180 | ); |
| 12181 | } |
| 12182 | |
| 12183 | /* Figure out which of the candidate indexes are preferred by the query |
| 12184 | ** planner and report the results to the user. */ |
| 12185 | if( rc==SQLITE_OK ){ |
| 12186 | rc = idxFindIndexes(p, pzErr); |
| 12187 | } |
| 12188 | |
| 12189 | if( rc==SQLITE_OK ){ |
| 12190 | p->bRun = 1; |
| 12191 | } |
| 12192 | return rc; |
| 12193 | } |
| 12194 | |
| 12195 | /* |
| 12196 | ** Return the total number of statements that have been added to this |
no test coverage detected