SQLite

Check-in [864bfdbfe7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improved tracing capabilities in fuzzcheck.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | fuzzcheck
Files: files | file ages | folders
SHA1: 864bfdbfe7b196cc9df2136b15a28e2a0f2713cb
User & Date: drh 2015-05-25 22:17:06.593
Context
2015-05-25
22:18
Merge in trunk fixes. (check-in: c71c2e1a99 user: drh tags: fuzzcheck)
22:17
Improved tracing capabilities in fuzzcheck. (check-in: 864bfdbfe7 user: drh tags: fuzzcheck)
21:59
Add the --native-vfs option on fuzzcheck. (check-in: 12e95e3f17 user: drh tags: fuzzcheck)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/fuzzcheck.c.
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534














535
536
537
538
539
540
541
542
543
544
545
546
547
  inmemVfs.xRandomness = pDefault->xRandomness;
  inmemVfs.xSleep = pDefault->xSleep;
  inmemVfs.xCurrentTime = pDefault->xCurrentTime;
  inmemVfs.xGetLastError = inmemGetLastError;
  sqlite3_vfs_register(&inmemVfs, 0);
};

#ifndef SQLITE_OMIT_TRACE
/*
** This callback is invoked by sqlite3_trace() as each SQL statement
** starts.
*/
static void traceCallback(void *NotUsed, const char *zMsg){
  printf("TRACE: %s\n", zMsg);
  fflush(stdout);
}
static void traceNoop(void *NotUsed, const char *zMsg){
  return;
}
#endif

/*
** Run multiple commands of SQL.  Similar to sqlite3_exec(), but does not
** stop if an error is encountered.
*/
static void runSql(sqlite3 *db, const char *zSql){
  const char *zMore;
  sqlite3_stmt *pStmt;

  while( zSql && zSql[0] ){
    zMore = 0;
    pStmt = 0;
    sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zMore);














    zSql = zMore;
    if( pStmt ){
      while( SQLITE_ROW==sqlite3_step(pStmt) );
      sqlite3_finalize(pStmt);
    }else{
      break;
    }
  }
}

/*
** Print sketchy documentation for this utility program
*/







<
<
<
<
<
<
<
<
<
<
<
<
<
<




|







>
>
>
>
>
>
>
>
>
>
>
>
>
>


|

<
<







502
503
504
505
506
507
508














509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538


539
540
541
542
543
544
545
  inmemVfs.xRandomness = pDefault->xRandomness;
  inmemVfs.xSleep = pDefault->xSleep;
  inmemVfs.xCurrentTime = pDefault->xCurrentTime;
  inmemVfs.xGetLastError = inmemGetLastError;
  sqlite3_vfs_register(&inmemVfs, 0);
};















/*
** Run multiple commands of SQL.  Similar to sqlite3_exec(), but does not
** stop if an error is encountered.
*/
static void runSql(sqlite3 *db, const char *zSql, int traceFlag){
  const char *zMore;
  sqlite3_stmt *pStmt;

  while( zSql && zSql[0] ){
    zMore = 0;
    pStmt = 0;
    sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zMore);
    if( zMore==zSql ) break;
    if( traceFlag ){
      const char *z = zSql;
      int n;
      while( z<zMore && isspace(z[0]) ) z++;
      n = (int)(zMore - z);
      while( n>0 && isspace(z[n-1]) ) n--;
      if( n==0 ) break;
      if( pStmt==0 ){
        printf("TRACE: %.*s (error: %s)\n", n, z, sqlite3_errmsg(db));
      }else{
        printf("TRACE: %.*s\n", n, z);
      }
    }
    zSql = zMore;
    if( pStmt ){
      while( SQLITE_ROW==sqlite3_step(pStmt) ){}
      sqlite3_finalize(pStmt);


    }
  }
}

/*
** Print sketchy documentation for this utility program
*/
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
      createVFile("main.db", pDb->sz, pDb->a);
      openFlags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE;
      if( nativeFlag && pDb->sz==0 ){
        openFlags |= SQLITE_OPEN_MEMORY;
        zVfs = 0;
      }
      rc = sqlite3_open_v2("main.db", &db, openFlags, zVfs);
#ifndef SQLITE_OMIT_TRACE
      sqlite3_trace(db, verboseFlag ? traceCallback : traceNoop, 0);
#endif
      if( rc ) fatalError("cannot open inmem database");
      runSql(db, (char*)pSql->a);
      sqlite3_close(db);
      if( sqlite3_memory_used()>0 ) fatalError("memory leak");
      reformatVfs();
      g.zTestName[0] = 0;
    }
  }








<
<
<

|







723
724
725
726
727
728
729



730
731
732
733
734
735
736
737
738
      createVFile("main.db", pDb->sz, pDb->a);
      openFlags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE;
      if( nativeFlag && pDb->sz==0 ){
        openFlags |= SQLITE_OPEN_MEMORY;
        zVfs = 0;
      }
      rc = sqlite3_open_v2("main.db", &db, openFlags, zVfs);



      if( rc ) fatalError("cannot open inmem database");
      runSql(db, (char*)pSql->a, verboseFlag);
      sqlite3_close(db);
      if( sqlite3_memory_used()>0 ) fatalError("memory leak");
      reformatVfs();
      g.zTestName[0] = 0;
    }
  }