Fossil SCM

Add a pre-packaged CONFIG table query to the administrator SQL interface.

drh 2017-07-03 20:04 trunk
Commit 6a679311bba2a26e01b1500ac5f4f6735838376889ff26fde5bb3d36f873a5ba
1 file changed +18 -2
+18 -2
--- src/setup.c
+++ src/setup.c
@@ -1995,10 +1995,11 @@
19951995
style_header("Raw SQL Commands");
19961996
@ <p><b>Caution:</b> There are no restrictions on the SQL that can be
19971997
@ run by this page. You can do serious and irrepairable damage to the
19981998
@ repository. Proceed with extreme caution.</p>
19991999
@
2000
+#if 0
20002001
@ <p>Only the first statement in the entry box will be run.
20012002
@ Any subsequent statements will be silently ignored.</p>
20022003
@
20032004
@ <p>Database names:<ul><li>repository
20042005
if( g.zConfigDbName ){
@@ -2006,22 +2007,37 @@
20062007
}
20072008
if( g.localOpen ){
20082009
@ <li>localdb
20092010
}
20102011
@ </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
+ }
20112026
@
20122027
@ <form method="post" action="%s(g.zTop)/admin_sql">
20132028
login_insert_csrf_secret();
20142029
@ 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 />
20162031
@ <input type="submit" name="go" value="Run SQL">
20172032
@ <input type="submit" name="schema" value="Show Schema">
20182033
@ <input type="submit" name="tablelist" value="List Tables">
2034
+ @ <input type="submit" name="configtab" value="CONFIG Table Query">
20192035
@ </form>
20202036
if( P("schema") ){
20212037
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");
20232039
go = 1;
20242040
}else if( P("tablelist") ){
20252041
zQ = sqlite3_mprintf(
20262042
"SELECT name FROM repository.sqlite_master WHERE type='table'"
20272043
" ORDER BY name");
20282044
--- 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

Keyboard Shortcuts

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