Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Postgres10.php « database « src - github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b283f1a93f1b2bb0880ebf54afca4e0b6bcc76e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php

/**
 * PHPPgAdmin 6.1.3
 */

namespace PHPPgAdmin\Database;

use PHPPgAdmin\ADORecordSet;
use PHPPgAdmin\Help\PostgresDoc10;

/**
 * @file
 * PostgreSQL 10.x support
 *
 * @todo add support for identify columns
 *
 * @see https://blog.2ndquadrant.com/postgresql-10-identity-columns/
 */
/**
 * Class to add support for Postgres10.
 */
class Postgres10 extends Postgres96
{
    /**
     * @var float
     */
    public $major_version = 10;

    /**
     * @var class-string
     */
    public $help_classname = PostgresDoc10::class;

    /**
     * Return all tables in current database (and schema).
     *
     * @return \RecordSet|int|string All tables, sorted alphabetically
     */
    public function getTables()
    {
        $c_schema = $this->_schema;
        $this->clean($c_schema);

        $sql = "
                SELECT c.relname,
                    pg_catalog.pg_get_userbyid(c.relowner) AS relowner,
                    pg_catalog.obj_description(c.oid, 'pg_class') AS relcomment,
                    reltuples::bigint as reltuples,
                    pt.spcname as tablespace, ";

        /*
         * Either display_sizes is true for tables and schemas,
         * or we must check if said config is an associative array
         */
        if ($this->conf['display_sizes']['tables']) {
            $sql .= ' pg_size_pretty(pg_total_relation_size(c.oid)) as table_size ';
        } else {
            $sql .= "   'N/A' as table_size ";
        }

        $sql .= \sprintf(
            ' FROM pg_catalog.pg_class c
                LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
                LEFT JOIN  pg_catalog.pg_tablespace pt ON  pt.oid=c.reltablespace
                WHERE c.relkind IN (\'r\',\'p\')
                AND nspname=\'%s\'
                ORDER BY c.relname',
            $c_schema
        );

        return $this->selectSet($sql);
    }
}