@@ 429-454 (lines=26) @@ | ||
426 | * |
|
427 | * @return \PHPPgAdmin\ADORecordSet A recordset |
|
428 | */ |
|
429 | public function getLocks() |
|
430 | { |
|
431 | $conf = $this->conf; |
|
432 | ||
433 | if (!$conf['show_system']) { |
|
434 | $where = 'AND pn.nspname NOT LIKE $$pg\_%$$'; |
|
435 | } else { |
|
436 | $where = "AND nspname !~ '^pg_t(emp_[0-9]+|oast)$'"; |
|
437 | } |
|
438 | ||
439 | $sql = " |
|
440 | SELECT |
|
441 | pn.nspname, pc.relname AS tablename, pl.pid, pl.mode, pl.granted, pl.virtualtransaction, |
|
442 | (select transactionid from pg_catalog.pg_locks l2 where l2.locktype='transactionid' |
|
443 | and l2.mode='ExclusiveLock' and l2.virtualtransaction=pl.virtualtransaction) as transaction |
|
444 | FROM |
|
445 | pg_catalog.pg_locks pl, |
|
446 | pg_catalog.pg_class pc, |
|
447 | pg_catalog.pg_namespace pn |
|
448 | WHERE |
|
449 | pl.relation = pc.oid AND pc.relnamespace=pn.oid |
|
450 | {$where} |
|
451 | ORDER BY pid,nspname,tablename"; |
|
452 | ||
453 | return $this->selectSet($sql); |
|
454 | } |
|
455 | ||
456 | /** |
|
457 | * Sends a cancel or kill command to a process. |
@@ 21-44 (lines=24) @@ | ||
18 | * |
|
19 | * @return \PHPPgAdmin\ADORecordSet All schemas, sorted alphabetically |
|
20 | */ |
|
21 | public function getSchemas() |
|
22 | { |
|
23 | $conf = $this->conf; |
|
24 | ||
25 | if (!$conf['show_system']) { |
|
26 | $where = "WHERE nspname NOT LIKE 'pg@_%' ESCAPE '@' AND nspname != 'information_schema'"; |
|
27 | } else { |
|
28 | $where = "WHERE nspname !~ '^pg_t(emp_[0-9]+|oast)$'"; |
|
29 | } |
|
30 | ||
31 | $sql = " |
|
32 | SELECT pn.nspname, |
|
33 | pu.rolname AS nspowner, |
|
34 | pg_catalog.obj_description(pn.oid, 'pg_namespace') AS nspcomment, |
|
35 | pg_size_pretty(SUM(pg_total_relation_size(pg_class.oid))) as schema_size |
|
36 | FROM pg_catalog.pg_namespace pn |
|
37 | LEFT JOIN pg_catalog.pg_class ON relnamespace = pn.oid |
|
38 | LEFT JOIN pg_catalog.pg_roles pu ON (pn.nspowner = pu.oid) |
|
39 | {$where} |
|
40 | GROUP BY pn.nspname, pu.rolname, pg_catalog.obj_description(pn.oid, 'pg_namespace') |
|
41 | ORDER BY nspname"; |
|
42 | ||
43 | return $this->selectSet($sql); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * Sets the current working schema. Will also set Class variable. |
@@ 430-468 (lines=39) @@ | ||
427 | * |
|
428 | * @return \PHPPgAdmin\ADORecordSet All casts |
|
429 | */ |
|
430 | public function getCasts() |
|
431 | { |
|
432 | $conf = $this->conf; |
|
433 | ||
434 | if ($conf['show_system']) { |
|
435 | $where = ''; |
|
436 | } else { |
|
437 | $where = ' |
|
438 | AND n1.nspname NOT LIKE $$pg\_%$$ |
|
439 | AND n2.nspname NOT LIKE $$pg\_%$$ |
|
440 | AND n3.nspname NOT LIKE $$pg\_%$$ |
|
441 | '; |
|
442 | } |
|
443 | ||
444 | $sql = " |
|
445 | SELECT |
|
446 | c.castsource::pg_catalog.regtype AS castsource, |
|
447 | c.casttarget::pg_catalog.regtype AS casttarget, |
|
448 | CASE WHEN c.castfunc=0 THEN NULL |
|
449 | ELSE c.castfunc::pg_catalog.regprocedure END AS castfunc, |
|
450 | c.castcontext, |
|
451 | obj_description(c.oid, 'pg_cast') as castcomment |
|
452 | FROM |
|
453 | (pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p ON c.castfunc=p.oid JOIN pg_catalog.pg_namespace n3 ON p.pronamespace=n3.oid), |
|
454 | pg_catalog.pg_type t1, |
|
455 | pg_catalog.pg_type t2, |
|
456 | pg_catalog.pg_namespace n1, |
|
457 | pg_catalog.pg_namespace n2 |
|
458 | WHERE |
|
459 | c.castsource=t1.oid |
|
460 | AND c.casttarget=t2.oid |
|
461 | AND t1.typnamespace=n1.oid |
|
462 | AND t2.typnamespace=n2.oid |
|
463 | {$where} |
|
464 | ORDER BY 1, 2 |
|
465 | "; |
|
466 | ||
467 | return $this->selectSet($sql); |
|
468 | } |
|
469 | ||
470 | /** |
|
471 | * Returns a list of all conversions in the database. |
@@ 382-403 (lines=22) @@ | ||
379 | * |
|
380 | * @return \PHPPgAdmin\ADORecordSet A recordset |
|
381 | */ |
|
382 | public function getLanguages($all = false) |
|
383 | { |
|
384 | $conf = $this->conf; |
|
385 | ||
386 | if ($conf['show_system'] || $all) { |
|
387 | $where = ''; |
|
388 | } else { |
|
389 | $where = 'WHERE lanispl'; |
|
390 | } |
|
391 | ||
392 | $sql = " |
|
393 | SELECT |
|
394 | lanname, lanpltrusted, |
|
395 | lanplcallfoid::pg_catalog.regproc AS lanplcallf |
|
396 | FROM |
|
397 | pg_catalog.pg_language |
|
398 | {$where} |
|
399 | ORDER BY lanname |
|
400 | "; |
|
401 | ||
402 | return $this->selectSet($sql); |
|
403 | } |
|
404 | ||
405 | /** |
|
406 | * Executes an SQL script as a series of SQL statements. Returns |
@@ 262-278 (lines=17) @@ | ||
259 | * |
|
260 | * @return \PHPPgAdmin\ADORecordSet A recordset |
|
261 | */ |
|
262 | public function getLocks() |
|
263 | { |
|
264 | $conf = $this->conf; |
|
265 | ||
266 | if (!$conf['show_system']) { |
|
267 | $where = "AND pn.nspname NOT LIKE 'pg\\\\_%'"; |
|
268 | } else { |
|
269 | $where = "AND nspname !~ '^pg_t(emp_[0-9]+|oast)$'"; |
|
270 | } |
|
271 | ||
272 | $sql = "SELECT pn.nspname, pc.relname AS tablename, pl.transaction, pl.pid, pl.mode, pl.granted |
|
273 | FROM pg_catalog.pg_locks pl, pg_catalog.pg_class pc, pg_catalog.pg_namespace pn |
|
274 | WHERE pl.relation = pc.oid AND pc.relnamespace=pn.oid {$where} |
|
275 | ORDER BY nspname,tablename"; |
|
276 | ||
277 | return $this->selectSet($sql); |
|
278 | } |
|
279 | ||
280 | /** |
|
281 | * Returns the current database encoding. |
|
@@ 564-602 (lines=39) @@ | ||
561 | * |
|
562 | * @return \PHPPgAdmin\ADORecordSet All casts |
|
563 | */ |
|
564 | public function getCasts() |
|
565 | { |
|
566 | $conf = $this->conf; |
|
567 | ||
568 | if ($conf['show_system']) { |
|
569 | $where = ''; |
|
570 | } else { |
|
571 | $where = " |
|
572 | AND n1.nspname NOT LIKE 'pg\\\\_%' |
|
573 | AND n2.nspname NOT LIKE 'pg\\\\_%' |
|
574 | AND n3.nspname NOT LIKE 'pg\\\\_%' |
|
575 | "; |
|
576 | } |
|
577 | ||
578 | $sql = " |
|
579 | SELECT |
|
580 | c.castsource::pg_catalog.regtype AS castsource, |
|
581 | c.casttarget::pg_catalog.regtype AS casttarget, |
|
582 | CASE WHEN c.castfunc=0 THEN NULL |
|
583 | ELSE c.castfunc::pg_catalog.regprocedure END AS castfunc, |
|
584 | c.castcontext, |
|
585 | obj_description(c.oid, 'pg_cast') as castcomment |
|
586 | FROM |
|
587 | (pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p ON c.castfunc=p.oid JOIN pg_catalog.pg_namespace n3 ON p.pronamespace=n3.oid), |
|
588 | pg_catalog.pg_type t1, |
|
589 | pg_catalog.pg_type t2, |
|
590 | pg_catalog.pg_namespace n1, |
|
591 | pg_catalog.pg_namespace n2 |
|
592 | WHERE |
|
593 | c.castsource=t1.oid |
|
594 | AND c.casttarget=t2.oid |
|
595 | AND t1.typnamespace=n1.oid |
|
596 | AND t2.typnamespace=n2.oid |
|
597 | {$where} |
|
598 | ORDER BY 1, 2 |
|
599 | "; |
|
600 | ||
601 | return $this->selectSet($sql); |
|
602 | } |
|
603 | ||
604 | public function hasAlterColumnType() |
|
605 | { |
@@ 109-128 (lines=20) @@ | ||
106 | * |
|
107 | * @return \PHPPgAdmin\ADORecordSet All schemas, sorted alphabetically |
|
108 | */ |
|
109 | public function getSchemas() |
|
110 | { |
|
111 | $conf = $this->conf; |
|
112 | ||
113 | if (!$conf['show_system']) { |
|
114 | $where = "WHERE nspname NOT LIKE 'pg@_%' ESCAPE '@' AND nspname != 'information_schema'"; |
|
115 | } else { |
|
116 | $where = "WHERE nspname !~ '^pg_t(emp_[0-9]+|oast)$'"; |
|
117 | } |
|
118 | ||
119 | $sql = " |
|
120 | SELECT pn.nspname, pu.usename AS nspowner, |
|
121 | pg_catalog.obj_description(pn.oid, 'pg_namespace') AS nspcomment |
|
122 | FROM pg_catalog.pg_namespace pn |
|
123 | LEFT JOIN pg_catalog.pg_user pu ON (pn.nspowner = pu.usesysid) |
|
124 | {$where} |
|
125 | ORDER BY nspname"; |
|
126 | ||
127 | return $this->selectSet($sql); |
|
128 | } |
|
129 | ||
130 | /** |
|
131 | * Return all information relating to a schema. |
@@ 56-72 (lines=17) @@ | ||
53 | * |
|
54 | * @return \PHPPgAdmin\ADORecordSet A recordset |
|
55 | */ |
|
56 | public function getLocks() |
|
57 | { |
|
58 | $conf = $this->conf; |
|
59 | ||
60 | if (!$conf['show_system']) { |
|
61 | $where = 'AND pn.nspname NOT LIKE $$pg\_%$$'; |
|
62 | } else { |
|
63 | $where = "AND nspname !~ '^pg_t(emp_[0-9]+|oast)$'"; |
|
64 | } |
|
65 | ||
66 | $sql = "SELECT pn.nspname, pc.relname AS tablename, pl.transaction, pl.pid, pl.mode, pl.granted |
|
67 | FROM pg_catalog.pg_locks pl, pg_catalog.pg_class pc, pg_catalog.pg_namespace pn |
|
68 | WHERE pl.relation = pc.oid AND pc.relnamespace=pn.oid {$where} |
|
69 | ORDER BY nspname,tablename"; |
|
70 | ||
71 | return $this->selectSet($sql); |
|
72 | } |
|
73 | ||
74 | // Sequence functions |
|
75 |