Fossil SCM
Add a pre-packaged CONFIG table query to the administrator SQL interface.
Commit
6a679311bba2a26e01b1500ac5f4f6735838376889ff26fde5bb3d36f873a5ba
Parent
3ca935ef556ef2d…
1 file changed
+18
-2
+18
-2
| --- src/setup.c | ||
| +++ src/setup.c | ||
| @@ -1995,10 +1995,11 @@ | ||
| 1995 | 1995 | style_header("Raw SQL Commands"); |
| 1996 | 1996 | @ <p><b>Caution:</b> There are no restrictions on the SQL that can be |
| 1997 | 1997 | @ run by this page. You can do serious and irrepairable damage to the |
| 1998 | 1998 | @ repository. Proceed with extreme caution.</p> |
| 1999 | 1999 | @ |
| 2000 | +#if 0 | |
| 2000 | 2001 | @ <p>Only the first statement in the entry box will be run. |
| 2001 | 2002 | @ Any subsequent statements will be silently ignored.</p> |
| 2002 | 2003 | @ |
| 2003 | 2004 | @ <p>Database names:<ul><li>repository |
| 2004 | 2005 | if( g.zConfigDbName ){ |
| @@ -2006,22 +2007,37 @@ | ||
| 2006 | 2007 | } |
| 2007 | 2008 | if( g.localOpen ){ |
| 2008 | 2009 | @ <li>localdb |
| 2009 | 2010 | } |
| 2010 | 2011 | @ </ul></p> |
| 2012 | +#endif | |
| 2013 | + | |
| 2014 | + if( P("configtab") ){ | |
| 2015 | + /* If the user presses the "CONFIG Table Query" button, populate the | |
| 2016 | + ** query text with a pre-packaged query against the CONFIG table */ | |
| 2017 | + zQ = "SELECT\n" | |
| 2018 | + " CASE WHEN length(name)<50 THEN name ELSE printf('%.50s...',name) END AS name,\n" | |
| 2019 | + " CASE WHEN typeof(value)<>'blob' AND length(value)<80 THEN value\n" | |
| 2020 | + " ELSE '...' END AS value,\n" | |
| 2021 | + " datetime(mtime, 'unixepoch') AS mtime\n" | |
| 2022 | + "FROM config\n" | |
| 2023 | + "-- ORDER BY mtime DESC; -- optional"; | |
| 2024 | + go = 1; | |
| 2025 | + } | |
| 2011 | 2026 | @ |
| 2012 | 2027 | @ <form method="post" action="%s(g.zTop)/admin_sql"> |
| 2013 | 2028 | login_insert_csrf_secret(); |
| 2014 | 2029 | @ SQL:<br /> |
| 2015 | - @ <textarea name="q" rows="5" cols="80">%h(zQ)</textarea><br /> | |
| 2030 | + @ <textarea name="q" rows="8" cols="80">%h(zQ)</textarea><br /> | |
| 2016 | 2031 | @ <input type="submit" name="go" value="Run SQL"> |
| 2017 | 2032 | @ <input type="submit" name="schema" value="Show Schema"> |
| 2018 | 2033 | @ <input type="submit" name="tablelist" value="List Tables"> |
| 2034 | + @ <input type="submit" name="configtab" value="CONFIG Table Query"> | |
| 2019 | 2035 | @ </form> |
| 2020 | 2036 | if( P("schema") ){ |
| 2021 | 2037 | zQ = sqlite3_mprintf( |
| 2022 | - "SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL"); | |
| 2038 | + "SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL ORDER BY name"); | |
| 2023 | 2039 | go = 1; |
| 2024 | 2040 | }else if( P("tablelist") ){ |
| 2025 | 2041 | zQ = sqlite3_mprintf( |
| 2026 | 2042 | "SELECT name FROM repository.sqlite_master WHERE type='table'" |
| 2027 | 2043 | " ORDER BY name"); |
| 2028 | 2044 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -1995,10 +1995,11 @@ | |
| 1995 | style_header("Raw SQL Commands"); |
| 1996 | @ <p><b>Caution:</b> There are no restrictions on the SQL that can be |
| 1997 | @ run by this page. You can do serious and irrepairable damage to the |
| 1998 | @ repository. Proceed with extreme caution.</p> |
| 1999 | @ |
| 2000 | @ <p>Only the first statement in the entry box will be run. |
| 2001 | @ Any subsequent statements will be silently ignored.</p> |
| 2002 | @ |
| 2003 | @ <p>Database names:<ul><li>repository |
| 2004 | if( g.zConfigDbName ){ |
| @@ -2006,22 +2007,37 @@ | |
| 2006 | } |
| 2007 | if( g.localOpen ){ |
| 2008 | @ <li>localdb |
| 2009 | } |
| 2010 | @ </ul></p> |
| 2011 | @ |
| 2012 | @ <form method="post" action="%s(g.zTop)/admin_sql"> |
| 2013 | login_insert_csrf_secret(); |
| 2014 | @ SQL:<br /> |
| 2015 | @ <textarea name="q" rows="5" cols="80">%h(zQ)</textarea><br /> |
| 2016 | @ <input type="submit" name="go" value="Run SQL"> |
| 2017 | @ <input type="submit" name="schema" value="Show Schema"> |
| 2018 | @ <input type="submit" name="tablelist" value="List Tables"> |
| 2019 | @ </form> |
| 2020 | if( P("schema") ){ |
| 2021 | zQ = sqlite3_mprintf( |
| 2022 | "SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL"); |
| 2023 | go = 1; |
| 2024 | }else if( P("tablelist") ){ |
| 2025 | zQ = sqlite3_mprintf( |
| 2026 | "SELECT name FROM repository.sqlite_master WHERE type='table'" |
| 2027 | " ORDER BY name"); |
| 2028 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -1995,10 +1995,11 @@ | |
| 1995 | style_header("Raw SQL Commands"); |
| 1996 | @ <p><b>Caution:</b> There are no restrictions on the SQL that can be |
| 1997 | @ run by this page. You can do serious and irrepairable damage to the |
| 1998 | @ repository. Proceed with extreme caution.</p> |
| 1999 | @ |
| 2000 | #if 0 |
| 2001 | @ <p>Only the first statement in the entry box will be run. |
| 2002 | @ Any subsequent statements will be silently ignored.</p> |
| 2003 | @ |
| 2004 | @ <p>Database names:<ul><li>repository |
| 2005 | if( g.zConfigDbName ){ |
| @@ -2006,22 +2007,37 @@ | |
| 2007 | } |
| 2008 | if( g.localOpen ){ |
| 2009 | @ <li>localdb |
| 2010 | } |
| 2011 | @ </ul></p> |
| 2012 | #endif |
| 2013 | |
| 2014 | if( P("configtab") ){ |
| 2015 | /* If the user presses the "CONFIG Table Query" button, populate the |
| 2016 | ** query text with a pre-packaged query against the CONFIG table */ |
| 2017 | zQ = "SELECT\n" |
| 2018 | " CASE WHEN length(name)<50 THEN name ELSE printf('%.50s...',name) END AS name,\n" |
| 2019 | " CASE WHEN typeof(value)<>'blob' AND length(value)<80 THEN value\n" |
| 2020 | " ELSE '...' END AS value,\n" |
| 2021 | " datetime(mtime, 'unixepoch') AS mtime\n" |
| 2022 | "FROM config\n" |
| 2023 | "-- ORDER BY mtime DESC; -- optional"; |
| 2024 | go = 1; |
| 2025 | } |
| 2026 | @ |
| 2027 | @ <form method="post" action="%s(g.zTop)/admin_sql"> |
| 2028 | login_insert_csrf_secret(); |
| 2029 | @ SQL:<br /> |
| 2030 | @ <textarea name="q" rows="8" cols="80">%h(zQ)</textarea><br /> |
| 2031 | @ <input type="submit" name="go" value="Run SQL"> |
| 2032 | @ <input type="submit" name="schema" value="Show Schema"> |
| 2033 | @ <input type="submit" name="tablelist" value="List Tables"> |
| 2034 | @ <input type="submit" name="configtab" value="CONFIG Table Query"> |
| 2035 | @ </form> |
| 2036 | if( P("schema") ){ |
| 2037 | zQ = sqlite3_mprintf( |
| 2038 | "SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL ORDER BY name"); |
| 2039 | go = 1; |
| 2040 | }else if( P("tablelist") ){ |
| 2041 | zQ = sqlite3_mprintf( |
| 2042 | "SELECT name FROM repository.sqlite_master WHERE type='table'" |
| 2043 | " ORDER BY name"); |
| 2044 |