]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
For the kvtest utility, add the --vacuum option to "kvtest stat" and also
authordrh <drh@noemail.net>
Mon, 5 Jun 2017 13:28:17 +0000 (13:28 +0000)
committerdrh <drh@noemail.net>
Mon, 5 Jun 2017 13:28:17 +0000 (13:28 +0000)
run PRAGMA integrity_check with "kvtest stat".

FossilOrigin-Name: f3c25df4562efda2adeb211a4cc893246354917849a0fa4d95da3d7970e9588e

manifest
manifest.uuid
test/kvtest.c

index 0513f7b6e6b66b3c128a677532ababc704db3d14..4b0d5e14b9b8f94ad6b0b6670091d38eb16008f7 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sthe\scolumn\swidth\sdeduction\slogic\sin\sthe\scommand-line\sshell\sto\saccount\nfor\smulti-byte\sutf8\scharacters.
-D 2017-06-05T12:29:26.935
+C For\sthe\skvtest\sutility,\sadd\sthe\s--vacuum\soption\sto\s"kvtest\sstat"\sand\salso\nrun\sPRAGMA\sintegrity_check\swith\s"kvtest\sstat".
+D 2017-06-05T13:28:17.990
 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc
@@ -925,7 +925,7 @@ F test/json102.test eeb54efa221e50b74a2d6fb9259963b48d7414dca3ce2fdfdeed45cb2848
 F test/json103.test c5f6b85e69de05f6b3195f9f9d5ce9cd179099a0
 F test/json104.test 877d5845f6303899b7889ea5dd1bea99076e3100574d5c536082245c5805dcaa
 F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff
-F test/kvtest.c d6c222497db645838afe6c48e173e337ca24b97be4fd4d1dc05c38cdb4af560e
+F test/kvtest.c 4e274696ee1cc588be38ce2d50015b564a79c076084126839a4599bf705fbd15
 F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63
 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200
 F test/like.test 0603f4fa0dad50987f70032c05800cbfa8985302
@@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P ead29f9cb757a5f9921086e3bb4998f60e0d6cfcf41ef0f9a230b365b6226947
-R a0798b817cd3131e3fcd85873638461d
+P ed0842c156ab1a78d5d00d3a55dab5e3f08cd349328d606724688f1528df3f6b
+R 469299041958944268a194091870ce94
 U drh
-Z 989f90c118a47ae7c1914060875ac3d8
+Z 36dcea3e9252ed2e301fc8394580d033
index eda3a2f91cb2530c5b839f394addab5e02fd0c06..f94cd4d895a751d94412707bf61089821d3ea36d 100644 (file)
@@ -1 +1 @@
-ed0842c156ab1a78d5d00d3a55dab5e3f08cd349328d606724688f1528df3f6b
\ No newline at end of file
+f3c25df4562efda2adeb211a4cc893246354917849a0fa4d95da3d7970e9588e
\ No newline at end of file
index ae576035fba3733af005f594665a8c1153933560..21a35fc07eb7505ed3b03306aa07b807c29f2e26 100644 (file)
@@ -81,9 +81,11 @@ static const char zHelp[] =
 "        files are in the top-level directory with names like 000000, 000001,\n"
 "        000002, and so forth.\n"
 "\n"
-"   kvtest stat DBFILE\n"
+"   kvtest stat DBFILE [options]\n"
 "\n"
-"        Display summary information about DBFILE\n"
+"        Display summary information about DBFILE.  Options:\n"
+"\n"
+"           --vacuum               Run VACUUM on the database file\n"
 "\n"
 "   kvtest run DBFILE [options]\n"
 "\n"
@@ -383,6 +385,7 @@ static int statMain(int argc, char **argv){
   sqlite3 *db;
   char *zSql;
   sqlite3_stmt *pStmt;
+  int doVacuum = 0;
 
   assert( strcmp(argv[1],"stat")==0 );
   assert( argc>=3 );
@@ -391,12 +394,21 @@ static int statMain(int argc, char **argv){
     char *z = argv[i];
     if( z[0]!='-' ) fatalError("unknown argument: \"%s\"", z);
     if( z[1]=='-' ) z++;
+    if( strcmp(z, "-vacuum")==0 ){
+      doVacuum = 1;
+      continue;
+    }
     fatalError("unknown option: \"%s\"", argv[i]);
   }
   rc = sqlite3_open(zDb, &db);
   if( rc ){
     fatalError("cannot open database \"%s\": %s", zDb, sqlite3_errmsg(db));
   }
+  if( doVacuum ){
+    printf("Vacuuming...."); fflush(stdout);
+    sqlite3_exec(db, "VACUUM", 0, 0, 0);
+    printf("       done\n");
+  }
   zSql = sqlite3_mprintf(
     "SELECT count(*), min(length(v)), max(length(v)), avg(length(v))"
     "  FROM kv"
@@ -429,6 +441,20 @@ static int statMain(int argc, char **argv){
     printf("Page-count:         %8d\n", sqlite3_column_int(pStmt, 0));
   }
   sqlite3_finalize(pStmt);
+  zSql = sqlite3_mprintf("PRAGMA freelist_count");
+  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
+  if( rc ) fatalError("cannot prepare SQL [%s]: %s", zSql, sqlite3_errmsg(db));
+  sqlite3_free(zSql);
+  if( sqlite3_step(pStmt)==SQLITE_ROW ){
+    printf("Freelist-count:     %8d\n", sqlite3_column_int(pStmt, 0));
+  }
+  sqlite3_finalize(pStmt);
+  rc = sqlite3_prepare_v2(db, "PRAGMA integrity_check(10)", -1, &pStmt, 0);
+  if( rc ) fatalError("cannot prepare integrity check: %s", sqlite3_errmsg(db));
+  while( sqlite3_step(pStmt)==SQLITE_ROW ){
+    printf("Integrity-check:    %s\n", sqlite3_column_text(pStmt, 0));
+  }
+  sqlite3_finalize(pStmt);
   sqlite3_close(db);
   return 0;
 }