1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* PHPPgAdmin 6.1.3 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace PHPPgAdmin\Database; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @file |
11
|
|
|
* PostgreSQL 9.1 support |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Id: Postgres82.php,v 1.10 2007/12/28 16:21:25 ioguix Exp $. |
16
|
|
|
*/ |
17
|
|
|
class Postgres91 extends Postgres92 |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var float |
21
|
|
|
*/ |
22
|
|
|
public $major_version = 9.1; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var class-string |
|
|
|
|
26
|
|
|
*/ |
27
|
|
|
public $help_classname = \PHPPgAdmin\Help\PostgresDoc91::class; |
28
|
|
|
|
29
|
|
|
// Administration functions |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Returns all available process information. |
33
|
|
|
* |
34
|
|
|
* @param null|string $database (optional) Find only connections to specified database |
35
|
|
|
* |
36
|
|
|
* @return int|\PHPPgAdmin\ADORecordSet A recordset |
37
|
|
|
*/ |
38
|
|
|
public function getProcesses($database = null) |
39
|
|
|
{ |
40
|
|
|
if (null === $database) { |
41
|
|
|
$sql = 'SELECT datname, usename, procpid AS pid, waiting, current_query AS query, query_start |
42
|
|
|
FROM pg_catalog.pg_stat_activity |
43
|
|
|
ORDER BY datname, usename, procpid'; |
44
|
|
|
} else { |
45
|
|
|
$this->clean($database); |
46
|
|
|
$sql = "SELECT datname, usename, procpid AS pid, waiting, current_query AS query, query_start |
47
|
|
|
FROM pg_catalog.pg_stat_activity |
48
|
|
|
WHERE datname='{$database}' |
49
|
|
|
ORDER BY usename, procpid"; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
return $this->selectSet($sql); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
// Tablespace functions |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Retrieves information for all tablespaces. |
59
|
|
|
* |
60
|
|
|
* @param bool $all Include all tablespaces (necessary when moving objects back to the default space) |
61
|
|
|
* |
62
|
|
|
* @return int|\PHPPgAdmin\ADORecordSet A recordset |
63
|
|
|
*/ |
64
|
|
|
public function getTablespaces($all = false) |
65
|
|
|
{ |
66
|
|
|
$conf = $this->conf; |
67
|
|
|
|
68
|
|
|
$sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, spclocation, |
69
|
|
|
(SELECT description FROM pg_catalog.pg_shdescription pd WHERE pg_tablespace.oid=pd.objoid AND pd.classoid='pg_tablespace'::regclass) AS spccomment |
70
|
|
|
FROM pg_catalog.pg_tablespace"; |
71
|
|
|
|
72
|
|
|
if (!$conf['show_system'] && !$all) { |
73
|
|
|
$sql .= ' WHERE spcname NOT LIKE $$pg\_%$$'; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$sql .= ' ORDER BY spcname'; |
77
|
|
|
|
78
|
|
|
return $this->selectSet($sql); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Retrieves a tablespace's information. |
83
|
|
|
* |
84
|
|
|
* @param string $spcname |
85
|
|
|
* |
86
|
|
|
* @return int|\PHPPgAdmin\ADORecordSet A recordset |
87
|
|
|
*/ |
88
|
|
|
public function getTablespace($spcname) |
89
|
|
|
{ |
90
|
|
|
$this->clean($spcname); |
91
|
|
|
|
92
|
|
|
$sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, spclocation, |
93
|
|
|
(SELECT description FROM pg_catalog.pg_shdescription pd WHERE pg_tablespace.oid=pd.objoid AND pd.classoid='pg_tablespace'::regclass) AS spccomment |
94
|
|
|
FROM pg_catalog.pg_tablespace WHERE spcname='{$spcname}'"; |
95
|
|
|
|
96
|
|
|
return $this->selectSet($sql); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
// Capabilities |
100
|
|
|
public function hasUserSignals() |
101
|
|
|
{ |
102
|
|
|
return false; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|