MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / expertFinish

Function expertFinish

modules/dasSQLITE/sqlite/shell.c:19102–19142  ·  view source on GitHub ↗

** This function is called either to silently clean up the object ** created by the ".expert" command (if bCancel==1), or to generate a ** report from it and then clean it up (if bCancel==0). ** ** If successful, SQLITE_OK is returned. Otherwise, an SQLite error ** code. In this case, (*pzErr) may be set to point to a buffer containing ** an English language error message. It is the responsibility

Source from the content-addressed store, hash-verified

19100** caller to eventually free this buffer using sqlite3_free().
19101*/
19102static int expertFinish(
19103 ShellState *pState,
19104 int bCancel,
19105 char **pzErr
19106){
19107 int rc = SQLITE_OK;
19108 sqlite3expert *p = pState->expert.pExpert;
19109 assert( p );
19110 assert( bCancel || pzErr==0 || *pzErr==0 );
19111 if( bCancel==0 ){
19112 FILE *out = pState->out;
19113 int bVerbose = pState->expert.bVerbose;
19114
19115 rc = sqlite3_expert_analyze(p, pzErr);
19116 if( rc==SQLITE_OK ){
19117 int nQuery = sqlite3_expert_count(p);
19118 int i;
19119
19120 if( bVerbose ){
19121 const char *zCand = sqlite3_expert_report(p,0,EXPERT_REPORT_CANDIDATES);
19122 raw_printf(out, "-- Candidates -----------------------------\n");
19123 raw_printf(out, "%s\n", zCand);
19124 }
19125 for(i=0; i<nQuery; i++){
19126 const char *zSql = sqlite3_expert_report(p, i, EXPERT_REPORT_SQL);
19127 const char *zIdx = sqlite3_expert_report(p, i, EXPERT_REPORT_INDEXES);
19128 const char *zEQP = sqlite3_expert_report(p, i, EXPERT_REPORT_PLAN);
19129 if( zIdx==0 ) zIdx = "(no new indexes)\n";
19130 if( bVerbose ){
19131 raw_printf(out, "-- Query %d --------------------------------\n",i+1);
19132 raw_printf(out, "%s\n\n", zSql);
19133 }
19134 raw_printf(out, "%s\n", zIdx);
19135 raw_printf(out, "%s\n", zEQP);
19136 }
19137 }
19138 }
19139 sqlite3_expert_destroy(p);
19140 pState->expert.pExpert = 0;
19141 return rc;
19142}
19143
19144/*
19145** Implementation of ".expert" dot command.

Callers 2

shell_execFunction · 0.85
do_meta_commandFunction · 0.85

Calls 5

assertFunction · 0.85
sqlite3_expert_analyzeFunction · 0.85
sqlite3_expert_countFunction · 0.85
sqlite3_expert_reportFunction · 0.85
sqlite3_expert_destroyFunction · 0.85

Tested by

no test coverage detected