Fossil SCM

Add ANALYZE buttons to the /repo_schema page in cases where only a single table is being shown.

drh 2023-12-31 13:57 trunk
Commit e90fd9bef8f47f518e1df10b1b5e81ad2759cce2fcd81a509a5d8b7f8d367763
1 file changed +19 -2
+19 -2
--- src/stat.c
+++ src/stat.c
@@ -714,10 +714,21 @@
714714
Stmt q;
715715
Blob sql;
716716
const char *zArg = P("n");
717717
login_check_credentials();
718718
if( !g.perm.Admin ){ login_needed(0); return; }
719
+
720
+ if( zArg!=0
721
+ && db_table_exists("repository",zArg)
722
+ && cgi_csrf_safe(1)
723
+ ){
724
+ if( P("analyze")!=0 ){
725
+ db_multi_exec("ANALYZE \"%w\"", zArg);
726
+ }else if( P("analyze200")!=0 ){
727
+ db_multi_exec("PRAGMA analysis_limit=200; ANALYZE \"%w\"", zArg);
728
+ }
729
+ }
719730
720731
style_set_current_feature("stat");
721732
style_header("Repository Schema");
722733
style_adunit_config(ADUNIT_RIGHT_OK);
723734
style_submenu_element("Stat", "stat");
@@ -759,10 +770,16 @@
759770
db_finalize(&q);
760771
}else{
761772
style_submenu_element("Stat1","repo_stat1");
762773
}
763774
}
775
+ @ <hr><form method="POST">
776
+ @ <input type="submit" name="analyze" value="Run ANALYZE"><br />
777
+ @ <input type="submit" name="analyze200"\
778
+ @ value="Run ANALYZE with limit=200">
779
+ @ </form>
780
+
764781
style_finish_page();
765782
}
766783
767784
/*
768785
** WEBPAGE: repo_stat1
@@ -773,13 +790,13 @@
773790
int bTabular;
774791
login_check_credentials();
775792
if( !g.perm.Admin ){ login_needed(0); return; }
776793
bTabular = PB("tabular");
777794
778
- if( P("analyze")!=0 ){
795
+ if( P("analyze")!=0 && cgi_csrf_safe(1) ){
779796
db_multi_exec("ANALYZE");
780
- }else if( P("analyze200")!=0 ){
797
+ }else if( P("analyze200")!=0 && cgi_csrf_safe(1) ){
781798
db_multi_exec("PRAGMA analysis_limit=200; ANALYZE;");
782799
}
783800
style_set_current_feature("stat");
784801
style_header("Repository STAT1 Table");
785802
style_adunit_config(ADUNIT_RIGHT_OK);
786803
--- src/stat.c
+++ src/stat.c
@@ -714,10 +714,21 @@
714 Stmt q;
715 Blob sql;
716 const char *zArg = P("n");
717 login_check_credentials();
718 if( !g.perm.Admin ){ login_needed(0); return; }
 
 
 
 
 
 
 
 
 
 
 
719
720 style_set_current_feature("stat");
721 style_header("Repository Schema");
722 style_adunit_config(ADUNIT_RIGHT_OK);
723 style_submenu_element("Stat", "stat");
@@ -759,10 +770,16 @@
759 db_finalize(&q);
760 }else{
761 style_submenu_element("Stat1","repo_stat1");
762 }
763 }
 
 
 
 
 
 
764 style_finish_page();
765 }
766
767 /*
768 ** WEBPAGE: repo_stat1
@@ -773,13 +790,13 @@
773 int bTabular;
774 login_check_credentials();
775 if( !g.perm.Admin ){ login_needed(0); return; }
776 bTabular = PB("tabular");
777
778 if( P("analyze")!=0 ){
779 db_multi_exec("ANALYZE");
780 }else if( P("analyze200")!=0 ){
781 db_multi_exec("PRAGMA analysis_limit=200; ANALYZE;");
782 }
783 style_set_current_feature("stat");
784 style_header("Repository STAT1 Table");
785 style_adunit_config(ADUNIT_RIGHT_OK);
786
--- src/stat.c
+++ src/stat.c
@@ -714,10 +714,21 @@
714 Stmt q;
715 Blob sql;
716 const char *zArg = P("n");
717 login_check_credentials();
718 if( !g.perm.Admin ){ login_needed(0); return; }
719
720 if( zArg!=0
721 && db_table_exists("repository",zArg)
722 && cgi_csrf_safe(1)
723 ){
724 if( P("analyze")!=0 ){
725 db_multi_exec("ANALYZE \"%w\"", zArg);
726 }else if( P("analyze200")!=0 ){
727 db_multi_exec("PRAGMA analysis_limit=200; ANALYZE \"%w\"", zArg);
728 }
729 }
730
731 style_set_current_feature("stat");
732 style_header("Repository Schema");
733 style_adunit_config(ADUNIT_RIGHT_OK);
734 style_submenu_element("Stat", "stat");
@@ -759,10 +770,16 @@
770 db_finalize(&q);
771 }else{
772 style_submenu_element("Stat1","repo_stat1");
773 }
774 }
775 @ <hr><form method="POST">
776 @ <input type="submit" name="analyze" value="Run ANALYZE"><br />
777 @ <input type="submit" name="analyze200"\
778 @ value="Run ANALYZE with limit=200">
779 @ </form>
780
781 style_finish_page();
782 }
783
784 /*
785 ** WEBPAGE: repo_stat1
@@ -773,13 +790,13 @@
790 int bTabular;
791 login_check_credentials();
792 if( !g.perm.Admin ){ login_needed(0); return; }
793 bTabular = PB("tabular");
794
795 if( P("analyze")!=0 && cgi_csrf_safe(1) ){
796 db_multi_exec("ANALYZE");
797 }else if( P("analyze200")!=0 && cgi_csrf_safe(1) ){
798 db_multi_exec("PRAGMA analysis_limit=200; ANALYZE;");
799 }
800 style_set_current_feature("stat");
801 style_header("Repository STAT1 Table");
802 style_adunit_config(ADUNIT_RIGHT_OK);
803

Keyboard Shortcuts

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