* Context-sensitive online help system
* Use language preferencies from browser (Markus Bertheau, Nicola Soranzo)
* Tablespace support for 7.5
+* Support cancelling and killing backend processes in 7.5
Translations
* Arabic from Zaki
/**
* Class to hold various commonly used functions
*
- * $Id: Misc.php,v 1.67 2004/07/07 03:00:01 chriskl Exp $
+ * $Id: Misc.php,v 1.68 2004/07/08 03:23:01 chriskl Exp $
*/
class Misc {
function printTable(&$tabledata, &$columns, &$actions, $nodata = null, $pre_fn = null) {
global $data, $conf, $misc;
global $PHP_SELF;
-
+
if ($tabledata->recordCount() > 0) {
// Remove the 'comment' column if they have been disabled
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: BaseDB.php,v 1.49 2004/07/04 15:02:35 chriskl Exp $
+ * $Id: BaseDB.php,v 1.50 2004/07/08 03:23:02 chriskl Exp $
*/
include_once('./classes/database/ADODB_base.php');
function hasForeignKeysInfo() { return false; }
function hasViewColumnRename() { return false; }
function hasTablespaces() { return false; }
+ function hasSignals() { return false; }
}
/**
* PostgreSQL 7.5 support
*
- * $Id: Postgres75.php,v 1.9 2004/07/07 03:00:07 chriskl Exp $
+ * $Id: Postgres75.php,v 1.10 2004/07/08 03:23:02 chriskl Exp $
*/
include_once('./classes/database/Postgres74.php');
return $this->endTransaction();
}
+
+ // Backend process signalling functions
+
+ /**
+ * Sends a cancel or kill command to a process
+ * @param $pid The ID of the backend process
+ * @param $signal 'CANCEL' or 'KILL'
+ * @return 0 success
+ * @return -1 invalid signal type
+ */
+ function sendSignal($pid, $signal) {
+ // Clean
+ $pid = (int)$pid;
+
+ if ($signal == 'CANCEL')
+ $sql = "SELECT pg_catalog.pg_cancel_backend({$pid}) AS val";
+ elseif ($signal == 'KILL')
+ $sql = "SELECT pg_catalog.pg_terminate_backend({$pid}) AS val";
+ else
+ return -1;
+
+ // Execute the query
+ $val = $this->selectField($sql, 'val');
+ if ($val === -1) return -1;
+ elseif ($val == '1') return 0;
+ else return -1;
+ }
+
function hasAlterColumnType() { return true; }
function hasTablespaces() {
$platform = $this->getPlatform();
return $platform != 'MINGW';
}
+ function hasSignals() { return true; }
}
/**
* Manage schemas within a database
*
- * $Id: database.php,v 1.50 2004/07/07 02:59:56 chriskl Exp $
+ * $Id: database.php,v 1.51 2004/07/08 03:23:01 chriskl Exp $
*/
// Include application functions
return str_replace($term, "<b>{$term}</b>", $string);
}
+ /**
+ * Sends a signal to a process
+ */
+ function doSignal() {
+ global $data, $lang;
+
+ $status = $data->sendSignal($_REQUEST['procpid'], $_REQUEST['signal']);
+ if ($status == 0)
+ doProcesses($lang['strsignalsent']);
+ else
+ doProcesses($lang['strsignalsentbad']);
+ }
+
/**
* Searches for a named database object
*/
* Show all current database connections and any queries they
* are running.
*/
- function doProcesses() {
+ function doProcesses($msg = '') {
global $PHP_SELF, $data, $misc;
global $lang;
$processes = &$data->getProcesses($_REQUEST['database']);
$misc->printDatabaseNav();
- $misc->printTitle(array($misc->printVal($_REQUEST['database']),$lang['strprocesses']),'processes');
-
+ $misc->printTitle(array($misc->printVal($_REQUEST['database']), $lang['strprocesses']), 'processes');
+ $misc->printMsg($msg);
+
$columns = array(
'user' => array(
'title' => $lang['strusername'],
'field' => 'query_start',
),
);
-
- $actions = array();
+
+ if ($data->hasSignals()) {
+ $columns['actions'] = array('title' => $lang['stractions']);
+
+ $actions = array(
+ 'cancel' => array(
+ 'title' => $lang['strcancel'],
+ 'url' => "{$PHP_SELF}?action=signal&signal=CANCEL&database=" . urlencode($_REQUEST['database']) . "&",
+ 'vars' => array('procpid' => 'procpid')
+ ),
+ 'kill' => array(
+ 'title' => $lang['strkill'],
+ 'url' => "{$PHP_SELF}?action=signal&signal=KILL&database=" . urlencode($_REQUEST['database']) . "&",
+ 'vars' => array('procpid' => 'procpid')
+ )
+ );
+ }
+ else $actions = array();
// Remove query start time for <7.4
if (!isset($processes->f['query_start'])) unset($columns['start_time']);
case 'export':
doExport();
break;
+ case 'signal':
+ doSignal();
+ break;
default:
if ($data->hasSchemas())
doDefault();
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.151 2004/07/07 03:00:07 chriskl Exp $
+ * $Id: english.php,v 1.152 2004/07/08 03:23:02 chriskl Exp $
*/
// Language and character set
$lang['strstarttime'] = 'Start Time';
$lang['strfile'] = 'File';
$lang['strfileimported'] = 'File imported.';
+ $lang['strkill'] = 'Kill';
// Error handling
$lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
$lang['strfull'] = 'Full';
$lang['strfreeze'] = 'Freeze';
$lang['strforce'] = 'Force';
+ $lang['strsignalsent'] = 'Signal sent.';
+ $lang['strsignalsentbad'] = 'Failed sending signal.';
// Views
$lang['strview'] = 'View';
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.104 2004/07/07 03:00:07 chriskl Exp $
+ * $Id: english.php,v 1.105 2004/07/08 03:23:02 chriskl Exp $
*/
// Language and character set
$lang['strstarttime'] = 'Start Time';
$lang['strfile'] = 'File';
$lang['strfileimported'] = 'File imported.';
+ $lang['strkill'] = 'Kill';
// Error handling
$lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
$lang['strfull'] = 'Full';
$lang['strfreeze'] = 'Freeze';
$lang['strforce'] = 'Force';
+ $lang['strsignalsent'] = 'Signal sent.';
+ $lang['strsignalsentbad'] = 'Failed sending signal.';
// Views
$lang['strview'] = 'View';