Fossil SCM
Add the "gather_artifact_stats()" SQL function to the "fossil sql" command. This function invokes the gather_artifact_stats() C-language routine in order to populate the temporary ARTSTAT table.
Commit
6e890f737f0337f6b685d13ca7382a37d2c51723ec5617bf9538943900d41b45
Parent
88b8df356b46893…
2 files changed
+15
+1
-1
+15
| --- src/sqlcmd.c | ||
| +++ src/sqlcmd.c | ||
| @@ -124,10 +124,23 @@ | ||
| 124 | 124 | }else{ |
| 125 | 125 | sqlite3_free(pOut); |
| 126 | 126 | sqlite3_result_error(context, "input is not zlib compressed", -1); |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | + | |
| 130 | +/* | |
| 131 | +** Implementation of the "gather_artifact_stats(X)" SQL function. | |
| 132 | +** That function merely calls the gather_artifact_stats() function | |
| 133 | +** in stat.c to populate the ARTSTAT temporary table. | |
| 134 | +*/ | |
| 135 | +static void sqlcmd_gather_artifact_stats( | |
| 136 | + sqlite3_context *context, | |
| 137 | + int argc, | |
| 138 | + sqlite3_value **argv | |
| 139 | +){ | |
| 140 | + gather_artifact_stats(1); | |
| 141 | +} | |
| 129 | 142 | |
| 130 | 143 | /* |
| 131 | 144 | ** Add the content(), compress(), and decompress() SQL functions to |
| 132 | 145 | ** database connection db. |
| 133 | 146 | */ |
| @@ -136,10 +149,12 @@ | ||
| 136 | 149 | sqlcmd_content, 0, 0); |
| 137 | 150 | sqlite3_create_function(db, "compress", 1, SQLITE_UTF8, 0, |
| 138 | 151 | sqlcmd_compress, 0, 0); |
| 139 | 152 | sqlite3_create_function(db, "decompress", 1, SQLITE_UTF8, 0, |
| 140 | 153 | sqlcmd_decompress, 0, 0); |
| 154 | + sqlite3_create_function(db, "gather_artifact_stats", 0, SQLITE_UTF8, 0, | |
| 155 | + sqlcmd_gather_artifact_stats, 0, 0); | |
| 141 | 156 | return SQLITE_OK; |
| 142 | 157 | } |
| 143 | 158 | |
| 144 | 159 | /* |
| 145 | 160 | ** This is the "automatic extension" initializer that runs right after |
| 146 | 161 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -124,10 +124,23 @@ | |
| 124 | }else{ |
| 125 | sqlite3_free(pOut); |
| 126 | sqlite3_result_error(context, "input is not zlib compressed", -1); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | /* |
| 131 | ** Add the content(), compress(), and decompress() SQL functions to |
| 132 | ** database connection db. |
| 133 | */ |
| @@ -136,10 +149,12 @@ | |
| 136 | sqlcmd_content, 0, 0); |
| 137 | sqlite3_create_function(db, "compress", 1, SQLITE_UTF8, 0, |
| 138 | sqlcmd_compress, 0, 0); |
| 139 | sqlite3_create_function(db, "decompress", 1, SQLITE_UTF8, 0, |
| 140 | sqlcmd_decompress, 0, 0); |
| 141 | return SQLITE_OK; |
| 142 | } |
| 143 | |
| 144 | /* |
| 145 | ** This is the "automatic extension" initializer that runs right after |
| 146 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -124,10 +124,23 @@ | |
| 124 | }else{ |
| 125 | sqlite3_free(pOut); |
| 126 | sqlite3_result_error(context, "input is not zlib compressed", -1); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | /* |
| 131 | ** Implementation of the "gather_artifact_stats(X)" SQL function. |
| 132 | ** That function merely calls the gather_artifact_stats() function |
| 133 | ** in stat.c to populate the ARTSTAT temporary table. |
| 134 | */ |
| 135 | static void sqlcmd_gather_artifact_stats( |
| 136 | sqlite3_context *context, |
| 137 | int argc, |
| 138 | sqlite3_value **argv |
| 139 | ){ |
| 140 | gather_artifact_stats(1); |
| 141 | } |
| 142 | |
| 143 | /* |
| 144 | ** Add the content(), compress(), and decompress() SQL functions to |
| 145 | ** database connection db. |
| 146 | */ |
| @@ -136,10 +149,12 @@ | |
| 149 | sqlcmd_content, 0, 0); |
| 150 | sqlite3_create_function(db, "compress", 1, SQLITE_UTF8, 0, |
| 151 | sqlcmd_compress, 0, 0); |
| 152 | sqlite3_create_function(db, "decompress", 1, SQLITE_UTF8, 0, |
| 153 | sqlcmd_decompress, 0, 0); |
| 154 | sqlite3_create_function(db, "gather_artifact_stats", 0, SQLITE_UTF8, 0, |
| 155 | sqlcmd_gather_artifact_stats, 0, 0); |
| 156 | return SQLITE_OK; |
| 157 | } |
| 158 | |
| 159 | /* |
| 160 | ** This is the "automatic extension" initializer that runs right after |
| 161 |
+1
-1
| --- src/stat.c | ||
| +++ src/stat.c | ||
| @@ -659,11 +659,11 @@ | ||
| 659 | 659 | /* |
| 660 | 660 | ** Gather statistics on artifact types, counts, and sizes. |
| 661 | 661 | ** |
| 662 | 662 | ** Only populate the artstat.atype field if the bWithTypes parameter is true. |
| 663 | 663 | */ |
| 664 | -static void gather_artifact_stats(int bWithTypes){ | |
| 664 | +void gather_artifact_stats(int bWithTypes){ | |
| 665 | 665 | static const char zSql[] = |
| 666 | 666 | @ CREATE TEMP TABLE artstat( |
| 667 | 667 | @ id INTEGER PRIMARY KEY, -- Corresponds to BLOB.RID |
| 668 | 668 | @ atype TEXT, -- 'data', 'manifest', 'tag', 'wiki', etc. |
| 669 | 669 | @ isDelta BOOLEAN, -- true if stored as a delta |
| 670 | 670 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -659,11 +659,11 @@ | |
| 659 | /* |
| 660 | ** Gather statistics on artifact types, counts, and sizes. |
| 661 | ** |
| 662 | ** Only populate the artstat.atype field if the bWithTypes parameter is true. |
| 663 | */ |
| 664 | static void gather_artifact_stats(int bWithTypes){ |
| 665 | static const char zSql[] = |
| 666 | @ CREATE TEMP TABLE artstat( |
| 667 | @ id INTEGER PRIMARY KEY, -- Corresponds to BLOB.RID |
| 668 | @ atype TEXT, -- 'data', 'manifest', 'tag', 'wiki', etc. |
| 669 | @ isDelta BOOLEAN, -- true if stored as a delta |
| 670 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -659,11 +659,11 @@ | |
| 659 | /* |
| 660 | ** Gather statistics on artifact types, counts, and sizes. |
| 661 | ** |
| 662 | ** Only populate the artstat.atype field if the bWithTypes parameter is true. |
| 663 | */ |
| 664 | void gather_artifact_stats(int bWithTypes){ |
| 665 | static const char zSql[] = |
| 666 | @ CREATE TEMP TABLE artstat( |
| 667 | @ id INTEGER PRIMARY KEY, -- Corresponds to BLOB.RID |
| 668 | @ atype TEXT, -- 'data', 'manifest', 'tag', 'wiki', etc. |
| 669 | @ isDelta BOOLEAN, -- true if stored as a delta |
| 670 |