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