- Dan Boren (Object comments)
- Adrian Nida (Fix time outs)
- Russell Smith
+- Guillaume Lelarge
+- Ian Barwick
Third Party Libraries
Corporate Sponsors
-- SpikeSource (www.spikesource.com) - Slony support
\ No newline at end of file
+- SpikeSource (www.spikesource.com) - Slony support
* New icons by Niko <ennixo@free.fr>, from the graphics repository on pgFoundry.
* Added icons to bread crumb trail and tabs.
* Send encrypted passwords over the wire wherever possible.
+* Alter sequence, nextval and setval (Guillaume)
+* Auto-select 'WITHOUT OIDS' if 'default_with_oids' setting is false (Guillaume)
+* Autovacuum configuration support (Robert Treat)
+* Basic ROLE support (Chris Kings-Lynne)
Version 4.0
-----------
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.283 2006/04/21 03:31:25 chriskl Exp $
+ * $Id: Postgres.php,v 1.284 2006/05/19 07:17:30 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
return true;
}
+ /**
+ * Returns the current default_with_oids setting
+ * @return default_with_oids setting
+ */
+ function getDefaultWithOid() {
+ // 8.0 is the first release to have this setting
+ // Prior releases don't have this setting... oids always activated
+ return 'on';
+ }
+
/**
* Creates a new table in the database
* @param $name The name of the table
return $this->execute($sql);
}
+ /**
+ * Execute nextval on a given sequence
+ * @param $sequence Sequence name
+ * @return 0 success
+ * @return -1 sequence not found
+ */
+ function nextvalSequence($sequence) {
+ /* This double-cleaning is deliberate */
+ $this->fieldClean($sequence);
+ $this->clean($sequence);
+
+ $sql = "SELECT NEXTVAL('\"{$sequence}\"')";
+
+ return $this->execute($sql);
+ }
+
+ /**
+ * Execute setval on a given sequence
+ * @param $sequence Sequence name
+ * @param $nextvalue The next value
+ * @return 0 success
+ * @return -1 sequence not found
+ */
+ function setvalSequence($sequence, $nextvalue) {
+ /* This double-cleaning is deliberate */
+ $this->fieldClean($sequence);
+ $this->clean($sequence);
+ $this->clean($nextvalue);
+
+ $sql = "SELECT SETVAL('\"{$sequence}\"', '{$nextvalue}')";
+
+ return $this->execute($sql);
+ }
+
/**
* Creates a new sequence
* @param $sequence Sequence name
function hasServerAdminFuncs() { return false; }
function hasRoles() { return false; }
function hasAutovacuum() { return false; }
+ function hasAlterSequence() { return false; }
}
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres73.php,v 1.155 2006/04/10 21:25:06 xzilla Exp $
+ * $Id: Postgres73.php,v 1.156 2006/05/19 07:17:30 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
// Sequence functions
+ /**
+ * Resets a given sequence to min value of sequence
+ * @param $sequence Sequence name
+ * @return 0 success
+ * @return -1 sequence not found
+ */
+ function resetSequence($sequence) {
+ // Get the minimum value of the sequence
+ $seq = $this->getSequence($sequence);
+ if ($seq->recordCount() != 1) return -1;
+ $minvalue = $seq->f['min_value'];
+
+ /* This double-cleaning is deliberate */
+ $this->fieldClean($sequence);
+ $this->clean($sequence);
+
+ $sql = "SELECT pg_catalog.SETVAL('\"{$sequence}\"', {$minvalue})";
+
+ return $this->execute($sql);
+ }
+
+ /**
+ * Execute nextval on a given sequence
+ * @param $sequence Sequence name
+ * @return 0 success
+ * @return -1 sequence not found
+ */
+ function nextvalSequence($sequence) {
+ /* This double-cleaning is deliberate */
+ $this->fieldClean($sequence);
+ $this->clean($sequence);
+
+ $sql = "SELECT pg_catalog.NEXTVAL('\"{$sequence}\"')";
+
+ return $this->execute($sql);
+ }
+
+ /**
+ * Execute setval on a given sequence
+ * @param $sequence Sequence name
+ * @param $nextvalue The next value
+ * @return 0 success
+ * @return -1 sequence not found
+ */
+ function setvalSequence($sequence, $nextvalue) {
+ /* This double-cleaning is deliberate */
+ $this->fieldClean($sequence);
+ $this->clean($sequence);
+ $this->clean($nextvalue);
+
+ $sql = "SELECT pg_catalog.SETVAL('\"{$sequence}\"', '{$nextvalue}')";
+
+ return $this->execute($sql);
+ }
+
/**
* Returns all sequences in the current database
* @return A recordset
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres74.php,v 1.50 2005/09/07 08:09:21 chriskl Exp $
+ * $Id: Postgres74.php,v 1.51 2006/05/19 07:17:30 chriskl Exp $
*/
include_once('./classes/database/Postgres73.php');
return $this->endTransaction();
}
+
+ // Sequences
+
+ /**
+ * Alters a sequence
+ * @param $sequence Sequence name
+ * @param $increment The increment
+ * @param $minvalue The min value
+ * @param $maxvalue The max value
+ * @param $startvalue The starting value
+ * @param $cachevalue The cache value
+ * @param $cycledvalue True if cycled, false otherwise
+ * @return 0 success
+ * @return -1 get sequence error
+ */
+ function alterSequence($sequence, $increment, $minvalue, $maxvalue,
+ $startvalue, $cachevalue, $cycledvalue) {
+ $data = $this->getSequence($sequence);
+ if ($data->recordCount() != 1) {
+ return -1;
+ }
+
+ $this->fieldClean($sequence);
+ $this->clean($increment);
+ $this->clean($minvalue);
+ $this->clean($maxvalue);
+ $this->clean($startvalue);
+ $this->clean($cachevalue);
+ $this->clean($cycledvalue);
+
+ $sql = "ALTER SEQUENCE \"{$sequence}\"";
+ if ($increment != '' && $increment != $data->f['increment_by']) $sql .= " INCREMENT {$increment}";
+ if ($minvalue != '' && $minvalue != $data->f['min_value']) $sql .= " MINVALUE {$minvalue}";
+ if ($maxvalue != '' && $maxvalue != $data->f['max_value']) $sql .= " MAXVALUE {$maxvalue}";
+ if ($startvalue != '' && $startvalue != $data->f['last_value']) $sql .= " START {$startvalue}";
+ if ($cachevalue != '' && $cachevalue != $data->f['cache_value']) $sql .= " CACHE {$cachevalue}";
+ if ($cycledvalue && $cycledvalue != $data->f['is_cycled']) $sql .= " CYCLE";
+
+ return $this->execute($sql);
+ }
// Capabilities
function hasAlterDatabaseRename() { return true; }
function hasUserRename() { return true; }
function hasRecluster() { return true; }
function hasReadOnlyQueries() { return true; }
+ function hasAlterSequence() { return true; }
}
?>
/**
* PostgreSQL 8.0 support
*
- * $Id: Postgres80.php,v 1.18 2005/09/07 08:09:21 chriskl Exp $
+ * $Id: Postgres80.php,v 1.19 2006/05/19 07:17:30 chriskl Exp $
*/
include_once('./classes/database/Postgres74.php');
return $this->execute($sql);
}
+ /**
+ * Returns the current default_with_oids setting
+ * @return default_with_oids setting
+ */
+ function getDefaultWithOid() {
+ // Try to avoid a query if at all possible (5)
+ if (function_exists('pg_parameter_status')) {
+ $default = pg_parameter_status($this->conn->_connectionID, 'default_with_oids');
+ if ($default !== false) return $default;
+ }
+
+ $sql = "SHOW default_with_oids";
+
+ return $this->selectField($sql, 'default_with_oids');
+ }
+
// Table functions
/**
/**
* Manage schemas within a database
*
- * $Id: database.php,v 1.81 2006/03/17 21:14:30 xzilla Exp $
+ * $Id: database.php,v 1.82 2006/05/19 07:17:29 chriskl Exp $
*/
// Include application functions
echo "<br />";
echo "<br />";
- echo "<h3>{$lang['strautovacuum']}</h3>";
- // Autovacuum
- // Fetch the processes from the database
- $autovac = $data->getAutovacuum();
+
+ if($data->hasAutovacuum()) {
+ echo "<h3>{$lang['strautovacuum']}</h3>";
+ // Autovacuum
+ // Fetch the processes from the database
+ $autovac = $data->getAutovacuum();
- $columns = array(
- 'namespace' => array(
- 'title' => $lang['strschema'],
- 'field' => 'nspname',
- ),
- 'relname' => array(
- 'title' => $lang['strtable'],
- 'field' => 'relname',
- ),
- 'enabled' => array(
- 'title' => $lang['strenabled'],
- 'field' => 'enabled',
- ),
- 'vac_base_thresh' => array(
- 'title' => $lang['strvacuumbasethreshold'],
- 'field' => 'vac_base_thresh',
- ),
- 'vac_scale_factor' => array(
- 'title' => $lang['strvacuumscalefactor'],
- 'field' => 'vac_scale_factor',
- ),
- 'anl_base_thresh' => array(
- 'title' => $lang['stranalybasethreshold'],
- 'field' => 'anl_base_thresh',
- ),
- 'anl_scale_factor' => array(
- 'title' => $lang['stranalyzescalefactor'],
- 'field' => 'anl_scale_factor',
- ),
- 'vac_cost_delay' => array(
- 'title' => $lang['strvacuumcostdelay'],
- 'field' => 'vac_cost_delay',
- ),
- 'vac_cost_limit' => array(
- 'title' => $lang['strvacuumcostlimit'],
- 'field' => 'vac_cost_limit',
- ),
- );
-
-
- // Maybe we need to check permissions here?
- $columns['actions'] = array('title' => $lang['stractions']);
+ $columns = array(
+ 'namespace' => array(
+ 'title' => $lang['strschema'],
+ 'field' => 'nspname',
+ ),
+ 'relname' => array(
+ 'title' => $lang['strtable'],
+ 'field' => 'relname',
+ ),
+ 'enabled' => array(
+ 'title' => $lang['strenabled'],
+ 'field' => 'enabled',
+ ),
+ 'vac_base_thresh' => array(
+ 'title' => $lang['strvacuumbasethreshold'],
+ 'field' => 'vac_base_thresh',
+ ),
+ 'vac_scale_factor' => array(
+ 'title' => $lang['strvacuumscalefactor'],
+ 'field' => 'vac_scale_factor',
+ ),
+ 'anl_base_thresh' => array(
+ 'title' => $lang['stranalybasethreshold'],
+ 'field' => 'anl_base_thresh',
+ ),
+ 'anl_scale_factor' => array(
+ 'title' => $lang['stranalyzescalefactor'],
+ 'field' => 'anl_scale_factor',
+ ),
+ 'vac_cost_delay' => array(
+ 'title' => $lang['strvacuumcostdelay'],
+ 'field' => 'vac_cost_delay',
+ ),
+ 'vac_cost_limit' => array(
+ 'title' => $lang['strvacuumcostlimit'],
+ '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' => "{$PHP_SELF}?action=autovacuum&{$misc->href}&",
- 'vars' => array('vacrelid' => 'vacrelid')
- )
- );
-
- $misc->printTable($autovac, $columns, $actions, $lang['strnodata']);
+ $actions = array(
+ 'edit' => array(
+ 'title' => $lang['stredit'],
+ 'url' => "{$PHP_SELF}?action=autovacuum&{$misc->href}&",
+ 'vars' => array('vacrelid' => 'vacrelid')
+ )
+ );
+
+ $misc->printTable($autovac, $columns, $actions, $lang['strnodata']);
+ }
break;
}
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.186 2006/04/21 03:31:26 chriskl Exp $
+ * $Id: english.php,v 1.187 2006/05/19 07:17:30 chriskl Exp $
*/
// Language and character set
$lang['strsequencedroppedbad'] = 'Sequence drop failed.';
$lang['strsequencereset'] = 'Sequence reset.';
$lang['strsequenceresetbad'] = 'Sequence reset failed.';
+ $lang['straltersequence'] = 'Alter sequence';
+ $lang['strsequencealtered'] = 'Sequence altered.';
+ $lang['strsequencealteredbad'] = 'Sequence alteration failed.';
+ $lang['strsetval'] = 'Set Value';
+ $lang['strsequencesetval'] = 'Sequence value set.';
+ $lang['strsequencesetvalbad'] = 'Sequence value set failed.';
+ $lang['strnextval'] = 'Increment Value';
+ $lang['strsequencenextval'] = 'Sequence incremented.';
+ $lang['strsequencenextvalbad'] = 'Sequence increment failed.';
// Indexes
$lang['strindex'] = 'Index';
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.139 2006/04/21 03:31:26 chriskl Exp $
+ * $Id: english.php,v 1.140 2006/05/19 07:17:30 chriskl Exp $
*/
// Language and character set
$lang['strsequencedroppedbad'] = 'Sequence drop failed.';
$lang['strsequencereset'] = 'Sequence reset.';
$lang['strsequenceresetbad'] = 'Sequence reset failed.';
+ $lang['straltersequence'] = 'Alter sequence';
+ $lang['strsequencealtered'] = 'Sequence altered.';
+ $lang['strsequencealteredbad'] = 'Sequence alteration failed.';
+ $lang['strsetval'] = 'Set Value';
+ $lang['strsequencesetval'] = 'Sequence value set.';
+ $lang['strsequencesetvalbad'] = 'Sequence value set failed.';
+ $lang['strnextval'] = 'Increment Value';
+ $lang['strsequencenextval'] = 'Sequence incremented.';
+ $lang['strsequencenextvalbad'] = 'Sequence increment failed.';
// Indexes
$lang['strindex'] = 'Index';
/**
* Manage sequences in a database
*
- * $Id: sequences.php,v 1.31 2005/11/25 08:49:08 jollytoad Exp $
+ * $Id: sequences.php,v 1.32 2006/05/19 07:17:29 chriskl Exp $
*/
// Include application functions
echo "</tr>";
echo "</table>";
- echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=reset&{$misc->href}&sequence=", urlencode($sequence->f['seqname']), "\">{$lang['strreset']}</a> |\n";
+ if ($data->hasAlterSequence()) {
+ echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=confirm_alter&{$misc->href}&sequence=", urlencode($sequence->f['seqname']), "\">{$lang['straltersequence']}</a> |\n";
+ }
+ echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=confirm_setval&{$misc->href}&sequence=", urlencode($sequence->f['seqname']), "\">{$lang['strsetval']}</a> |\n";
+ echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=nextval&{$misc->href}&sequence=", urlencode($sequence->f['seqname']), "\">{$lang['strnextval']}</a> |\n";
+ echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=reset&{$misc->href}&sequence=", urlencode($sequence->f['seqname']), "\">{$lang['strreset']}</a> |\n";
echo "<a class=\"navlink\" href=\"{$PHP_SELF}?{$misc->href}\">{$lang['strshowallsequences']}</a></p>\n";
}
else echo "<p>{$lang['strnodata']}</p>\n";
doProperties($lang['strsequenceresetbad']);
}
+ /**
+ * Set Nextval of a sequence
+ */
+ function doNextval() {
+ global $data;
+ global $PHP_SELF, $lang;
+
+ $status = $data->nextvalSequence($_REQUEST['sequence']);
+ if ($status == 0)
+ doProperties($lang['strsequencenextval']);
+ else
+ doProperties($lang['strsequencenextvalbad']);
+ }
+
+ /**
+ * Function to save after 'setval'ing a sequence
+ */
+ function doSaveSetval() {
+ global $data, $lang, $_reload_browser;
+
+ $status = $data->setvalSequence($_POST['sequence'], $_POST['nextvalue']);
+ if ($status == 0)
+ doProperties($lang['strsequencesetval']);
+ else
+ doProperties($lang['strsequencesetvalbad']);
+ }
+
+ /**
+ * Function to allow 'setval'ing of a sequence
+ */
+ function doSetval($msg = '') {
+ global $data, $misc;
+ global $PHP_SELF, $lang;
+
+ $misc->printTrail('sequence');
+ $misc->printTitle($lang['strsetval'], 'pg.sequence');
+ $misc->printMsg($msg);
+
+ // Fetch the sequence information
+ $sequence = $data->getSequence($_REQUEST['sequence']);
+
+ if (is_object($sequence) && $sequence->recordCount() > 0) {
+ echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
+ echo "<table border=\"0\">";
+ echo "<tr><th class=\"data left required\">{$lang['strlastvalue']}</th>\n";
+ echo "<td class=\"data1\">";
+ echo "<input name=\"nextvalue\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"",
+ $misc->printVal($sequence->f['last_value']), "\" /></td></tr>\n";
+ echo "</table>\n";
+ echo "<p><input type=\"hidden\" name=\"action\" value=\"setval\" />\n";
+ echo "<input type=\"hidden\" name=\"sequence\" value=\"", htmlspecialchars($_REQUEST['sequence']), "\" />\n";
+ echo $misc->form;
+ echo "<input type=\"submit\" name=\"setval\" value=\"{$lang['strsetval']}\" />\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
+ echo "</form>\n";
+ }
+ else echo "<p>{$lang['strnodata']}</p>\n";
+ }
+
+ /**
+ * Function to save after altering a sequence
+ */
+ function doSaveAlter() {
+ global $data, $lang, $_reload_browser;
+
+ $status = $data->alterSequence($_POST['sequence'], $_POST['formIncrement'], $_POST['formMinValue'], $_POST['formMaxValue'], $_POST['formStartValue'], $_POST['formCacheValue'], $_POST['formCycledValue']);
+ if ($status == 0) {
+ doProperties($lang['strsequencealtered']);
+ }
+ else
+ doProperties($lang['strsequencealteredbad']);
+ }
+
+ /**
+ * Function to allow altering of a sequence
+ */
+ function doAlter($msg = '') {
+ global $data, $misc;
+ global $PHP_SELF, $lang;
+
+ $misc->printTrail('sequence');
+ $misc->printTitle($lang['stralter'], 'pg.sequence.alter');
+ $misc->printMsg($msg);
+
+ // Fetch the sequence information
+ $sequence = $data->getSequence($_REQUEST['sequence']);
+
+ if (is_object($sequence) && $sequence->recordCount() > 0) {
+ echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
+ echo "<table>\n";
+
+ echo "<tr><th class=\"data left\">{$lang['strincrementby']}</th>\n";
+ echo "<td class=\"data1\"><input name=\"formIncrement\" size=\"5\" value=\"",
+ htmlspecialchars($sequence->f['increment_by']), "\" /> </td></tr>\n";
+
+ echo "<tr><th class=\"data left\">{$lang['strminvalue']}</th>\n";
+ echo "<td class=\"data1\"><input name=\"formMinValue\" size=\"5\" value=\"",
+ htmlspecialchars($sequence->f['min_value']), "\" /></td></tr>\n";
+
+ echo "<tr><th class=\"data left\">{$lang['strmaxvalue']}</th>\n";
+ echo "<td class=\"data1\"><input name=\"formMaxValue\" size=\"5\" value=\"",
+ htmlspecialchars($sequence->f['max_value']), "\" /></td></tr>\n";
+
+ echo "<tr><th class=\"data left\">{$lang['strstartvalue']}</th>\n";
+ echo "<td class=\"data1\"><input name=\"formStartValue\" size=\"5\" value=\"",
+ htmlspecialchars($sequence->f['last_value']), "\" /></td></tr>\n";
+
+ echo "<tr><th class=\"data left\">{$lang['strcachevalue']}</th>\n";
+ echo "<td class=\"data1\"><input name=\"formCacheValue\" size=\"5\" value=\"",
+ htmlspecialchars($sequence->f['cache_value']), "\" /></td></tr>\n";
+
+ echo "<tr><th class=\"data left\">{$lang['striscycled']}</th>\n";
+ echo "<td class=\"data1\"><input type=\"checkbox\" name=\"formCycledValue\" value=\"",
+ ($sequence->f['is_cycled'] ? ' checked="checked"' : ''), "\" /></td></tr>\n";
+
+ echo "</table>\n";
+ echo "<p><input type=\"hidden\" name=\"action\" value=\"alter\" />\n";
+ echo $misc->form;
+ echo "<input type=\"hidden\" name=\"sequence\" value=\"", htmlspecialchars($_REQUEST['sequence']), "\" />\n";
+ echo "<input type=\"submit\" name=\"alter\" value=\"{$lang['stralter']}\" />\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
+ echo "</form>\n";
+ }
+ else echo "<p>{$lang['strnodata']}</p>\n";
+ }
+
if ($action == 'tree') doTree();
// Print header
case 'reset':
doReset();
break;
+ case 'nextval':
+ doNextval();
+ break;
+ case 'setval':
+ if (isset($_POST['setval'])) doSaveSetval();
+ else doDefault();
+ break;
+ case 'confirm_setval':
+ doSetval();
+ break;
+ case 'alter':
+ if (isset($_POST['alter'])) doSaveAlter();
+ else doDefault();
+ break;
+ case 'confirm_alter':
+ doAlter();
+ break;
default:
doDefault();
break;
/**
* List tables in a database
*
- * $Id: tables.php,v 1.75 2005/11/25 08:49:08 jollytoad Exp $
+ * $Id: tables.php,v 1.76 2006/05/19 07:17:30 chriskl Exp $
*/
// Include application functions
global $data, $misc;
global $PHP_SELF, $lang;
- if (!isset($_REQUEST['stage'])) $_REQUEST['stage'] = 1;
+ if (!isset($_REQUEST['stage'])) {
+ $_REQUEST['stage'] = 1;
+ $default_with_oids = $data->getDefaultWithOid();
+ if ($default_with_oids == 'off') $_REQUEST['withoutoids'] = 'on';
+ }
+
if (!isset($_REQUEST['name'])) $_REQUEST['name'] = '';
if (!isset($_REQUEST['fields'])) $_REQUEST['fields'] = '';
if (!isset($_REQUEST['tblcomment'])) $_REQUEST['tblcomment'] = '';
htmlspecialchars($_REQUEST['fields']), "\" /></td>\n\t</tr>\n";
if ($data->hasWithoutOIDs()) {
echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['stroptions']}</th>\n";
- echo "\t\t<td class=\"data\"><input type=\"checkbox\" name=\"withoutoids\"",
- (isset($_REQUEST['withoutoids']) ? ' checked="checked"' : ''), " />WITHOUT OIDS</td>\n\t</tr>\n";
+ echo "\t\t<td class=\"data\"><label><input type=\"checkbox\" name=\"withoutoids\"", isset($_REQUEST['withoutoids']) ? ' checked="checked"' : '', " />WITHOUT OIDS</label></td>\n\t</tr>\n";
}
// Tablespace (if there are any)