@@ 243-271 (lines=29) @@ | ||
240 | * @return \PommProject\Foundation\ConvertedResultIterator |
|
241 | * @deprecated |
|
242 | */ |
|
243 | public function getSchemaRelations($schema_oid, Where $where = null) |
|
244 | { |
|
245 | $condition = Where::create('relnamespace = $*', [$schema_oid]) |
|
246 | ->andWhere(Where::createWhereIn('relkind', ['r', 'v', 'm', 'f'])) |
|
247 | ->andWhere($where) |
|
248 | ; |
|
249 | ||
250 | $sql = <<<SQL |
|
251 | select |
|
252 | cl.relname as "name", |
|
253 | case |
|
254 | when cl.relkind = 'r' then 'table' |
|
255 | when cl.relkind = 'v' then 'view' |
|
256 | when cl.relkind = 'm' then 'materialized view' |
|
257 | when cl.relkind = 'f' then 'foreign table' |
|
258 | else 'other' |
|
259 | end as "type", |
|
260 | cl.oid as "oid", |
|
261 | des.description as "comment" |
|
262 | from |
|
263 | pg_catalog.pg_class cl |
|
264 | left join pg_catalog.pg_description des on |
|
265 | cl.oid = des.objoid and des.objsubid = 0 |
|
266 | where {condition} |
|
267 | order by name asc |
|
268 | SQL; |
|
269 | ||
270 | return $this->executeSql($sql, $condition); |
|
271 | } |
|
272 | ||
273 | /** |
|
274 | * getTableComment |
@@ 62-93 (lines=32) @@ | ||
59 | * @param Where $where |
|
60 | * @return ConvertedResultIterator |
|
61 | */ |
|
62 | public function getRelations(Where $where = null) |
|
63 | { |
|
64 | $condition = Where::createWhereIn('relkind', ['r', 'v', 'm', 'f']) |
|
65 | ->andWhere($where) |
|
66 | ; |
|
67 | ||
68 | $sql = <<<SQL |
|
69 | select |
|
70 | cl.relname as "name", |
|
71 | case |
|
72 | when cl.relkind = 'r' then 'table' |
|
73 | when cl.relkind = 'v' then 'view' |
|
74 | when cl.relkind = 'm' then 'materialized view' |
|
75 | when cl.relkind = 'f' then 'foreign table' |
|
76 | else 'other' |
|
77 | end as "type", |
|
78 | n.nspname as "schema", |
|
79 | cl.oid as "oid", |
|
80 | o.rolname as "owner", |
|
81 | case |
|
82 | when cl.relkind = 'r' then pg_size_pretty(pg_relation_size(cl.oid::regclass)) |
|
83 | else null |
|
84 | end as "size", |
|
85 | des.description as "comment" |
|
86 | from |
|
87 | pg_catalog.pg_class cl |
|
88 | left join pg_catalog.pg_description des on |
|
89 | cl.oid = des.objoid and des.objsubid = 0 |
|
90 | join pg_catalog.pg_roles o on cl.relowner = o.oid |
|
91 | join pg_catalog.pg_namespace n on cl.relnamespace = n.oid |
|
92 | where {condition} |
|
93 | order by name asc |
|
94 | SQL; |
|
95 | ||
96 | return $this->executeSql($sql, $condition); |