Fossil SCM
Add ANALYZE buttons to the /repo_schema page in cases where only a single table is being shown.
Commit
e90fd9bef8f47f518e1df10b1b5e81ad2759cce2fcd81a509a5d8b7f8d367763
Parent
349fb1fa16e7875…
1 file changed
+19
-2
+19
-2
| --- src/stat.c | ||
| +++ src/stat.c | ||
| @@ -714,10 +714,21 @@ | ||
| 714 | 714 | Stmt q; |
| 715 | 715 | Blob sql; |
| 716 | 716 | const char *zArg = P("n"); |
| 717 | 717 | login_check_credentials(); |
| 718 | 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 | + } | |
| 719 | 730 | |
| 720 | 731 | style_set_current_feature("stat"); |
| 721 | 732 | style_header("Repository Schema"); |
| 722 | 733 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 723 | 734 | style_submenu_element("Stat", "stat"); |
| @@ -759,10 +770,16 @@ | ||
| 759 | 770 | db_finalize(&q); |
| 760 | 771 | }else{ |
| 761 | 772 | style_submenu_element("Stat1","repo_stat1"); |
| 762 | 773 | } |
| 763 | 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 | + | |
| 764 | 781 | style_finish_page(); |
| 765 | 782 | } |
| 766 | 783 | |
| 767 | 784 | /* |
| 768 | 785 | ** WEBPAGE: repo_stat1 |
| @@ -773,13 +790,13 @@ | ||
| 773 | 790 | int bTabular; |
| 774 | 791 | login_check_credentials(); |
| 775 | 792 | if( !g.perm.Admin ){ login_needed(0); return; } |
| 776 | 793 | bTabular = PB("tabular"); |
| 777 | 794 | |
| 778 | - if( P("analyze")!=0 ){ | |
| 795 | + if( P("analyze")!=0 && cgi_csrf_safe(1) ){ | |
| 779 | 796 | db_multi_exec("ANALYZE"); |
| 780 | - }else if( P("analyze200")!=0 ){ | |
| 797 | + }else if( P("analyze200")!=0 && cgi_csrf_safe(1) ){ | |
| 781 | 798 | db_multi_exec("PRAGMA analysis_limit=200; ANALYZE;"); |
| 782 | 799 | } |
| 783 | 800 | style_set_current_feature("stat"); |
| 784 | 801 | style_header("Repository STAT1 Table"); |
| 785 | 802 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 786 | 803 |
| --- 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 |