Fossil SCM

Add the --db-only and --quick options to the test-integrity command.

drh 2020-05-13 11:59 trunk
Commit 6711b2225115c8a92e63b812a2569998da88903d0366b473fba7e24f294dcb9d
--- src/allrepo.c
+++ src/allrepo.c
@@ -283,11 +283,13 @@
283283
}else if( strncmp(zCmd, "sync", n)==0 ){
284284
zCmd = "sync -autourl -R";
285285
collect_argument(&extra, "verbose","v");
286286
collect_argument(&extra, "unversioned","u");
287287
}else if( strncmp(zCmd, "test-integrity", n)==0 ){
288
+ collect_argument(&extra, "db-only", "d");
288289
collect_argument(&extra, "parse", 0);
290
+ collect_argument(&extra, "quick", "q");
289291
zCmd = "test-integrity";
290292
}else if( strncmp(zCmd, "test-orphans", n)==0 ){
291293
zCmd = "test-orphans -R";
292294
}else if( strncmp(zCmd, "test-missing", n)==0 ){
293295
zCmd = "test-missing -q -R";
294296
--- src/allrepo.c
+++ src/allrepo.c
@@ -283,11 +283,13 @@
283 }else if( strncmp(zCmd, "sync", n)==0 ){
284 zCmd = "sync -autourl -R";
285 collect_argument(&extra, "verbose","v");
286 collect_argument(&extra, "unversioned","u");
287 }else if( strncmp(zCmd, "test-integrity", n)==0 ){
 
288 collect_argument(&extra, "parse", 0);
 
289 zCmd = "test-integrity";
290 }else if( strncmp(zCmd, "test-orphans", n)==0 ){
291 zCmd = "test-orphans -R";
292 }else if( strncmp(zCmd, "test-missing", n)==0 ){
293 zCmd = "test-missing -q -R";
294
--- src/allrepo.c
+++ src/allrepo.c
@@ -283,11 +283,13 @@
283 }else if( strncmp(zCmd, "sync", n)==0 ){
284 zCmd = "sync -autourl -R";
285 collect_argument(&extra, "verbose","v");
286 collect_argument(&extra, "unversioned","u");
287 }else if( strncmp(zCmd, "test-integrity", n)==0 ){
288 collect_argument(&extra, "db-only", "d");
289 collect_argument(&extra, "parse", 0);
290 collect_argument(&extra, "quick", "q");
291 zCmd = "test-integrity";
292 }else if( strncmp(zCmd, "test-orphans", n)==0 ){
293 zCmd = "test-orphans -R";
294 }else if( strncmp(zCmd, "test-missing", n)==0 ){
295 zCmd = "test-missing -q -R";
296
--- src/content.c
+++ src/content.c
@@ -944,13 +944,19 @@
944944
** Verify that all content can be extracted from the BLOB table correctly.
945945
** If the BLOB table is correct, then the repository can always be
946946
** successfully reconstructed using "fossil rebuild".
947947
**
948948
** Options:
949
+**
950
+** -d|--db-only Run "PRAGMA integrity_check" on the database only.
951
+** No other validation is performed.
949952
**
950953
** --parse Parse all manifests, wikis, tickets, events, and
951954
** so forth, reporting any errors found.
955
+**
956
+** -q|--quick Run "PRAGMA quick_check" on the database only.
957
+** No other validation is performed.
952958
*/
953959
void test_integrity(void){
954960
Stmt q;
955961
Blob content;
956962
int n1 = 0;
@@ -958,11 +964,25 @@
958964
int nErr = 0;
959965
int total;
960966
int nCA = 0;
961967
int anCA[10];
962968
int bParse = find_option("parse",0,0)!=0;
969
+ int bDbOnly = find_option("db-only","d",0)!=0;
970
+ int bQuick = find_option("quick","q",0)!=0;
963971
db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
972
+ if( bDbOnly || bQuick ){
973
+ const char *zType = bQuick ? "quick" : "integrity";
974
+ char *zRes;
975
+ zRes = db_text(0,"PRAGMA repository.%s_check", zType/*safe-for-%s*/);
976
+ if( fossil_strcmp(zRes,"ok")!=0 ){
977
+ fossil_print("%s_check failed!\n", zType);
978
+ exit(1);
979
+ }else{
980
+ fossil_print("ok\n");
981
+ }
982
+ return;
983
+ }
964984
memset(anCA, 0, sizeof(anCA));
965985
966986
/* Make sure no public artifact is a delta from a private artifact */
967987
db_prepare(&q,
968988
"SELECT "
969989
--- src/content.c
+++ src/content.c
@@ -944,13 +944,19 @@
944 ** Verify that all content can be extracted from the BLOB table correctly.
945 ** If the BLOB table is correct, then the repository can always be
946 ** successfully reconstructed using "fossil rebuild".
947 **
948 ** Options:
 
 
 
949 **
950 ** --parse Parse all manifests, wikis, tickets, events, and
951 ** so forth, reporting any errors found.
 
 
 
952 */
953 void test_integrity(void){
954 Stmt q;
955 Blob content;
956 int n1 = 0;
@@ -958,11 +964,25 @@
958 int nErr = 0;
959 int total;
960 int nCA = 0;
961 int anCA[10];
962 int bParse = find_option("parse",0,0)!=0;
 
 
963 db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
 
 
 
 
 
 
 
 
 
 
 
 
964 memset(anCA, 0, sizeof(anCA));
965
966 /* Make sure no public artifact is a delta from a private artifact */
967 db_prepare(&q,
968 "SELECT "
969
--- src/content.c
+++ src/content.c
@@ -944,13 +944,19 @@
944 ** Verify that all content can be extracted from the BLOB table correctly.
945 ** If the BLOB table is correct, then the repository can always be
946 ** successfully reconstructed using "fossil rebuild".
947 **
948 ** Options:
949 **
950 ** -d|--db-only Run "PRAGMA integrity_check" on the database only.
951 ** No other validation is performed.
952 **
953 ** --parse Parse all manifests, wikis, tickets, events, and
954 ** so forth, reporting any errors found.
955 **
956 ** -q|--quick Run "PRAGMA quick_check" on the database only.
957 ** No other validation is performed.
958 */
959 void test_integrity(void){
960 Stmt q;
961 Blob content;
962 int n1 = 0;
@@ -958,11 +964,25 @@
964 int nErr = 0;
965 int total;
966 int nCA = 0;
967 int anCA[10];
968 int bParse = find_option("parse",0,0)!=0;
969 int bDbOnly = find_option("db-only","d",0)!=0;
970 int bQuick = find_option("quick","q",0)!=0;
971 db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
972 if( bDbOnly || bQuick ){
973 const char *zType = bQuick ? "quick" : "integrity";
974 char *zRes;
975 zRes = db_text(0,"PRAGMA repository.%s_check", zType/*safe-for-%s*/);
976 if( fossil_strcmp(zRes,"ok")!=0 ){
977 fossil_print("%s_check failed!\n", zType);
978 exit(1);
979 }else{
980 fossil_print("ok\n");
981 }
982 return;
983 }
984 memset(anCA, 0, sizeof(anCA));
985
986 /* Make sure no public artifact is a delta from a private artifact */
987 db_prepare(&q,
988 "SELECT "
989

Keyboard Shortcuts

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