1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* PHPPgAdmin 6.1.3 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace PHPPgAdmin\Database; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @file |
11
|
|
|
* PostgreSQL 11.x support |
12
|
|
|
*/ |
13
|
|
|
/** |
14
|
|
|
* Class to add support for Postgres11. |
15
|
|
|
*/ |
16
|
|
|
class Postgres11 extends Postgres10 |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var float |
20
|
|
|
*/ |
21
|
|
|
public $major_version = 11; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var class-string |
|
|
|
|
25
|
|
|
*/ |
26
|
|
|
public $help_classname = \PHPPgAdmin\Help\PostgresDoc11::class; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Returns a list of all functions in the database. |
30
|
|
|
* In PG 11 proagg was replaced with prokind. |
31
|
|
|
* |
32
|
|
|
* @see https://www.postgresql.org/docs/11/catalog-pg-proc.html |
33
|
|
|
* |
34
|
|
|
* @param bool $all If true, will find all available functions, if false just those in search path |
35
|
|
|
* @param mixed $type If truthy, will return functions of type trigger |
36
|
|
|
* |
37
|
|
|
* @return int|\PHPPgAdmin\ADORecordSet All functions |
38
|
|
|
*/ |
39
|
|
|
public function getFunctions($all = false, $type = null) |
40
|
|
|
{ |
41
|
|
|
if ($all) { |
42
|
|
|
$where = 'pg_catalog.pg_function_is_visible(p.oid)'; |
43
|
|
|
$distinct = 'DISTINCT ON (p.proname)'; |
44
|
|
|
|
45
|
|
|
if ($type) { |
46
|
|
|
$where .= " AND p.prorettype = (select oid from pg_catalog.pg_type p where p.typname = 'trigger') "; |
47
|
|
|
} |
48
|
|
|
} else { |
49
|
|
|
$c_schema = $this->_schema; |
50
|
|
|
$this->clean($c_schema); |
51
|
|
|
$where = "n.nspname = '{$c_schema}'"; |
52
|
|
|
$distinct = ''; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$sql = " |
56
|
|
|
SELECT |
57
|
|
|
{$distinct} |
58
|
|
|
p.oid AS prooid, |
59
|
|
|
p.proname, |
60
|
|
|
p.proretset, |
61
|
|
|
pg_catalog.format_type(p.prorettype, NULL) AS proresult, |
62
|
|
|
pg_catalog.oidvectortypes(p.proargtypes) AS proarguments, |
63
|
|
|
pl.lanname AS prolanguage, |
64
|
|
|
pg_catalog.obj_description(p.oid, 'pg_proc') AS procomment, |
65
|
|
|
p.proname || ' (' || pg_catalog.oidvectortypes(p.proargtypes) || ')' AS proproto, |
66
|
|
|
CASE WHEN p.proretset THEN 'setof ' ELSE '' END || pg_catalog.format_type(p.prorettype, NULL) AS proreturns, |
67
|
|
|
coalesce(u.usename::text,p.proowner::text) AS proowner |
68
|
|
|
|
69
|
|
|
FROM pg_catalog.pg_proc p |
70
|
|
|
INNER JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace |
71
|
|
|
INNER JOIN pg_catalog.pg_language pl ON pl.oid = p.prolang |
72
|
|
|
LEFT JOIN pg_catalog.pg_user u ON u.usesysid = p.proowner |
73
|
|
|
WHERE p.prokind !='a' |
74
|
|
|
AND {$where} |
75
|
|
|
ORDER BY p.proname, proresult |
76
|
|
|
"; |
77
|
|
|
|
78
|
|
|
return $this->selectSet($sql); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|