Issues (217)

src/database/Postgres93.php (1 issue)

1
<?php
2
3
/**
4
 * PHPPgAdmin 6.1.3
5
 */
6
7
namespace PHPPgAdmin\Database;
8
9
/**
10
 * @file
11
 * PostgreSQL 9.3 support
12
 */
13
class Postgres93 extends Postgres94
14
{
15
    /**
16
     * @var float
17
     */
18
    public $major_version = 9.3;
19
20
    /**
21
     * @var class-string
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string.
Loading history...
22
     */
23
    public $help_classname = \PHPPgAdmin\Help\PostgresDoc93::class;
24
25
    /**
26
     * Returns a list of all functions in the database.
27
     *
28
     * @param bool  $all  If true, will find all available functions, if false just those in search path
29
     * @param mixed $type If not null, will find all trigger functions
30
     *
31
     * @return int|\PHPPgAdmin\ADORecordSet All functions
32
     */
33
    public function getFunctions($all = false, $type = null)
34
    {
35
        if ($all) {
36
            $where = 'pg_catalog.pg_function_is_visible(p.oid)';
37
            $distinct = 'DISTINCT ON (p.proname)';
38
39
            if ($type) {
40
                $where .= " AND p.prorettype = (select oid from pg_catalog.pg_type p where p.typname = 'trigger') ";
41
            }
42
        } else {
43
            $c_schema = $this->_schema;
44
            $this->clean($c_schema);
45
            $where = "n.nspname = '{$c_schema}'";
46
            $distinct = '';
47
        }
48
49
        $sql = "
50
			SELECT
51
				{$distinct}
52
				p.oid AS prooid,
53
				p.proname,
54
				p.proretset,
55
				pg_catalog.format_type(p.prorettype, NULL) AS proresult,
56
				pg_catalog.oidvectortypes(p.proargtypes) AS proarguments,
57
				pl.lanname AS prolanguage,
58
				pg_catalog.obj_description(p.oid, 'pg_proc') AS procomment,
59
				p.proname || ' (' || pg_catalog.oidvectortypes(p.proargtypes) || ')' AS proproto,
60
				CASE WHEN p.proretset THEN 'setof ' ELSE '' END || pg_catalog.format_type(p.prorettype, NULL) AS proreturns,
61
				coalesce(u.rolname::text,p.proowner::text) AS proowner
62
63
			FROM pg_catalog.pg_proc p
64
				INNER JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
65
				INNER JOIN pg_catalog.pg_language pl ON pl.oid = p.prolang
66
				LEFT JOIN pg_catalog.pg_roles u ON u.oid = p.proowner
67
			WHERE NOT p.proisagg
68
				AND {$where}
69
			ORDER BY p.proname, proresult
70
			";
71
72
        return $this->selectSet($sql);
73
    }
74
}
75