1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
<?php
/**
* PHPPgAdmin v6.0.0-beta.51
*/
namespace PHPPgAdmin\Database;
/**
* @file
* PostgreSQL 9.2 support
*/
class Postgres92 extends Postgres93
{
public $typIndexes = ['BTREE', 'RTREE', 'GIST', 'GIN', 'HASH'];
public $major_version = 9.2;
/**
* Returns all available process information.
*
* @param null|string $database (optional) Find only connections to specified database
*
* @return \PHPPgAdmin\ADORecordSet A recordset
*/
public function getProcesses($database = null)
{
if ($database === null) {
$sql = "SELECT datname, usename, pid, waiting, state_change as query_start,
case when state='idle in transaction' then '<IDLE> in transaction' when state = 'idle' then '<IDLE>' else query end as query
FROM pg_catalog.pg_stat_activity
ORDER BY datname, usename, pid";
} else {
$this->clean($database);
$sql = "SELECT datname, usename, pid, waiting, state_change as query_start,
case when state='idle in transaction' then '<IDLE> in transaction' when state = 'idle' then '<IDLE>' else query end as query
FROM pg_catalog.pg_stat_activity
WHERE datname='{$database}'
ORDER BY usename, pid";
}
return $this->selectSet($sql);
}
/**
* Retrieves information for all tablespaces.
*
* @param bool $all Include all tablespaces (necessary when moving objects back to the default space)
*
* @return \PHPPgAdmin\ADORecordSet A recordset
*/
public function getTablespaces($all = false)
{
$conf = $this->conf;
$sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, pg_catalog.pg_tablespace_location(oid) as spclocation,
(SELECT description FROM pg_catalog.pg_shdescription pd WHERE pg_tablespace.oid=pd.objoid AND pd.classoid='pg_tablespace'::regclass) AS spccomment
FROM pg_catalog.pg_tablespace";
if (!$conf['show_system'] && !$all) {
$sql .= ' WHERE spcname NOT LIKE $$pg\_%$$';
}
$sql .= ' ORDER BY spcname';
return $this->selectSet($sql);
}
// Misc functions
/**
* Retrieves a tablespace's information.
*
* @param $spcname
*
* @return \PHPPgAdmin\ADORecordSet A recordset
*/
public function getTablespace($spcname)
{
$this->clean($spcname);
$sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, pg_catalog.pg_tablespace_location(oid) as spclocation,
(SELECT description FROM pg_catalog.pg_shdescription pd WHERE pg_tablespace.oid=pd.objoid AND pd.classoid='pg_tablespace'::regclass) AS spccomment
FROM pg_catalog.pg_tablespace WHERE spcname='{$spcname}'";
return $this->selectSet($sql);
}
}
|