]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enhance the "rbu" command line utility a bit.
authordan <dan@noemail.net>
Fri, 20 Apr 2018 20:37:25 +0000 (20:37 +0000)
committerdan <dan@noemail.net>
Fri, 20 Apr 2018 20:37:25 +0000 (20:37 +0000)
FossilOrigin-Name: 61eb516f83d1a7fe44f72bebe2a2745ab904a02e06e38fb6d932348c49607976

ext/rbu/rbu.c
manifest
manifest.uuid

index be5c72413d3b05b007393c81b0c18a399d3abf56..1dac4523057a142b26d85219768317e33cbc0b07 100644 (file)
@@ -29,7 +29,9 @@ void usage(const char *zArgv0){
 "Where options are:\n"
 "\n"
 "    -step NSTEP\n"
+"    -statstep NSTATSTEP\n"
 "    -vacuum\n"
+"    -presql SQL\n"
 "\n"
 "  If the -vacuum switch is not present, argument RBU-DB must be an RBU\n"
 "  database containing an update suitable for target database TARGET-DB.\n"
@@ -79,7 +81,9 @@ int main(int argc, char **argv){
   char *zErrmsg;                  /* Error message, if any */
   sqlite3rbu *pRbu;               /* RBU handle */
   int nStep = 0;                  /* Maximum number of step() calls */
+  int nStatStep = 0;              /* Report stats after this many step calls */
   int bVacuum = 0;
+  const char *zPreSql = 0;
   int rc;
   sqlite3_int64 nProgress = 0;
   int nArgc = argc-2;
@@ -90,9 +94,18 @@ int main(int argc, char **argv){
     int nArg = strlen(zArg);
     if( nArg>1 && nArg<=8 && 0==memcmp(zArg, "-vacuum", nArg) ){
       bVacuum = 1;
+    }else if( nArg>1 && nArg<=7 
+           && 0==memcmp(zArg, "-presql", nArg) && i<nArg-1 ){
+      i++;
+      zPreSql = argv[i];
     }else if( nArg>1 && nArg<=5 && 0==memcmp(zArg, "-step", nArg) && i<nArg-1 ){
       i++;
       nStep = atoi(argv[i]);
+    }else if( nArg>1 && nArg<=9 
+           && 0==memcmp(zArg, "-statstep", nArg) && i<nArg-1 
+    ){
+      i++;
+      nStatStep = atoi(argv[i]);
     }else{
       usage(argv[0]);
     }
@@ -112,13 +125,40 @@ int main(int argc, char **argv){
   }
   report_rbu_vfs(pRbu);
 
+  if( zPreSql && pRbu ){
+    sqlite3 *db = sqlite3rbu_db(pRbu, 0);
+    rc = sqlite3_exec(db, zPreSql, 0, 0, 0);
+    if( rc==SQLITE_OK ){
+      sqlite3 *db = sqlite3rbu_db(pRbu, 1);
+      rc = sqlite3_exec(db, zPreSql, 0, 0, 0);
+    }
+  }
+
   /* If nStep is less than or equal to zero, call
   ** sqlite3rbu_step() until either the RBU has been completely applied
   ** or an error occurs. Or, if nStep is greater than zero, call
   ** sqlite3rbu_step() a maximum of nStep times.  */
-  for(i=0; (nStep<=0 || i<nStep) && sqlite3rbu_step(pRbu)==SQLITE_OK; i++);
-  nProgress = sqlite3rbu_progress(pRbu);
-  rc = sqlite3rbu_close(pRbu, &zErrmsg);
+  if( rc==SQLITE_OK ){
+    for(i=0; (nStep<=0 || i<nStep) && sqlite3rbu_step(pRbu)==SQLITE_OK; i++){
+      if( nStatStep>0 && (i % nStatStep)==0 ){
+        sqlite3_int64 nUsed;
+        sqlite3_int64 nHighwater;
+        sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &nUsed, &nHighwater, 0);
+        fprintf(stdout, "memory used=%lld highwater=%lld", nUsed, nHighwater);
+        if( bVacuum==0 ){
+          int one;
+          int two;
+          sqlite3rbu_bp_progress(pRbu, &one, &two);
+          fprintf(stdout, "  progress=%d/%d\n", one, two);
+        }else{
+          fprintf(stdout, "\n");
+        }
+        fflush(stdout);
+      }
+    }
+    nProgress = sqlite3rbu_progress(pRbu);
+    rc = sqlite3rbu_close(pRbu, &zErrmsg);
+  }
 
   /* Let the user know what happened. */
   switch( rc ){
index b38c494186b92f252521368f76379caefe4a9774..d8bd5a6a8e32e8859eaf662d93f1f91279044465 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sharmless\scompiler\swarning.
-D 2018-04-20T20:09:22.155
+C Enhance\sthe\s"rbu"\scommand\sline\sutility\sa\sbit.
+D 2018-04-20T20:37:25.557
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F Makefile.in 5ce9343cba9c189046f1afe6d2bcc1f68079439febc05267b98aec6ecc752439
@@ -307,7 +307,7 @@ F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd
 F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
 F ext/misc/zipfile.c c4de8f0ad446ce4a49aae11ff7b771cd7af60d7136c0bcfb53da1475b9075e79
 F ext/misc/zorder.c b0ff58fa643afa1d846786d51ea8d5c4b6b35aa0254ab5a82617db92f3adda64
-F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e
+F ext/rbu/rbu.c 4ae41f01d78dfae2204a63bcf39d5eb3548d039b094c29eec9a8d6683a66a5d3
 F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842
 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee
 F ext/rbu/rbu11.test 9bc68c2d3dbeb1720153626e3bd0466dcc017702
@@ -1724,7 +1724,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 20bf5800808ea02b2aa4bf01a380926784c0e7514a2c73ca303cac1f5c732ae0
-R c4d0464d41166a1353ad8fa1877326ad
-U drh
-Z 2c474dfea923266db5087d809c736452
+P d2ab24f59d92527fe503fa7dc2128078fbc4dd2d2c1148effa9ea1957ab19940
+R 0a01952ab5e7062b6ef99418ce0e1189
+U dan
+Z 04ee3d5e6c96c9d55fb19cc03ce1ab7e
index 07db5ea0410b0eadd4ac302fd89afe19e2229b17..84aab461c10eca1f3d2a2b07e70a9635aeaf83ab 100644 (file)
@@ -1 +1 @@
-d2ab24f59d92527fe503fa7dc2128078fbc4dd2d2c1148effa9ea1957ab19940
\ No newline at end of file
+61eb516f83d1a7fe44f72bebe2a2745ab904a02e06e38fb6d932348c49607976
\ No newline at end of file