* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.237 2004/07/14 19:09:38 soranzo Exp $
+ * $Id: Postgres.php,v 1.238 2004/07/15 10:59:55 soranzo Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
function hasIndicies() { return true; }
function hasLanguages() { return true; }
function hasOpClasses() { return true; }
- function hasFunctionRename() { return true; }
}
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres72.php,v 1.73 2004/07/14 18:32:02 soranzo Exp $
+ * $Id: Postgres72.php,v 1.74 2004/07/15 10:59:55 soranzo Exp $
*/
* @param $comment The comment on the function
* @return 0 success
* @return -1 transaction error
- * @return -2 commenting error
- * @return -3 rename error
+ * @return -2 drop function error
+ * @return -3 create function error
+ * @return -4 comment error
*/
function setFunction($function_oid, $funcname, $newname, $args, $returns, $definition, $language, $flags, $setof, $comment) {
// Begin a transaction
}
// Replace the existing function
- $status = $this->createFunction($funcname, $args, $returns, $definition, $language, $flags, $setof, true);
- if ($status != 0) {
- $this->rollbackTransaction();
- return -1;
+ if ($funcname != $newname) {
+ $status = $this->dropFunction($function_oid, false);
+ if ($status != 0) {
+ $this->rollbackTransaction();
+ return -2;
+ }
+
+ $status = $this->createFunction($newname, $args, $returns, $definition, $language, $flags, $setof, false);
+ if ($status != 0) {
+ $this->rollbackTransaction();
+ return -3;
+ }
+ } else {
+ $status = $this->createFunction($funcname, $args, $returns, $definition, $language, $flags, $setof, true);
+ if ($status != 0) {
+ $this->rollbackTransaction();
+ return -3;
+ }
}
// Comment on the function
- $this->fieldClean($funcname);
+ $this->fieldClean($newname);
$this->clean($comment);
- $status = $this->setComment('FUNCTION', "\"{$funcname}\"({$args})", null, $comment);
+ $status = $this->setComment('FUNCTION', "\"{$newname}\"({$args})", null, $comment);
if ($status != 0) {
$this->rollbackTransaction();
- return -2;
- }
-
- // Rename the function, if necessary
- $this->fieldClean($newname);
- if ($funcname != $newname && $this->hasFunctionRename()) {
- $sql = "ALTER FUNCTION \"{$funcname}\"({$args}) RENAME TO \"{$newname}\"";
- $status = $this->execute($sql);
- if ($status != 0) {
- $this->rollbackTransaction();
- return -3;
- }
+ return -4;
}
return $this->endTransaction();
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres73.php,v 1.130 2004/07/15 09:35:30 jollytoad Exp $
+ * $Id: Postgres73.php,v 1.131 2004/07/15 10:59:55 soranzo Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
function hasUserSessionDefaults() { return true; }
function hasVariables() { return true; }
function hasFullExplain() { return true; }
- function hasFunctionRename() { return false; }
function hasForeignKeysInfo() { return true; }
function hasViewColumnRename() { return true; }
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres74.php,v 1.37 2004/07/14 14:52:18 jollytoad Exp $
+ * $Id: Postgres74.php,v 1.38 2004/07/15 10:59:55 soranzo Exp $
*/
include_once('./classes/database/Postgres73.php');
return $this->endTransaction();
}
+ // User functions
+
/**
* Renames a user
* @param $username The username of the user to rename
return $this->endTransaction();
}
+ // Function functions
+
+ /**
+ * Updates (replaces) a function.
+ * @param $function_oid The OID of the function
+ * @param $funcname The name of the function to create
+ * @param $newname The new name for the function
+ * @param $args The array of argument types
+ * @param $returns The return type
+ * @param $definition The definition for the new function
+ * @param $language The language the function is written for
+ * @param $flags An array of optional flags
+ * @param $setof True if returns a set, false otherwise
+ * @param $comment The comment on the function
+ * @return 0 success
+ * @return -1 transaction error
+ * @return -3 create function error
+ * @return -4 comment error
+ * @return -5 rename function error
+ */
+ function setFunction($function_oid, $funcname, $newname, $args, $returns, $definition, $language, $flags, $setof, $comment) {
+ // Begin a transaction
+ $status = $this->beginTransaction();
+ if ($status != 0) {
+ $this->rollbackTransaction();
+ return -1;
+ }
+
+ // Replace the existing function
+ $status = $this->createFunction($funcname, $args, $returns, $definition, $language, $flags, $setof, true);
+ if ($status != 0) {
+ $this->rollbackTransaction();
+ return -3;
+ }
+
+ // Comment on the function
+ $this->fieldClean($funcname);
+ $this->clean($comment);
+ $status = $this->setComment('FUNCTION', "\"{$funcname}\"({$args})", null, $comment);
+ if ($status != 0) {
+ $this->rollbackTransaction();
+ return -4;
+ }
+
+ // Rename the function, if necessary
+ $this->fieldClean($newname);
+ if ($funcname != $newname) {
+ $sql = "ALTER FUNCTION \"{$funcname}\"({$args}) RENAME TO \"{$newname}\"";
+ $status = $this->execute($sql);
+ if ($status != 0) {
+ $this->rollbackTransaction();
+ return -5;
+ }
+ }
+
+ return $this->endTransaction();
+ }
+
// Capabilities
function hasGrantOption() { return true; }
function hasDomainConstraints() { return true; }
function hasUserRename() { return true; }
- function hasFunctionRename() { return true; }
function hasSchemaDump() { return true; }
function hasRecluster() { return true; }