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.

drh 2020-03-12 00:44 trunk
Commit 6e890f737f0337f6b685d13ca7382a37d2c51723ec5617bf9538943900d41b45
2 files changed +15 +1 -1
+15
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -124,10 +124,23 @@
124124
}else{
125125
sqlite3_free(pOut);
126126
sqlite3_result_error(context, "input is not zlib compressed", -1);
127127
}
128128
}
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
+}
129142
130143
/*
131144
** Add the content(), compress(), and decompress() SQL functions to
132145
** database connection db.
133146
*/
@@ -136,10 +149,12 @@
136149
sqlcmd_content, 0, 0);
137150
sqlite3_create_function(db, "compress", 1, SQLITE_UTF8, 0,
138151
sqlcmd_compress, 0, 0);
139152
sqlite3_create_function(db, "decompress", 1, SQLITE_UTF8, 0,
140153
sqlcmd_decompress, 0, 0);
154
+ sqlite3_create_function(db, "gather_artifact_stats", 0, SQLITE_UTF8, 0,
155
+ sqlcmd_gather_artifact_stats, 0, 0);
141156
return SQLITE_OK;
142157
}
143158
144159
/*
145160
** This is the "automatic extension" initializer that runs right after
146161
--- 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 @@
659659
/*
660660
** Gather statistics on artifact types, counts, and sizes.
661661
**
662662
** Only populate the artstat.atype field if the bWithTypes parameter is true.
663663
*/
664
-static void gather_artifact_stats(int bWithTypes){
664
+void gather_artifact_stats(int bWithTypes){
665665
static const char zSql[] =
666666
@ CREATE TEMP TABLE artstat(
667667
@ id INTEGER PRIMARY KEY, -- Corresponds to BLOB.RID
668668
@ atype TEXT, -- 'data', 'manifest', 'tag', 'wiki', etc.
669669
@ isDelta BOOLEAN, -- true if stored as a delta
670670
--- 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

Keyboard Shortcuts

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