* Fix grant option/grantor stuff
* First and last links in browse table
-* Can't grant/revoke on functions with spaces in them
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.117 2003/05/31 10:55:41 chriskl Exp $
+ * $Id: Postgres.php,v 1.118 2003/06/01 11:53:46 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
* @return -4 invalid mode
*/
function setPrivileges($mode, $type, $object, $public, $usernames, $groupnames, $privileges) {
- $this->fieldClean($object);
$this->fieldArrayClean($usernames);
$this->fieldArrayClean($groupnames);
$sql = "{$mode} ALL PRIVILEGES ON";
else
$sql = "{$mode} " . join(', ', $privileges) . " ON";
- // @@ WE NEED SCHEMA SUPPORT BELOW
switch ($type) {
case 'table':
case 'view':
case 'sequence':
+ $this->fieldClean($object);
$sql .= " \"{$object}\"";
break;
case 'database':
+ $this->fieldClean($object);
$sql .= " DATABASE \"{$object}\"";
break;
case 'function':
- // This is deliberately unquoted - $object is something like
- // "function(arg1, arg2)"
- $sql .= " FUNCTION {$object}";
+ // Function comes in with $object as function OID
+ $fn = &$this->getFunction($object);
+ $this->fieldClean($fn->f[$this->fnFields['fnname']]);
+ $sql .= " FUNCTION \"{$fn->f[$this->fnFields['fnname']]}\"({$fn->f[$this->fnFields['fnarguments']]})";
break;
case 'language':
+ $this->fieldClean($object);
$sql .= " LANGUAGE \"{$object}\"";
break;
case 'schema':
- // @@ MOVE THIS TO 7.3 ONLY
+ $this->fieldClean($object);
$sql .= " SCHEMA \"{$object}\"";
break;
default:
/**
* Updates a function. Postgres 7.1 doesn't have CREATE OR REPLACE function,
* so we do it with a drop and a recreate.
+ * @param $function_oid The OID of the function
* @param $funcname The name of the function to create
* @param $args The array of argument types
* @param $returns The return type
* @return -2 drop function error
* @return -3 create function error
*/
- function setFunction($funcname, $args, $returns, $definition, $language, $flags, $setof) {
+ function setFunction($function_oid, $funcname, $args, $returns, $definition, $language, $flags, $setof) {
$status = $this->beginTransaction();
if ($status != 0) return -1;
- $status = $this->dropFunction("$funcname({$args})", false);
+ $status = $this->dropFunction($function_oid, false);
if ($status != 0) {
$this->rollbackTransaction();
return -2;
/**
* Drops a function.
- * @param $funcname The name of the function to drop
+ * @param $function_oid The OID of the function to drop
* @param $cascade True to cascade drop, false to restrict
* @return 0 success
*/
- function dropFunction($funcname, $cascade) {
- $this->clean($funcname);
-
- $sql = "DROP FUNCTION {$funcname} ";
+ function dropFunction($function_oid, $cascade) {
+ // Function comes in with $object as function OID
+ $fn = &$this->getFunction($function_oid);
+ $this->fieldClean($fn->f[$this->fnFields['fnname']]);
+
+ $sql = "DROP FUNCTION \"{$fn->f[$this->fnFields['fnname']]}\"({$fn->f[$this->fnFields['fnarguments']]})";
if ($cascade) $sql .= " CASCADE";
return $this->execute($sql);
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres72.php,v 1.45 2003/05/19 15:15:49 chriskl Exp $
+ * $Id: Postgres72.php,v 1.46 2003/06/01 11:53:47 chriskl Exp $
*/
/**
* Updates (replaces) a function.
+ * @param $function_oid The OID of the function
* @param $funcname The name of the function to create
* @param $args The array of argument types
* @param $returns The return type
* @param $setof True if returns a set, false otherwise
* @return 0 success
*/
- function setFunction($funcname, $args, $returns, $definition, $language, $flags, $setof) {
+ function setFunction($function_oid, $funcname, $args, $returns, $definition, $language, $flags, $setof) {
return $this->createFunction($funcname, $args, $returns, $definition, $language, $flags, $setof, true);
}
/**
* Manage functions in a database
*
- * $Id: functions.php,v 1.16 2003/05/31 07:23:24 chriskl Exp $
+ * $Id: functions.php,v 1.17 2003/06/01 11:53:45 chriskl Exp $
*/
// Include application functions
function doSaveEdit() {
global $localData, $lang;
- $status = $localData->setFunction($_POST['original_function'], $_POST['original_arguments'],
+ $status = $localData->setFunction($_POST['function_oid'], $_POST['original_function'], $_POST['original_arguments'],
$_POST['original_returns'], $_POST['formDefinition'],
$_POST['original_lang'], $_POST['formProperties'], isset($_POST['original_setof']), true);
if ($status == 0)
echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"drop\">\n";
echo "<input type=\"hidden\" name=\"function\" value=\"", htmlspecialchars($_REQUEST['function']), "\">\n";
+ echo "<input type=\"hidden\" name=\"function_oid\" value=\"", htmlspecialchars($_REQUEST['function_oid']), "\">\n";
echo $misc->form;
// Show cascade drop option if supportd
if ($localData->hasDropBehavior()) {
echo "<p><input type=\"checkbox\" name=\"cascade\"> {$lang['strcascade']}</p>\n";
}
- echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\"> <input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\">\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 = $localData->dropFunction($_POST['function'], isset($_POST['cascade']));
+ $status = $localData->dropFunction($_POST['function_oid'], isset($_POST['cascade']));
if ($status == 0)
doDefault($lang['strfunctiondropped']);
else
/**
* Manage privileges in a database
*
- * $Id: privileges.php,v 1.14 2003/05/23 03:10:59 chriskl Exp $
+ * $Id: privileges.php,v 1.15 2003/06/01 11:53:45 chriskl Exp $
*/
// Include application functions
// Set name
switch ($_REQUEST['type']) {
case 'function':
- $name = $_REQUEST['function'];
+ $fn = &$localData->getFunction($_REQUEST['object']);
+ $data->fieldClean($fn->f[$data->fnFields['fnname']]);
+ $name = $fn->f[$data->fnFields['fnname']] . "(". $fn->f[$data->fnFields['fnarguments']] .")";
break;
default:
$name = $_REQUEST['object'];
echo "</form>\n";
}
else {
- $status = $localData->setPrivileges(isset($_REQUEST['grant']) ? 'GRANT' : 'REVOKE', $_REQUEST['type'], $name,
+ $status = $localData->setPrivileges(isset($_REQUEST['grant']) ? 'GRANT' : 'REVOKE', $_REQUEST['type'], $_REQUEST['object'],
isset($_REQUEST['public']), $_REQUEST['username'], $_REQUEST['groupname'], array_keys($_REQUEST['privilege']));
if ($status == 0)
doDefault($lang['strgranted']);