Fossil SCM

Add the --deanalyze option to "fossil rebuild" for removing ANALYZE results. We really don't want ANALYZE run on a repository because all the queries are tuned to work without it. Add the ability to pass rebuild arguments to "fossil all rebuild".

drh 2012-10-26 21:34 trunk
Commit 85233c40c9bb05a87574cdc25402ec0d34b0b7ee
2 files changed +34 -1 +7
+34 -1
--- src/allrepo.c
+++ src/allrepo.c
@@ -45,10 +45,40 @@
4545
}else{
4646
return mprintf("%s", zFilename);
4747
}
4848
}
4949
50
+/*
51
+** Build a string that contains all of the command-line options
52
+** specified as arguments. If the option name begins with "+" then
53
+** it takes an argument. Without the "+" it does not.
54
+*/
55
+static const char *collect_arguments(const char *zArg, ...){
56
+ va_list ap;
57
+ Blob res;
58
+ blob_zero(&res);
59
+ va_start(ap, zArg);
60
+ while( zArg!=0 ){
61
+ if( zArg[0]=='+' ){
62
+ const char *zValue = find_option(&zArg[1], 0, 1);
63
+ if( zValue ){
64
+ blob_appendf(&res, " --%s %s", &zArg[1], zValue);
65
+ }
66
+ }else{
67
+ if( find_option(zArg, 0, 0)!=0 ){
68
+ blob_appendf(&res, " --%s", zArg);
69
+ }
70
+ }
71
+ zArg = va_arg(ap, const char*);
72
+ }
73
+ if( blob_size(&res)==0 ){
74
+ return "";
75
+ }else{
76
+ return blob_str(&res);
77
+ }
78
+}
79
+
5080
5181
/*
5282
** COMMAND: all
5383
**
5484
** Usage: %fossil all (list|ls|pull|push|rebuild|sync)
@@ -89,10 +119,11 @@
89119
Stmt q;
90120
const char *zCmd;
91121
char *zSyscmd;
92122
char *zFossil;
93123
char *zQFilename;
124
+ const char *zExtra = "";
94125
int useCheckouts = 0;
95126
int quiet = 0;
96127
int testRun = 0;
97128
int stopOnError = find_option("dontstop",0,0)==0;
98129
int rc;
@@ -117,10 +148,12 @@
117148
zCmd = "push -autourl -R";
118149
}else if( strncmp(zCmd, "pull", n)==0 ){
119150
zCmd = "pull -autourl -R";
120151
}else if( strncmp(zCmd, "rebuild", n)==0 ){
121152
zCmd = "rebuild";
153
+ zExtra = collect_arguments("cluster","compress","noverify","+pagesize",
154
+ "vacuum","deanalyze","wal","stats", 0);
122155
}else if( strncmp(zCmd, "sync", n)==0 ){
123156
zCmd = "sync -autourl -R";
124157
}else if( strncmp(zCmd, "test-integrity", n)==0 ){
125158
zCmd = "test-integrity";
126159
}else if( strncmp(zCmd, "changes", n)==0 ){
@@ -180,11 +213,11 @@
180213
if( zCmd[0]=='l' ){
181214
fossil_print("%s\n", zFilename);
182215
continue;
183216
}
184217
zQFilename = quoteFilename(zFilename);
185
- zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename);
218
+ zSyscmd = mprintf("%s %s %s%s", zFossil, zCmd, zQFilename, zExtra);
186219
if( !quiet || testRun ){
187220
fossil_print("%s\n", zSyscmd);
188221
fflush(stdout);
189222
}
190223
rc = testRun ? 0 : fossil_system(zSyscmd);
191224
--- src/allrepo.c
+++ src/allrepo.c
@@ -45,10 +45,40 @@
45 }else{
46 return mprintf("%s", zFilename);
47 }
48 }
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
51 /*
52 ** COMMAND: all
53 **
54 ** Usage: %fossil all (list|ls|pull|push|rebuild|sync)
@@ -89,10 +119,11 @@
89 Stmt q;
90 const char *zCmd;
91 char *zSyscmd;
92 char *zFossil;
93 char *zQFilename;
 
94 int useCheckouts = 0;
95 int quiet = 0;
96 int testRun = 0;
97 int stopOnError = find_option("dontstop",0,0)==0;
98 int rc;
@@ -117,10 +148,12 @@
117 zCmd = "push -autourl -R";
118 }else if( strncmp(zCmd, "pull", n)==0 ){
119 zCmd = "pull -autourl -R";
120 }else if( strncmp(zCmd, "rebuild", n)==0 ){
121 zCmd = "rebuild";
 
 
122 }else if( strncmp(zCmd, "sync", n)==0 ){
123 zCmd = "sync -autourl -R";
124 }else if( strncmp(zCmd, "test-integrity", n)==0 ){
125 zCmd = "test-integrity";
126 }else if( strncmp(zCmd, "changes", n)==0 ){
@@ -180,11 +213,11 @@
180 if( zCmd[0]=='l' ){
181 fossil_print("%s\n", zFilename);
182 continue;
183 }
184 zQFilename = quoteFilename(zFilename);
185 zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename);
186 if( !quiet || testRun ){
187 fossil_print("%s\n", zSyscmd);
188 fflush(stdout);
189 }
190 rc = testRun ? 0 : fossil_system(zSyscmd);
191
--- src/allrepo.c
+++ src/allrepo.c
@@ -45,10 +45,40 @@
45 }else{
46 return mprintf("%s", zFilename);
47 }
48 }
49
50 /*
51 ** Build a string that contains all of the command-line options
52 ** specified as arguments. If the option name begins with "+" then
53 ** it takes an argument. Without the "+" it does not.
54 */
55 static const char *collect_arguments(const char *zArg, ...){
56 va_list ap;
57 Blob res;
58 blob_zero(&res);
59 va_start(ap, zArg);
60 while( zArg!=0 ){
61 if( zArg[0]=='+' ){
62 const char *zValue = find_option(&zArg[1], 0, 1);
63 if( zValue ){
64 blob_appendf(&res, " --%s %s", &zArg[1], zValue);
65 }
66 }else{
67 if( find_option(zArg, 0, 0)!=0 ){
68 blob_appendf(&res, " --%s", zArg);
69 }
70 }
71 zArg = va_arg(ap, const char*);
72 }
73 if( blob_size(&res)==0 ){
74 return "";
75 }else{
76 return blob_str(&res);
77 }
78 }
79
80
81 /*
82 ** COMMAND: all
83 **
84 ** Usage: %fossil all (list|ls|pull|push|rebuild|sync)
@@ -89,10 +119,11 @@
119 Stmt q;
120 const char *zCmd;
121 char *zSyscmd;
122 char *zFossil;
123 char *zQFilename;
124 const char *zExtra = "";
125 int useCheckouts = 0;
126 int quiet = 0;
127 int testRun = 0;
128 int stopOnError = find_option("dontstop",0,0)==0;
129 int rc;
@@ -117,10 +148,12 @@
148 zCmd = "push -autourl -R";
149 }else if( strncmp(zCmd, "pull", n)==0 ){
150 zCmd = "pull -autourl -R";
151 }else if( strncmp(zCmd, "rebuild", n)==0 ){
152 zCmd = "rebuild";
153 zExtra = collect_arguments("cluster","compress","noverify","+pagesize",
154 "vacuum","deanalyze","wal","stats", 0);
155 }else if( strncmp(zCmd, "sync", n)==0 ){
156 zCmd = "sync -autourl -R";
157 }else if( strncmp(zCmd, "test-integrity", n)==0 ){
158 zCmd = "test-integrity";
159 }else if( strncmp(zCmd, "changes", n)==0 ){
@@ -180,11 +213,11 @@
213 if( zCmd[0]=='l' ){
214 fossil_print("%s\n", zFilename);
215 continue;
216 }
217 zQFilename = quoteFilename(zFilename);
218 zSyscmd = mprintf("%s %s %s%s", zFossil, zCmd, zQFilename, zExtra);
219 if( !quiet || testRun ){
220 fossil_print("%s\n", zSyscmd);
221 fflush(stdout);
222 }
223 rc = testRun ? 0 : fossil_system(zSyscmd);
224
--- src/rebuild.c
+++ src/rebuild.c
@@ -523,10 +523,11 @@
523523
** --force Force the rebuild to complete even if errors are seen
524524
** --noverify Skip the verification of changes to the BLOB table
525525
** --pagesize N Set the database pagesize to N. (512..65536 and power of 2)
526526
** --randomize Scan artifacts in a random order
527527
** --vacuum Run VACUUM on the database after rebuilding
528
+** --deanalyze Remove ANALYZE tables from the database
528529
** --wal Set Write-Ahead-Log journalling mode on the database
529530
** --stats Show artifact statistics after rebuilding
530531
**
531532
** See also: deconstruct, reconstruct
532533
*/
@@ -538,18 +539,20 @@
538539
int doClustering;
539540
const char *zPagesize;
540541
int newPagesize = 0;
541542
int activateWal;
542543
int runVacuum;
544
+ int runDeanalyze;
543545
int runCompress;
544546
int showStats;
545547
546548
omitVerify = find_option("noverify",0,0)!=0;
547549
forceFlag = find_option("force","f",0)!=0;
548550
randomizeFlag = find_option("randomize", 0, 0)!=0;
549551
doClustering = find_option("cluster", 0, 0)!=0;
550552
runVacuum = find_option("vacuum",0,0)!=0;
553
+ runDeanalyze = find_option("deanalyze",0,0)!=0;
551554
runCompress = find_option("compress",0,0)!=0;
552555
zPagesize = find_option("pagesize",0,1);
553556
showStats = find_option("stats",0,0)!=0;
554557
if( zPagesize ){
555558
newPagesize = atoi(zPagesize);
@@ -598,10 +601,14 @@
598601
db_open_repository(g.zRepositoryName);
599602
if( newPagesize ){
600603
db_multi_exec("PRAGMA page_size=%d", newPagesize);
601604
runVacuum = 1;
602605
}
606
+ if( runDeanalyze ){
607
+ db_multi_exec("DROP TABLE IF EXISTS sqlite_stat1;"
608
+ "DROP TABLE IF EXISTS sqlite_stat3;");
609
+ }
603610
if( runVacuum ){
604611
fossil_print("Vacuuming the database... "); fflush(stdout);
605612
db_multi_exec("VACUUM");
606613
fossil_print("done\n");
607614
}
608615
--- src/rebuild.c
+++ src/rebuild.c
@@ -523,10 +523,11 @@
523 ** --force Force the rebuild to complete even if errors are seen
524 ** --noverify Skip the verification of changes to the BLOB table
525 ** --pagesize N Set the database pagesize to N. (512..65536 and power of 2)
526 ** --randomize Scan artifacts in a random order
527 ** --vacuum Run VACUUM on the database after rebuilding
 
528 ** --wal Set Write-Ahead-Log journalling mode on the database
529 ** --stats Show artifact statistics after rebuilding
530 **
531 ** See also: deconstruct, reconstruct
532 */
@@ -538,18 +539,20 @@
538 int doClustering;
539 const char *zPagesize;
540 int newPagesize = 0;
541 int activateWal;
542 int runVacuum;
 
543 int runCompress;
544 int showStats;
545
546 omitVerify = find_option("noverify",0,0)!=0;
547 forceFlag = find_option("force","f",0)!=0;
548 randomizeFlag = find_option("randomize", 0, 0)!=0;
549 doClustering = find_option("cluster", 0, 0)!=0;
550 runVacuum = find_option("vacuum",0,0)!=0;
 
551 runCompress = find_option("compress",0,0)!=0;
552 zPagesize = find_option("pagesize",0,1);
553 showStats = find_option("stats",0,0)!=0;
554 if( zPagesize ){
555 newPagesize = atoi(zPagesize);
@@ -598,10 +601,14 @@
598 db_open_repository(g.zRepositoryName);
599 if( newPagesize ){
600 db_multi_exec("PRAGMA page_size=%d", newPagesize);
601 runVacuum = 1;
602 }
 
 
 
 
603 if( runVacuum ){
604 fossil_print("Vacuuming the database... "); fflush(stdout);
605 db_multi_exec("VACUUM");
606 fossil_print("done\n");
607 }
608
--- src/rebuild.c
+++ src/rebuild.c
@@ -523,10 +523,11 @@
523 ** --force Force the rebuild to complete even if errors are seen
524 ** --noverify Skip the verification of changes to the BLOB table
525 ** --pagesize N Set the database pagesize to N. (512..65536 and power of 2)
526 ** --randomize Scan artifacts in a random order
527 ** --vacuum Run VACUUM on the database after rebuilding
528 ** --deanalyze Remove ANALYZE tables from the database
529 ** --wal Set Write-Ahead-Log journalling mode on the database
530 ** --stats Show artifact statistics after rebuilding
531 **
532 ** See also: deconstruct, reconstruct
533 */
@@ -538,18 +539,20 @@
539 int doClustering;
540 const char *zPagesize;
541 int newPagesize = 0;
542 int activateWal;
543 int runVacuum;
544 int runDeanalyze;
545 int runCompress;
546 int showStats;
547
548 omitVerify = find_option("noverify",0,0)!=0;
549 forceFlag = find_option("force","f",0)!=0;
550 randomizeFlag = find_option("randomize", 0, 0)!=0;
551 doClustering = find_option("cluster", 0, 0)!=0;
552 runVacuum = find_option("vacuum",0,0)!=0;
553 runDeanalyze = find_option("deanalyze",0,0)!=0;
554 runCompress = find_option("compress",0,0)!=0;
555 zPagesize = find_option("pagesize",0,1);
556 showStats = find_option("stats",0,0)!=0;
557 if( zPagesize ){
558 newPagesize = atoi(zPagesize);
@@ -598,10 +601,14 @@
601 db_open_repository(g.zRepositoryName);
602 if( newPagesize ){
603 db_multi_exec("PRAGMA page_size=%d", newPagesize);
604 runVacuum = 1;
605 }
606 if( runDeanalyze ){
607 db_multi_exec("DROP TABLE IF EXISTS sqlite_stat1;"
608 "DROP TABLE IF EXISTS sqlite_stat3;");
609 }
610 if( runVacuum ){
611 fossil_print("Vacuuming the database... "); fflush(stdout);
612 db_multi_exec("VACUUM");
613 fossil_print("done\n");
614 }
615

Keyboard Shortcuts

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