-----
* -Support for 8.1 roles (removing users and groups) (chriskl,javier)
-* Support for ALTER ROLE
+* -Support for ALTER ROLE (done by ?)
Permissions
-----------
* -Alter sequence (Guillaume LELARGE)
* -setval & nextval (Guillaume LELARGE)
-* change schema
-* rename (done using alter table)
+* -change schema (ioguix)
+* -rename (done using alter table) (ioguix)
Functions
---------
* -Support 8.1 IN, OUT and INOUT parameters.(Jawed)
* Remove options for OUT/INOUT params in older servers
* Clean up javascript html spec warnings
-* Display owner
-* Alter owner
-* Alter schema
+* -Display owner (xzilla)
+* -Alter owner (xzilla)
+* -Alter schema (xzilla)
* GUC settings [8.3]
Indexes
/**
* Class to hold various commonly used functions
*
- * $Id: Misc.php,v 1.162 2007/10/17 18:24:32 ioguix Exp $
+ * $Id: Misc.php,v 1.163 2007/11/21 12:59:42 ioguix Exp $
*/
class Misc {
$_SESSION['webdbLogin'][$server_id][$key] = $value;
}
}
+
+ /**
+ * Set the current schema
+ * @param $schema The schema name
+ * @return 0 on success
+ * @return $data->seSchema() on error
+ */
+ function setCurrentSchema($schema) {
+ global $data;
+
+ $status = $data->setSchema($schema);
+ if($status != 0)
+ return $status;
+
+ $_REQUEST['schema'] = $schema;
+ $this->setHREF();
+ return 0;
+ }
}
?>
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.310 2007/11/15 23:09:21 xzilla Exp $
+ * $Id: Postgres.php,v 1.311 2007/11/21 12:59:42 ioguix Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
* @param $name The new name for the sequence
* @param $comment The comment on the sequence
* @param $owner The new owner for the sequence
+ * @param $schema The new schema for the sequence
* @param $increment The increment
* @param $minvalue The min value
* @param $maxvalue The max value
* @return 0 success
* @return -3 rename error
* @return -4 comment error
+ * @return -5 owner error
+ * @return -7 schema error
*/
/*protected*/
- function _alterSequence($seqrs, $name, $comment, $owner, $increment,
+ function _alterSequence($seqrs, $name, $comment, $owner, $schema, $increment,
$minvalue, $maxvalue, $startvalue, $cachevalue, $cycledvalue) {
$sequence = $seqrs->fields['seqname'];
$this->fieldClean($name);
$this->clean($comment);
- /* $owner, $increment, $minvalue, $maxvalue,
+ /* $owner, $schema, $increment, $minvalue, $maxvalue,
* $startvalue, $cachevalue, $cycledvalue not supported in pg70 */
// Comment
* @param $name The new name for the sequence
* @param $comment The comment on the sequence
* @param $owner The new owner for the sequence
+ * @param $schema The new schema for the sequence
* @param $increment The increment
* @param $minvalue The min value
* @param $maxvalue The max value
* @return -2 get existing sequence error
* @return $this->_alterSequence error code
*/
- function alterSequence($sequence, $name, $comment, $owner=null, $increment=null,
+ function alterSequence($sequence, $name, $comment, $owner=null, $schema=null, $increment=null,
$minvalue=null, $maxvalue=null, $startvalue=null, $cachevalue=null, $cycledvalue=null) {
$this->fieldClean($sequence);
return -1;
}
- $status = $this->_alterSequence($data, $name, $comment, $owner, $increment,
+ $status = $this->_alterSequence($data, $name, $comment, $owner, $schema, $increment,
$minvalue, $maxvalue, $startvalue, $cachevalue, $cycledvalue);
if ($status != 0) {
function hasAlterTableOwner() { return false; }
function hasAlterSequenceOwner() { return false; }
function hasAlterSequenceProps() { return false; }
+ function hasSequenceAlterSchema() { return false; }
function hasPartialIndexes() { return false; }
function hasCasts() { return false; }
function hasFullSubqueries() { return false; }
function hasVirtualTransactionId() {return false;}
function hasFunctionCosting() {return false;}
function hasFunctionGUC() {return false;}
- function hasFunctionAlterSchema() { return false; }
- function hasFunctionAlterOwner() { return false; }
+ function hasFunctionAlterSchema() { return false; }
+ function hasFunctionAlterOwner() { return false; }
}
?>
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres71.php,v 1.77 2007/10/17 15:55:33 ioguix Exp $
+ * $Id: Postgres71.php,v 1.78 2007/11/21 12:59:42 ioguix Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
* @param $name The new name for the sequence
* @param $comment The comment on the sequence
* @param $owner The new owner for the sequence
+ * @param $schema The new schema for the sequence
* @param $increment The increment
* @param $minvalue The min value
* @param $maxvalue The max value
* @return -5 owner error
*/
/*protected*/
- function _alterSequence($seqrs, $name, $comment, $owner, $increment,
+ function _alterSequence($seqrs, $name, $comment, $owner, $schema, $increment,
$minvalue, $maxvalue, $startvalue, $cachevalue, $cycledvalue) {
- $status = parent::_alterSequence($seqrs, $name, $comment, $owner, $increment,
+ $status = parent::_alterSequence($seqrs, $name, $comment, $owner, $schema, $increment,
$minvalue, $maxvalue, $startvalue, $cachevalue, $cycledvalue);
if ($status != 0)
return $status;
- /* $increment, $minvalue, $maxvalue, $startvalue, $cachevalue,
+ /* $schema, $increment, $minvalue, $maxvalue, $startvalue, $cachevalue,
* $cycledvalue not supported in pg71 */
// if name != seqname, sequence has been renamed in parent
$sequence = ($seqrs->fields['seqname'] = $name) ? $seqrs->fields['seqname'] : $name;
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres73.php,v 1.176 2007/11/16 18:34:24 ioguix Exp $
+ * $Id: Postgres73.php,v 1.177 2007/11/21 12:59:42 ioguix Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
$sql = "SELECT c.relname AS seqname, s.*,
pg_catalog.obj_description(s.tableoid, 'pg_class') AS seqcomment,
- u.usename AS seqowner
+ u.usename AS seqowner, n.nspname
FROM \"{$sequence}\" AS s, pg_catalog.pg_class c, pg_catalog.pg_user u, pg_catalog.pg_namespace n
WHERE c.relowner=u.usesysid AND c.relnamespace=n.oid
- AND c.relname = '{$sequence}' AND c.relkind = 'S' AND n.nspname='{$this->_schema}'";
+ AND c.relname = '{$sequence}' AND c.relkind = 'S' AND n.nspname='{$this->_schema}'
+ AND n.oid = c.relnamespace";
return $this->selectSet( $sql );
}
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres74.php,v 1.66 2007/11/15 23:09:21 xzilla Exp $
+ * $Id: Postgres74.php,v 1.67 2007/11/21 12:59:42 ioguix Exp $
*/
include_once('./classes/database/Postgres73.php');
$funcname = $newname;
}
- // Alter the owner, if necessary
- if ($this->hasFunctionAlterOwner()) {
- $this->fieldClean($newown);
+ // Alter the owner, if necessary
+ if ($this->hasFunctionAlterOwner()) {
+ $this->fieldClean($newown);
if ($funcown != $newown) {
- $sql = "ALTER FUNCTION \"{$funcname}\"({$args}) OWNER TO \"{$newown}\"";
- $status = $this->execute($sql);
- if ($status != 0) {
- $this->rollbackTransaction();
- return -6;
- }
+ $sql = "ALTER FUNCTION \"{$funcname}\"({$args}) OWNER TO \"{$newown}\"";
+ $status = $this->execute($sql);
+ if ($status != 0) {
+ $this->rollbackTransaction();
+ return -6;
+ }
}
- }
+ }
- // Alter the schema, if necessary
- if ($this->hasFunctionAlterSchema()) {
+ // Alter the schema, if necessary
+ if ($this->hasFunctionAlterSchema()) {
$this->fieldClean($newschema);
if ($funcschema != $newschema) {
- $sql = "ALTER FUNCTION \"{$funcname}\"({$args}) SET SCHEMA \"{$newschema}\"";
- $status = $this->execute($sql);
- if ($status != 0) {
- $this->rollbackTransaction();
- return -7;
- }
+ $sql = "ALTER FUNCTION \"{$funcname}\"({$args}) SET SCHEMA \"{$newschema}\"";
+ $status = $this->execute($sql);
+ if ($status != 0) {
+ $this->rollbackTransaction();
+ return -7;
+ }
}
-
- }
-
+ }
return $this->endTransaction();
}
* @param $name The new name for the sequence
* @param $comment The comment on the sequence
* @param $owner The new owner for the sequence
+ * @param $schema The new schema for the sequence
* @param $increment The increment
* @param $minvalue The min value
* @param $maxvalue The max value
* @return -6 get sequence error
*/
/*protected*/
- function _alterSequence($seqrs, $name, $comment, $owner, $increment,
+ function _alterSequence($seqrs, $name, $comment, $owner, $schema, $increment,
$minvalue, $maxvalue, $startvalue, $cachevalue, $cycledvalue) {
- $status = parent::_alterSequence($seqrs, $name, $comment, $owner, $increment,
+ $status = parent::_alterSequence($seqrs, $name, $comment, $owner, $schema, $increment,
$minvalue, $maxvalue, $startvalue, $cachevalue, $cycledvalue);
if ($status != 0)
return $status;
-
+
+ /* $schema not supported in pg74 */
+
// if name != seqname, sequence has been renamed in parent
$sequence = ($seqrs->fields['seqname'] = $name) ? $seqrs->fields['seqname'] : $name;
$this->clean($increment);
/**
* PostgreSQL 8.1 support
*
- * $Id: Postgres81.php,v 1.15 2007/11/15 23:09:21 xzilla Exp $
+ * $Id: Postgres81.php,v 1.16 2007/11/21 12:59:42 ioguix Exp $
*/
include_once('./classes/database/Postgres80.php');
return $this->selectSet($sql);
}
+ // Database methods
+
/**
* Returns all available process information.
* @return A recordset
return $this->selectSet($sql);
}
+ // Table methods
+
/**
* Enables a trigger
* @param $tgname The name of the trigger to enable
return $this->execute($sql);
}
+ // Sequence methods
+
+ /**
+ * Protected method which alter a sequence
+ * SHOULDN'T BE CALLED OUTSIDE OF A TRANSACTION
+ * @param $seqrs The sequence recordSet returned by getSequence()
+ * @param $name The new name for the sequence
+ * @param $comment The comment on the sequence
+ * @param $owner The new owner for the sequence
+ * @param $schema The new schema for the sequence
+ * @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 -3 rename error
+ * @return -4 comment error
+ * @return -5 owner error
+ * @return -6 get sequence error
+ * @return -7 schema error
+ */
+ /*protected*/
+ function _alterSequence($seqrs, $name, $comment, $owner, $schema, $increment,
+ $minvalue, $maxvalue, $startvalue, $cachevalue, $cycledvalue) {
+
+ $status = parent::_alterSequence($seqrs, $name, $comment, $owner, $schema, $increment,
+ $minvalue, $maxvalue, $startvalue, $cachevalue, $cycledvalue);
+ if ($status != 0)
+ return $status;
+
+ // if name != seqname, sequence has been renamed in parent
+ $sequence = ($seqrs->fields['seqname'] = $name) ? $seqrs->fields['seqname'] : $name;
+
+ $this->clean($schema);
+ if ($seqrs->fields['nspname'] != $schema) {
+ $sql = "ALTER SEQUENCE \"{$sequence}\" SET SCHEMA $schema";
+ $status = $this->execute($sql);
+ if ($status != 0)
+ return -7;
+ }
+
+ return 0;
+ }
// Capabilities
function hasServerAdminFuncs() { return true; }
function hasAutovacuum() { return true; }
function hasPreparedXacts() { return true; }
function hasDisableTriggers() { return true; }
- function hasFunctionAlterSchema() { return true; }
+ function hasFunctionAlterSchema() { return true; }
+ function hasSequenceAlterSchema() { return true; }
}
?>
/**
* Manage sequences in a database
*
- * $Id: sequences.php,v 1.46 2007/10/17 15:55:33 ioguix Exp $
+ * $Id: sequences.php,v 1.47 2007/11/21 12:59:42 ioguix Exp $
*/
// Include application functions
* Function to save after altering a sequence
*/
function doSaveAlter() {
- global $data, $lang, $_reload_browser;
+ global $data, $lang, $_reload_browser, $misc;
if (!isset($_POST['owner'])) $_POST['owner'] = null;
+ if (!isset($_POST['newschema'])) $_POST['newschema'] = null;
if (!isset($_POST['formIncrement'])) $_POST['formIncrement'] = null;
if (!isset($_POST['formMinValue'])) $_POST['formMinValue'] = null;
if (!isset($_POST['formMaxValue'])) $_POST['formMaxValue'] = null;
if (!isset($_POST['formCycledValue'])) $_POST['formCycledValue'] = null;
$status = $data->alterSequence($_POST['sequence'], $_POST['name'], $_POST['comment'], $_POST['owner'],
- $_POST['formIncrement'], $_POST['formMinValue'], $_POST['formMaxValue'], $_POST['formStartValue'],
- $_POST['formCacheValue'], isset($_POST['formCycledValue']));
+ $_POST['newschema'], $_POST['formIncrement'], $_POST['formMinValue'], $_POST['formMaxValue'],
+ $_POST['formStartValue'], $_POST['formCacheValue'], isset($_POST['formCycledValue']));
if ($status == 0) {
if ($_POST['sequence'] != $_POST['name']) {
// Force a browser reload
$_reload_browser = true;
}
+ if (!empty($_POST['newschema']) && ($_POST['newschema'] != $data->_schema)) {
+ // Jump them to the new sequence schema
+ $misc->setCurrentSchema($_POST['newschema']);
+ $_reload_browser = true;
+ }
doProperties($lang['strsequencealtered']);
}
else
if (!isset($_POST['name'])) $_POST['name'] = $_REQUEST['sequence'];
if (!isset($_POST['comment'])) $_POST['comment'] = $sequence->fields['seqcomment'];
if (!isset($_POST['owner'])) $_POST['owner'] = $sequence->fields['seqowner'];
+ if (!isset($_POST['newschema'])) $_POST['newschema'] = $sequence->fields['nspname'];
// Handle Checkbox Value
$sequence->fields['is_cycled'] = $data->phpBool($sequence->fields['is_cycled']);
}
echo "</select></td></tr>\n";
}
+
+ if ($data->hasSequenceAlterSchema()) {
+ $schemas = $data->getSchemas();
+ echo "<tr><th class=\"data left required\">{$lang['strschema']}</th>\n";
+ echo "<td class=\"data1\"><select name=\"newschema\">";
+ while (!$schemas->EOF) {
+ $schema = $schemas->fields['nspname'];
+ echo "<option value=\"", htmlspecialchars($schema), "\"",
+ ($schema == $_POST['newschema']) ? ' selected="selected"' : '', ">", htmlspecialchars($schema), "</option>\n";
+ $schemas->moveNext();
+ }
+ echo "</select></td></tr>\n";
+ }
echo "<tr><th class=\"data left\">{$lang['strcomment']}</th>\n";
echo "<td class=\"data1\">";