Passed
Push — master ( 2856b4...cf0423 )
by Felipe
10:02 queued 05:52
created

Postgres92::hasUserSignals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * PHPPgAdmin v6.0.0-beta.33
5
 */
6
7
namespace PHPPgAdmin\Database;
8
9
/**
10
 * @file
11
 * PostgreSQL 9.2 support
12
 */
13
class Postgres92 extends Postgres93
14
{
15
    public $major_version = 9.2;
16
17
    /**
18
     * Returns all available process information.
19
     *
20
     * @param $database (optional) Find only connections to specified database
0 ignored issues
show
Bug introduced by
The type PHPPgAdmin\Database\optional was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
     *
22
     * @return \ADORecordSet A recordset
23
     */
24
    public function getProcesses($database = null)
25
    {
26
        if ($database === null) {
27
            $sql = "SELECT datname, usename, pid, waiting, state_change as query_start,
28
                  case when state='idle in transaction' then '<IDLE> in transaction' when state = 'idle' then '<IDLE>' else query end as query
29
				FROM pg_catalog.pg_stat_activity
30
				ORDER BY datname, usename, pid";
31
        } else {
32
            $this->clean($database);
33
            $sql = "SELECT datname, usename, pid, waiting, state_change as query_start,
34
                  case when state='idle in transaction' then '<IDLE> in transaction' when state = 'idle' then '<IDLE>' else query end as query
35
				FROM pg_catalog.pg_stat_activity
36
				WHERE datname='{$database}'
37
				ORDER BY usename, pid";
38
        }
39
40
        return $this->selectSet($sql);
41
    }
42
43
    /**
44
     * Retrieves information for all tablespaces.
45
     *
46
     * @param bool $all Include all tablespaces (necessary when moving objects back to the default space)
47
     *
48
     * @return \ADORecordSet A recordset
49
     */
50
    public function getTablespaces($all = false)
51
    {
52
        $conf = $this->conf;
53
54
        $sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, pg_catalog.pg_tablespace_location(oid) as spclocation,
55
                    (SELECT description FROM pg_catalog.pg_shdescription pd WHERE pg_tablespace.oid=pd.objoid AND pd.classoid='pg_tablespace'::regclass) AS spccomment
56
					FROM pg_catalog.pg_tablespace";
57
58
        if (!$conf['show_system'] && !$all) {
59
            $sql .= ' WHERE spcname NOT LIKE $$pg\_%$$';
60
        }
61
62
        $sql .= ' ORDER BY spcname';
63
64
        return $this->selectSet($sql);
65
    }
66
67
    // Misc functions
68
69
    /**
70
     * Retrieves a tablespace's information.
71
     *
72
     * @param $spcname
73
     *
74
     * @return \ADORecordSet A recordset
75
     */
76
    public function getTablespace($spcname)
77
    {
78
        $this->clean($spcname);
79
80
        $sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, pg_catalog.pg_tablespace_location(oid) as spclocation,
81
                    (SELECT description FROM pg_catalog.pg_shdescription pd WHERE pg_tablespace.oid=pd.objoid AND pd.classoid='pg_tablespace'::regclass) AS spccomment
82
					FROM pg_catalog.pg_tablespace WHERE spcname='{$spcname}'";
83
84
        return $this->selectSet($sql);
85
    }
86
87
}
88