1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Add the --valid-sql option to the optfuzz test program.

FossilOrigin-Name: a8dfeec73b069f2dd7371c2792b36f152945d32120843db5361ff7e04de177bc
This commit is contained in:
drh
2018-03-22 11:28:31 +00:00
parent 00f0375df7
commit 66651c2b4b
3 changed files with 19 additions and 7 deletions

View File

@ -207,6 +207,7 @@ int main(int argc, char **argv){
sqlite3 *dbOut = 0; /* Database to hold results */
sqlite3 *dbRun = 0; /* Database used for tests */
int bTrace = 0; /* Show query results */
int bShowValid = 0; /* Just list inputs that are valid SQL */
int nRow, nStmt; /* Number of rows and statements */
int i, rc;
@ -218,11 +219,15 @@ int main(int argc, char **argv){
printf("Options:\n");
printf(" --help Show his message\n");
printf(" --output-trace Show each line of SQL output\n");
printf(" --valid-sql List FILEs that are valid SQL\n");
return 0;
}
else if( strcmp(z,"-output-trace")==0 ){
bTrace = 1;
}
else if( strcmp(z,"-valid-sql")==0 ){
bShowValid = 1;
}
else if( z[0]=='-' ){
printf("unknown option \"%s\". Use --help for details\n", argv[i]);
return 1;
@ -245,6 +250,13 @@ int main(int argc, char **argv){
for(i=0; i<nIn; i++){
char *zSql = readFile(azIn[i], 0);
sqlite3_stmt *pCk;
sqlite3_exec(dbRun, "ROLLBACK", 0, 0, 0);
if( bShowValid ){
rc = sqlite3_exec(dbRun, zSql, 0, 0, 0);
if( rc==SQLITE_OK ) printf("%s\n", azIn[i]);
sqlite3_free(zSql);
continue;
}
sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, dbRun, 0);
if( bTrace ) printf("%s: Optimized\n", azIn[i]);
rc = optfuzz_exec(dbRun, zSql, dbOut, "opt", &nStmt, &nRow, bTrace);