]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the --script option to speedtest1.
authordrh <>
Thu, 25 Aug 2022 19:19:25 +0000 (19:19 +0000)
committerdrh <>
Thu, 25 Aug 2022 19:19:25 +0000 (19:19 +0000)
FossilOrigin-Name: 1c87d7c58d5aec83f9e2ae3771a81aa17cfae0cf06169025a5db085e2d5749f9

manifest
manifest.uuid
test/speedtest1.c

index 990e9ba135992db90b3ac78d885c1a65a57176e1..aeabd1333c37cbf8694f5eb007ba10dfea41c7ad 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sa\sNEVER()\smacro\sfor\sa\scondition\sthat\sis\sactually\sreachable\sfollowing\san\sOOM.\sdbsqlfuzz\scrash-6ef3cd3b18ccc5de86120950a0498641acd90a33.txt.
-D 2022-08-25T13:32:55.636
+C Add\sthe\s--script\soption\sto\sspeedtest1.
+D 2022-08-25T19:19:25.119
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -1480,7 +1480,7 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef
 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715
 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa
 F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c
-F test/speedtest1.c 61f8a72bbcc80edb0b95e957f108feb4013ff3d08721cc87ae1865fd4d20652d
+F test/speedtest1.c 8146658813bb1451369258dbb525d6176001265861845e51e5c120f708111749
 F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e
 F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3
 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33
@@ -1999,8 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 459ad8846ee1ee2d3b277a291c47121692bdf477e779b06e77be8338f62237a6
-R c074d758a3f9086fc4005e904b417c57
-U dan
-Z 63f19aa3edc2a77d03599cb0f52bdf8f
+P b573e2cffa5fedc893ed30e76e47022b3617ac5583e1eb486afa810b2514c419
+R 23f5860feef99c79720c0e0c9fd78020
+U drh
+Z c96eb730eff0b666933a1a2c900265aa
 # Remove this line to create a well-formed Fossil manifest.
index 763566ed042ea33ff080674ea71244db5e28efb2..62c567913c49cc1f5bf71b706589b2007ba7de38 100644 (file)
@@ -1 +1 @@
-b573e2cffa5fedc893ed30e76e47022b3617ac5583e1eb486afa810b2514c419
\ No newline at end of file
+1c87d7c58d5aec83f9e2ae3771a81aa17cfae0cf06169025a5db085e2d5749f9
\ No newline at end of file
index 83c503c8c789a7b8290cc13dc09219a0a6a2c1ae..ee6d9bb8d5b8985b9654067b6cf8464a83bfe955 100644 (file)
@@ -29,6 +29,7 @@ static const char zHelp[] =
   "  --repeat N          Repeat each SELECT N times (default: 1)\n"
   "  --reprepare         Reprepare each statement upon every invocation\n"
   "  --reserve N         Reserve N bytes on each database page\n"
+  "  --script FILE       Write an SQL script for the test into FILE\n"
   "  --serialized        Set serialized threading mode\n"
   "  --singlethread      Set single-threaded mode - disables all mutexing\n"
   "  --sqlonly           No-op.  Only show the SQL that would have been run.\n"
@@ -103,6 +104,7 @@ static struct Global {
   u64 nResByte;              /* Total number of result bytes */
   int nResult;               /* Size of the current result */
   char zResult[3000];        /* Text of the current result */
+  FILE *pScript;             /* Write an SQL script into this file */
 #ifndef SPEEDTEST_OMIT_HASH
   FILE *hashFile;            /* Store all hash results in this file */
   HashContext hash;          /* Hash of all output */
@@ -473,7 +475,11 @@ void speedtest1_exec(const char *zFormat, ...){
     printSql(zSql);
   }else{
     char *zErrMsg = 0;
-    int rc = sqlite3_exec(g.db, zSql, 0, 0, &zErrMsg);
+    int rc;
+    if( g.pScript ){
+      fprintf(g.pScript,"%s;\n",zSql);
+    }
+    rc = sqlite3_exec(g.db, zSql, 0, 0, &zErrMsg);
     if( zErrMsg ) fatal_error("SQL error: %s\n%s\n", zErrMsg, zSql);
     if( rc!=SQLITE_OK ) fatal_error("exec error: %s\n", sqlite3_errmsg(g.db));
   }
@@ -500,6 +506,11 @@ char *speedtest1_once(const char *zFormat, ...){
     if( rc ){
       fatal_error("SQL error: %s\n", sqlite3_errmsg(g.db));
     }
+    if( g.pScript ){
+      char *z = sqlite3_expanded_sql(pStmt);
+      fprintf(g.pScript,"%s\n",z);
+      sqlite3_free(z);
+    }
     if( sqlite3_step(pStmt)==SQLITE_ROW ){
       const char *z = (const char*)sqlite3_column_text(pStmt, 0);
       if( z ) zResult = sqlite3_mprintf("%s", z);
@@ -537,6 +548,11 @@ void speedtest1_run(void){
   if( g.bSqlOnly ) return;
   assert( g.pStmt );
   g.nResult = 0;
+  if( g.pScript ){
+    char *z = sqlite3_expanded_sql(g.pStmt);
+    fprintf(g.pScript,"%s\n",z);
+    sqlite3_free(z);
+  }
   while( sqlite3_step(g.pStmt)==SQLITE_ROW ){
     n = sqlite3_column_count(g.pStmt);
     for(i=0; i<n; i++){
@@ -2281,6 +2297,13 @@ int main(int argc, char **argv){
       }else if( strcmp(z,"singlethread")==0 ){
         sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
 #endif
+      }else if( strcmp(z,"script")==0 ){
+        if( i>=argc-1 ) fatal_error("missing arguments on %s\n", argv[i]);
+        if( g.pScript ) fclose(g.pScript);
+        g.pScript = fopen(argv[++i], "wb");
+        if( g.pScript==0 ){
+          fatal_error("unable to open output file \"%s\"\n", argv[i]);
+        }
       }else if( strcmp(z,"sqlonly")==0 ){
         g.bSqlOnly = 1;
       }else if( strcmp(z,"shrink-memory")==0 ){
@@ -2547,6 +2570,9 @@ int main(int argc, char **argv){
     displayLinuxIoStats(stdout);
   }
 #endif
+  if( g.pScript ){
+    fclose(g.pScript);
+  }
 
   /* Release memory */
   free( pLook );