summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume (ioguix) de Rorthais2010-04-05 20:56:34 +0000
committerGuillaume (ioguix) de Rorthais2010-04-05 20:56:34 +0000
commit674b6ec6df7f6e5e1fa1fcd10a36f8f2f1d4c2e4 (patch)
tree6d8364e4ad89d5c9dd911381e056b8347120b7ab
parent433b5f87ef84efaa484ff759417318a32add8de1 (diff)
Refactor admin page, adding it in table level, fixes and support for autovacuum per table for pg 8.4+
-rw-r--r--admin.php638
-rw-r--r--classes/Misc.php6
-rwxr-xr-xclasses/database/Postgres.php171
-rw-r--r--classes/database/Postgres73.php1
-rw-r--r--classes/database/Postgres80.php1
-rw-r--r--classes/database/Postgres83.php167
-rwxr-xr-xdatabase.php339
-rw-r--r--lang/english.php27
-rw-r--r--lang/recoded/english.php27
-rw-r--r--tables.php163
10 files changed, 1031 insertions, 509 deletions
diff --git a/admin.php b/admin.php
new file mode 100644
index 00000000..60f546f5
--- /dev/null
+++ b/admin.php
@@ -0,0 +1,638 @@
+<?php
+
+ $script = ''; // init global value script
+
+ /**
+ * Show confirmation of reindex and perform reindex
+ */
+ function doReindex($type, $confirm=false) {
+ global $script, $data, $misc, $lang, $_reload_browser;
+
+ if (($type == 'table') && empty($_REQUEST['table']) && empty($_REQUEST['ma'])) {
+ doDefault($lang['strspecifytabletoreindex']);
+ return;
+ }
+
+ if ($confirm) {
+ if (isset($_REQUEST['ma'])) {
+ $misc->printTrail('schema');
+ $misc->printTitle($lang['strreindex'], 'pg.reindex');
+
+ echo "<form action=\"{$script}\" method=\"post\">\n";
+ foreach($_REQUEST['ma'] as $v) {
+ $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES));
+ echo "<p>", sprintf($lang['strconfreindextable'], $misc->printVal($a['table'])), "</p>\n";
+ echo "<input type=\"hidden\" name=\"table[]\" value=\"", htmlspecialchars($a['table']), "\" />\n";
+ }
+ } // END if multi reindex
+ else {
+ $misc->printTrail($type);
+ $misc->printTitle($lang['strreindex'], 'pg.reindex');
+
+ echo "<form action=\"{$script}\" method=\"post\">\n";
+
+ if ($type == 'table') {
+ echo "<p>", sprintf($lang['strconfreindextable'], $misc->printVal($_REQUEST['object'])), "</p>\n";
+ echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['object']), "\" />\n";
+ }
+ else {
+ echo "<p>", sprintf($lang['strconfreindexdatabase'], $misc->printVal($_REQUEST['object'])), "</p>\n";
+ echo "<input type=\"hidden\" name=\"table\" value=\"\" />\n";
+ }
+ }
+ echo "<input type=\"hidden\" name=\"action\" value=\"reindex\" />\n";
+
+ if ($data->hasForceReindex())
+ echo "<p><input type=\"checkbox\" id=\"reindex_force\" name=\"reindex_force\" /><label for=\"reindex_force\">{$lang['strforce']}</label></p>\n";
+
+ echo $misc->form;
+
+ echo "<input type=\"submit\" name=\"reindex\" value=\"{$lang['strreindex']}\" />\n"; //TODO
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
+ echo "</form>\n";
+ } // END single reindex
+ else {
+ //If multi table reindex
+ if (($type == 'table') && is_array($_REQUEST['table'])) {
+ $msg='';
+ foreach($_REQUEST['table'] as $o) {
+ $status = $data->reindex(strtoupper($type), $o, isset($_REQUEST['reindex_force']));
+ if ($status == 0)
+ $msg.= sprintf('%s: %s<br />', htmlentities($o), $lang['strreindexgood']);
+ else {
+ doDefault($type, sprintf('%s%s: %s<br />', $msg, htmlentities($o), $lang['strreindexbad']));
+ return;
+ }
+ }
+ // Everything went fine, back to the Default page....
+ $_reload_browser = true;
+ doDefault($msg);
+ }
+ else {
+ $status = $data->reindex(strtoupper($type), $_REQUEST['object'], isset($_REQUEST['reindex_force']));
+ if ($status == 0) {
+ $_reload_browser = true;
+ doAdmin($type, $lang['strreindexgood']);
+ }
+ else
+ doAdmin($type, $lang['strreindexbad']);
+ }
+ }
+ }
+
+ /**
+ * Show confirmation of analyze and perform analyze
+ */
+ function doAnalyze($type, $confirm=false) {
+ global $script, $data, $misc, $lang, $_reload_browser;
+
+ if (($type == 'table') && empty($_REQUEST['table']) && empty($_REQUEST['ma'])) {
+ doDefault($lang['strspecifytabletoanalyze']);
+ return;
+ }
+
+ if ($confirm) {
+ if (isset($_REQUEST['ma'])) {
+ $misc->printTrail('schema');
+ $misc->printTitle($lang['stranalyze'], 'pg.analyze');
+
+ echo "<form action=\"{$script}\" method=\"post\">\n";
+ foreach($_REQUEST['ma'] as $v) {
+ $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES));
+ echo "<p>", sprintf($lang['strconfanalyzetable'], $misc->printVal($a['table'])), "</p>\n";
+ echo "<input type=\"hidden\" name=\"table[]\" value=\"", htmlspecialchars($a['table']), "\" />\n";
+ }
+ } // END if multi analyze
+ else {
+ $misc->printTrail($type);
+ $misc->printTitle($lang['stranalyze'], 'pg.analyze');
+
+ echo "<form action=\"{$script}\" method=\"post\">\n";
+
+ if ($type == 'table') {
+ echo "<p>", sprintf($lang['strconfanalyzetable'], $misc->printVal($_REQUEST['object'])), "</p>\n";
+ echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['object']), "\" />\n";
+ }
+ else {
+ echo "<p>", sprintf($lang['strconfanalyzedatabase'], $misc->printVal($_REQUEST['object'])), "</p>\n";
+ echo "<input type=\"hidden\" name=\"table\" value=\"\" />\n";
+ }
+ }
+ echo "<input type=\"hidden\" name=\"action\" value=\"analyze\" />\n";
+ echo $misc->form;
+
+ echo "<input type=\"submit\" name=\"analyze\" value=\"{$lang['stranalyze']}\" />\n"; //TODO
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
+ echo "</form>\n";
+ } // END single analyze
+ else {
+ //If multi table analyze
+ if (($type == 'table') && is_array($_REQUEST['table'])) {
+ $msg='';
+ foreach($_REQUEST['table'] as $o) {
+ $status = $data->analyzeDB($o);
+ if ($status == 0)
+ $msg.= sprintf('%s: %s<br />', htmlentities($o), $lang['stranalyzegood']);
+ else {
+ doDefault($type, sprintf('%s%s: %s<br />', $msg, htmlentities($o), $lang['stranalyzebad']));
+ return;
+ }
+ }
+ // Everything went fine, back to the Default page....
+ $_reload_browser = true;
+ doDefault($msg);
+ }
+ else {
+ //we must pass table here. When empty, analyze the whole db
+ $status = $data->analyzeDB($_REQUEST['table']);
+ if ($status == 0) {
+ $_reload_browser = true;
+ doAdmin($type, $lang['stranalyzegood']);
+ }
+ else
+ doAdmin($type, $lang['stranalyzebad']);
+ }
+ }
+ }
+
+ /**
+ * Show confirmation of vacuum and perform actual vacuum
+ */
+ function doVacuum($type, $confirm = false) {
+ global $script, $data, $misc, $lang, $_reload_browser;
+
+ if (($type == 'table') && empty($_REQUEST['table']) && empty($_REQUEST['ma'])) {
+ doDefault($lang['strspecifytabletovacuum']);
+ return;
+ }
+
+ if ($confirm) {
+ if (isset($_REQUEST['ma'])) {
+ $misc->printTrail('schema');
+ $misc->printTitle($lang['strvacuum'], 'pg.vacuum');
+
+ echo "<form action=\"{$script}\" method=\"post\">\n";
+ foreach($_REQUEST['ma'] as $v) {
+ $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES));
+ echo "<p>", sprintf($lang['strconfvacuumtable'], $misc->printVal($a['table'])), "</p>\n";
+ echo "<input type=\"hidden\" name=\"table[]\" value=\"", htmlspecialchars($a['table']), "\" />\n";
+ }
+ } // END if multi vacuum
+ else {
+ $misc->printTrail($type);
+ $misc->printTitle($lang['strvacuum'], 'pg.vacuum');
+
+ echo "<form action=\"{$script}\" method=\"post\">\n";
+
+ if ($type == 'table') {
+ echo "<p>", sprintf($lang['strconfvacuumtable'], $misc->printVal($_REQUEST['object'])), "</p>\n";
+ echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['object']), "\" />\n";
+ }
+ else {
+ echo "<p>", sprintf($lang['strconfvacuumdatabase'], $misc->printVal($_REQUEST['object'])), "</p>\n";
+ echo "<input type=\"hidden\" name=\"table\" value=\"\" />\n";
+ }
+ }
+ echo "<input type=\"hidden\" name=\"action\" value=\"vacuum\" />\n";
+ echo $misc->form;
+ echo "<p><input type=\"checkbox\" id=\"vacuum_full\" name=\"vacuum_full\" /> <label for=\"vacuum_full\">{$lang['strfull']}</label></p>\n";
+ echo "<p><input type=\"checkbox\" id=\"vacuum_analyze\" name=\"vacuum_analyze\" /> <label for=\"vacuum_analyze\">{$lang['stranalyze']}</label></p>\n";
+ echo "<p><input type=\"checkbox\" id=\"vacuum_freeze\" name=\"vacuum_freeze\" /><label for=\"vacuum_freeze\">{$lang['strfreeze']}</label></p>\n";
+ echo "<input type=\"submit\" name=\"vacuum\" value=\"{$lang['strvacuum']}\" />\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
+ echo "</form>\n";
+ } // END single vacuum
+ else {
+ //If multi drop
+ if (is_array($_REQUEST['table'])) {
+ $msg='';
+ foreach($_REQUEST['table'] as $t) {
+ $status = $data->vacuumDB($t, isset($_REQUEST['vacuum_analyze']), isset($_REQUEST['vacuum_full']), isset($_REQUEST['vacuum_freeze']));
+ if ($status == 0)
+ $msg.= sprintf('%s: %s<br />', htmlentities($t), $lang['strvacuumgood']);
+ else {
+ doDefault($type, sprintf('%s%s: %s<br />', $msg, htmlentities($t), $lang['strvacuumbad']));
+ return;
+ }
+ }
+ // Everything went fine, back to the Default page....
+ $_reload_browser = true;
+ doDefault($msg);
+ }
+ else {
+ //we must pass table here. When empty, vacuum the whole db
+ $status = $data->vacuumDB($_REQUEST['table'], isset($_REQUEST['vacuum_analyze']), isset($_REQUEST['vacuum_full']), isset($_REQUEST['vacuum_freeze']));
+ if ($status == 0) {
+ $_reload_browser = true;
+ doAdmin($type, $lang['strvacuumgood']);
+ }
+ else
+ doAdmin($type, $lang['strvacuumbad']);
+ }
+ }
+ }
+
+ /**
+ * Add or Edit autovacuum params and save them
+ */
+ function doEditAutovacuum($type, $confirm, $msg='') {
+ global $script, $data, $misc, $lang;
+
+ if (empty($_REQUEST['table'])) {
+ doAdmin($type, '', $lang['strspecifyeditvacuumtable']);
+ return;
+ }
+
+ $script = ($type == 'database')? 'database.php' : 'tables.php';
+
+ if ($confirm) {
+ $misc->printTrail($type);
+ $misc->printTitle(sprintf($lang['streditvacuumtable'], $misc->printVal($_REQUEST['table'])));
+ $misc->printMsg(sprintf($msg, $misc->printVal($_REQUEST['table'])));
+
+ if (empty($_REQUEST['table'])) {
+ doAdmin($type, '', $lang['strspecifyeditvacuumtable']);
+ return;
+ }
+
+ $old_val = $data->getTableAutovacuum($_REQUEST['table']);
+ $defaults = $data->getAutovacuum();
+ $old_val = $old_val->fields;
+
+ if (isset($old_val['autovacuum_enabled']) and ($old_val['autovacuum_enabled'] == 'off')) {
+ $enabled = '';
+ $disabled = 'checked="checked"';
+ }
+ else {
+ $enabled = 'checked="checked"';
+ $disabled = '';
+ }
+
+ if (!isset($old_val['autovacuum_vacuum_threshold'])) $old_val['autovacuum_vacuum_threshold'] = '';
+ if (!isset($old_val['autovacuum_vacuum_scale_factor'])) $old_val['autovacuum_vacuum_scale_factor'] = '';
+ if (!isset($old_val['autovacuum_analyze_threshold'])) $old_val['autovacuum_analyze_threshold'] = '';
+ if (!isset($old_val['autovacuum_analyze_scale_factor'])) $old_val['autovacuum_analyze_scale_factor'] = '';
+ if (!isset($old_val['autovacuum_vacuum_cost_delay'])) $old_val['autovacuum_vacuum_cost_delay'] = '';
+ if (!isset($old_val['autovacuum_vacuum_cost_limit'])) $old_val['autovacuum_vacuum_cost_limit'] = '';
+
+ echo "<form action=\"{$script}\" method=\"post\">\n";
+ echo $misc->form;
+ echo "<input type=\"hidden\" name=\"action\" value=\"editautovac\" />\n";
+ echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
+
+ echo "<br />\n<br />\n<table>\n";
+ echo "\t<tr><td>&nbsp;</td>\n";
+ echo "<th class=\"data\">{$lang['strnewvalues']}</th><th class=\"data\">{$lang['strdefaultvalues']}</th></tr>\n";
+ echo "\t<tr><th class=\"data left\">{$lang['strenable']}</th>\n";
+ echo "<td class=\"data1\">\n";
+ echo "<label for=\"on\">on</label><input type=\"radio\" name=\"autovacuum_enabled\" id=\"on\" value=\"on\" {$enabled} />\n";
+ echo "<label for=\"off\">off</label><input type=\"radio\" name=\"autovacuum_enabled\" id=\"off\" value=\"off\" {$disabled} /></td>\n";
+ echo "<th class=\"data left\">{$defaults['autovacuum']}</th></tr>\n";
+ echo "\t<tr><th class=\"data left\">{$lang['strvacuumbasethreshold']}</th>\n";
+ echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_vacuum_threshold\" value=\"{$old_val['autovacuum_vacuum_threshold']}\" /></td>\n";
+ echo "<th class=\"data left\">{$defaults['autovacuum_vacuum_threshold']}</th></tr>\n";
+ echo "\t<tr><th class=\"data left\">{$lang['strvacuumscalefactor']}</th>\n";
+ echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_vacuum_scale_factor\" value=\"{$old_val['autovacuum_vacuum_scale_factor']}\" /></td>\n";
+ echo "<th class=\"data left\">{$defaults['autovacuum_vacuum_scale_factor']}</th></tr>\n";
+ echo "\t<tr><th class=\"data left\">{$lang['stranalybasethreshold']}</th>\n";
+ echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_analyze_threshold\" value=\"{$old_val['autovacuum_analyze_threshold']}\" /></td>\n";
+ echo "<th class=\"data left\">{$defaults['autovacuum_analyze_threshold']}</th></tr>\n";
+ echo "\t<tr><th class=\"data left\">{$lang['stranalyzescalefactor']}</th>\n";
+ echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_analyze_scale_factor\" value=\"{$old_val['autovacuum_analyze_scale_factor']}\" /></td>\n";
+ echo "<th class=\"data left\">{$defaults['autovacuum_analyze_scale_factor']}</th></tr>\n";
+ echo "\t<tr><th class=\"data left\">{$lang['strvacuumcostdelay']}</th>\n";
+ echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_vacuum_cost_delay\" value=\"{$old_val['autovacuum_vacuum_cost_delay']}\" /></td>\n";
+ echo "<th class=\"data left\">{$defaults['autovacuum_vacuum_cost_delay']}</th></tr>\n";
+ echo "\t<tr><th class=\"data left\">{$lang['strvacuumcostlimit']}</th>\n";
+ echo "<td class=\"datat1\"><input type=\"text\" name=\"autovacuum_vacuum_cost_limit\" value=\"{$old_val['autovacuum_vacuum_cost_limit']}\" /></td>\n";
+ echo "<th class=\"data left\">{$defaults['autovacuum_vacuum_cost_limit']}</th></tr>\n";
+ echo "</table>\n";
+ echo "<br />";
+ echo "<br />";
+ echo "<input type=\"submit\" name=\"save\" value=\"{$lang['strsave']}\" />\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
+
+ echo "</form>\n";
+ }
+ else {
+ $status = $data->saveAutovacuum($_REQUEST['table'], $_POST['autovacuum_enabled'], $_POST['autovacuum_vacuum_threshold'],
+ $_POST['autovacuum_vacuum_scale_factor'], $_POST['autovacuum_analyze_threshold'], $_POST['autovacuum_analyze_scale_factor'],
+ $_POST['autovacuum_vacuum_cost_delay'], $_POST['autovacuum_vacuum_cost_limit']);
+
+ if ($status == 0)
+ doAdmin($type, '', sprintf($lang['strsetvacuumtablesaved'], $_REQUEST['table']));
+ else
+ doEditAutovacuum($type, true, $lang['strsetvacuumtablefail']);
+ }
+ }
+
+ /**
+ * confirm drop autovacuum params for a table and drop it
+ */
+ function doDropAutovacuum($type, $confirm) {
+ global $script, $data, $misc, $lang;
+
+ if (empty($_REQUEST['table'])) {
+ doAdmin($type, '', $lang['strspecifydelvacuumtable']);
+ return;
+ }
+
+ if ($confirm) {
+ $misc->printTrail($type);
+ $misc->printTabs($type,'admin');
+
+ $script = ($type == 'database')? 'database.php' : 'tables.php';
+
+ printf("<p>{$lang['strdelvacuumtable']}</p>\n",
+ $misc->printVal("\"{$_GET['schema']}"."{$_GET['table']}\""));
+
+ echo "<form style=\"float: left\" action=\"{$script}\" method=\"post\">\n";
+ echo "<input type=\"hidden\" name=\"action\" value=\"delautovac\" />\n";
+ echo $misc->form;
+ echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
+ echo "<input type=\"hidden\" name=\"rel\" value=\"", htmlspecialchars(serialize(array($_REQUEST['schema'], $_REQUEST['table']))), "\" />\n";
+ echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" />\n";
+ echo "</form>\n";
+
+ echo "<form action=\"{$script}\" method=\"post\">\n";
+ echo "<input type=\"hidden\" name=\"action\" value=\"admin\" />\n";
+ echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
+ echo $misc->form;
+ echo "<input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\" />\n";
+ echo "</form>\n";
+ }
+ else {
+
+ $status = $data->dropAutovacuum($_POST['table']);
+
+ if ($status == 0) {
+ doAdmin($type, '', sprintf($lang['strvacuumtablereset'], $misc->printVal($_POST['table'])));
+ }
+ else
+ doAdmin($type, '', sprintf($lang['strdelvacuumtablefail'], $misc->printVal($_POST['table'])));
+ }
+ }
+
+ /**
+ * database/table administration and tuning tasks
+ *
+ * $Id: admin.php
+ */
+
+ function doAdmin($type, $msg = '') {
+ global $script, $data, $misc, $lang;
+
+ $misc->printTrail($type);
+ $misc->printTabs($type,'admin');
+ $misc->printMsg($msg);
+
+ if ($type == 'database')
+ printf("<p>{$lang['stradminondatabase']}</p>\n", $misc->printVal($_REQUEST['object']));
+ else
+ printf("<p>{$lang['stradminontable']}</p>\n", $misc->printVal($_REQUEST['object']));
+
+ echo "<table style=\"width: 50%\">\n";
+ echo "<tr>\n";
+ echo "<th class=\"data\">";
+ $misc->printHelp($lang['strvacuum'],'pg.admin.vacuum')."</th>\n";
+ echo "</th>";
+ echo "<th class=\"data\">";
+ $misc->printHelp($lang['stranalyze'],'pg.admin.analyze');
+ echo "</th>";
+ if ($data->hasRecluster()){
+ echo "<th class=\"data\">";
+ $misc->printHelp($lang['strclusterindex'],'pg.index.cluster');
+ echo "</th>";
+ }
+ echo "<th class=\"data\">";
+ $misc->printHelp($lang['strreindex'],'pg.index.reindex');
+ echo "</th>";
+ echo "</tr>";
+
+ // Vacuum
+ echo "<tr>\n";
+ echo "<td class=\"data1\" style=\"text-align: center; vertical-align: bottom\">\n";
+ echo "<form action=\"{$script}\" method=\"post\">\n";
+
+ echo "<p><input type=\"hidden\" name=\"action\" value=\"confirm_vacuum\" />\n";
+ echo $misc->form;
+ if ($type == 'table') {
+ echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['object']), "\" />\n";
+ echo "<input type=\"hidden\" name=\"subject\" value=\"table\" />\n";
+ }
+ echo "<input type=\"submit\" value=\"{$lang['strvacuum']}\" /></p>\n";
+ echo "</form>\n";
+ echo "</td>\n";
+
+ // Analyze
+ echo "<td class=\"data1\" style=\"text-align: center; vertical-align: bottom\">\n";
+ echo "<form action=\"{$script}\" method=\"post\">\n";
+ echo "<p><input type=\"hidden\" name=\"action\" value=\"confirm_analyze\" />\n";
+ echo $misc->form;
+ if ($type == 'table') {
+ echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['object']), "\" />\n";
+ echo "<input type=\"hidden\" name=\"subject\" value=\"table\" />\n";
+ }
+ echo "<input type=\"submit\" value=\"{$lang['stranalyze']}\" /></p>\n";
+ echo "</form>\n";
+ echo "</td>\n";
+
+ // Recluster
+ if ($data->hasRecluster()){
+ echo "<td class=\"data1\" style=\"text-align: center; vertical-align: bottom\">\n";
+ echo "<form action=\"{$script}\" method=\"post\">\n";
+ echo "<p><input type=\"hidden\" name=\"action\" value=\"recluster\" />\n";
+ echo $misc->form;
+ if ($type == 'table') {
+ echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($table), "\" />\n";
+ echo "<input type=\"hidden\" name=\"subject\" value=\"table\" />\n";
+ }
+ echo "<input type=\"submit\" value=\"{$lang['strclusterindex']}\" /></p>\n";
+ echo "</form>\n";
+ echo "</td>\n";
+ }
+
+ // Reindex
+ echo "<td class=\"data1\" style=\"text-align: center; vertical-align: bottom\">\n";
+ echo "<form action=\"{$script}\" method=\"post\">\n";
+ echo "<p><input type=\"hidden\" name=\"action\" value=\"confirm_reindex\" />\n";
+ echo $misc->form;
+ if ($type == 'table') {
+ echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['object']), "\" />\n";
+ echo "<input type=\"hidden\" name=\"subject\" value=\"table\" />\n";
+ }
+ echo "<input type=\"submit\" value=\"{$lang['strreindex']}\" /></p>\n";
+ echo "</form>\n";
+ echo "</td>\n";
+ echo "</tr>\n";
+ echo "</table>\n";
+
+ // Autovacuum
+ if($data->hasAutovacuum()) {
+ // get defaults values for autovacuum
+ $defaults = $data->getAutovacuum();
+ // Fetch the autovacuum properties from the database or table if != ''
+ if ($type == 'table') $autovac = $data->getTableAutovacuum($_REQUEST['table']);
+ else $autovac = $data->getTableAutovacuum();
+
+ echo "<br /><br /><h2>{$lang['strvacuumpertable']}</h2>";
+ echo '<p>' . (($defaults->fields['autovacuum'] == 'on') ? $lang['strturnedon'] : $lang['strturnedoff'] ) . '</p>';
+ echo "<p class=\"message\">{$lang['strnotdefaultinred']}</p>";
+
+ function enlight($f, $p) {
+ if ( isset($f[$p[0]]) and ($f[$p[0]] != $p[1]))
+ return "<span style=\"color:#F33;font-weight:bold\">". htmlspecialchars($f[$p[0]]) ."</span>";
+ return htmlspecialchars($p[1]);
+ }
+
+ $columns = array(
+ 'namespace' => array(
+ 'title' => $lang['strschema'],
+ 'field' => field('nspname'),
+ ),
+ 'relname' => array(
+ 'title' => $lang['strtable'],
+ 'field' => field('relname'),
+ ),
+ 'autovacuum_enabled' => array(
+ 'title' => $lang['strenabled'],
+ 'field' => callback('enlight', array('autovacuum_enabled', $defaults['autovacuum'])),
+ 'type' => 'verbatim'
+ ),
+ 'autovacuum_vacuum_threshold' => array(
+ 'title' => $lang['strvacuumbasethreshold'],
+ 'field' => callback('enlight', array('autovacuum_vacuum_threshold', $defaults['autovacuum_vacuum_threshold'])),
+ 'type' => 'verbatim'
+ ),
+ 'autovacuum_vacuum_scale_factor' => array(
+ 'title' => $lang['strvacuumscalefactor'],
+ 'field' => callback('enlight', array('autovacuum_vacuum_scale_factor', $defaults['autovacuum_vacuum_scale_factor'])),
+ 'type' => 'verbatim'
+ ),
+ 'autovacuum_analyze_threshold' => array(
+ 'title' => $lang['stranalybasethreshold'],
+ 'field' => callback('enlight', array('autovacuum_analyze_threshold', $defaults['autovacuum_analyze_threshold'])),
+ 'type' => 'verbatim'
+ ),
+ 'autovacuum_analyze_scale_factor' => array(
+ 'title' => $lang['stranalyzescalefactor'],
+ 'field' => callback('enlight', array('autovacuum_analyze_scale_factor', $defaults['autovacuum_analyze_scale_factor'])),
+ 'type' => 'verbatim'
+ ),
+ 'autovacuum_vacuum_cost_delay' => array(
+ 'title' => $lang['strvacuumcostdelay'],
+ 'field' => concat(callback('enlight', array('autovacuum_vacuum_cost_delay', $defaults['autovacuum_vacuum_cost_delay'])), 'ms'),
+ 'type' => 'verbatim'
+ ),
+ 'autovacuum_vacuum_cost_limit' => array(
+ 'title' => $lang['strvacuumcostlimit'],
+ 'field' => callback('enlight', array('autovacuum_vacuum_cost_limit', $defaults['autovacuum_vacuum_cost_limit'])),
+ 'type' => 'verbatim'
+ ),
+ );
+
+ // Maybe we need to check permissions here?
+ $columns['actions'] = array('title' => $lang['stractions']);
+
+ $actions = array(
+ 'edit' => array(
+ 'title' => $lang['stredit'],
+ 'url' => "{$script}?action=confeditautovac&amp;{$misc->href}&amp;subject={$type}&amp;",
+ 'vars' => array(
+ 'schema' => 'nspname',
+ 'table' => 'relname'
+ )
+ ),
+ 'delete' => array(
+ 'title' => $lang['strdelete'],
+ 'url' => "{$script}?action=confdelautovac&amp;{$misc->href}&amp;subject={$type}&amp;",
+ 'vars' => array(
+ 'schema' => 'nspname',
+ 'table' => 'relname'
+ )
+ )
+ );
+
+ if ($type == 'table') {
+ unset($actions['edit']['vars']['schema'], $actions['delete']['vars']['schema']);
+ }
+
+ $misc->printTable($autovac, $columns, $actions, $lang['strnovacuumconf']);
+
+ if (($type == 'table') and ($autovac->recordCount() == 0)) {
+ echo "<br />";
+ echo "<a href=\"tables.php?action=confeditautovac&amp;{$misc->href}&amp;table=", htmlspecialchars($_REQUEST['table'])
+ ,"\">{$lang['straddvacuumtable']}</a>";
+ }
+ }
+ }
+
+ function adminActions($action, $type) {
+ global $script;
+
+ if ($type == 'database') {
+ $_REQUEST['object'] = $_REQUEST['database'];
+ $script = 'database.php';
+ }
+ else {
+ // $_REQUEST['table'] is no set if we are in the schema page
+ $_REQUEST['object'] = (isset($_REQUEST['table']) ? $_REQUEST['table']:'');
+ $script = 'tables.php';
+ }
+
+ switch ($action) {
+ //case 'confirm_recluster':
+ case 'confirm_reindex':
+ doReindex($type, true);
+ break;
+ case 'confirm_analyze':
+ doAnalyze($type, true);
+ break;
+ case 'confirm_vacuum':
+ doVacuum($type, true);
+ break;
+ //case 'recluster':
+ case 'reindex':
+ if (isset($_POST['reindex'])) doReindex($type);
+ // if multi-action from table canceled: back to the schema default page
+ else if (($type == 'table') && is_array($_REQUEST['object']) ) doDefault();
+ else doAdmin($type);
+ break;
+ case 'analyze':
+ if (isset($_POST['analyze'])) doAnalyze($type);
+ // if multi-action from table canceled: back to the schema default page
+ else if (($type == 'table') && is_array($_REQUEST['object']) ) doDefault();
+ else doAdmin($type);
+ break;
+ case 'vacuum':
+ if (isset($_POST['vacuum'])) doVacuum($type);
+ // if multi-action from table canceled: back to the schema default page
+ else if (($type == 'table') && is_array($_REQUEST['object']) ) doDefault();
+ else doAdmin($type);
+ break;
+ case 'admin':
+ doAdmin($type);
+ break;
+ case 'confeditautovac':
+ doEditAutovacuum($type, true);
+ break;
+ case 'confdelautovac':
+ doDropAutovacuum($type, true);
+ break;
+ case 'confaddautovac':
+ doAddAutovacuum(true);
+ break;
+ case 'editautovac':
+ if (isset($_POST['save'])) doEditAutovacuum($type, false);
+ else doAdmin($type);
+ break;
+ case 'delautovac':
+ doDropAutovacuum($type, false);
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
+
+?>
diff --git a/classes/Misc.php b/classes/Misc.php
index 69688881..67323b87 100644
--- a/classes/Misc.php
+++ b/classes/Misc.php
@@ -838,6 +838,12 @@
'icon' => 'Rules',
'branch'=> true,
),
+ 'admin' => array (
+ 'title' => $lang['stradmin'],
+ 'url' => 'tables.php',
+ 'urlvars' => array('subject' => 'table', 'table' => field('table'), 'action' => 'admin'),
+ 'icon' => 'Admin',
+ ),
'info' => array (
'title' => $lang['strinfo'],
'url' => 'info.php',
diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php
index e16cb087..817bc511 100755
--- a/classes/database/Postgres.php
+++ b/classes/database/Postgres.php
@@ -2370,6 +2370,66 @@ class Postgres extends ADODB_base {
return $this->selectSet("SELECT {$oid_str}* FROM \"{$relation}\"");
}
+
+ /**
+ * Returns all available autovacuum per table information.
+ * @param $table if given, return autovacuum info for the given table or return all informations for all table
+ *
+ * @return A recordset
+ */
+ function getTableAutovacuum($table='') {
+
+ $sql = '';
+
+ if ($table !== '') {
+ $this->clean($table);
+ $f_schema = $this->_schema;
+ $this->fieldClean($f_schema);
+
+ $sql = "SELECT c.oid, nspname, relname, pg_catalog.array_to_string(reloptions, E',') AS reloptions
+ FROM pg_class c
+ LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
+ WHERE c.relkind = 'r'::\"char\"
+ AND n.nspname NOT IN ('pg_catalog','information_schema')
+ AND c.reloptions IS NOT NULL
+ AND c.relname = '{$table}' AND n.nspname = '{$f_schema}'
+ ORDER BY nspname, relname";
+ }
+ else {
+ $sql = "SELECT c.oid, nspname, relname, pg_catalog.array_to_string(reloptions, E',') AS reloptions
+ FROM pg_class c
+ LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
+ WHERE c.relkind = 'r'::\"char\"
+ AND n.nspname NOT IN ('pg_catalog','information_schema')
+ AND c.reloptions IS NOT NULL
+ ORDER BY nspname, relname";
+
+ }
+
+ /* tmp var to parse the results */
+ $_autovacs = $this->selectSet($sql);
+
+ /* result aray to return as RS */
+ $autovacs = array();
+ while (!$_autovacs->EOF) {
+ $_ = array(
+ 'nspname' => $_autovacs->fields['nspname'],
+ 'relname' => $_autovacs->fields['relname']
+ );
+
+ foreach (explode(',', $_autovacs->fields['reloptions']) AS $var) {
+ list($o, $v) = explode('=', $var);
+ $_[$o] = $v;
+ }
+
+ $autovacs[] = $_;
+
+ $_autovacs->moveNext();
+ }
+
+ include_once('./classes/ArrayRecordSet.php');
+ return new ArrayRecordSet($autovacs);
+ }
// Row functions
@@ -2548,7 +2608,7 @@ class Postgres extends ADODB_base {
* @param $key An array mapping column => value to delete
* @return 0 success
*/
- function deleteRow($table, $key) {
+ function deleteRow($table, $key, $schema=false) {
if (!is_array($key)) return -1;
else {
// Begin transaction. We do this so that we can ensure only one row is
@@ -2558,8 +2618,10 @@ class Postgres extends ADODB_base {
$this->rollbackTransaction();
return -1;
}
+
+ if ($schema === false) $schema = $this->_schema;
- $status = $this->delete($table, $key, $this->_schema);
+ $status = $this->delete($table, $key, $schema);
if ($status != 0 || $this->conn->Affected_Rows() != 1) {
$this->rollbackTransaction();
return -2;
@@ -3292,7 +3354,7 @@ class Postgres extends ADODB_base {
$this->fieldClean($f_schema);
$this->fieldClean($index);
$this->fieldClean($table);
-
+
// We don't bother with a transaction here, as there's no point rolling
// back an expensive cluster if a cheap analyze fails for whatever reason
$sql = "CLUSTER \"{$f_schema}\".\"{$table}\" USING \"{$index}\"";
@@ -6929,7 +6991,6 @@ class Postgres extends ADODB_base {
/**
* Analyze a database
- * @note PostgreSQL 7.2 finally had an independent ANALYZE command
* @param $table (optional) The table to analyze
*/
function analyzeDB($table = '') {
@@ -6950,8 +7011,8 @@ class Postgres extends ADODB_base {
* Vacuums a database
* @param $table The table to vacuum
* @param $analyze If true, also does analyze
- * @param $full If true, selects "full" vacuum (PostgreSQL >= 7.2)
- * @param $freeze If true, selects aggressive "freezing" of tuples (PostgreSQL >= 7.2)
+ * @param $full If true, selects "full" vacuum
+ * @param $freeze If true, selects aggressive "freezing" of tuples
*/
function vacuumDB($table = '', $analyze = false, $full = false, $freeze = false) {
@@ -6970,19 +7031,93 @@ class Postgres extends ADODB_base {
}
/**
- * Returns all available process information.
- * @return A recordset
+ * Returns all autovacuum global configuration
+ * @return associative array array( param => value, ...)
*/
function getAutovacuum() {
- $sql = "
- SELECT vacrelid, nspname, relname, enabled, vac_base_thresh,
- vac_scale_factor, anl_base_thresh, anl_scale_factor, vac_cost_delay, vac_cost_limit
- FROM pg_autovacuum
- join pg_class on (oid=vacrelid)
- join pg_namespace on (oid=relnamespace)
- ORDER BY nspname, relname";
- return $this->selectSet($sql);
+ $_defaults = $this->selectSet("SELECT name, setting
+ FROM pg_catalog.pg_settings
+ WHERE
+ name = 'autovacuum'
+ OR name = 'autovacuum_vacuum_threshold'
+ OR name = 'autovacuum_vacuum_scale_factor'
+ OR name = 'autovacuum_analyze_threshold'
+ OR name = 'autovacuum_analyze_scale_factor'
+ OR name = 'autovacuum_vacuum_cost_delay'
+ OR name = 'autovacuum_vacuum_cost_limit'
+ OR name = 'vacuum_freeze_min_age'
+ OR name = 'autovacuum_freeze_max_age'
+ "
+ );
+
+ $ret = array();
+ while (!$_defaults->EOF) {
+ $ret[$_defaults->fields['name']] = $_defaults->fields['setting'];
+ $_defaults->moveNext();
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Returns all available autovacuum per table information.
+ * @return A recordset
+ */
+ function saveAutovacuum($table, $vacenabled, $vacthreshold, $vacscalefactor, $anathresold,
+ $anascalefactor, $vaccostdelay, $vaccostlimit)
+ {
+ $f_schema = $this->_schema;
+ $this->fieldClean($f_schema);
+ $this->fieldClean($table);
+
+ $sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" SET (";
+
+ if (!empty($vacenabled)) {
+ $this->clean($vacenabled);
+ $params[] = "autovacuum_enabled='{$vacenabled}'";
+ }
+ if (!empty($vacthreshold)) {
+ $this->clean($vacthreshold);
+ $params[] = "autovacuum_vacuum_threshold='{$vacthreshold}'";
+ }
+ if (!empty($vacscalefactor)) {
+ $this->clean($vacscalefactor);
+ $params[] = "autovacuum_vacuum_scale_factor='{$vacscalefactor}'";
+ }
+ if (!empty($anathresold)) {
+ $this->clean($anathresold);
+ $params[] = "autovacuum_analyze_threshold='{$anathresold}'";
+ }
+ if (!empty($anascalefactor)) {
+ $this->clean($anascalefactor);
+ $params[] = "autovacuum_analyze_scale_factor='{$anascalefactor}'";
+ }
+ if (!empty($vaccostdelay)) {
+ $this->clean($vaccostdelay);
+ $params[] = "autovacuum_vacuum_cost_delay='{$vaccostdelay}'";
+ }
+ if (!empty($vaccostlimit)) {
+ $this->clean($vaccostlimit);
+ $params[] = "autovacuum_vacuum_cost_limit='{$vaccostlimit}'";
+ }
+
+ $sql = $sql . implode(',', $params) . ');';
+
+ return $this->execute($sql);
+ }
+
+ function dropAutovacuum($table) {
+ $c_schema = $this->_schema;
+ $this->clean($c_schema);
+ $this->clean($table);
+
+ return $this->execute("
+ ALTER TABLE \"{$c_schema}\".\"{$table}\" RESET (autovacuum_enabled, autovacuum_vacuum_threshold,
+ autovacuum_vacuum_scale_factor, autovacuum_analyze_threshold, autovacuum_analyze_scale_factor,
+ autovacuum_vacuum_cost_delay, autovacuum_vacuum_cost_limit
+ );"
+ );
}
/**
@@ -7682,7 +7817,7 @@ class Postgres extends ADODB_base {
$sql = "SELECT * FROM pg_stat_database WHERE datname='{$database}'";
return $this->selectSet($sql);
- }
+ }
/**
* Fetches tuple statistics for a table
@@ -7762,7 +7897,6 @@ class Postgres extends ADODB_base {
function hasAlterSequenceSchema() { return true; }
function hasAlterTableSchema() { return true; }
function hasAutovacuum() { return true; }
- function hasAutovacuumSysTable() { return false; }
function hasCreateTableLike() { return true; }
function hasCreateTableLikeWithConstraints() { return true; }
function hasCreateTableLikeWithIndexes() { return true; }
@@ -7794,6 +7928,7 @@ class Postgres extends ADODB_base {
function hasMagicTypes() { return true; }
function hasQueryKill() { return true; }
function hasConcurrentIndexBuild() { return true; }
+ function hasForceReindex() { return false; }
}
?>
diff --git a/classes/database/Postgres73.php b/classes/database/Postgres73.php
index 11e141c6..dd806db1 100644
--- a/classes/database/Postgres73.php
+++ b/classes/database/Postgres73.php
@@ -545,6 +545,7 @@ class Postgres73 extends Postgres74 {
function hasReadOnlyQueries() { return false; }
function hasRecluster() { return false; }
function hasUserRename() { return false; }
+ function hasForceReindex() { return true; }
}
?>
diff --git a/classes/database/Postgres80.php b/classes/database/Postgres80.php
index c8da9f43..9e037c33 100644
--- a/classes/database/Postgres80.php
+++ b/classes/database/Postgres80.php
@@ -317,7 +317,6 @@ class Postgres80 extends Postgres81 {
function hasAggregateSortOp() { return false; }
function hasAlterTableSchema() { return false; }
function hasAutovacuum() { return false; }
- function hasAutovacuumSysTable() { return false; }
function hasDisableTriggers() { return false; }
function hasFunctionAlterSchema() { return false; }
function hasPreparedXacts() { return false; }
diff --git a/classes/database/Postgres83.php b/classes/database/Postgres83.php
index 9f26ad75..238d623e 100644
--- a/classes/database/Postgres83.php
+++ b/classes/database/Postgres83.php
@@ -100,7 +100,172 @@ class Postgres83 extends Postgres {
return $this->selectSet($sql);
}
- function hasAutovacuumSysTable() { return true; }
+ // Administration functions
+
+ /**
+ * Returns all available autovacuum per table information.
+ * @return A recordset
+ */
+ function getTableAutovacuum($table='') {
+ $sql = '';
+
+ if ($table !== '') {
+ $this->clean($table);
+ $f_schema = $this->_schema;
+ $this->fieldClean($f_schema);
+
+ $sql = "
+ SELECT vacrelid, nspname, relname,
+ CASE enabled
+ WHEN 't' THEN 'on'
+ ELSE 'off'
+ END AS autovacuum_enabled, vac_base_thresh AS autovacuum_vacuum_threshold,
+ vac_scale_factor AS autovacuum_vacuum_scale_factor, anl_base_thresh AS autovacuum_analyze_threshold,
+ anl_scale_factor AS autovacuum_analyze_scale_factor, vac_cost_delay AS autovacuum_vacuum_cost_delay,
+ vac_cost_limit AS autovacuum_vacuum_cost_limit
+ FROM pg_autovacuum AS a
+ join pg_class AS c on (c.oid=a.vacrelid)
+ join pg_namespace AS n on (n.oid=c.relnamespace)
+ WHERE c.relname = '{$table}' AND n.nspname = '{$f_schema}'
+ ORDER BY nspname, relname
+ ";
+ }
+ else {
+ $sql = "
+ SELECT vacrelid, nspname, relname,
+ CASE enabled
+ WHEN 't' THEN 'on'
+ ELSE 'off'
+ END AS autovacuum_enabled, vac_base_thresh AS autovacuum_vacuum_threshold,
+ vac_scale_factor AS autovacuum_vacuum_scale_factor, anl_base_thresh AS autovacuum_analyze_threshold,
+ anl_scale_factor AS autovacuum_analyze_scale_factor, vac_cost_delay AS autovacuum_vacuum_cost_delay,
+ vac_cost_limit AS autovacuum_vacuum_cost_limit
+ FROM pg_autovacuum AS a
+ join pg_class AS c on (c.oid=a.vacrelid)
+ join pg_namespace AS n on (n.oid=c.relnamespace)
+ ORDER BY nspname, relname
+ ";
+ }
+
+ return $this->selectSet($sql);
+ }
+
+ function saveAutovacuum($table, $vacenabled, $vacthreshold, $vacscalefactor, $anathresold,
+ $anascalefactor, $vaccostdelay, $vaccostlimit)
+ {
+ $defaults = $this->getAutovacuum();
+ $c_schema = $this->_schema;
+ $this->clean($c_schema);
+
+ $rs = $this->selectSet("
+ SELECT c.oid
+ FROM pg_catalog.pg_class AS c
+ LEFT JOIN pg_catalog.pg_namespace AS n ON (n.oid=c.relnamespace)
+ WHERE
+ c.relname = '{$table}' AND n.nspname = '{$c_schema}'
+ ");
+
+ if ($rs->EOF)
+ return -1;
+
+ $toid = $rs->fields('oid');
+ unset ($rs);
+
+ if (empty($_POST['autovacuum_vacuum_threshold']))
+ $_POST['autovacuum_vacuum_threshold'] = $defaults['autovacuum_vacuum_threshold'];
+
+ if (empty($_POST['autovacuum_vacuum_scale_factor']))
+ $_POST['autovacuum_vacuum_scale_factor'] = $defaults['autovacuum_vacuum_scale_factor'];
+
+ if (empty($_POST['autovacuum_analyze_threshold']))
+ $_POST['autovacuum_analyze_threshold'] = $defaults['autovacuum_analyze_threshold'];
+
+ if (empty($_POST['autovacuum_analyze_scale_factor']))
+ $_POST['autovacuum_analyze_scale_factor'] = $defaults['autovacuum_analyze_scale_factor'];
+
+ if (empty($_POST['autovacuum_vacuum_cost_delay']))
+ $_POST['autovacuum_vacuum_cost_delay'] = $defaults['autovacuum_vacuum_cost_delay'];
+
+ if (empty($_POST['autovacuum_vacuum_cost_limit']))
+ $_POST['autovacuum_vacuum_cost_limit'] = $defaults['autovacuum_vacuum_cost_limit'];
+
+ if (empty($_POST['vacuum_freeze_min_age']))
+ $_POST['vacuum_freeze_min_age'] = $defaults['vacuum_freeze_min_age'];
+
+ if (empty($_POST['autovacuum_freeze_max_age']))
+ $_POST['autovacuum_freeze_max_age'] = $defaults['autovacuum_freeze_max_age'];
+
+
+ $rs = $this->selectSet("SELECT vacrelid
+ FROM \"pg_catalog\".\"pg_autovacuum\"
+ WHERE vacrelid = {$toid};");
+
+ $status = -1; // ini
+ if (isset($rs->fields['vacrelid']) and ($rs->fields['vacrelid'] == $toid)) {
+ // table exists in pg_autovacuum, UPDATE
+ $sql = sprintf("UPDATE \"pg_catalog\".\"pg_autovacuum\" SET
+ enabled = '%s',
+ vac_base_thresh = %s,
+ vac_scale_factor = %s,
+ anl_base_thresh = %s,
+ anl_scale_factor = %s,
+ vac_cost_delay = %s,
+ vac_cost_limit = %s,
+ freeze_min_age = %s,
+ freeze_max_age = %s
+ WHERE vacrelid = {$toid};
+ ",
+ ($_POST['autovacuum_enabled'] == 'on')? 't':'f',
+ $_POST['autovacuum_vacuum_threshold'],
+ $_POST['autovacuum_vacuum_scale_factor'],
+ $_POST['autovacuum_analyze_threshold'],
+ $_POST['autovacuum_analyze_scale_factor'],
+ $_POST['autovacuum_vacuum_cost_delay'],
+ $_POST['autovacuum_vacuum_cost_limit'],
+ $_POST['vacuum_freeze_min_age'],
+ $_POST['autovacuum_freeze_max_age']
+ );
+ $status = $this->execute($sql);
+ }
+ else {
+ // table doesn't exists in pg_autovacuum, INSERT
+ $sql = sprintf("INSERT INTO \"pg_catalog\".\"pg_autovacuum\"
+ VALUES (%s, '%s', %s, %s, %s, %s, %s, %s, %s, %s )
+ WHERE
+ c.relname = '{$table}' AND n.nspname = '{$c_schema}';",
+ $toid,
+ ($_POST['autovacuum_enabled'] == 'on')? 't':'f',
+ $_POST['autovacuum_vacuum_threshold'],
+ $_POST['autovacuum_vacuum_scale_factor'],
+ $_POST['autovacuum_analyze_threshold'],
+ $_POST['autovacuum_analyze_scale_factor'],
+ $_POST['autovacuum_vacuum_cost_delay'],
+ $_POST['autovacuum_vacuum_cost_limit'],
+ $_POST['vacuum_freeze_min_age'],
+ $_POST['autovacuum_freeze_max_age']
+ );
+ $status = $this->execute($sql);
+ }
+
+ return $status;
+ }
+
+ function dropAutovacuum($table) {
+ $c_schema = $this->_schema;
+ $this->clean($c_schema);
+ $this->clean($table);
+
+ $rs = $this->selectSet("
+ SELECT c.oid
+ FROM pg_catalog.pg_class AS c
+ LEFT JOIN pg_catalog.pg_namespace AS n ON (n.oid=c.relnamespace)
+ WHERE
+ c.relname = '{$table}' AND n.nspname = '{$c_schema}'
+ ");
+
+ return $this->deleteRow('pg_autovacuum', array('vacrelid' => $rs->fields['oid']), 'pg_catalog');
+ }
+
function hasQueryKill() { return false; }
function hasDatabaseCollation() { return false; }
diff --git a/database.php b/database.php
index 71d2f0e2..8b4ced1f 100755
--- a/database.php
+++ b/database.php
@@ -523,312 +523,6 @@
}
/**
- * Allow database administration and tuning tasks
- */
- function doAdmin($action = '', $msg = '') {
- global $data, $misc;
- global $lang;
- switch ($action) {
- case 'vacuum':
- $status = $data->vacuumDB('', isset($_REQUEST['vacuum_analyze']), isset($_REQUEST['vacuum_full']), isset($_REQUEST['vacuum_freeze']) );
- if ($status == 0) doAdmin('', $lang['strvacuumgood']);
- else doAdmin('', $lang['strvacuumbad']);
- break;
- case 'analyze':
- $status = $data->analyzeDB();
- if ($status == 0) doAdmin('', $lang['stranalyzegood']);
- else doAdmin('', $lang['stranalyzebad']);
- break;
- case 'recluster':
- $status = $data->recluster();
- if ($status == 0) doAdmin('', $lang['strclusteredgood']);
- else doAdmin('', $lang['strclusteredbad']);
- break;
- case 'reindex';
- $status = $data->reindex('DATABASE', $_REQUEST['database'], isset($_REQUEST['reindex_force']));
- if ($status == 0) doAdmin('', $lang['strreindexgood']);
- else doAdmin('', $lang['strreindexbad']);
- break;
- default:
- $misc->printTrail('database');
- $misc->printTabs('database','admin');
- $misc->printMsg($msg);
-
- echo "<table style=\"width: 50%\">\n";
- echo "<tr>\n";
- echo "<th class=\"data\">";
- $misc->printHelp($lang['strvacuum'],'pg.admin.vacuum')."</th>\n";
- echo "</th>";
- echo "<th class=\"data\">";
- $misc->printHelp($lang['stranalyze'],'pg.admin.analyze');
- echo "</th>";
- if ($data->hasRecluster()){
- echo "<th class=\"data\">";
- $misc->printHelp($lang['strclusterindex'],'pg.index.cluster');
- echo "</th>";
- }
- echo "<th class=\"data\">";
- $misc->printHelp($lang['strreindex'],'pg.index.reindex');
- echo "</th>";
- echo "</tr>";
-
- // Vacuum
- echo "<tr>\n";
- echo "<td class=\"data1\" style=\"text-align: center; vertical-align: bottom\">\n";
- echo "<form action=\"database.php\" method=\"post\">\n";
- echo "<p><input type=\"checkbox\" id=\"vacuum_analyze\" name=\"vacuum_analyze\" /><label for=\"vacuum_analyze\">{$lang['stranalyze']}</label>\n";
- echo "<br /><input type=\"checkbox\" id=\"vacuum_full\" name=\"vacuum_full\" /><label for=\"vacuum_full\">{$lang['strfull']}</label>\n";
- echo "<br /><input type=\"checkbox\" id=\"vacuum_freeze\" name=\"vacuum_freeze\" /><label for=\"vacuum_freeze\">{$lang['strfreeze']}</label>\n";
- echo "<input type=\"hidden\" name=\"action\" value=\"vacuum\" />\n";
- echo $misc->form;
- echo "<br /><input type=\"submit\" value=\"{$lang['strvacuum']}\" /></p>\n";
- echo "</form>\n";
- echo "</td>\n";
-
- // Analyze
- echo "<td class=\"data1\" style=\"text-align: center; vertical-align: bottom\">\n";
- echo "<form action=\"database.php\" method=\"post\">\n";
- echo "<p><input type=\"hidden\" name=\"action\" value=\"analyze\" />\n";
- echo $misc->form;
- echo "<input type=\"submit\" value=\"{$lang['stranalyze']}\" /></p>\n";
- echo "</form>\n";
- echo "</td>\n";
-
- // Recluster
- if ($data->hasRecluster()){
- echo "<td class=\"data1\" style=\"text-align: center; vertical-align: bottom\">\n";
- echo "<form action=\"database.php\" method=\"post\">\n";
- echo "<p><input type=\"hidden\" name=\"action\" value=\"recluster\" />\n";
- echo $misc->form;
- echo "<input type=\"submit\" value=\"{$lang['strclusterindex']}\" /></p>\n";
- echo "</form>\n";
- echo "</td>\n";
- }
-
- // Reindex
- echo "<td class=\"data1\" style=\"text-align: center; vertical-align: bottom\">\n";
- echo "<form action=\"database.php\" method=\"post\">\n";
- echo "<p><input type=\"checkbox\" id=\"reindex_force\" name=\"reindex_force\" /><label for=\"reindex_force\">{$lang['strforce']}</label><br />\n";
- echo "<input type=\"hidden\" name=\"action\" value=\"reindex\" />\n";
- echo $misc->form;
- echo "<input type=\"submit\" value=\"{$lang['strreindex']}\" /></p>\n";
- echo "</form>\n";
- echo "</td>\n";
- echo "</tr>\n";
- echo "</table>\n";
-
- // Autovacuum
- if($data->hasAutovacuum()) {
- $enabled = $data->getVariable('autovacuum');
- echo "<h3>{$lang['strautovacuum']}</h3>";
- echo '<p>' . (($enabled->fields['autovacuum'] == 'on') ? $lang['strturnedon'] : $lang['strturnedoff'] ) . '</p>';
-
- if($data->hasAutovacuumSysTable()) {
-
- // Fetch the processes from the database
- $autovac = $data->getAutovacuum();
-
- $columns = array(
- 'namespace' => array(
- 'title' => $lang['strschema'],
- 'field' => field('nspname'),
- ),
- 'relname' => array(
- 'title' => $lang['strtable'],
- 'field' => field('relname'),
- ),
- 'enabled' => array(
- 'title' => $lang['strenabled'],
- 'field' => field('enabled'),
- ),
- 'vac_base_thresh' => array(
- 'title' => $lang['strvacuumbasethreshold'],
- 'field' => field('vac_base_thresh'),
- ),
- 'vac_scale_factor' => array(
- 'title' => $lang['strvacuumscalefactor'],
- 'field' => field('vac_scale_factor'),
- ),
- 'anl_base_thresh' => array(
- 'title' => $lang['stranalybasethreshold'],
- 'field' => field('anl_base_thresh'),
- ),
- 'anl_scale_factor' => array(
- 'title' => $lang['stranalyzescalefactor'],
- 'field' => field('anl_scale_factor'),
- ),
- 'vac_cost_delay' => array(
- 'title' => $lang['strvacuumcostdelay'],
- 'field' => field('vac_cost_delay'),
- ),
- 'vac_cost_limit' => array(
- 'title' => $lang['strvacuumcostlimit'],
- 'field' => field('vac_cost_limit'),
- ),
- );
-
- // Maybe we need to check permissions here?
- $columns['actions'] = array('title' => $lang['stractions']);
-
- $actions = array(
- 'edit' => array(
- 'title' => $lang['stredit'],
- 'url' => "database.php?action=editautovac&amp;schema=pg_catalog&amp;{$misc->href}&amp;",
- 'vars' => array('key[vacrelid]' => 'vacrelid')
- ),
- 'delete' => array(
- 'title' => $lang['strdelete'],
- 'url' => "database.php?action=delautovac&amp;{$misc->href}&amp;",
- 'vars' => array('key[vacrelid]' => 'vacrelid')
- )
- );
-
- $misc->printTable($autovac, $columns, $actions, $lang['strnodata']);
-
- }
-
- }
-
- break;
- }
- }
-
- /**
- * Show confirmation of edit and perform actual update of autovacuum entry
- */
- function doEditAutovacuum($confirm, $msg = '') {
- global $data, $misc, $conf;
- global $lang;
-
- $key = $_REQUEST['key'];
-
- if ($confirm) {
- $misc->printTrail('database');
- $misc->printTabs('database','admin');
- $misc->printMsg($msg);
-
- $attrs = $data->getTableAttributes('pg_autovacuum');
- $rs = $data->browseRow('pg_autovacuum', $key);
-
- echo "<form action=\"database.php\" method=\"post\" id=\"ac_form\">\n";
- $elements = 0;
- $error = true;
- if ($rs->recordCount() == 1 && $attrs->recordCount() > 0) {
- echo "<table>\n";
-
- // Output table header
- echo "<tr><th class=\"data\">{$lang['strcolumn']}</th><th class=\"data\">{$lang['strtype']}</th>";
- echo "<th class=\"data\">{$lang['strformat']}</th>\n";
- echo "<th class=\"data\">{$lang['strvalue']}</th></tr>";
-
- $i = 0;
- $nCC = 0;
- while (!$attrs->EOF) {
- $szValueName = "values[{$attrs->fields['attname']}]";
- $szEvents = "";
- $szDivPH = "";
-
- $attrs->fields['attnotnull'] = $data->phpBool($attrs->fields['attnotnull']);
- $id = (($i % 2) == 0 ? '1' : '2');
-
- // Initialise variables
- if (!isset($_REQUEST['format'][$attrs->fields['attname']]))
- $_REQUEST['format'][$attrs->fields['attname']] = 'VALUE';
-
- echo "<tr>\n";
- echo "<td class=\"data{$id}\" style=\"white-space:nowrap;\">", $misc->printVal($attrs->fields['attname']), "</td>";
- echo "<td class=\"data{$id}\" style=\"white-space:nowrap;\">\n";
- echo $misc->printVal($data->formatType($attrs->fields['type'], $attrs->fields['atttypmod']));
- echo "<input type=\"hidden\" name=\"types[", htmlspecialchars($attrs->fields['attname']), "]\" value=\"",
- htmlspecialchars($attrs->fields['type']), "\" /></td>";
- $elements++;
- echo "<td class=\"data{$id}\" style=\"white-space:nowrap;\">\n";
- echo "<select name=\"format[", htmlspecialchars($attrs->fields['attname']), "]\">\n";
- echo "<option value=\"VALUE\"", ($_REQUEST['format'][$attrs->fields['attname']] == 'VALUE') ? ' selected="selected"' : '', ">{$lang['strvalue']}</option>\n";
- echo "<option value=\"EXPRESSION\"", ($_REQUEST['format'][$attrs->fields['attname']] == 'EXPRESSION') ? ' selected="selected"' : '', ">{$lang['strexpression']}</option>\n";
- echo "</select>\n</td>\n";
- $elements++;
-
- echo "<td class=\"data{$id}\" id=\"aciwp{$i}\" style=\"white-space:nowrap;\">";
- echo $data->printField($szValueName, $rs->fields[$attrs->fields['attname']], $attrs->fields['type'],array(),$szEvents) . $szDivPH;
- echo "</td>";
- $elements++;
- echo "</tr>\n";
- $i++;
- $attrs->moveNext();
- }
- echo "</table>\n";
- $error = false;
- }
- elseif ($rs->recordCount() != 1) {
- echo "<p>{$lang['strrownotunique']}</p>\n";
- }
- else {
- echo "<p>{$lang['strinvalidparam']}</p>\n";
- }
-
- echo "<input type=\"hidden\" name=\"action\" value=\"confeditautovac\" />\n";
- echo $misc->form;
- echo "<input type=\"hidden\" name=\"table\" value=\"pg_autovacuum\" />\n";
- echo "<input type=\"hidden\" name=\"key\" value=\"", htmlspecialchars(serialize($key)), "\" />\n";
- echo "<p>";
- if (!$error) echo "<input type=\"submit\" name=\"save\" value=\"{$lang['strsave']}\" />\n";
- echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
- echo "</p>\n";
- echo "</form>\n";
- }
- else {
- if (!isset($_POST['values'])) $_POST['values'] = array();
- if (!isset($_POST['nulls'])) $_POST['nulls'] = array();
-
- $status = $data->editRow($_POST['table'], $_POST['values'], $_POST['nulls'],
- $_POST['format'], $_POST['types'], unserialize($_POST['key']));
- if ($status == 0)
- doAdmin($lang['strrowupdated']);
- elseif ($status == -2)
- doEditAutovacuum(true, $lang['strrownotunique']);
- else
- doEditAutovacuum(true, $lang['strrowupdatedbad']);
- }
-
- }
-
-
- /**
- * Delete rows from the autovacuum table
- */
- function doDelAutovacuum($confirm) {
- global $data, $misc;
- global $lang;
-
- if ($confirm) {
- $misc->printTrail('database');
- $misc->printTabs('database','admin');
- $misc->printTitle($lang['strdeleterow']);
-
- echo "<p>{$lang['strconfdeleterow']}</p>\n";
-
- echo "<form action=\"database.php\" method=\"post\">\n";
- echo "<input type=\"hidden\" name=\"action\" value=\"confdelautovac\" />\n";
- echo $misc->form;
- echo "<input type=\"hidden\" name=\"table\" value=\"pg_autovacuum\" />\n";
- echo "<input type=\"hidden\" name=\"key\" value=\"", htmlspecialchars(serialize($_REQUEST['key'])), "\" />\n";
- echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" />\n";
- echo "<input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\" />\n";
- echo "</form>\n";
- }
- else {
- $status = $data->deleteRow($_POST['table'], unserialize($_POST['key']));
- if ($status == 0)
- doAdmin('',$lang['strrowdeleted']);
- elseif ($status == -2)
- doAdmin('',$lang['strrownotunique']);
- else
- doAdmin('',$lang['strrowdeletedbad']);
- }
- }
-
- /**
* Allow execution of arbitrary SQL statements on a database
*/
function doSQL() {
@@ -844,7 +538,7 @@
echo "<p>{$lang['strsql']}<br />\n";
echo "<textarea style=\"width:100%;\" rows=\"20\" cols=\"50\" name=\"query\">",
htmlspecialchars($_SESSION['sqlquery']), "</textarea></p>\n";
-
+
// Check that file uploads are enabled
if (ini_get('file_uploads')) {
// Don't show upload option if max size of uploads is zero
@@ -873,7 +567,7 @@
$tabs = $misc->getNavTabs('database');
$items = $misc->adjustTabsForTree($tabs);
-
+
$attrs = array(
'text' => noEscape(field('title')),
'icon' => field('icon'),
@@ -893,25 +587,18 @@
exit;
}
+ require('./admin.php');
+
if ($action == 'tree') doTree();
$misc->printHeader($lang['strschemas']);
$misc->printBody();
-
+
switch ($action) {
case 'find':
if (isset($_REQUEST['term'])) doFind(false);
else doFind(true);
break;
- case 'recluster':
- case 'reindex':
- case 'analyze':
- case 'vacuum':
- doAdmin($action);
- break;
- case 'admin':
- doAdmin();
- break;
case 'sql':
doSQL();
break;
@@ -930,22 +617,8 @@
case 'signal':
doSignal();
break;
- case 'editautovac':
- doEditAutovacuum(true);
- break;
- case 'confeditautovac':
- if (isset($_POST['save'])) doEditAutovacuum(false);
- else doAdmin();
- break;
- case 'delautovac':
- doDelAutovacuum(true);
- break;
- case 'confdelautovac':
- if (isset($_POST['yes'])) doDelAutovacuum(false);
- else doAdmin();
- break;
default:
- doSQL();
+ if (adminActions($action, 'database') === false) doSQL();
break;
}
diff --git a/lang/english.php b/lang/english.php
index 2b48c931..76b268ad 100644
--- a/lang/english.php
+++ b/lang/english.php
@@ -143,7 +143,13 @@
$lang['strlocale'] = 'Locale';
$lang['strcollation'] = 'Collation';
$lang['strctype'] = 'Character Type';
-
+ $lang['strdefaultvalues'] = 'Default values';
+ $lang['strnewvalues'] = 'New values';
+
+ // Admin
+ $lang['stradminondatabase'] = 'The following administrative tasks apply on the whole %s database.';
+ $lang['stradminontable'] = 'The following administrative tasks apply on the table %s.';
+
// User-supplied SQL history
$lang['strhistory'] = 'History';
$lang['strnohistory'] = 'No history.';
@@ -152,6 +158,11 @@
$lang['strconfdelhistory'] = 'Really remove this request from history?';
$lang['strconfclearhistory'] = 'Really clear history?';
$lang['strnodatabaseselected'] = 'Please, select a database.';
+
+ // Database
+ $lang['strconfanalyzedatabase'] = 'Are you sure you want to analyze all tables in database "%s"?';
+ $lang['strconfvacuumdatabase'] = 'Are you sure you want to vacuum all tables in database "%s"?';
+ $lang['strconfreindexdatabase'] = 'Are you sure you want to reindex all tables in database "%s"?';
// Database sizes
$lang['strnoaccess'] = 'No Access';
@@ -250,11 +261,13 @@
$lang['strauto'] = 'Auto';
$lang['strconfvacuumtable'] = 'Are you sure you want to vacuum "%s"?';
$lang['strconfanalyzetable'] = 'Are you sure you want to analyze "%s"?';
+ $lang['strconfreindextable'] = 'Are you sure you want to reindex "%s"?';
$lang['strestimatedrowcount'] = 'Estimated row count';
$lang['strspecifytabletoanalyze'] = 'You must specify at least one table to analyze.';
$lang['strspecifytabletoempty'] = 'You must specify at least one table to empty.';
$lang['strspecifytabletodrop'] = 'You must specify at least one table to drop.';
$lang['strspecifytabletovacuum'] = 'You must specify at least one table to vacuum.';
+ $lang['strspecifytabletoreindex'] = 'You must specify at least one table to reindex.';
$lang['strnofieldsforinsert'] = 'You cannot insert a row into a table with no column.';
// Columns
@@ -912,12 +925,24 @@
$lang['strturnedon'] = 'Turned On';
$lang['strturnedoff'] = 'Turned Off';
$lang['strenabled'] = 'Enabled';
+ $lang['strnovacuumconf'] = 'No autovacuum configuration found.';
$lang['strvacuumbasethreshold'] = 'Vacuum Base Threshold';
$lang['strvacuumscalefactor'] = 'Vacuum Scale Factor';
$lang['stranalybasethreshold'] = 'Analyze Base Threshold';
$lang['stranalyzescalefactor'] = 'Analyze Scale Factor';
$lang['strvacuumcostdelay'] = 'Vacuum Cost Delay';
$lang['strvacuumcostlimit'] = 'Vacuum Cost Limit';
+ $lang['strvacuumpertable'] = 'Autovacuum setup per table';
+ $lang['straddvacuumtable'] = 'Add autovacuum setup for a table';
+ $lang['streditvacuumtable'] = 'Edit autovacuum setup for table %s';
+ $lang['strdelvacuumtable'] = 'Delete autovacuum setup for table %s ?';
+ $lang['strvacuumtablereset'] = 'Autovacuum setup for table %s reset to default values';
+ $lang['strdelvacuumtablefail'] = 'Fail to remove the autovacuum setup for table %s';
+ $lang['strsetvacuumtablesaved'] = 'Autovacuum setup for table %s saved.';
+ $lang['strsetvacuumtablefail'] = 'Autovacuum setup for table %s failed.';
+ $lang['strspecifydelvacuumtable'] = 'You must specify the table you want remove the autovacuum parameters from.';
+ $lang['strspecifyeditvacuumtable'] = 'You must specify the table you want to edit the autovacuum parameters from.';
+ $lang['strnotdefaultinred'] = 'Not default values are in red.';
// Table-level Locks
$lang['strlocks'] = 'Locks';
diff --git a/lang/recoded/english.php b/lang/recoded/english.php
index fdb5ae41..b8f66915 100644
--- a/lang/recoded/english.php
+++ b/lang/recoded/english.php
@@ -143,7 +143,13 @@
$lang['strlocale'] = 'Locale';
$lang['strcollation'] = 'Collation';
$lang['strctype'] = 'Character Type';
-
+ $lang['strdefaultvalues'] = 'Default values';
+ $lang['strnewvalues'] = 'New values';
+
+ // Admin
+ $lang['stradminondatabase'] = 'The following administrative tasks apply on the whole %s database.';
+ $lang['stradminontable'] = 'The following administrative tasks apply on the table %s.';
+
// User-supplied SQL history
$lang['strhistory'] = 'History';
$lang['strnohistory'] = 'No history.';
@@ -152,6 +158,11 @@
$lang['strconfdelhistory'] = 'Really remove this request from history?';
$lang['strconfclearhistory'] = 'Really clear history?';
$lang['strnodatabaseselected'] = 'Please, select a database.';
+
+ // Database
+ $lang['strconfanalyzedatabase'] = 'Are you sure you want to analyze all tables in database &quot;%s&quot;?';
+ $lang['strconfvacuumdatabase'] = 'Are you sure you want to vacuum all tables in database &quot;%s&quot;?';
+ $lang['strconfreindexdatabase'] = 'Are you sure you want to reindex all tables in database &quot;%s&quot;?';
// Database sizes
$lang['strnoaccess'] = 'No Access';
@@ -250,11 +261,13 @@
$lang['strauto'] = 'Auto';
$lang['strconfvacuumtable'] = 'Are you sure you want to vacuum &quot;%s&quot;?';
$lang['strconfanalyzetable'] = 'Are you sure you want to analyze &quot;%s&quot;?';
+ $lang['strconfreindextable'] = 'Are you sure you want to reindex &quot;%s&quot;?';
$lang['strestimatedrowcount'] = 'Estimated row count';
$lang['strspecifytabletoanalyze'] = 'You must specify at least one table to analyze.';
$lang['strspecifytabletoempty'] = 'You must specify at least one table to empty.';
$lang['strspecifytabletodrop'] = 'You must specify at least one table to drop.';
$lang['strspecifytabletovacuum'] = 'You must specify at least one table to vacuum.';
+ $lang['strspecifytabletoreindex'] = 'You must specify at least one table to reindex.';
$lang['strnofieldsforinsert'] = 'You cannot insert a row into a table with no column.';
// Columns
@@ -912,12 +925,24 @@
$lang['strturnedon'] = 'Turned On';
$lang['strturnedoff'] = 'Turned Off';
$lang['strenabled'] = 'Enabled';
+ $lang['strnovacuumconf'] = 'No autovacuum configuration found.';
$lang['strvacuumbasethreshold'] = 'Vacuum Base Threshold';
$lang['strvacuumscalefactor'] = 'Vacuum Scale Factor';
$lang['stranalybasethreshold'] = 'Analyze Base Threshold';
$lang['stranalyzescalefactor'] = 'Analyze Scale Factor';
$lang['strvacuumcostdelay'] = 'Vacuum Cost Delay';
$lang['strvacuumcostlimit'] = 'Vacuum Cost Limit';
+ $lang['strvacuumpertable'] = 'Autovacuum setup per table';
+ $lang['straddvacuumtable'] = 'Add autovacuum setup for a table';
+ $lang['streditvacuumtable'] = 'Edit autovacuum setup for table %s';
+ $lang['strdelvacuumtable'] = 'Delete autovacuum setup for table %s ?';
+ $lang['strvacuumtablereset'] = 'Autovacuum setup for table %s reset to default values';
+ $lang['strdelvacuumtablefail'] = 'Fail to remove the autovacuum setup for table %s';
+ $lang['strsetvacuumtablesaved'] = 'Autovacuum setup for table %s saved.';
+ $lang['strsetvacuumtablefail'] = 'Autovacuum setup for table %s failed.';
+ $lang['strspecifydelvacuumtable'] = 'You must specify the table you want remove the autovacuum parameters from.';
+ $lang['strspecifyeditvacuumtable'] = 'You must specify the table you want to edit the autovacuum parameters from.';
+ $lang['strnotdefaultinred'] = 'Not default values are in red.';
// Table-level Locks
$lang['strlocks'] = 'Locks';
diff --git a/tables.php b/tables.php
index af01e52a..ff6493ec 100644
--- a/tables.php
+++ b/tables.php
@@ -446,7 +446,6 @@
exit;
}
}
-
}
/**
@@ -789,144 +788,6 @@
} // END DROP
}// END Function
-
- /**
- * Show confirmation of vacuum and perform actual vacuum
- */
- function doVacuum($confirm) {
- global $data, $misc;
- global $lang, $_reload_browser;
-
- if (empty($_REQUEST['table']) && empty($_REQUEST['ma'])) {
- doDefault($lang['strspecifytabletovacuum']);
- exit();
- }
- if ($confirm) {
- if (isset($_REQUEST['ma'])) {
- $misc->printTrail('schema');
- $misc->printTitle($lang['strvacuum'], 'pg.vacuum');
-
- echo "<form action=\"tables.php\" method=\"post\">\n";
- foreach($_REQUEST['ma'] as $v) {
- $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES));
- echo "<p>", sprintf($lang['strconfvacuumtable'], $misc->printVal($a['table'])), "</p>\n";
- echo "<input type=\"hidden\" name=\"table[]\" value=\"", htmlspecialchars($a['table']), "\" />\n";
- }
- } // END if multi vacuum
- else {
- $misc->printTrail('table');
- $misc->printTitle($lang['strvacuum'], 'pg.vacuum');
-
- echo "<p>", sprintf($lang['strconfvacuumtable'], $misc->printVal($_REQUEST['table'])), "</p>\n";
-
- echo "<form action=\"tables.php\" method=\"post\">\n";
- echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
- }
- echo "<input type=\"hidden\" name=\"action\" value=\"vacuum\" />\n";
- echo $misc->form;
- echo "<p><input type=\"checkbox\" id=\"vacuum_full\" name=\"vacuum_full\" /> <label for=\"vacuum_full\">{$lang['strfull']}</label></p>\n";
- echo "<p><input type=\"checkbox\" id=\"vacuum_analyze\" name=\"vacuum_analyze\" /> <label for=\"vacuum_analyze\">{$lang['stranalyze']}</label></p>\n";
- echo "<input type=\"submit\" name=\"vacuum\" value=\"{$lang['strvacuum']}\" />\n";
- echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
- echo "</form>\n";
- } // END single vacuum
- else {
- //If multi drop
- if (is_array($_REQUEST['table'])) {
- $msg='';
- foreach($_REQUEST['table'] as $t) {
- $status = $data->vacuumDB($t, isset($_REQUEST['vacuum_analyze']), isset($_REQUEST['vacuum_full']), '');
- if ($status == 0)
- $msg.= sprintf('%s: %s<br />', htmlentities($t), $lang['strvacuumgood']);
- else {
- doDefault(sprintf('%s%s: %s<br />', $msg, htmlentities($t), $lang['strvacuumbad']));
- return;
- }
- }
- // Everything went fine, back to the Default page....
- $_reload_browser = true;
- doDefault($msg);
- }
- else {
- $status = $data->vacuumDB($_POST['table'], isset($_REQUEST['vacuum_analyze']), isset($_REQUEST['vacuum_full']), '');
- if ($status == 0) {
- $_reload_browser = true;
- doDefault($lang['strvacuumgood']);
- }
- else
- doDefault($lang['strvacuumbad']);
- }
- }
- }
-
- /**
- * Show confirmation of analyze and perform analyze
- */
- function doAnalyze($confirm) {
- global $data, $misc;
- global $lang, $_reload_browser;
-
- if (empty($_REQUEST['table']) && empty($_REQUEST['ma'])) {
- doDefault($lang['strspecifytabletoanalyze']);
- exit();
- }
- if ($confirm) {
- if (isset($_REQUEST['ma'])) {
- $misc->printTrail('schema');
- $misc->printTitle($lang['stranalyze'], 'pg.analyze'); //TODO
-
- echo "<form action=\"tables.php\" method=\"post\">\n";
- foreach($_REQUEST['ma'] as $v) {
- $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES));
- echo "<p>", sprintf($lang['strconfanalyzetable'], $misc->printVal($a['table'])), "</p>\n";
- echo "<input type=\"hidden\" name=\"table[]\" value=\"", htmlspecialchars($a['table']), "\" />\n";
- }
- } // END if multi analyze
- else {
- $misc->printTrail('table');
- $misc->printTitle($lang['stranalyze'], 'pg.analyze'); //TODO
-
- echo "<p>", sprintf($lang['strconfanalyzetable'], $misc->printVal($_REQUEST['table'])), "</p>\n";
-
- echo "<form action=\"tables.php\" method=\"post\">\n";
- echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
- }
- echo "<input type=\"hidden\" name=\"action\" value=\"analyze\" />\n";
- echo $misc->form;
-
- echo "<input type=\"submit\" name=\"analyze\" value=\"{$lang['stranalyze']}\" />\n"; //TODO
- echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
- echo "</form>\n";
- } // END single analyze
- else {
- //If multi drop
- if (is_array($_REQUEST['table'])) {
- $msg='';
- foreach($_REQUEST['table'] as $t) {
- $status = $data->analyzeDB($t);
- if ($status == 0)
- $msg.= sprintf('%s: %s<br />', htmlentities($t), $lang['stranalyzegood']);
- else {
- doDefault(sprintf('%s%s: %s<br />', $msg, htmlentities($t), $lang['stranalyzebad']));
- return;
- }
- }
- // Everything went fine, back to the Default page....
- $_reload_browser = true;
- doDefault($msg);
- }
- else {
- $status = $data->analyzeDB($_POST['table']);
- if ($status == 0) {
- $_reload_browser = true;
- doDefault($lang['stranalyzegood']);
- }
- else
- doDefault($lang['stranalyzebad']);
- }
- }
- }
-
/**
* Show default list of tables in the database
*/
@@ -1019,6 +880,12 @@
'vars' => array('table' => 'relname'),
'multiaction' => 'confirm_analyze',
),
+ 'reindex' => array(
+ 'title' => $lang['strreindex'],
+ 'url' => "tables.php?action=confirm_reindex&amp;{$misc->href}&amp;",
+ 'vars' => array('table' => 'relname'),
+ 'multiaction' => 'confirm_reindex',
+ ),
);
if (!$data->hasTablespaces()) unset($columns['tablespace']);
@@ -1030,6 +897,8 @@
echo "\t<li><a href=\"tables.php?action=createlike&amp;{$misc->href}\">{$lang['strcreatetablelike']}</a></li>\n";
echo "</ul>\n";
}
+
+ require('./admin.php');
/**
* Generate XML for the browser tree.
@@ -1144,22 +1013,8 @@
case 'confirm_drop':
doDrop(true);
break;
- case 'vacuum':
- if (isset($_POST['vacuum'])) doVacuum(false);
- else doDefault();
- break;
- case 'confirm_vacuum':
- doVacuum(true);
- break;
- case 'analyze':
- if (isset($_POST['analyze'])) doAnalyze(false);
- else doDefault();
- break;
- case 'confirm_analyze':
- doAnalyze(true);
- break;
default:
- doDefault();
+ if (adminActions($action, 'table') === false) doDefault();
break;
}