Fossil SCM

Add a page (admin access only) to show the repository schema. Fix a bug in the "Last Rebuilt" display.

drh 2013-11-19 18:49 trunk
Commit 3ea94847d19c078df177de8de9813116f5fb2463
2 files changed -5 +27 -2
-5
--- src/db.c
+++ src/db.c
@@ -1805,15 +1805,10 @@
18051805
char *db_get_mtime(const char *zName, char *zFormat, char *zDefault){
18061806
char *z = 0;
18071807
if( g.repositoryOpen ){
18081808
z = db_text(0, "SELECT mtime FROM config WHERE name=%Q", zName);
18091809
}
1810
- if( z==0 && g.zConfigDbName ){
1811
- db_swap_connections();
1812
- z = db_text(0, "SELECT mtime FROM global_config WHERE name=%Q", zName);
1813
- db_swap_connections();
1814
- }
18151810
if( z==0 ){
18161811
z = zDefault;
18171812
}else if( zFormat!=0 ){
18181813
z = db_text(0, "SELECT strftime(%Q,%Q,'unixepoch');", zFormat, z);
18191814
}
18201815
--- src/db.c
+++ src/db.c
@@ -1805,15 +1805,10 @@
1805 char *db_get_mtime(const char *zName, char *zFormat, char *zDefault){
1806 char *z = 0;
1807 if( g.repositoryOpen ){
1808 z = db_text(0, "SELECT mtime FROM config WHERE name=%Q", zName);
1809 }
1810 if( z==0 && g.zConfigDbName ){
1811 db_swap_connections();
1812 z = db_text(0, "SELECT mtime FROM global_config WHERE name=%Q", zName);
1813 db_swap_connections();
1814 }
1815 if( z==0 ){
1816 z = zDefault;
1817 }else if( zFormat!=0 ){
1818 z = db_text(0, "SELECT strftime(%Q,%Q,'unixepoch');", zFormat, z);
1819 }
1820
--- src/db.c
+++ src/db.c
@@ -1805,15 +1805,10 @@
1805 char *db_get_mtime(const char *zName, char *zFormat, char *zDefault){
1806 char *z = 0;
1807 if( g.repositoryOpen ){
1808 z = db_text(0, "SELECT mtime FROM config WHERE name=%Q", zName);
1809 }
 
 
 
 
 
1810 if( z==0 ){
1811 z = zDefault;
1812 }else if( zFormat!=0 ){
1813 z = db_text(0, "SELECT strftime(%Q,%Q,'unixepoch');", zFormat, z);
1814 }
1815
+27 -2
--- src/stat.c
+++ src/stat.c
@@ -55,10 +55,11 @@
5555
if( !g.perm.Read ){ login_needed(); return; }
5656
brief = P("brief")!=0;
5757
style_header("Repository Statistics");
5858
if( g.perm.Admin ){
5959
style_submenu_element("URLs", "URLs and Checkouts", "urllist");
60
+ style_submenu_element("Schema", "Repository Schema", "repo_schema");
6061
}
6162
@ <table class="label-value">
6263
@ <tr><th>Repository&nbsp;Size:</th><td>
6364
fsize = file_size(g.zRepositoryName);
6465
bigSizeName(sizeof(zBuf), zBuf, fsize);
@@ -237,12 +238,10 @@
237238
db_text(0, "PRAGMA %s.encoding", zDb),
238239
db_text(0, "PRAGMA %s.journal_mode", zDb));
239240
240241
}
241242
242
-
243
-
244243
/*
245244
** WEBPAGE: urllist
246245
**
247246
** Show ways in which this repository has been accessed
248247
*/
@@ -252,10 +251,11 @@
252251
login_check_credentials();
253252
if( !g.perm.Admin ){ login_needed(); return; }
254253
255254
style_header("URLs and Checkouts");
256255
style_submenu_element("Stat", "Repository Stats", "stat");
256
+ style_submenu_element("Schema", "Repository Schema", "repo_schema");
257257
@ <div class="section">URLs</div>
258258
@ <table border="0" width='100%%'>
259259
db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')"
260260
" FROM config WHERE name GLOB 'baseurl:*' ORDER BY 2 DESC");
261261
cnt = 0;
@@ -284,5 +284,30 @@
284284
@ <tr><td>(none)</td>
285285
}
286286
@ </table>
287287
style_footer();
288288
}
289
+
290
+/*
291
+** WEBPAGE: repo_schema
292
+**
293
+** Show the repository schema
294
+*/
295
+void repo_schema_page(void){
296
+ Stmt q;
297
+ int cnt;
298
+ login_check_credentials();
299
+ if( !g.perm.Admin ){ login_needed(); return; }
300
+
301
+ style_header("Repository Schema");
302
+ style_submenu_element("Stat", "Repository Stats", "stat");
303
+ style_submenu_element("URLs", "URLs and Checkouts", "urllist");
304
+ db_prepare(&q, "SELECT sql FROM %s.sqlite_master WHERE sql IS NOT NULL",
305
+ db_name("repository"));
306
+ @ <pre>
307
+ while( db_step(&q)==SQLITE_ROW ){
308
+ @ %h(db_column_text(&q, 0));
309
+ }
310
+ @ </pre>
311
+ db_finalize(&q);
312
+ style_footer();
313
+}
289314
--- src/stat.c
+++ src/stat.c
@@ -55,10 +55,11 @@
55 if( !g.perm.Read ){ login_needed(); return; }
56 brief = P("brief")!=0;
57 style_header("Repository Statistics");
58 if( g.perm.Admin ){
59 style_submenu_element("URLs", "URLs and Checkouts", "urllist");
 
60 }
61 @ <table class="label-value">
62 @ <tr><th>Repository&nbsp;Size:</th><td>
63 fsize = file_size(g.zRepositoryName);
64 bigSizeName(sizeof(zBuf), zBuf, fsize);
@@ -237,12 +238,10 @@
237 db_text(0, "PRAGMA %s.encoding", zDb),
238 db_text(0, "PRAGMA %s.journal_mode", zDb));
239
240 }
241
242
243
244 /*
245 ** WEBPAGE: urllist
246 **
247 ** Show ways in which this repository has been accessed
248 */
@@ -252,10 +251,11 @@
252 login_check_credentials();
253 if( !g.perm.Admin ){ login_needed(); return; }
254
255 style_header("URLs and Checkouts");
256 style_submenu_element("Stat", "Repository Stats", "stat");
 
257 @ <div class="section">URLs</div>
258 @ <table border="0" width='100%%'>
259 db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')"
260 " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 2 DESC");
261 cnt = 0;
@@ -284,5 +284,30 @@
284 @ <tr><td>(none)</td>
285 }
286 @ </table>
287 style_footer();
288 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
--- src/stat.c
+++ src/stat.c
@@ -55,10 +55,11 @@
55 if( !g.perm.Read ){ login_needed(); return; }
56 brief = P("brief")!=0;
57 style_header("Repository Statistics");
58 if( g.perm.Admin ){
59 style_submenu_element("URLs", "URLs and Checkouts", "urllist");
60 style_submenu_element("Schema", "Repository Schema", "repo_schema");
61 }
62 @ <table class="label-value">
63 @ <tr><th>Repository&nbsp;Size:</th><td>
64 fsize = file_size(g.zRepositoryName);
65 bigSizeName(sizeof(zBuf), zBuf, fsize);
@@ -237,12 +238,10 @@
238 db_text(0, "PRAGMA %s.encoding", zDb),
239 db_text(0, "PRAGMA %s.journal_mode", zDb));
240
241 }
242
 
 
243 /*
244 ** WEBPAGE: urllist
245 **
246 ** Show ways in which this repository has been accessed
247 */
@@ -252,10 +251,11 @@
251 login_check_credentials();
252 if( !g.perm.Admin ){ login_needed(); return; }
253
254 style_header("URLs and Checkouts");
255 style_submenu_element("Stat", "Repository Stats", "stat");
256 style_submenu_element("Schema", "Repository Schema", "repo_schema");
257 @ <div class="section">URLs</div>
258 @ <table border="0" width='100%%'>
259 db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch')"
260 " FROM config WHERE name GLOB 'baseurl:*' ORDER BY 2 DESC");
261 cnt = 0;
@@ -284,5 +284,30 @@
284 @ <tr><td>(none)</td>
285 }
286 @ </table>
287 style_footer();
288 }
289
290 /*
291 ** WEBPAGE: repo_schema
292 **
293 ** Show the repository schema
294 */
295 void repo_schema_page(void){
296 Stmt q;
297 int cnt;
298 login_check_credentials();
299 if( !g.perm.Admin ){ login_needed(); return; }
300
301 style_header("Repository Schema");
302 style_submenu_element("Stat", "Repository Stats", "stat");
303 style_submenu_element("URLs", "URLs and Checkouts", "urllist");
304 db_prepare(&q, "SELECT sql FROM %s.sqlite_master WHERE sql IS NOT NULL",
305 db_name("repository"));
306 @ <pre>
307 while( db_step(&q)==SQLITE_ROW ){
308 @ %h(db_column_text(&q, 0));
309 }
310 @ </pre>
311 db_finalize(&q);
312 style_footer();
313 }
314

Keyboard Shortcuts

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