* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.65 2003/03/25 15:28:23 chriskl Exp $
+ * $Id: Postgres.php,v 1.66 2003/03/26 02:14:03 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
}
// Table name
- $tgdef .= " ON \"{$trigger['tgname']}\" ";
+ $tgdef .= " ON \"{$trigger['relname']}\" ";
// Deferrability
if ($trigger['tgisconstraint']) {
$tgdef .= "EXECUTE PROCEDURE \"{$trigger['tgfname']}\"(";
// Parameters
- $params = explode('\\000', $trigger['tgargs']);
- for ($findx = 0; $findx < $trigger['tgnargs']; $findx++) {
- $param = str_replace('\'', '\\\'', $params[$findx]);
- $tgdef .= $param;
- if ($findx < ($trigger['tgnargs'] - 1))
- $tgdef .= ', ';
- }
-
+ // @@ WHY DOESN'T ALL THIS WORK?
+ // @@ ACTUALLY, pg_unescape_bytea is unnecessary
+ /*
+ if (function_exists('pg_unescape_bytea')) {
+ $params = explode('\000', pg_unescape_bytea($trigger['tgargs']));
+ for ($findx = 0; $findx < $trigger['tgnargs']; $findx++) {
+ $param = str_replace('\'', '\\\'', $params[$findx]);
+ $tgdef .= $param;
+ if ($findx < ($trigger['tgnargs'] - 1))
+ $tgdef .= ', ';
+ }
+ }
+ else */ $tgdef .= "args here";
+
// Finish it off
$tgdef .= ')';
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres73.php,v 1.31 2003/03/25 15:28:24 chriskl Exp $
+ * $Id: Postgres73.php,v 1.32 2003/03/26 02:14:04 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
function &getTriggers($table = '') {
$this->clean($table);
- $sql = "SELECT t.tgname, NULL AS tgdef
- FROM pg_catalog.pg_trigger t
- WHERE t.tgrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='{$table}'
- AND relnamespace=(SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$this->_schema}'))
+ $sql = "SELECT t.tgname, t.tgisconstraint, t.tgdeferrable, t.tginitdeferred, t.tgtype,
+ t.tgargs, t.tgnargs, p.proname AS tgfname, c.relname, NULL AS tgdef
+ FROM pg_catalog.pg_trigger t LEFT JOIN pg_catalog.pg_proc p
+ ON t.tgfoid=p.oid, pg_catalog.pg_class c
+ WHERE t.tgrelid=c.oid
+ AND c.relname='{$table}'
+ AND c.relnamespace=(SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$this->_schema}')
AND (NOT tgisconstraint OR NOT EXISTS
(SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c
ON (d.refclassid = c.tableoid AND d.refobjid = c.oid)
/**
* List triggers on a table
*
- * $Id: triggers.php,v 1.9 2003/03/25 15:28:22 chriskl Exp $
+ * $Id: triggers.php,v 1.10 2003/03/26 02:14:03 chriskl Exp $
*/
// Include application functions
$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
$PHP_SELF = $_SERVER['PHP_SELF'];
-
-
- function getTriggerExecTime($type) {
- $execTime = "AFTER";
- if ($type & TRIGGER_TYPE_BEFORE) $execTime = "BEFORE";
-
- return $execTime;
- }
-
- function getTriggerEvent($type) {
- if ($type & TRIGGER_TYPE_INSERT) $event = "INSERT";
- elseif ($type & TRIGGER_TYPE_DELETE) $event = "DELETE";
-
- if ($type & TRIGGER_TYPE_UPDATE) $event .= (empty($event)) ? "UPDATE" : " OR UPDATE";
-
- return $event;
-
- }
-
/**
* Show confirmation of drop and perform actual drop
*/
$i = 0;
while (!$triggers->EOF) {
- //$execTime = htmlspecialchars( getTriggerExecTime($triggers->f[$data->tgFields['tgtype']]));
- //$event = htmlspecialchars( getTriggerEvent($triggers->f[$data->tgFields['tgtype']]));
$id = ( ($i % 2 ) == 0 ? '1' : '2' );
echo "<tr><td class=\"data{$id}\">", htmlspecialchars( $triggers->f[$data->tgFields['tgname']]), "</td>";
- echo "<td class=\"data{$id}\">", htmlspecialchars( $triggers->f[$data->tgFields['tgdef']]), "</td>";
echo "<td class=\"data{$id}\">";
+ // Nasty hack to support pre-7.4 PostgreSQL
+ if ($triggers->f[$data->tgFields['tgdef']] !== null)
+ echo htmlspecialchars($triggers->f[$data->tgFields['tgdef']]);
+ else
+ echo $localData->getTriggerDef($triggers->f);
+ echo "</td>\n<td class=\"data{$id}\">";
echo "<a href=\"$PHP_SELF?action=confirm_drop&{$misc->href}&trigger=", urlencode( $triggers->f[$data->tgFields['tgname']]),
"&table=", urlencode($_REQUEST['table']), "\">{$lang['strdrop']}</td></tr>\n";