1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* PHPPgAdmin v6.0.0-beta.44 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace PHPPgAdmin\Database; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @file |
11
|
|
|
* PostgreSQL 9.6 support |
12
|
|
|
*/ |
13
|
|
|
class Postgres96 extends Postgres |
14
|
|
|
{ |
15
|
|
|
public $major_version = 9.6; |
16
|
|
|
|
17
|
|
|
// Administration functions |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Returns all available process information. |
21
|
|
|
* |
22
|
|
|
* @param $database (optional) Find only connections to specified database |
|
|
|
|
23
|
|
|
* |
24
|
|
|
* @return \PHPPgAdmin\ADORecordSet A recordset |
25
|
|
|
*/ |
26
|
|
|
public function getProcesses($database = null) |
27
|
|
|
{ |
28
|
|
|
if ($database === null) { |
29
|
|
|
$sql = "SELECT datid, datname, pid, usename, application_name, client_addr, state, wait_event_type, wait_event, state_change as query_start, |
30
|
|
|
CASE |
31
|
|
|
WHEN state='active' THEN query |
32
|
|
|
ELSE state |
33
|
|
|
END AS query |
34
|
|
|
FROM pg_catalog.pg_stat_activity |
35
|
|
|
ORDER BY datname, usename, pid"; |
36
|
|
|
} else { |
37
|
|
|
$this->clean($database); |
38
|
|
|
$sql = "SELECT datid, datname, pid, usename, application_name, client_addr, state, wait_event_type, wait_event, state_change as query_start, |
39
|
|
|
CASE |
40
|
|
|
WHEN state='active' THEN query |
41
|
|
|
ELSE state |
42
|
|
|
END AS query |
43
|
|
|
FROM pg_catalog.pg_stat_activity |
44
|
|
|
WHERE datname='{$database}' |
45
|
|
|
ORDER BY usename, pid"; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
return $this->selectSet($sql); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function hasUserSignals() |
52
|
|
|
{ |
53
|
|
|
return true; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Creates a new user. As of PG 9.6, CREATEUSER privilege has been deprecated |
58
|
|
|
* @see {@link https://www.postgresql.org/docs/9.6/static/sql-createrole.html} |
59
|
|
|
* @param string $username The username of the user to create |
|
|
|
|
60
|
|
|
* @param string $password A password for the user |
61
|
|
|
* @param bool $createdb boolean Whether or not the user can create databases |
62
|
|
|
* @param bool $createrole boolean Whether or not the user can create other users |
63
|
|
|
* @param string $expiry string Format 'YYYY-MM-DD HH:MM:SS'. '' means never expire |
64
|
|
|
* @param array $groups The groups to create the user in |
65
|
|
|
* |
66
|
|
|
* @return int 0 if operation was successful |
67
|
|
|
* |
68
|
|
|
* @internal param $group (array) The groups to create the user in |
69
|
|
|
*/ |
70
|
|
|
public function createUser($username, $password, $createdb, $createrole, $expiry, $groups) |
71
|
|
|
{ |
72
|
|
|
$enc = $this->_encryptPassword($username, $password); |
73
|
|
|
$this->fieldClean($username); |
74
|
|
|
$this->clean($enc); |
75
|
|
|
$this->clean($expiry); |
76
|
|
|
$this->fieldArrayClean($groups); |
77
|
|
|
|
78
|
|
|
$sql = "CREATE USER \"{$username}\""; |
79
|
|
|
if ($password != '') { |
80
|
|
|
$sql .= " WITH ENCRYPTED PASSWORD '{$enc}'"; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
$sql .= $createdb ? ' CREATEDB' : ' NOCREATEDB'; |
84
|
|
|
$sql .= $createrole ? ' CREATEROLE' : ' NOCREATEROLE'; |
85
|
|
|
if (is_array($groups) && sizeof($groups) > 0) { |
86
|
|
|
$sql .= ' IN GROUP "' . join('", "', $groups) . '"'; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
if ($expiry != '') { |
90
|
|
|
$sql .= " VALID UNTIL '{$expiry}'"; |
91
|
|
|
} else { |
92
|
|
|
$sql .= " VALID UNTIL 'infinity'"; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
return $this->execute($sql); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
} |
99
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths