Enhance the "rbu" command line utility a bit.
FossilOrigin-Name: 61eb516f83d1a7fe44f72bebe2a2745ab904a02e06e38fb6d932348c49607976
This commit is contained in:
parent
4b8bd84302
commit
340e9e125b
@ -29,7 +29,9 @@ void usage(const char *zArgv0){
|
|||||||
"Where options are:\n"
|
"Where options are:\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -step NSTEP\n"
|
" -step NSTEP\n"
|
||||||
|
" -statstep NSTATSTEP\n"
|
||||||
" -vacuum\n"
|
" -vacuum\n"
|
||||||
|
" -presql SQL\n"
|
||||||
"\n"
|
"\n"
|
||||||
" If the -vacuum switch is not present, argument RBU-DB must be an RBU\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"
|
" 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 */
|
char *zErrmsg; /* Error message, if any */
|
||||||
sqlite3rbu *pRbu; /* RBU handle */
|
sqlite3rbu *pRbu; /* RBU handle */
|
||||||
int nStep = 0; /* Maximum number of step() calls */
|
int nStep = 0; /* Maximum number of step() calls */
|
||||||
|
int nStatStep = 0; /* Report stats after this many step calls */
|
||||||
int bVacuum = 0;
|
int bVacuum = 0;
|
||||||
|
const char *zPreSql = 0;
|
||||||
int rc;
|
int rc;
|
||||||
sqlite3_int64 nProgress = 0;
|
sqlite3_int64 nProgress = 0;
|
||||||
int nArgc = argc-2;
|
int nArgc = argc-2;
|
||||||
@ -90,9 +94,18 @@ int main(int argc, char **argv){
|
|||||||
int nArg = strlen(zArg);
|
int nArg = strlen(zArg);
|
||||||
if( nArg>1 && nArg<=8 && 0==memcmp(zArg, "-vacuum", nArg) ){
|
if( nArg>1 && nArg<=8 && 0==memcmp(zArg, "-vacuum", nArg) ){
|
||||||
bVacuum = 1;
|
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 ){
|
}else if( nArg>1 && nArg<=5 && 0==memcmp(zArg, "-step", nArg) && i<nArg-1 ){
|
||||||
i++;
|
i++;
|
||||||
nStep = atoi(argv[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{
|
}else{
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
@ -112,13 +125,40 @@ int main(int argc, char **argv){
|
|||||||
}
|
}
|
||||||
report_rbu_vfs(pRbu);
|
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
|
/* If nStep is less than or equal to zero, call
|
||||||
** sqlite3rbu_step() until either the RBU has been completely applied
|
** sqlite3rbu_step() until either the RBU has been completely applied
|
||||||
** or an error occurs. Or, if nStep is greater than zero, call
|
** or an error occurs. Or, if nStep is greater than zero, call
|
||||||
** sqlite3rbu_step() a maximum of nStep times. */
|
** sqlite3rbu_step() a maximum of nStep times. */
|
||||||
for(i=0; (nStep<=0 || i<nStep) && sqlite3rbu_step(pRbu)==SQLITE_OK; i++);
|
if( rc==SQLITE_OK ){
|
||||||
nProgress = sqlite3rbu_progress(pRbu);
|
for(i=0; (nStep<=0 || i<nStep) && sqlite3rbu_step(pRbu)==SQLITE_OK; i++){
|
||||||
rc = sqlite3rbu_close(pRbu, &zErrmsg);
|
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. */
|
/* Let the user know what happened. */
|
||||||
switch( rc ){
|
switch( rc ){
|
||||||
|
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
|||||||
C Fix\sa\sharmless\scompiler\swarning.
|
C Enhance\sthe\s"rbu"\scommand\sline\sutility\sa\sbit.
|
||||||
D 2018-04-20T20:09:22.155
|
D 2018-04-20T20:37:25.557
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F Makefile.in 5ce9343cba9c189046f1afe6d2bcc1f68079439febc05267b98aec6ecc752439
|
F Makefile.in 5ce9343cba9c189046f1afe6d2bcc1f68079439febc05267b98aec6ecc752439
|
||||||
@ -307,7 +307,7 @@ F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd
|
|||||||
F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
|
F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
|
||||||
F ext/misc/zipfile.c c4de8f0ad446ce4a49aae11ff7b771cd7af60d7136c0bcfb53da1475b9075e79
|
F ext/misc/zipfile.c c4de8f0ad446ce4a49aae11ff7b771cd7af60d7136c0bcfb53da1475b9075e79
|
||||||
F ext/misc/zorder.c b0ff58fa643afa1d846786d51ea8d5c4b6b35aa0254ab5a82617db92f3adda64
|
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/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842
|
||||||
F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee
|
F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee
|
||||||
F ext/rbu/rbu11.test 9bc68c2d3dbeb1720153626e3bd0466dcc017702
|
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.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 20bf5800808ea02b2aa4bf01a380926784c0e7514a2c73ca303cac1f5c732ae0
|
P d2ab24f59d92527fe503fa7dc2128078fbc4dd2d2c1148effa9ea1957ab19940
|
||||||
R c4d0464d41166a1353ad8fa1877326ad
|
R 0a01952ab5e7062b6ef99418ce0e1189
|
||||||
U drh
|
U dan
|
||||||
Z 2c474dfea923266db5087d809c736452
|
Z 04ee3d5e6c96c9d55fb19cc03ce1ab7e
|
||||||
|
@ -1 +1 @@
|
|||||||
d2ab24f59d92527fe503fa7dc2128078fbc4dd2d2c1148effa9ea1957ab19940
|
61eb516f83d1a7fe44f72bebe2a2745ab904a02e06e38fb6d932348c49607976
|
Loading…
Reference in New Issue
Block a user