* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres74.php,v 1.56 2007/01/10 02:01:17 soranzo Exp $
+ * $Id: Postgres74.php,v 1.57 2007/03/28 18:52:34 soranzo Exp $
*/
include_once('./classes/database/Postgres73.php');
* @return -2 owner error
* @return -3 rename error
*/
- function alterDatabase($dbName, $newName, $newOwner = '')
+ function alterDatabase($dbName, $newName, $newOwner = '', $comment = '')
{
//ignore $newowner, not supported pre 8.0
+ //ignore $comment, not supported pre 8.2
$this->clean($dbName);
$this->clean($newName);
/**
* PostgreSQL 8.0 support
*
- * $Id: Postgres80.php,v 1.21 2006/12/31 15:35:49 xzilla Exp $
+ * $Id: Postgres80.php,v 1.22 2007/03/28 18:52:34 soranzo Exp $
*/
include_once('./classes/database/Postgres74.php');
* @return -2 owner error
* @return -3 rename error
*/
- function alterDatabase($dbName, $newName, $newOwner = '')
+ function alterDatabase($dbName, $newName, $newOwner = '', $comment = '')
{
$this->clean($dbName);
$this->clean($newName);
$this->clean($newOwner);
+ //ignore $comment, not supported pre 8.2
$status = $this->beginTransaction();
if ($status != 0) {
}
return $this->endTransaction();
}
+
/**
* Changes ownership of a database
* This can only be done by a superuser or the owner of the database
/**
* PostgreSQL 8.2 support
*
- * $Id: Postgres82.php,v 1.4 2006/12/31 19:06:16 xzilla Exp $
+ * $Id: Postgres82.php,v 1.5 2007/03/28 18:52:34 soranzo Exp $
*/
include_once('./classes/database/Postgres81.php');
* @return -3 rename error
* @return -4 comment error
*/
- function alterDatabase($dbName, $newName, $newOwner = '',$comment = '')
+ function alterDatabase($dbName, $newName, $newOwner = '', $comment = '')
{
- //ignore $newowner, not supported pre 8.0
- //ignore $comment, not supported pre 8.2
$this->clean($dbName);
$this->clean($newName);
+ $this->clean($newOwner);
+ $this->clean($comment);
- $status = $this->alterDatabaseRename($dbName, $newName);
- if ($status != 0) return -3;
+ $status = $this->beginTransaction();
+ if ($status != 0) {
+ $this->rollbackTransaction();
+ return -1;
+ }
+
+ if ($dbName != $newName) {
+ $status = $this->alterDatabaseRename($dbName, $newName);
+ if ($status != 0) {
+ $this->rollbackTransaction();
+ return -3;
+ }
+ }
+
+ $status = $this->alterDatabaseOwner($newName, $newOwner);
+ if ($status != 0) {
+ $this->rollbackTransaction();
+ return -2;
+ }
if (trim($comment) != '' ) {
- $status = $this->setComment('DATABASE',$dbName,'', $comment);
- if ($status != 0) return -4;
+ $status = $this->setComment('DATABASE', $dbName, '', $comment);
+ if ($status != 0) {
+ $this->rollbackTransaction();
+ return -4;
+ }
}
- else return 0;
+ return $this->endTransaction();
}
/**