* A class that implements the DB interface for Postgres\r
* Note: This class uses ADODB and returns RecordSets.\r
*\r
- * $Id: Postgres72.php,v 1.3 2002/09/09 21:16:40 xzilla Exp $\r
+ * $Id: Postgres72.php,v 1.4 2002/09/10 18:46:25 xzilla Exp $\r
*/\r
\r
\r
\r
class Postgres72 extends Postgres71 {\r
\r
- var $fnFields = array('fnname' => 'proname', 'fnresult' => 'result', 'fnarguments' => 'arguments','fnoid' => 'oid');\r
+ var $fnFields = array('fnname' => 'proname', 'fnreturns' => 'return_type', 'fnarguments' => 'arguments','fnoid' => 'oid', 'fndef' => 'source', 'fnlang' => 'language' );\r
\r
// @@ Set the maximum built-in ID. Should we bother querying for this?\r
var $_lastSystemOID = 16554;\r
$sql = "SELECT \r
pc.oid,\r
proname, \r
- pt.typname AS result, \r
+ pt.typname AS return_type, \r
oidvectortypes(pc.proargtypes) AS arguments\r
FROM \r
pg_proc pc, pg_user pu, pg_type pt\r
AND pc.prorettype = 0\r
AND pc.oid > '$this->_lastSystemOID'::oid\r
ORDER BY\r
- proname, result\r
+ proname, return_type\r
";\r
\r
return $this->selectSet($sql);\r
* @param $func The name of the function to retrieve\r
* @return Function info\r
*/\r
- function getFunc($func) {\r
- $this->clean($func);\r
+ function getFunction($function_oid) {\r
+ $this->clean($function_oid);\r
\r
- $sql = "SELECT viewname, viewowner, definition FROM pg_views WHERE viewname='$view'";\r
-\r
+ $sql = "SELECT \r
+ pc.oid,\r
+ proname, \r
+ lanname as language,\r
+ format_type(prorettype, NULL) as return_type,\r
+ prosrc as source,\r
+ probin as binary,\r
+ oidvectortypes(pc.proargtypes) AS arguments\r
+ FROM \r
+ pg_proc pc, pg_language pl\r
+ WHERE \r
+ pc.oid = '$function_oid'::oid\r
+ AND pc.prolang = pl.oid\r
+ ";\r
+ \r
return $this->selectSet($sql);\r
} \r
\r
/**\r
* Manage functions in a database\r
*\r
- * $Id: functions.php,v 1.2 2002/09/09 21:16:40 xzilla Exp $\r
+ * $Id: functions.php,v 1.3 2002/09/10 18:46:25 xzilla Exp $\r
*/\r
\r
// Include application functions\r
}\r
\r
/**\r
- * Show read only properties for a view\r
+ * Show read only properties for a function\r
+ pc.oid,\r
+ proname, \r
+ lanname as language,\r
+ format_type(prorettype, NULL) as return_type,\r
+ prosrc as source,\r
+ probin as binary,\r
+ oidvectortypes(pc.proargtypes) AS arguments\r
+\r
+\r
+\r
*/\r
function doProperties($msg = '') {\r
global $data, $localData, $misc;\r
- global $PHP_SELF, $strName, $strDefinition;\r
+ global $PHP_SELF, $strFunctions, $strArguments, $strReturns, $strActions, $strNoFunctions, $strDefinition, $strLanguage;\r
\r
- echo "<h2>", htmlspecialchars($_REQUEST['database']), ": Views: ", htmlspecialchars($_REQUEST['view']), ": Properties</h2>\n";\r
+ echo "<h2>", htmlspecialchars($_REQUEST['database']), ": Functions: ", htmlspecialchars($_REQUEST['function']), ": Properties</h2>\n";\r
$misc->printMsg($msg);\r
\r
- $viewdata = &$localData->getView($_REQUEST['view']);\r
+ $funcdata = &$localData->getFunction($_REQUEST['function_oid']);\r
\r
- if ($viewdata->recordCount() > 0) {\r
- echo "<table width=100%>\n";\r
- echo "<tr><th class=data>{$strName}</th></tr>\n";\r
- echo "<tr><td class=data1>", htmlspecialchars($viewdata->f[$data->vwFields['vwname']]), "</td></tr>\n";\r
- echo "<tr><th class=data>{$strDefinition}</th></tr>\n";\r
- echo "<tr><td class=data1>", nl2br(htmlspecialchars($viewdata->f[$data->vwFields['vwdef']])), "</td></tr>\n";\r
+ if ($funcdata->recordCount() > 0) {\r
+ echo "<table width=90%>\n";\r
+ echo "<tr><th class=data>{$strFunctions}</th>\n";\r
+ echo "<th class=data>{$strArguments}</th>\n";\r
+ echo "<th class=data>{$strReturns}</th>\n";\r
+ echo "<th class=data>{$strLanguage}</th></tr>\n";\r
+ echo "<tr><td class=data1>", htmlspecialchars($funcdata->f[$data->fnFields['fnname']]), "</td>\n";\r
+ echo "<td class=data1>", htmlspecialchars($funcdata->f[$data->fnFields['fnarguments']]), "</td>\n";\r
+ echo "<td class=data1>", htmlspecialchars($funcdata->f[$data->fnFields['fnreturns']]), "</td>\n";\r
+ echo "<td class=data1>", htmlspecialchars($funcdata->f[$data->fnFields['fnlang']]), "</td></tr>\n";\r
+ echo "<tr><th class=data colspan=4>{$strDefinition}</th></tr>\n";\r
+ echo "<tr><td class=data1 colspan=4>", nl2br(htmlspecialchars($funcdata->f[$data->fnFields['fndef']])), "</td></tr>\n";\r
echo "</table>\n";\r
}\r
else echo "<p>No data.</p>\n";\r
\r
- echo "<p><a class=navlink href=\"$PHP_SELF?database=", urlencode($_REQUEST['database']), "\">Show All Views</a> |\n";\r
- echo "<a class=navlink href=\"$PHP_SELF?action=edit&database=", urlencode($_REQUEST['database']), "&view=", \r
- urlencode($_REQUEST['view']), "\">Edit</a></p>\n";\r
+ echo "<p><a class=navlink href=\"$PHP_SELF?database=", urlencode($_REQUEST['database']), "\">Show All Functions</a> |\n";\r
+ echo "<a class=navlink href=\"$PHP_SELF?action=edit&database=", urlencode($_REQUEST['database']), "&function=", \r
+ urlencode($_REQUEST['function']), "\">Edit</a></p>\n";\r
}\r
\r
/**\r
*/\r
function doDefault($msg = '') {\r
global $data, $localData, $misc, $database, $func;\r
- global $PHP_SELF, $strFunctions, $strParams, $strReturns, $strActions, $strNoFunctions;\r
+ global $PHP_SELF, $strFunctions, $strArguments, $strReturns, $strActions, $strNoFunctions;\r
\r
echo "<h2>", htmlspecialchars($_REQUEST['database']), ": Functions</h2>\n";\r
$misc->printMsg($msg);\r
\r
if ($funcs->recordCount() > 0) {\r
echo "<table>\n";\r
- echo "<tr><th class=data>{$strFunctions}</th><th class=data>{$strReturns}</th><th class=data>{$strParams}</th><th colspan=3 class=data>{$strActions}</th>\n";\r
+ echo "<tr><th class=data>{$strFunctions}</th><th class=data>{$strReturns}</th><th class=data>{$strArguments}</th><th colspan=3 class=data>{$strActions}</th>\n";\r
$i = 0;\r
while (!$funcs->EOF) {\r
\r
\r
$id = (($i % 2) == 0 ? '1' : '2');\r
echo "<tr><td class=data{$id}>", htmlspecialchars($funcs->f[$data->fnFields['fnname']]), "</td>\n";\r
- echo "<td class=data{$id}>", htmlspecialchars($funcs->f[$data->fnFields['fnresult']]), "</td>\n";\r
+ echo "<td class=data{$id}>", htmlspecialchars($funcs->f[$data->fnFields['fnreturns']]), "</td>\n";\r
echo "<td class=data{$id}>", htmlspecialchars($funcs->f[$data->fnFields['fnarguments']]), "</td>\n";\r
echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=properties&database=", \r
- htmlspecialchars($_REQUEST['database']), "&function=", urlencode($funcs->f[$data->fnFields['fnname']]), "\">Properties</a></td>\n";\r
+ htmlspecialchars($_REQUEST['database']), "&function=", urlencode($func_full), "&function_oid=", $funcs->f[$data->fnFields['fnoid']], "\">Properties</a></td>\n";\r
echo "<td class=opbutton{$id}>Edit</td>\n";\r
echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=confirm_drop&database=", \r
htmlspecialchars($_REQUEST['database']), "&function=", urlencode($func_full), "&function_oid=", $funcs->f[$data->fnFields['fnoid']], "\">Drop</a></td>\n";\r