]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Further improvements to the ".scanstats on" display in the shell. Be sure scanstatus
authordrh <drh@noemail.net>
Thu, 6 Nov 2014 12:46:16 +0000 (12:46 +0000)
committerdrh <drh@noemail.net>
Thu, 6 Nov 2014 12:46:16 +0000 (12:46 +0000)
to show the results of all subqueries even if there are gaps in the
SELECTID values.  Add ".scanstats" to the ".help" output.

FossilOrigin-Name: ee922682bb7235dbcd23a22fcfdfa188f6d3228a

manifest
manifest.uuid
src/shell.c

index 05212e91e725fb3ab6fa5ce6021ca5b0a1a909e1..3bbd6d3bd35b1c25274d93d9fbe59e961511b6b9 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C On\sthe\s".scanstats\son"\soutput\sin\sthe\sshell,\sinitialize\sthe\sestimated\scount\sfor\nthe\sfirst\sloop\sof\seach\ssubquery\sto\sthe\sactual\sloop\scount.
-D 2014-11-06T12:17:24.789
+C Further\simprovements\sto\sthe\s".scanstats\son"\sdisplay\sin\sthe\sshell.\s\sBe\ssure\nto\sshow\sthe\sresults\sof\sall\ssubqueries\seven\sif\sthere\sare\sgaps\sin\sthe\s\nSELECTID\svalues.\s\sAdd\s".scanstats"\sto\sthe\s".help"\soutput.
+D 2014-11-06T12:46:16.708
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -228,7 +228,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
 F src/resolve.c 4965007d6497b6a4d7a6d98751cc39712885f952
 F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
 F src/select.c 428165951748151e87a15295b7357221433e311b
-F src/shell.c 64a941c079837fd1a0d920273832e6275b777402
+F src/shell.c 48fe276aada42a15722aee2584e6321345ed4609
 F src/sqlite.h.in 087d30a4c7ec7ae19bcaa03a9db9d6ee7a73b0b3
 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
 F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
@@ -1211,7 +1211,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P eacbbd8849db9b023eff15ef1cb42ec941299433
-R c65acc2e5374aae8ca471af05c87c9aa
+P d1c51c8455d5ce972a77720c2d56228646ced27c
+R 1f66f00948a1acda590c099646f9e3d3
 U drh
-Z b18ed09265a53348fca40701c374436f
+Z 2bc412ec02d784f50574dd160207db0a
index fc422bc396c62be6afab3dfafc0d2b5e7c9e948a..5ac436c5348828a5370165f54457cc41c67d38ea 100644 (file)
@@ -1 +1 @@
-d1c51c8455d5ce972a77720c2d56228646ced27c
\ No newline at end of file
+ee922682bb7235dbcd23a22fcfdfa188f6d3228a
\ No newline at end of file
index ca49e00a693c961909ef8e80ad3ae120fdd113a0..915b69263ba5d66750bde195c350aa7f421d7fba 100644 (file)
@@ -1194,9 +1194,10 @@ static void display_scanstats(
   ShellState *pArg                /* Pointer to ShellState */
 ){
 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
-  int i, k, n = 1;
+  int i, k, n, mx;
   fprintf(pArg->out, "-------- scanstats --------\n");
-  for(k=0; n>0; k++){
+  mx = 0;
+  for(k=0; k<=mx; k++){
     double rEstLoop = 1.0;
     for(i=n=0; 1; i++){
       sqlite3_stmt *p = pArg->pStmt;
@@ -1208,10 +1209,11 @@ static void display_scanstats(
         break;
       }
       sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_SELECTID, (void*)&iSid);
+      if( iSid>mx ) mx = iSid;
       if( iSid!=k ) continue;
       if( n==0 ){
         rEstLoop = (double)nLoop;
-        if( k>0 ) fprintf(pArg->out, "-------- subquery %d --------\n", k);
+        if( k>0 ) fprintf(pArg->out, "-------- subquery %d -------\n", k);
       }
       n++;
       sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit);
@@ -1224,14 +1226,8 @@ static void display_scanstats(
       );
     }
   }
-#else
-  fprintf(pArg->out, "-------- scanstats --------\n");
-  fprintf(pArg->out,
-      "sqlite3_stmt_scanstatus() unavailable - "
-      "rebuild with SQLITE_ENABLE_STMT_SCANSTATUS\n"
-  );
-#endif
   fprintf(pArg->out, "---------------------------\n");
+#endif
 }
 
 /*
@@ -1687,6 +1683,7 @@ static char zHelp[] =
   ".read FILENAME         Execute SQL in FILENAME\n"
   ".restore ?DB? FILE     Restore content of DB (default \"main\") from FILE\n"
   ".save FILE             Write in-memory database into FILE\n"
+  ".scanstats on|off      Turn sqlite3_stmt_scanstatus() metrics on or off\n"
   ".schema ?TABLE?        Show the CREATE statements\n"
   "                         If TABLE specified, only show tables matching\n"
   "                         LIKE pattern TABLE.\n"
@@ -3072,6 +3069,9 @@ static int do_meta_command(char *zLine, ShellState *p){
   if( c=='s' && strncmp(azArg[0], "scanstats", n)==0 ){
     if( nArg==2 ){
       p->scanstatsOn = booleanValue(azArg[1]);
+#ifndef SQLITE_ENABLE_STMT_SCANSTATUS
+      fprintf(stderr, "Warning: .scanstats not available in this build.\n");
+#endif
     }else{
       fprintf(stderr, "Usage: .scanstats on|off\n");
       rc = 1;