Fossil SCM

Add the --db-verify option to the "fossil dbstat" command. This option simply runs "fossil test-integrity" after doing the other dbstat processing. It is a way to access the test-integrity functionality without using the (unsupported) "test-integrity" command.

drh 2020-08-11 20:00 trunk
Commit 95e91b13d28d62c04cf740a4ac844b85aa170aa2e35ce4be45453aeb9dc69fbc
2 files changed +1 +22 -6
--- src/allrepo.c
+++ src/allrepo.c
@@ -219,10 +219,11 @@
219219
zCmd = "dbstat --omit-version-info -R";
220220
showLabel = 1;
221221
quiet = 1;
222222
collect_argument(&extra, "brief", "b");
223223
collect_argument(&extra, "db-check", 0);
224
+ collect_argument(&extra, "db-verify", 0);
224225
}else if( strncmp(zCmd, "extras", n)==0 ){
225226
if( showFile ){
226227
zCmd = "extras --chdir";
227228
}else{
228229
zCmd = "extras --header --chdir";
229230
--- src/allrepo.c
+++ src/allrepo.c
@@ -219,10 +219,11 @@
219 zCmd = "dbstat --omit-version-info -R";
220 showLabel = 1;
221 quiet = 1;
222 collect_argument(&extra, "brief", "b");
223 collect_argument(&extra, "db-check", 0);
 
224 }else if( strncmp(zCmd, "extras", n)==0 ){
225 if( showFile ){
226 zCmd = "extras --chdir";
227 }else{
228 zCmd = "extras --header --chdir";
229
--- src/allrepo.c
+++ src/allrepo.c
@@ -219,10 +219,11 @@
219 zCmd = "dbstat --omit-version-info -R";
220 showLabel = 1;
221 quiet = 1;
222 collect_argument(&extra, "brief", "b");
223 collect_argument(&extra, "db-check", 0);
224 collect_argument(&extra, "db-verify", 0);
225 }else if( strncmp(zCmd, "extras", n)==0 ){
226 if( showFile ){
227 zCmd = "extras --chdir";
228 }else{
229 zCmd = "extras --header --chdir";
230
+22 -6
--- src/stat.c
+++ src/stat.c
@@ -296,17 +296,21 @@
296296
/*
297297
** COMMAND: dbstat
298298
**
299299
** Usage: %fossil dbstat OPTIONS
300300
**
301
-** Shows statistics and global information about the repository.
301
+** Shows statistics and global information about the repository and/or
302
+** verify the integrity of a repository.
302303
**
303304
** Options:
304305
**
305
-** --brief|-b Only show essential elements
306
-** --db-check Run a PRAGMA quick_check on the repository database
307
-** --omit-version-info Omit the SQLite and Fossil version information
306
+** --brief|-b Only show essential elements.
307
+** --db-check Run "PRAGMA quick_check" on the repository database.
308
+** --db-verify Run a full verification of the repository integrity.
309
+** This involves decoding and reparsing all artifacts
310
+** and can take significant time.
311
+** --omit-version-info Omit the SQLite and Fossil version information.
308312
*/
309313
void dbstat_cmd(void){
310314
i64 t, fsize;
311315
int n, m;
312316
int szMax, szAvg;
@@ -317,10 +321,11 @@
317321
const char *p, *z;
318322
319323
brief = find_option("brief", "b",0)!=0;
320324
omitVers = find_option("omit-version-info", 0, 0)!=0;
321325
dbCheck = find_option("db-check",0,0)!=0;
326
+ if( find_option("db-verify",0,0)!=0 ) dbCheck = 2;
322327
db_find_and_open_repository(0,0);
323328
324329
/* We should be done with options.. */
325330
verify_all_options();
326331
@@ -414,12 +419,23 @@
414419
db_int(0, "PRAGMA repository.page_size"),
415420
db_int(0, "PRAGMA repository.freelist_count"),
416421
db_text(0, "PRAGMA repository.encoding"),
417422
db_text(0, "PRAGMA repository.journal_mode"));
418423
if( dbCheck ){
419
- fossil_print("%*s%s\n", colWidth, "database-check:",
420
- db_text(0, "PRAGMA quick_check(1)"));
424
+ if( dbCheck<2 ){
425
+ char *zRes = db_text(0, "PRAGMA repository.quick_check(1)");
426
+ fossil_print("%*s%s\n", colWidth, "database-check:", zRes);
427
+ }else{
428
+ char *newArgv[2];
429
+ newArgv[0] = g.argv[0];
430
+ newArgv[1] = "test-integrity";
431
+ newArgv[2] = 0;
432
+ g.argv = newArgv;
433
+ g.argc = 2;
434
+ fossil_print("Full repository verification follows:\n");
435
+ test_integrity();
436
+ }
421437
}
422438
}
423439
424440
/*
425441
** WEBPAGE: urllist
426442
--- src/stat.c
+++ src/stat.c
@@ -296,17 +296,21 @@
296 /*
297 ** COMMAND: dbstat
298 **
299 ** Usage: %fossil dbstat OPTIONS
300 **
301 ** Shows statistics and global information about the repository.
 
302 **
303 ** Options:
304 **
305 ** --brief|-b Only show essential elements
306 ** --db-check Run a PRAGMA quick_check on the repository database
307 ** --omit-version-info Omit the SQLite and Fossil version information
 
 
 
308 */
309 void dbstat_cmd(void){
310 i64 t, fsize;
311 int n, m;
312 int szMax, szAvg;
@@ -317,10 +321,11 @@
317 const char *p, *z;
318
319 brief = find_option("brief", "b",0)!=0;
320 omitVers = find_option("omit-version-info", 0, 0)!=0;
321 dbCheck = find_option("db-check",0,0)!=0;
 
322 db_find_and_open_repository(0,0);
323
324 /* We should be done with options.. */
325 verify_all_options();
326
@@ -414,12 +419,23 @@
414 db_int(0, "PRAGMA repository.page_size"),
415 db_int(0, "PRAGMA repository.freelist_count"),
416 db_text(0, "PRAGMA repository.encoding"),
417 db_text(0, "PRAGMA repository.journal_mode"));
418 if( dbCheck ){
419 fossil_print("%*s%s\n", colWidth, "database-check:",
420 db_text(0, "PRAGMA quick_check(1)"));
 
 
 
 
 
 
 
 
 
 
 
421 }
422 }
423
424 /*
425 ** WEBPAGE: urllist
426
--- src/stat.c
+++ src/stat.c
@@ -296,17 +296,21 @@
296 /*
297 ** COMMAND: dbstat
298 **
299 ** Usage: %fossil dbstat OPTIONS
300 **
301 ** Shows statistics and global information about the repository and/or
302 ** verify the integrity of a repository.
303 **
304 ** Options:
305 **
306 ** --brief|-b Only show essential elements.
307 ** --db-check Run "PRAGMA quick_check" on the repository database.
308 ** --db-verify Run a full verification of the repository integrity.
309 ** This involves decoding and reparsing all artifacts
310 ** and can take significant time.
311 ** --omit-version-info Omit the SQLite and Fossil version information.
312 */
313 void dbstat_cmd(void){
314 i64 t, fsize;
315 int n, m;
316 int szMax, szAvg;
@@ -317,10 +321,11 @@
321 const char *p, *z;
322
323 brief = find_option("brief", "b",0)!=0;
324 omitVers = find_option("omit-version-info", 0, 0)!=0;
325 dbCheck = find_option("db-check",0,0)!=0;
326 if( find_option("db-verify",0,0)!=0 ) dbCheck = 2;
327 db_find_and_open_repository(0,0);
328
329 /* We should be done with options.. */
330 verify_all_options();
331
@@ -414,12 +419,23 @@
419 db_int(0, "PRAGMA repository.page_size"),
420 db_int(0, "PRAGMA repository.freelist_count"),
421 db_text(0, "PRAGMA repository.encoding"),
422 db_text(0, "PRAGMA repository.journal_mode"));
423 if( dbCheck ){
424 if( dbCheck<2 ){
425 char *zRes = db_text(0, "PRAGMA repository.quick_check(1)");
426 fossil_print("%*s%s\n", colWidth, "database-check:", zRes);
427 }else{
428 char *newArgv[2];
429 newArgv[0] = g.argv[0];
430 newArgv[1] = "test-integrity";
431 newArgv[2] = 0;
432 g.argv = newArgv;
433 g.argc = 2;
434 fossil_print("Full repository verification follows:\n");
435 test_integrity();
436 }
437 }
438 }
439
440 /*
441 ** WEBPAGE: urllist
442

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button