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".
Commit
85233c40c9bb05a87574cdc25402ec0d34b0b7ee
Parent
60b409322ade042…
2 files changed
+34
-1
+7
+34
-1
| --- src/allrepo.c | ||
| +++ src/allrepo.c | ||
| @@ -45,10 +45,40 @@ | ||
| 45 | 45 | }else{ |
| 46 | 46 | return mprintf("%s", zFilename); |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 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 | + | |
| 50 | 80 | |
| 51 | 81 | /* |
| 52 | 82 | ** COMMAND: all |
| 53 | 83 | ** |
| 54 | 84 | ** Usage: %fossil all (list|ls|pull|push|rebuild|sync) |
| @@ -89,10 +119,11 @@ | ||
| 89 | 119 | Stmt q; |
| 90 | 120 | const char *zCmd; |
| 91 | 121 | char *zSyscmd; |
| 92 | 122 | char *zFossil; |
| 93 | 123 | char *zQFilename; |
| 124 | + const char *zExtra = ""; | |
| 94 | 125 | int useCheckouts = 0; |
| 95 | 126 | int quiet = 0; |
| 96 | 127 | int testRun = 0; |
| 97 | 128 | int stopOnError = find_option("dontstop",0,0)==0; |
| 98 | 129 | int rc; |
| @@ -117,10 +148,12 @@ | ||
| 117 | 148 | zCmd = "push -autourl -R"; |
| 118 | 149 | }else if( strncmp(zCmd, "pull", n)==0 ){ |
| 119 | 150 | zCmd = "pull -autourl -R"; |
| 120 | 151 | }else if( strncmp(zCmd, "rebuild", n)==0 ){ |
| 121 | 152 | zCmd = "rebuild"; |
| 153 | + zExtra = collect_arguments("cluster","compress","noverify","+pagesize", | |
| 154 | + "vacuum","deanalyze","wal","stats", 0); | |
| 122 | 155 | }else if( strncmp(zCmd, "sync", n)==0 ){ |
| 123 | 156 | zCmd = "sync -autourl -R"; |
| 124 | 157 | }else if( strncmp(zCmd, "test-integrity", n)==0 ){ |
| 125 | 158 | zCmd = "test-integrity"; |
| 126 | 159 | }else if( strncmp(zCmd, "changes", n)==0 ){ |
| @@ -180,11 +213,11 @@ | ||
| 180 | 213 | if( zCmd[0]=='l' ){ |
| 181 | 214 | fossil_print("%s\n", zFilename); |
| 182 | 215 | continue; |
| 183 | 216 | } |
| 184 | 217 | zQFilename = quoteFilename(zFilename); |
| 185 | - zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename); | |
| 218 | + zSyscmd = mprintf("%s %s %s%s", zFossil, zCmd, zQFilename, zExtra); | |
| 186 | 219 | if( !quiet || testRun ){ |
| 187 | 220 | fossil_print("%s\n", zSyscmd); |
| 188 | 221 | fflush(stdout); |
| 189 | 222 | } |
| 190 | 223 | rc = testRun ? 0 : fossil_system(zSyscmd); |
| 191 | 224 |
| --- 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 |
+7
| --- src/rebuild.c | ||
| +++ src/rebuild.c | ||
| @@ -523,10 +523,11 @@ | ||
| 523 | 523 | ** --force Force the rebuild to complete even if errors are seen |
| 524 | 524 | ** --noverify Skip the verification of changes to the BLOB table |
| 525 | 525 | ** --pagesize N Set the database pagesize to N. (512..65536 and power of 2) |
| 526 | 526 | ** --randomize Scan artifacts in a random order |
| 527 | 527 | ** --vacuum Run VACUUM on the database after rebuilding |
| 528 | +** --deanalyze Remove ANALYZE tables from the database | |
| 528 | 529 | ** --wal Set Write-Ahead-Log journalling mode on the database |
| 529 | 530 | ** --stats Show artifact statistics after rebuilding |
| 530 | 531 | ** |
| 531 | 532 | ** See also: deconstruct, reconstruct |
| 532 | 533 | */ |
| @@ -538,18 +539,20 @@ | ||
| 538 | 539 | int doClustering; |
| 539 | 540 | const char *zPagesize; |
| 540 | 541 | int newPagesize = 0; |
| 541 | 542 | int activateWal; |
| 542 | 543 | int runVacuum; |
| 544 | + int runDeanalyze; | |
| 543 | 545 | int runCompress; |
| 544 | 546 | int showStats; |
| 545 | 547 | |
| 546 | 548 | omitVerify = find_option("noverify",0,0)!=0; |
| 547 | 549 | forceFlag = find_option("force","f",0)!=0; |
| 548 | 550 | randomizeFlag = find_option("randomize", 0, 0)!=0; |
| 549 | 551 | doClustering = find_option("cluster", 0, 0)!=0; |
| 550 | 552 | runVacuum = find_option("vacuum",0,0)!=0; |
| 553 | + runDeanalyze = find_option("deanalyze",0,0)!=0; | |
| 551 | 554 | runCompress = find_option("compress",0,0)!=0; |
| 552 | 555 | zPagesize = find_option("pagesize",0,1); |
| 553 | 556 | showStats = find_option("stats",0,0)!=0; |
| 554 | 557 | if( zPagesize ){ |
| 555 | 558 | newPagesize = atoi(zPagesize); |
| @@ -598,10 +601,14 @@ | ||
| 598 | 601 | db_open_repository(g.zRepositoryName); |
| 599 | 602 | if( newPagesize ){ |
| 600 | 603 | db_multi_exec("PRAGMA page_size=%d", newPagesize); |
| 601 | 604 | runVacuum = 1; |
| 602 | 605 | } |
| 606 | + if( runDeanalyze ){ | |
| 607 | + db_multi_exec("DROP TABLE IF EXISTS sqlite_stat1;" | |
| 608 | + "DROP TABLE IF EXISTS sqlite_stat3;"); | |
| 609 | + } | |
| 603 | 610 | if( runVacuum ){ |
| 604 | 611 | fossil_print("Vacuuming the database... "); fflush(stdout); |
| 605 | 612 | db_multi_exec("VACUUM"); |
| 606 | 613 | fossil_print("done\n"); |
| 607 | 614 | } |
| 608 | 615 |
| --- 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 |