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

Function expertDotCommand

modules/dasSQLITE/sqlite/shell.c:19147–19201  ·  view source on GitHub ↗

** Implementation of ".expert" dot command. */

Source from the content-addressed store, hash-verified

19145** Implementation of ".expert" dot command.
19146*/
19147static int expertDotCommand(
19148 ShellState *pState, /* Current shell tool state */
19149 char **azArg, /* Array of arguments passed to dot command */
19150 int nArg /* Number of entries in azArg[] */
19151){
19152 int rc = SQLITE_OK;
19153 char *zErr = 0;
19154 int i;
19155 int iSample = 0;
19156
19157 assert( pState->expert.pExpert==0 );
19158 memset(&pState->expert, 0, sizeof(ExpertInfo));
19159
19160 for(i=1; rc==SQLITE_OK && i<nArg; i++){
19161 char *z = azArg[i];
19162 int n;
19163 if( z[0]=='-' && z[1]=='-' ) z++;
19164 n = strlen30(z);
19165 if( n>=2 && 0==cli_strncmp(z, "-verbose", n) ){
19166 pState->expert.bVerbose = 1;
19167 }
19168 else if( n>=2 && 0==cli_strncmp(z, "-sample", n) ){
19169 if( i==(nArg-1) ){
19170 raw_printf(stderr, "option requires an argument: %s\n", z);
19171 rc = SQLITE_ERROR;
19172 }else{
19173 iSample = (int)integerValue(azArg[++i]);
19174 if( iSample<0 || iSample>100 ){
19175 raw_printf(stderr, "value out of range: %s\n", azArg[i]);
19176 rc = SQLITE_ERROR;
19177 }
19178 }
19179 }
19180 else{
19181 raw_printf(stderr, "unknown option: %s\n", z);
19182 rc = SQLITE_ERROR;
19183 }
19184 }
19185
19186 if( rc==SQLITE_OK ){
19187 pState->expert.pExpert = sqlite3_expert_new(pState->db, &zErr);
19188 if( pState->expert.pExpert==0 ){
19189 raw_printf(stderr, "sqlite3_expert_new: %s\n",
19190 zErr ? zErr : "out of memory");
19191 rc = SQLITE_ERROR;
19192 }else{
19193 sqlite3_expert_config(
19194 pState->expert.pExpert, EXPERT_CONFIG_SAMPLE, iSample
19195 );
19196 }
19197 }
19198 sqlite3_free(zErr);
19199
19200 return rc;
19201}
19202#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
19203
19204/*

Callers 1

do_meta_commandFunction · 0.85

Calls 6

assertFunction · 0.85
strlen30Function · 0.85
cli_strncmpFunction · 0.85
integerValueFunction · 0.85
sqlite3_expert_newFunction · 0.85
sqlite3_expert_configFunction · 0.85

Tested by

no test coverage detected