From 16b6650726173410dd30ef1274da96d64d83d368 Mon Sep 17 00:00:00 2001 From: ffflabs Date: Mon, 25 May 2020 10:49:40 -0400 Subject: [PATCH] fixes type linting fixes type linting fixes type linting fixes type linting --- .php_cs | 2 +- Makefile | 2 +- README.md | 3 +- composer.json | 2 +- phpstan.neon | 5 +- src/classes/ADONewConnection.php | 19 + src/classes/ADORecordSet.php | 12 + src/classes/Misc.php | 9 +- src/classes/ViewManager.php | 7 +- src/controllers/DataimportController.php | 4 +- src/controllers/TreeController.php | 2 +- src/database/ADOdbBase.php | 15 +- src/database/Connection.php | 11 +- src/database/Postgres.php | 28 +- src/database/Postgres10.php | 2 +- src/database/Postgres11.php | 2 +- src/database/Postgres12.php | 2 +- src/database/Postgres74.php | 703 ------------------ src/database/Postgres80.php | 463 ------------ src/database/Postgres81.php | 348 --------- src/database/Postgres82.php | 439 ----------- src/database/Postgres83.php | 442 ----------- src/database/Postgres84.php | 224 ------ src/database/Postgres91.php | 6 +- src/database/Postgres92.php | 8 +- src/database/Postgres93.php | 2 +- src/database/Postgres96.php | 4 +- .../databasetraits/AggregateTrait.php | 12 +- src/database/databasetraits/ColumnTrait.php | 6 +- src/database/databasetraits/DatabaseTrait.php | 26 +- src/database/databasetraits/DomainTrait.php | 14 +- src/database/databasetraits/FunctionTrait.php | 12 +- src/database/databasetraits/IndexTrait.php | 18 +- src/database/databasetraits/OperatorTrait.php | 8 +- .../databasetraits/PrivilegesTrait.php | 2 +- src/database/databasetraits/RoleTrait.php | 44 +- src/database/databasetraits/RowTrait.php | 4 +- src/database/databasetraits/SchemaTrait.php | 10 +- src/database/databasetraits/StatsTrait.php | 10 +- src/database/databasetraits/TableTrait.php | 128 ++-- .../databasetraits/TablespaceTrait.php | 6 +- src/database/databasetraits/TriggerTrait.php | 18 +- src/database/databasetraits/ViewTrait.php | 36 +- src/router.php | 12 +- 44 files changed, 283 insertions(+), 2849 deletions(-) create mode 100644 src/classes/ADONewConnection.php delete mode 100644 src/database/Postgres74.php delete mode 100644 src/database/Postgres80.php delete mode 100644 src/database/Postgres81.php delete mode 100644 src/database/Postgres82.php delete mode 100644 src/database/Postgres83.php delete mode 100644 src/database/Postgres84.php diff --git a/.php_cs b/.php_cs index 6ed943a54..43d3c524d 100644 --- a/.php_cs +++ b/.php_cs @@ -43,7 +43,7 @@ $config->getFinder() 'docs', 'node_modules', 'temp', - + 'src/router.php', 'vendor', '.github', ]) diff --git a/Makefile b/Makefile index 02866b7ad..68f6d23f3 100644 --- a/Makefile +++ b/Makefile @@ -132,7 +132,7 @@ psalm: @if [ -f "vendor/bin/psalm" ]; then \ mkdir -p .build/psalm ;\ ${MAKE} disable_xdebug --no-print-directory ;\ - vendor/bin/psalm --show-info=false \ + vendor/bin/psalm --show-info=true \ --config=psalm.xml \ --set-baseline=.build/psalm/psalm-baseline$(FOLDER_BASENAME).xml \ --shepherd $(folder) ;\ diff --git a/README.md b/README.md index 47bce51a8..f2d9979cf 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,11 @@ Other enhancements are in progress and would be a nice to have: ## Requirements - PHP 7.1+ +- PostgreSQL v9+ - ext-psql - [Composer](https://getcomposer.org/download/) -(If you're using PHP 5.6+, you can still try versions RC2 and below, but you should really, realy upgrade). +(If you're using PostgreSQL 7.4 or 8.x, or PHP 5.6+, you can still try versions RC2 and below, but you should really, realy upgrade). --- diff --git a/composer.json b/composer.json index efa23e3c3..e6a19a85a 100644 --- a/composer.json +++ b/composer.json @@ -62,6 +62,6 @@ "php -r \"array_map( 'unlink', array_filter((array) glob('temp/twigcache/**/*.php', GLOB_BRACE)));\"", "php -r \"array_map( 'rmdir', array_filter((array) glob('temp/twigcache/*', GLOB_BRACE)));\"" ], - "phpstan": "phpstan analyse src --memory-limit=2G " + "phpstan": "phpstan analyse src " } } diff --git a/phpstan.neon b/phpstan.neon index 6c9235b45..7ea93f069 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -52,7 +52,10 @@ parameters: message: "#^Result of method PHPPgAdmin\\\\[a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+\\:\\:[a-zA-Z0-9_]+\\(\\) \\(void\\) is used\\.$#" path: src/* - + - + message: "#^Call to static method br2ln\\(\\) on trait PHPPgAdmin\\Traits\\HelperTrait\\.#" + path: src/* + - message: "#^Constructor of class [a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+ has an unused parameter \\$[a-zA-Z0-9_]+\\.$#" path: src/* diff --git a/src/classes/ADONewConnection.php b/src/classes/ADONewConnection.php new file mode 100644 index 000000000..8f998c3bb --- /dev/null +++ b/src/classes/ADONewConnection.php @@ -0,0 +1,19 @@ +NumRows(); } + + /** + * Returns the recordCount. + * + * @param int $fieldoffset + * + * @return \ADOFieldObject the field + */ + public function fetchField($fieldoffset = -1): \ADOFieldObject + { + return parent::fetchField(); + } } diff --git a/src/classes/Misc.php b/src/classes/Misc.php index e6a176190..ad4302aac 100644 --- a/src/classes/Misc.php +++ b/src/classes/Misc.php @@ -6,6 +6,8 @@ namespace PHPPgAdmin; +use PHPPgAdmin\Database\Postgres; + /** * @file * Class to hold various commonly used functions @@ -64,6 +66,9 @@ class Misc private $_reload_browser = false; + /** + * @var Postgres + */ private $_data; private $_database; @@ -279,9 +284,9 @@ public function getErrorMsg() * * @internal mixed $plaform placeholder that will receive the value of the platform * - * @return null|\PHPPgAdmin\Database\ADOdbBase the database accessor instance + * @return null|\PHPPgAdmin\Database\Postgres the database accessor instance */ - public function getDatabaseAccessor($database = '', $server_id = null): ?\PHPPgAdmin\Database\ADOdbBase + public function getDatabaseAccessor($database = '', $server_id = null): ?\PHPPgAdmin\Database\Postgres { $lang = $this->lang; diff --git a/src/classes/ViewManager.php b/src/classes/ViewManager.php index 8c96da42d..785096a32 100644 --- a/src/classes/ViewManager.php +++ b/src/classes/ViewManager.php @@ -60,6 +60,11 @@ class ViewManager extends \Slim\Views\Twig public $view; + /** + * @var \PHPPgAdmin\Misc + */ + public $misc; + protected $container; private $_connection; @@ -101,7 +106,7 @@ public function __construct($path, $settings, \Slim\Container $c) $this->addExtension(new \Slim\Views\TwigExtension($c['router'], $basePath)); - $this->offsetSet('subfolder', $c->subfolder); + $this->offsetSet('subfolder', self::SUBFOLDER); $this->offsetSet('theme', $this->misc->getConf('theme')); $this->offsetSet('Favicon', $this->icon('Favicon')); $this->offsetSet('Introduction', $this->icon('Introduction')); diff --git a/src/controllers/DataimportController.php b/src/controllers/DataimportController.php index 29ea6a8f9..8d917484a 100644 --- a/src/controllers/DataimportController.php +++ b/src/controllers/DataimportController.php @@ -37,8 +37,8 @@ public function render() /** * Character data handler for XML import feature. * - * @param $parser - * @param $cdata + * @param resource $parser + * @param string $cdata */ $_charHandler = static function ($parser, $cdata) use (&$state, &$curr_col_val): void { if ('COLUMN' === $state) { diff --git a/src/controllers/TreeController.php b/src/controllers/TreeController.php index 4d55ce575..29360a236 100644 --- a/src/controllers/TreeController.php +++ b/src/controllers/TreeController.php @@ -135,7 +135,7 @@ public function adjustTabsForTree(&$tabs) * 'nodata' - message to display when node has no children * @param bool $print either to return or echo the result * - * @return \Slim\Http\Response|string the json rendered tree + * @return array|bool|string> the json rendered tree */ private function printTreeJSON(&$treedata, &$attrs, $print = true) { diff --git a/src/database/ADOdbBase.php b/src/database/ADOdbBase.php index 33f180fa4..bae800af4 100644 --- a/src/database/ADOdbBase.php +++ b/src/database/ADOdbBase.php @@ -6,6 +6,8 @@ namespace PHPPgAdmin\Database; +use PHPPgAdmin\ADONewConnection; + /** * @file * Parent class of all ADODB objects. @@ -28,7 +30,7 @@ class ADOdbBase /** * Base constructor. * - * @param \ADODB_postgres9 $conn The connection object + * @param ADONewConnection $conn The connection object * @param mixed $container * @param mixed $server_info */ @@ -40,7 +42,7 @@ public function __construct(&$conn, $container, $server_info) $this->lang = $container->get('lang'); $this->conf = $container->get('conf'); - //$this->prtrace('instanced connection class'); + $this->prtrace('instanced connection class'); $this->conn = $conn; } @@ -55,7 +57,7 @@ public function __construct(&$conn, $container, $server_info) * @param string $comment the comment to add * @param null|string $basetype * - * @return \ADORecordSet|int recordset of results or error code + * @return int|\PHPPgAdmin\ADORecordSet recordset of results or error code */ public function setComment($obj_type, $obj_name, $table, $comment, $basetype = null) { @@ -174,8 +176,7 @@ public function arrayClean(&$arr) * * @param string $sql The SQL query to execute * - * @return \ADORecordSet|int A recordset or an error code - * (However, error code 0 means success WTF) + * @return int|\PHPPgAdmin\ADORecordSet A recordset or an error code */ public function execute($sql) { @@ -203,7 +204,7 @@ public function close(): void * * @param string $sql The SQL statement to be executed * - * @return \ADORecordSet|int A recordset or an error number + * @return int|\PHPPgAdmin\ADORecordSet A recordset or an error number */ public function selectSet($sql) { @@ -506,7 +507,7 @@ public function getPlatform() try { return $this->conn->platform; } catch (\Exception $e) { - //$this->prtrace($e->getMessage()); + $this->prtrace($e->getMessage()); return 'UNKNOWN'; } diff --git a/src/database/Connection.php b/src/database/Connection.php index 8c4917ebb..4f50cd49e 100644 --- a/src/database/Connection.php +++ b/src/database/Connection.php @@ -69,7 +69,7 @@ public function __construct($server_info, $database, $container, $fetchMode = AD $this->container = $container; - $this->conn = \ADONewConnection('postgres9'); + $this->conn = ADONewConnection('postgres9'); //$this->conn->debug = true; $this->conn->setFetchMode($fetchMode); @@ -93,14 +93,15 @@ public function __construct($server_info, $database, $container, $fetchMode = AD /*try { $this->_connection_result = $this->conn->connect($pghost, $user, $password, $database); - //$this->prtrace(['_connection_result' => $this->_connection_result, 'conn' => $this->conn]); + $this->prtrace(['_connection_result' => $this->_connection_result, 'conn' => $this->conn]); } catch (\PHPPgAdmin\ADOdbException $e) { - //$this->prtrace(['message' => $e->getMessage(), 'trace' => $e->getTraceAsString()]); + $this->prtrace(['message' => $e->getMessage(), 'trace' => $e->getTraceAsString()]); */ try { $this->conn->connect($pghost, $user, $password, $database); + //$this->prtrace($this->conn); } catch (\Exception $e) { - //$this->prtrace($e->getMessage(), $e->getTrace()); + $this->prtrace($e->getMessage(), $e->getTrace()); } } @@ -157,6 +158,8 @@ public function getDriver(&$description) } else { $major_version = \implode('.', [$version_parts[0], $version_parts[1]]); } + + //$this->prtrace(['pg_version' => pg_version($this->conn->_connectionID), 'version' => $version, 'major_version' => $major_version]); // Detect version and choose appropriate database driver if (\array_key_exists($major_version, $this->version_dictionary)) { return $this->version_dictionary[$major_version]; diff --git a/src/database/Postgres.php b/src/database/Postgres.php index c5c3c1a88..6e6dd3b5b 100644 --- a/src/database/Postgres.php +++ b/src/database/Postgres.php @@ -42,6 +42,7 @@ class Postgres extends ADOdbBase public function __construct(&$conn, $container, $server_info) { + //$this->prtrace('major_version :' . $this->major_version); $this->conn = $conn; $this->container = $container; @@ -182,7 +183,7 @@ public function printField($name, $value, $type, $extras = []): void * @param string $term The search term * @param string $filter The object type to restrict to ('' means no restriction) * - * @return \ADORecordSet|int A recordset + * @return int|\PHPPgAdmin\ADORecordSet A recordset */ public function findObject($term, $filter) { @@ -382,7 +383,7 @@ public function getAttributeNames($table, $atts) * * @param bool $all True to get all languages, regardless of show_system * - * @return \ADORecordSet|int A recordset + * @return int|\PHPPgAdmin\ADORecordSet A recordset */ public function getLanguages($all = false) { @@ -473,7 +474,7 @@ public function executeScript($name, $callback = null) for ($i = 0; $i < $len; $this->advance_1($i, $prevlen, $thislen)) { /* was the previous character a backslash? */ if (0 < $i && '\\' === \mb_substr($line, $i - $prevlen, 1)) { - //$this->prtrace('bslash_count', $bslash_count, $line); + $this->prtrace('bslash_count', $bslash_count, $line); ++$bslash_count; } else { $bslash_count = 0; @@ -487,6 +488,7 @@ public function executeScript($name, $callback = null) /* in quote? */ if (0 !== $in_quote) { + //$this->prtrace('in_quote', $in_quote, $line); /* * end of quote if matching non-backslashed character. * backslashes don't count for double quotes, though. @@ -497,7 +499,7 @@ public function executeScript($name, $callback = null) $in_quote = 0; } } elseif ($dol_quote) { - //$this->prtrace('dol_quote', $dol_quote, $line); + $this->prtrace('dol_quote', $dol_quote, $line); if (0 === \strncmp(\mb_substr($line, $i), $dol_quote, \mb_strlen($dol_quote))) { $this->advance_1($i, $prevlen, $thislen); @@ -509,7 +511,7 @@ public function executeScript($name, $callback = null) $dol_quote = ''; } } elseif ('/*' === \mb_substr($line, $i, 2)) { - //$this->prtrace('open_xcomment', $in_xcomment, $line, $i, $prevlen, $thislen); + $this->prtrace('open_xcomment', $in_xcomment, $line, $i, $prevlen, $thislen); if (0 === $in_xcomment) { ++$in_xcomment; @@ -695,12 +697,12 @@ public function executeScript($name, $callback = null) * @param null|int $page_size The number of rows per page * @param int $max_pages (return-by-ref) The max number of pages in the relation * - * @return \ADORecordSet|int A recordset on success or an int with error code - * - -1 transaction error - * - -2 counting error - * - -3 page or page_size invalid - * - -4 unknown type - * - -5 failed setting transaction read only + * @return int|\PHPPgAdmin\ADORecordSet A recordset on success or an int with error code + * - -1 transaction error + * - -2 counting error + * - -3 page or page_size invalid + * - -4 unknown type + * - -5 failed setting transaction read only */ public function browseQuery($type, $table, $query, $sortkey, $sortdir, $page, $page_size, &$max_pages) { @@ -742,7 +744,7 @@ public function browseQuery($type, $table, $query, $sortkey, $sortdir, $page, $p // Open a transaction $status = $this->beginTransaction(); - if (false !== $status) { + if (0 !== $status) { return -1; } @@ -802,7 +804,7 @@ public function browseQuery($type, $table, $query, $sortkey, $sortdir, $page, $p $rs = $this->selectSet("SELECT * FROM ({$query}) AS sub {$orderby} LIMIT {$page_size} OFFSET " . ($page - 1) * $page_size); $status = $this->endTransaction(); - if (false !== $status) { + if (0 !== $status) { $this->rollbackTransaction(); return -1; diff --git a/src/database/Postgres10.php b/src/database/Postgres10.php index 880271edb..c14ba4939 100644 --- a/src/database/Postgres10.php +++ b/src/database/Postgres10.php @@ -25,7 +25,7 @@ class Postgres10 extends Postgres96 /** * Return all tables in current database (and schema). * - * @return \ADORecordSet|int All tables, sorted alphabetically + * @return int|\PHPPgAdmin\ADORecordSet All tables, sorted alphabetically */ public function getTables() { diff --git a/src/database/Postgres11.php b/src/database/Postgres11.php index 9d6ac8956..850ae822e 100644 --- a/src/database/Postgres11.php +++ b/src/database/Postgres11.php @@ -26,7 +26,7 @@ class Postgres11 extends Postgres10 * @param bool $all If true, will find all available functions, if false just those in search path * @param mixed $type If truthy, will return functions of type trigger * - * @return \ADORecordSet|int All functions + * @return int|\PHPPgAdmin\ADORecordSet All functions */ public function getFunctions($all = false, $type = null) { diff --git a/src/database/Postgres12.php b/src/database/Postgres12.php index 90e79f926..d2b634614 100644 --- a/src/database/Postgres12.php +++ b/src/database/Postgres12.php @@ -25,7 +25,7 @@ class Postgres12 extends Postgres11 * * @param string $table The table name * - * @return bool false + * @return bool */ public function hasObjectID($table) { diff --git a/src/database/Postgres74.php b/src/database/Postgres74.php deleted file mode 100644 index c6df56bda..000000000 --- a/src/database/Postgres74.php +++ /dev/null @@ -1,703 +0,0 @@ - ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'], - 'view' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'], - 'sequence' => ['SELECT', 'UPDATE', 'ALL PRIVILEGES'], - 'database' => ['CREATE', 'TEMPORARY', 'ALL PRIVILEGES'], - 'function' => ['EXECUTE', 'ALL PRIVILEGES'], - 'language' => ['USAGE', 'ALL PRIVILEGES'], - 'schema' => ['CREATE', 'USAGE', 'ALL PRIVILEGES'], - ]; - - // Database functions - - /** - * Alters a database - * the multiple return vals are for postgres 8+ which support more functionality in alter database. - * - * @param string $dbName The name of the database - * @param string $newName new name for the database - * @param string $newOwner The new owner for the database - * @param string $comment - * - * @return bool|int 0 success - */ - public function alterDatabase($dbName, $newName, $newOwner = '', $comment = '') - { - //ignore $newowner, not supported pre 8.0 - //ignore $comment, not supported pre 8.2 - $this->clean($dbName); - $this->clean($newName); - - $status = $this->alterDatabaseRename($dbName, $newName); - - if (0 !== $status) { - return -3; - } - - return 0; - } - - /** - * Return all database available on the server. - * - * @param null|string $currentdatabase - * - * @return \ADORecordSet|int A list of databases, sorted alphabetically - */ - public function getDatabases($currentdatabase = null) - { - $conf = $this->conf; - $server_info = $this->server_info; - - if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) { - $username = $server_info['username']; - $this->clean($username); - $clause = " AND pu.usename='{$username}'"; - } else { - $clause = ''; - } - - if ($currentdatabase) { - $this->clean($currentdatabase); - $orderby = "ORDER BY pdb.datname = '{$currentdatabase}' DESC, pdb.datname"; - } else { - $orderby = 'ORDER BY pdb.datname'; - } - - if (!$conf['show_system']) { - $where = ' AND NOT pdb.datistemplate'; - } else { - $where = ' AND pdb.datallowconn'; - } - - $sql = "SELECT pdb.datname AS datname, - pu.usename AS datowner, - pg_encoding_to_char(encoding) AS datencoding, - (SELECT description FROM pg_description pd WHERE pdb.oid=pd.objoid) AS datcomment - FROM pg_database pdb, pg_user pu - WHERE pdb.datdba = pu.usesysid - {$where} - {$clause} - {$orderby}"; - - return $this->selectSet($sql); - } - - /** - * Searches all system catalogs to find objects that match a certain name. - * - * @param string $term The search term - * @param string $filter The object type to restrict to ('' means no restriction) - * - * @return \ADORecordSet|int A recordset - */ - public function findObject($term, $filter) - { - $conf = $this->conf; - - /** - * About escaping: - * SET standard_conforming_string is not available before 8.2 - * So we must use PostgreSQL specific notation :/ - * E'' notation is not available before 8.1 - * $$ is available since 8.0 - * Nothing specific from 7.4. - */ - - // Escape search term for ILIKE match - $term = \str_replace('_', '\\_', $term); - $term = \str_replace('%', '\\%', $term); - $this->clean($term); - $this->clean($filter); - - // Exclude system relations if necessary - if (!$conf['show_system']) { - // XXX: The mention of information_schema here is in the wrong place, but - // it's the quickest fix to exclude the info schema from 7.4 - $where = " AND pn.nspname NOT LIKE 'pg\\\\_%' AND pn.nspname != 'information_schema'"; - $lan_where = 'AND pl.lanispl'; - } else { - $where = ''; - $lan_where = ''; - } - - // Apply outer filter - $sql = ''; - - if ('' !== $filter) { - $sql = 'SELECT * FROM ('; - } - - $sql .= " - SELECT 'SCHEMA' AS type, oid, NULL AS schemaname, NULL AS relname, nspname AS name - FROM pg_catalog.pg_namespace pn WHERE nspname ILIKE '%{$term}%' {$where} - UNION ALL - SELECT CASE WHEN relkind='r' THEN 'TABLE' WHEN relkind='v' THEN 'VIEW' WHEN relkind='S' THEN 'SEQUENCE' END, pc.oid, - pn.nspname, NULL, pc.relname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn - WHERE pc.relnamespace=pn.oid AND relkind IN ('r', 'v', 'S') AND relname ILIKE '%{$term}%' {$where} - UNION ALL - SELECT CASE WHEN pc.relkind='r' THEN 'COLUMNTABLE' ELSE 'COLUMNVIEW' END, NULL, pn.nspname, pc.relname, pa.attname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn, - pg_catalog.pg_attribute pa WHERE pc.relnamespace=pn.oid AND pc.oid=pa.attrelid - AND pa.attname ILIKE '%{$term}%' AND pa.attnum > 0 AND NOT pa.attisdropped AND pc.relkind IN ('r', 'v') {$where} - UNION ALL - SELECT 'FUNCTION', pp.oid, pn.nspname, NULL, pp.proname || '(' || pg_catalog.oidvectortypes(pp.proargtypes) || ')' FROM pg_catalog.pg_proc pp, pg_catalog.pg_namespace pn - WHERE pp.pronamespace=pn.oid AND NOT pp.proisagg AND pp.proname ILIKE '%{$term}%' {$where} - UNION ALL - SELECT 'INDEX', NULL, pn.nspname, pc.relname, pc2.relname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn, - pg_catalog.pg_index pi, pg_catalog.pg_class pc2 WHERE pc.relnamespace=pn.oid AND pc.oid=pi.indrelid - AND pi.indexrelid=pc2.oid - AND NOT EXISTS ( - SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c - ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) - WHERE d.classid = pc2.tableoid AND d.objid = pc2.oid AND d.deptype = 'i' AND c.contype IN ('u', 'p') - ) - AND pc2.relname ILIKE '%{$term}%' {$where} - UNION ALL - SELECT 'CONSTRAINTTABLE', NULL, pn.nspname, pc.relname, pc2.conname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn, - pg_catalog.pg_constraint pc2 WHERE pc.relnamespace=pn.oid AND pc.oid=pc2.conrelid AND pc2.conrelid != 0 - AND CASE WHEN pc2.contype IN ('f', 'c') THEN TRUE ELSE NOT EXISTS ( - SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c - ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) - WHERE d.classid = pc2.tableoid AND d.objid = pc2.oid AND d.deptype = 'i' AND c.contype IN ('u', 'p') - ) END - AND pc2.conname ILIKE '%{$term}%' {$where} - UNION ALL - SELECT 'CONSTRAINTDOMAIN', pt.oid, pn.nspname, pt.typname, pc.conname FROM pg_catalog.pg_type pt, pg_catalog.pg_namespace pn, - pg_catalog.pg_constraint pc WHERE pt.typnamespace=pn.oid AND pt.oid=pc.contypid AND pc.contypid != 0 - AND pc.conname ILIKE '%{$term}%' {$where} - UNION ALL - SELECT 'TRIGGER', NULL, pn.nspname, pc.relname, pt.tgname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn, - pg_catalog.pg_trigger pt WHERE pc.relnamespace=pn.oid AND pc.oid=pt.tgrelid - AND ( pt.tgisconstraint = 'f' OR NOT EXISTS - (SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c - ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) - WHERE d.classid = pt.tableoid AND d.objid = pt.oid AND d.deptype = 'i' AND c.contype = 'f')) - AND pt.tgname ILIKE '%{$term}%' {$where} - UNION ALL - SELECT 'RULETABLE', NULL, pn.nspname AS schemaname, c.relname AS tablename, r.rulename FROM pg_catalog.pg_rewrite r - JOIN pg_catalog.pg_class c ON c.oid = r.ev_class - LEFT JOIN pg_catalog.pg_namespace pn ON pn.oid = c.relnamespace - WHERE c.relkind='r' AND r.rulename != '_RETURN' AND r.rulename ILIKE '%{$term}%' {$where} - UNION ALL - SELECT 'RULEVIEW', NULL, pn.nspname AS schemaname, c.relname AS tablename, r.rulename FROM pg_catalog.pg_rewrite r - JOIN pg_catalog.pg_class c ON c.oid = r.ev_class - LEFT JOIN pg_catalog.pg_namespace pn ON pn.oid = c.relnamespace - WHERE c.relkind='v' AND r.rulename != '_RETURN' AND r.rulename ILIKE '%{$term}%' {$where} - "; - - // Add advanced objects if show_advanced is set - if ($conf['show_advanced']) { - $sql .= " - UNION ALL - SELECT CASE WHEN pt.typtype='d' THEN 'DOMAIN' ELSE 'TYPE' END, pt.oid, pn.nspname, NULL, - pt.typname FROM pg_catalog.pg_type pt, pg_catalog.pg_namespace pn - WHERE pt.typnamespace=pn.oid AND typname ILIKE '%{$term}%' - AND (pt.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = pt.typrelid)) - {$where} - UNION ALL - SELECT 'OPERATOR', po.oid, pn.nspname, NULL, po.oprname FROM pg_catalog.pg_operator po, pg_catalog.pg_namespace pn - WHERE po.oprnamespace=pn.oid AND oprname ILIKE '%{$term}%' {$where} - UNION ALL - SELECT 'CONVERSION', pc.oid, pn.nspname, NULL, pc.conname FROM pg_catalog.pg_conversion pc, - pg_catalog.pg_namespace pn WHERE pc.connamespace=pn.oid AND conname ILIKE '%{$term}%' {$where} - UNION ALL - SELECT 'LANGUAGE', pl.oid, NULL, NULL, pl.lanname FROM pg_catalog.pg_language pl - WHERE lanname ILIKE '%{$term}%' {$lan_where} - UNION ALL - SELECT DISTINCT ON (p.proname) 'AGGREGATE', p.oid, pn.nspname, NULL, p.proname FROM pg_catalog.pg_proc p - LEFT JOIN pg_catalog.pg_namespace pn ON p.pronamespace=pn.oid - WHERE p.proisagg AND p.proname ILIKE '%{$term}%' {$where} - UNION ALL - SELECT DISTINCT ON (po.opcname) 'OPCLASS', po.oid, pn.nspname, NULL, po.opcname FROM pg_catalog.pg_opclass po, - pg_catalog.pg_namespace pn WHERE po.opcnamespace=pn.oid - AND po.opcname ILIKE '%{$term}%' {$where} - "; - } else { - // Otherwise just add domains - $sql .= " - UNION ALL - SELECT 'DOMAIN', pt.oid, pn.nspname, NULL, - pt.typname FROM pg_catalog.pg_type pt, pg_catalog.pg_namespace pn - WHERE pt.typnamespace=pn.oid AND pt.typtype='d' AND typname ILIKE '%{$term}%' - AND (pt.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = pt.typrelid)) - {$where} - "; - } - - if ('' !== $filter) { - // We use like to make RULE, CONSTRAINT and COLUMN searches work - $sql .= ") AS sub WHERE type LIKE '{$filter}%' "; - } - - $sql .= 'ORDER BY type, schemaname, relname, name'; - - return $this->selectSet($sql); - } - - /** - * Returns table locks information in the current database. - * - * @return \ADORecordSet|int A recordset - */ - public function getLocks() - { - $conf = $this->conf; - - if (!$conf['show_system']) { - $where = "AND pn.nspname NOT LIKE 'pg\\\\_%'"; - } else { - $where = "AND nspname !~ '^pg_t(emp_[0-9]+|oast)$'"; - } - - $sql = "SELECT pn.nspname, pc.relname AS tablename, pl.transaction, pl.pid, pl.mode, pl.granted - FROM pg_catalog.pg_locks pl, pg_catalog.pg_class pc, pg_catalog.pg_namespace pn - WHERE pl.relation = pc.oid AND pc.relnamespace=pn.oid {$where} - ORDER BY nspname,tablename"; - - return $this->selectSet($sql); - } - - /** - * Returns the current database encoding. - * - * @return int|string The encoding. eg. SQL_ASCII, UTF-8, etc. - */ - public function getDatabaseEncoding() - { - $sql = 'SELECT getdatabaseencoding() AS encoding'; - - return $this->selectField($sql, 'encoding'); - } - - // Table functions - - /** - * Alters a column in a table OR view. - * - * @param string $table The table in which the column resides - * @param string $column The column to alter - * @param string $name The new name for the column - * @param bool $notnull (boolean) True if not null, false otherwise - * @param bool $oldnotnull (boolean) True if column is already not null, false otherwise - * @param string $default The new default for the column - * @param string $olddefault The old default for the column - * @param string $type The new type for the column - * @param int $length The optional size of the column (ie. 30 for varchar(30)) - * @param bool $array True if array type, false otherwise - * @param string $oldtype The old type for the column - * @param string $comment Comment for the column - * - * @return array|bool|int 0 success - */ - public function alterColumn( - $table, - $column, - $name, - $notnull, - $oldnotnull, - $default, - $olddefault, - $type, - $length, - $array, - $oldtype, - $comment - ) { - $sql = ''; - $status = $this->beginTransaction(); - - if (0 !== $status) { - return -1; - } - - // @@ NEED TO HANDLE "NESTED" TRANSACTION HERE - if ($notnull !== $oldnotnull) { - $status = $this->setColumnNull($table, $column, !$notnull); - - if (0 !== $status) { - $this->rollbackTransaction(); - - return -2; - } - } - - // Set default, if it has changed - if ($default !== $olddefault) { - if ('' === $default) { - $status = $this->dropColumnDefault($table, $column); - } else { - $status = $this->setColumnDefault($table, $column, $default); - } - - if (0 !== $status) { - $this->rollbackTransaction(); - - return -3; - } - } - - // Rename the column, if it has been changed - if ($column !== $name) { - [$status, $sql] = $this->renameColumn($table, $column, $name); - - if (0 !== $status) { - $this->rollbackTransaction(); - - return -4; - } - } - - // The $name and $table parameters must be cleaned for the setComment function. - // It's ok to do that here since this is the last time these variables are used. - $this->fieldClean($name); - $this->fieldClean($table); - $status = $this->setComment('COLUMN', $name, $table, $comment); - - if (0 !== $status) { - $this->rollbackTransaction(); - - return -5; - } - - return [$this->endTransaction(), $sql]; - } - - /** - * Returns table information. - * - * @param string $table The name of the table - * - * @return \ADORecordSet|int A recordset - */ - public function getTable($table) - { - $c_schema = $this->_schema; - $this->clean($c_schema); - $this->clean($table); - - $sql = " - SELECT - c.relname, n.nspname, u.usename AS relowner, - pg_catalog.obj_description(c.oid, 'pg_class') AS relcomment - FROM pg_catalog.pg_class c - LEFT JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner - LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace - WHERE c.relkind = 'r' - AND n.nspname = '{$c_schema}' - AND c.relname = '{$table}'"; - - return $this->selectSet($sql); - } - - /** - * Returns the current default_with_oids setting. - * - * @return string default_with_oids setting - */ - public function getDefaultWithOid() - { - // 8.0 is the first release to have this setting - // Prior releases don't have this setting... oids always activated - return 'on'; - } - - /** - * Returns a list of all constraints on a table, - * including constraint name, definition, related col and referenced namespace, - * table and col if needed. - * - * @param string $table the table where we are looking for fk - * - * @return \ADORecordSet|int A recordset - */ - public function getConstraintsWithFields($table) - { - $c_schema = $this->_schema; - $this->clean($c_schema); - $this->clean($table); - - // get the max number of col used in a constraint for the table - $sql = "SELECT DISTINCT - max(SUBSTRING(array_dims(c.conkey) FROM '^\\\\[.*:(.*)\\\\]$')) as nb - FROM pg_catalog.pg_constraint AS c - JOIN pg_catalog.pg_class AS r ON (c.conrelid=r.oid) - JOIN pg_catalog.pg_namespace AS ns ON (r.relnamespace=ns.oid) - WHERE - r.relname = '{$table}' AND ns.nspname='{$c_schema}'"; - - $rs = $this->selectSet($sql); - - if ($rs->EOF) { - $max_col = 0; - } else { - $max_col = $rs->fields['nb']; - } - - $sql = ' - SELECT - c.oid AS conid, c.contype, c.conname, pg_catalog.pg_get_constraintdef(c.oid, true) AS consrc, - ns1.nspname as p_schema, r1.relname as p_table, ns2.nspname as f_schema, - r2.relname as f_table, f1.attname as p_field, f1.attnum AS p_attnum, f2.attname as f_field, - f2.attnum AS f_attnum, pg_catalog.obj_description(c.oid, \'pg_constraint\') AS constcomment, - c.conrelid, c.confrelid - FROM - pg_catalog.pg_constraint AS c - JOIN pg_catalog.pg_class AS r1 ON (c.conrelid=r1.oid) - JOIN pg_catalog.pg_attribute AS f1 ON (f1.attrelid=r1.oid AND (f1.attnum=c.conkey[1]'; - - for ($i = 2; $i <= $rs->fields['nb']; ++$i) { - $sql .= " OR f1.attnum=c.conkey[{$i}]"; - } - $sql .= ')) - JOIN pg_catalog.pg_namespace AS ns1 ON r1.relnamespace=ns1.oid - LEFT JOIN ( - pg_catalog.pg_class AS r2 JOIN pg_catalog.pg_namespace AS ns2 ON (r2.relnamespace=ns2.oid) - ) ON (c.confrelid=r2.oid) - LEFT JOIN pg_catalog.pg_attribute AS f2 ON - (f2.attrelid=r2.oid AND ((c.confkey[1]=f2.attnum AND c.conkey[1]=f1.attnum)'; - - for ($i = 2; $i <= $rs->fields['nb']; ++$i) { - $sql .= " OR (c.confkey[{$i}]=f2.attnum AND c.conkey[{$i}]=f1.attnum)"; - } - - $sql .= \sprintf(")) - WHERE - r1.relname = '%s' AND ns1.nspname='%s' - ORDER BY 1", $table, $c_schema); - - return $this->selectSet($sql); - } - - // Constraint functions - - /** - * Returns all sequences in the current database. - * - * @param bool $all - * - * @return \ADORecordSet|int A recordset - */ - public function getSequences($all = false) - { - $c_schema = $this->_schema; - $this->clean($c_schema); - - if ($all) { - // Exclude pg_catalog and information_schema tables - $sql = "SELECT n.nspname, c.relname AS seqname, u.usename AS seqowner - FROM pg_catalog.pg_class c, pg_catalog.pg_user u, pg_catalog.pg_namespace n - WHERE c.relowner=u.usesysid AND c.relnamespace=n.oid - AND c.relkind = 'S' - AND n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') - ORDER BY nspname, seqname"; - } else { - $sql = "SELECT c.relname AS seqname, u.usename AS seqowner, pg_catalog.obj_description(c.oid, 'pg_class') AS seqcomment - FROM pg_catalog.pg_class c, pg_catalog.pg_user u, pg_catalog.pg_namespace n - WHERE c.relowner=u.usesysid AND c.relnamespace=n.oid - AND c.relkind = 'S' AND n.nspname='{$c_schema}' ORDER BY seqname"; - } - - return $this->selectSet($sql); - } - - // Sequence functions - - /** - * Returns all details for a particular function. - * - * @param int $function_oid function identifier - * - * @return \ADORecordSet|int Function info - * - * @internal param string The $func name of the function to retrieve - */ - public function getFunction($function_oid) - { - $this->clean($function_oid); - - $sql = " - SELECT - pc.oid AS prooid, - proname, - pg_catalog.pg_get_userbyid(proowner) AS proowner, - nspname as proschema, - lanname as prolanguage, - pg_catalog.format_type(prorettype, NULL) as proresult, - prosrc, - probin, - proretset, - proisstrict, - provolatile, - prosecdef, - pg_catalog.oidvectortypes(pc.proargtypes) AS proarguments, - pg_catalog.obj_description(pc.oid, 'pg_proc') AS procomment - FROM - pg_catalog.pg_proc pc, pg_catalog.pg_language pl, pg_catalog.pg_namespace n - WHERE - pc.oid = '{$function_oid}'::oid - AND pc.prolang = pl.oid - AND n.oid = pc.pronamespace - "; - - return $this->selectSet($sql); - } - - // Function functions - - /** - * Returns a list of all casts in the database. - * - * @return \ADORecordSet|int All casts - */ - public function getCasts() - { - $conf = $this->conf; - - if ($conf['show_system']) { - $where = ''; - } else { - $where = " - AND n1.nspname NOT LIKE 'pg\\\\_%' - AND n2.nspname NOT LIKE 'pg\\\\_%' - AND n3.nspname NOT LIKE 'pg\\\\_%' - "; - } - - $sql = " - SELECT - c.castsource::pg_catalog.regtype AS castsource, - c.casttarget::pg_catalog.regtype AS casttarget, - CASE WHEN c.castfunc=0 THEN NULL - ELSE c.castfunc::pg_catalog.regprocedure END AS castfunc, - c.castcontext, - obj_description(c.oid, 'pg_cast') as castcomment - FROM - (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), - pg_catalog.pg_type t1, - pg_catalog.pg_type t2, - pg_catalog.pg_namespace n1, - pg_catalog.pg_namespace n2 - WHERE - c.castsource=t1.oid - AND c.casttarget=t2.oid - AND t1.typnamespace=n1.oid - AND t2.typnamespace=n2.oid - {$where} - ORDER BY 1, 2 - "; - - return $this->selectSet($sql); - } - - public function hasAlterColumnType() - { - return false; - } - - // Capabilities - - public function hasCreateFieldWithConstraints() - { - return false; - } - - public function hasAlterDatabaseOwner() - { - return false; - } - - public function hasAlterSchemaOwner() - { - return false; - } - - public function hasFunctionAlterOwner() - { - return false; - } - - public function hasNamedParams() - { - return false; - } - - public function hasQueryCancel() - { - return false; - } - - public function hasTablespaces() - { - return false; - } - - public function hasMagicTypes() - { - return false; - } - - /** - * Protected method which alter a table - * SHOULDN'T BE CALLED OUTSIDE OF A TRANSACTION. - * - * @param \ADORecordSet $tblrs The table recordSet returned by getTable() - * @param string $name The new name for the table - * @param string $owner The new owner for the table - * @param string $schema The new schema for the table - * @param string $comment The comment on the table - * @param string $tablespace The new tablespace for the table ('' means leave as is) - * - * @return int 0 success - */ - protected function _alterTable($tblrs, $name, $owner, $schema, $comment, $tablespace) - { - /* $schema and tablespace not supported in pg74- */ - $this->fieldArrayClean($tblrs->fields); - - // Comment - $status = $this->setComment('TABLE', '', $tblrs->fields['relname'], $comment); - - if (0 !== $status) { - return -4; - } - - // Owner - $this->fieldClean($owner); - $status = $this->alterTableOwner($tblrs, $owner); - - if (0 !== $status) { - return -5; - } - - // Rename - $this->fieldClean($name); - $status = $this->alterTableName($tblrs, $name); - - if (0 !== $status) { - return -3; - } - - return 0; - } -} diff --git a/src/database/Postgres80.php b/src/database/Postgres80.php deleted file mode 100644 index 20dbf5df6..000000000 --- a/src/database/Postgres80.php +++ /dev/null @@ -1,463 +0,0 @@ - 'CP866', - 'EUC_CN' => 'GB2312', - 'EUC_JP' => 'EUC-JP', - 'EUC_KR' => 'EUC-KR', - 'EUC_TW' => 'EUC-TW', - 'ISO_8859_5' => 'ISO-8859-5', - 'ISO_8859_6' => 'ISO-8859-6', - 'ISO_8859_7' => 'ISO-8859-7', - 'ISO_8859_8' => 'ISO-8859-8', - 'JOHAB' => 'CP1361', - 'KOI8' => 'KOI8-R', - 'LATIN1' => 'ISO-8859-1', - 'LATIN2' => 'ISO-8859-2', - 'LATIN3' => 'ISO-8859-3', - 'LATIN4' => 'ISO-8859-4', - // The following encoding map is a known error in PostgreSQL < 7.2 - // See the constructor for Postgres72. - 'LATIN5' => 'ISO-8859-5', - 'LATIN6' => 'ISO-8859-10', - 'LATIN7' => 'ISO-8859-13', - 'LATIN8' => 'ISO-8859-14', - 'LATIN9' => 'ISO-8859-15', - 'LATIN10' => 'ISO-8859-16', - 'SQL_ASCII' => 'US-ASCII', - 'TCVN' => 'CP1258', - 'UNICODE' => 'UTF-8', - 'WIN' => 'CP1251', - 'WIN874' => 'CP874', - 'WIN1256' => 'CP1256', - ]; - - /** - * Return all database available on the server. - * - * @param null|string $currentdatabase - * - * @return PHPPgAdmin\ArrayRecordSet A list of databases, sorted alphabetically - */ - public function getDatabases($currentdatabase = null) - { - $conf = $this->conf; - $server_info = $this->server_info; - - if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) { - $username = $server_info['username']; - $this->clean($username); - $clause = " AND pu.usename='{$username}'"; - } else { - $clause = ''; - } - - if ($currentdatabase) { - $this->clean($currentdatabase); - $orderby = "ORDER BY pdb.datname = '{$currentdatabase}' DESC, pdb.datname"; - } else { - $orderby = 'ORDER BY pdb.datname'; - } - - if (!$conf['show_system']) { - $where = ' AND NOT pdb.datistemplate'; - } else { - $where = ' AND pdb.datallowconn'; - } - - $sql = "SELECT pdb.datname AS datname, - pu.usename AS datowner, - pg_encoding_to_char(encoding) AS datencoding, - (SELECT description FROM pg_description pd WHERE pdb.oid=pd.objoid) AS datcomment, - (SELECT spcname FROM pg_catalog.pg_tablespace pt WHERE pt.oid=pdb.dattablespace) AS tablespace - FROM pg_database pdb, pg_user pu - WHERE pdb.datdba = pu.usesysid - {$where} - {$clause} - {$orderby}"; - - return $this->selectSet($sql); - } - - // Schema functions - - /** - * Return all schemas in the current database. - * - * @return PHPPgAdmin\ArrayRecordSet All schemas, sorted alphabetically - */ - public function getSchemas() - { - $conf = $this->conf; - - if (!$conf['show_system']) { - $where = "WHERE nspname NOT LIKE 'pg@_%' ESCAPE '@' AND nspname != 'information_schema'"; - } else { - $where = "WHERE nspname !~ '^pg_t(emp_[0-9]+|oast)$'"; - } - - $sql = " - SELECT pn.nspname, pu.usename AS nspowner, - pg_catalog.obj_description(pn.oid, 'pg_namespace') AS nspcomment - FROM pg_catalog.pg_namespace pn - LEFT JOIN pg_catalog.pg_user pu ON (pn.nspowner = pu.usesysid) - {$where} - ORDER BY nspname"; - - return $this->selectSet($sql); - } - - /** - * Return all information relating to a schema. - * - * @param string $schema The name of the schema - * - * @return PHPPgAdmin\ArrayRecordSet Schema information - */ - public function getSchemaByName($schema) - { - $this->clean($schema); - $sql = " - SELECT nspname, nspowner, u.usename AS ownername, nspacl, - pg_catalog.obj_description(pn.oid, 'pg_namespace') as nspcomment - FROM pg_catalog.pg_namespace pn - LEFT JOIN pg_shadow as u ON pn.nspowner = u.usesysid - WHERE nspname='{$schema}'"; - - return $this->selectSet($sql); - } - - // Table functions - - /** - * Changes a user's password. - * - * @param string $username The username - * @param string $password The new password - * - * @return PHPPgAdmin\ArrayRecordSet 0 if operation was successful - */ - public function changePassword($username, $password) - { - $enc = $this->_encryptPassword($username, $password); - $this->fieldClean($username); - $this->clean($enc); - - $sql = "ALTER USER \"{$username}\" WITH ENCRYPTED PASSWORD '{$enc}'"; - - return $this->execute($sql); - } - - // View functions - - /** - * Gets all information for an aggregate. - * - * @param string $name The name of the aggregate - * @param string $basetype The input data type of the aggregate - * - * @return PHPPgAdmin\ArrayRecordSet A recordset - */ - public function getAggregate($name, $basetype) - { - $c_schema = $this->_schema; - $this->clean($c_schema); - $this->clean($name); - $this->clean($basetype); - - $sql = " - SELECT p.proname, - CASE p.proargtypes[0] - WHEN 'pg_catalog.\"any\"'::pg_catalog.regtype THEN NULL - ELSE pg_catalog.format_type(p.proargtypes[0], NULL) - END AS proargtypes, a.aggtransfn, format_type(a.aggtranstype, NULL) AS aggstype, - a.aggfinalfn, a.agginitval, u.usename, pg_catalog.obj_description(p.oid, 'pg_proc') AS aggrcomment - FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n, pg_catalog.pg_user u, pg_catalog.pg_aggregate a - WHERE n.oid = p.pronamespace AND p.proowner=u.usesysid AND p.oid=a.aggfnoid - AND p.proisagg AND n.nspname='{$c_schema}' - AND p.proname='{$name}' - AND CASE p.proargtypes[0] - WHEN 'pg_catalog.\"any\"'::pg_catalog.regtype THEN '' - ELSE pg_catalog.format_type(p.proargtypes[0], NULL) - END ='{$basetype}'"; - - return $this->selectSet($sql); - } - - // Sequence functions - - public function hasAggregateSortOp() - { - return false; - } - - // Role, User/group functions - - public function hasAlterTableSchema() - { - return false; - } - - // Aggregate functions - - public function hasAutovacuum() - { - return false; - } - - // Capabilities - - public function hasDisableTriggers() - { - return false; - } - - public function hasFunctionAlterSchema() - { - return false; - } - - public function hasPreparedXacts() - { - return false; - } - - public function hasRoles() - { - return false; - } - - public function hasAlterSequenceSchema() - { - return false; - } - - public function hasServerAdminFuncs() - { - return false; - } - - /** - * Return all tables in current database (and schema). - * - * @return PHPPgAdmin\ArrayRecordSet 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, - null tablespace, - 'N/A' as table_size - FROM pg_catalog.pg_class c - LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace - WHERE c.relkind = 'r' - AND nspname='{$c_schema}' - ORDER BY c.relname"; - - return $this->selectSet($sql); - } - - /** - * Protected method which alter a table - * SHOULDN'T BE CALLED OUTSIDE OF A TRANSACTION. - * - * @param \ADORecordSet $tblrs The table recordSet returned by getTable() - * @param string $name The new name for the table - * @param string $owner The new owner for the table - * @param string $schema The new schema for the table - * @param string $comment The comment on the table - * @param string $tablespace The new tablespace for the table ('' means leave as is) - * - * @return int 0 success - */ - protected function _alterTable($tblrs, $name, $owner, $schema, $comment, $tablespace) - { - /* $schema not supported in pg80- */ - - // Comment - $status = $this->setComment('TABLE', '', $tblrs->fields['relname'], $comment); - - if (0 !== $status) { - return -4; - } - - // Owner - $this->fieldClean($owner); - $status = $this->alterTableOwner($tblrs, $owner); - - if (0 !== $status) { - return -5; - } - - // Tablespace - $this->fieldClean($tablespace); - $status = $this->alterTableTablespace($tblrs, $tablespace); - - if (0 !== $status) { - return -6; - } - - // Rename - $this->fieldClean($name); - $status = $this->alterTableName($tblrs, $name); - - if (0 !== $status) { - return -3; - } - - return 0; - } - - /** - * Protected method which alter a view - * SHOULDN'T BE CALLED OUTSIDE OF A TRANSACTION. - * - * @param \ADORecordSet $vwrs The view recordSet returned by getView() - * @param string $name The new name for the view - * @param string $owner The new owner for the view - * @param string $schema The view schema - * @param string $comment The comment on the view - * - * @return int 0 success, otherwise, an error code - */ - protected function _alterView($vwrs, $name, $owner, $schema, $comment) - { - $type = 'VIEW'; - - if ('m' === $vwrs->fields['relkind']) { - $type = 'MATERIALIZED VIEW'; - } - /* $schema not supported in pg80- */ - $this->fieldArrayClean($vwrs->fields); - - // Comment - if (0 !== $this->setComment($type, $vwrs->fields['relname'], '', $comment)) { - return -4; - } - - // Owner - $this->fieldClean($owner); - $status = $this->alterViewOwner($vwrs, $owner); - - if (0 !== $status) { - return -5; - } - - // Rename - $this->fieldClean($name); - $status = $this->alterViewName($vwrs, $name); - - if (0 !== $status) { - return -3; - } - - return 0; - } - - /** - * Protected method which alter a sequence - * SHOULDN'T BE CALLED OUTSIDE OF A TRANSACTION. - * - * @param \ADORecordSet $seqrs The sequence recordSet returned by getSequence() - * @param string $name The new name for the sequence - * @param string $comment The comment on the sequence - * @param string $owner The new owner for the sequence - * @param string $schema The new schema for the sequence - * @param int $increment The increment - * @param int $minvalue The min value - * @param int $maxvalue The max value - * @param int $restartvalue The starting value - * @param int $cachevalue The cache value - * @param bool $cycledvalue True if cycled, false otherwise - * @param int $startvalue The sequence start value when issueing a restart - * - * @return int 0 success - */ - protected function _alterSequence( - $seqrs, - $name, - $comment, - $owner, - $schema, - $increment, - $minvalue, - $maxvalue, - $restartvalue, - $cachevalue, - $cycledvalue, - $startvalue - ) { - /* $schema not supported in pg80- */ - $this->fieldArrayClean($seqrs->fields); - - // Comment - $status = $this->setComment('SEQUENCE', $seqrs->fields['seqname'], '', $comment); - - if (0 !== $status) { - return -4; - } - - // Owner - $this->fieldClean($owner); - $status = $this->alterSequenceOwner($seqrs, $owner); - - if (0 !== $status) { - return -5; - } - - // Props - $this->clean($increment); - $this->clean($minvalue); - $this->clean($maxvalue); - $this->clean($restartvalue); - $this->clean($cachevalue); - $this->clean($cycledvalue); - $this->clean($startvalue); - $status = $this->alterSequenceProps( - $seqrs, - $increment, - $minvalue, - $maxvalue, - $restartvalue, - $cachevalue, - $cycledvalue, - null - ); - - if (0 !== $status) { - return -6; - } - - // Rename - $this->fieldClean($name); - $status = $this->alterSequenceName($seqrs, $name); - - if (0 !== $status) { - return -3; - } - - return 0; - } -} diff --git a/src/database/Postgres81.php b/src/database/Postgres81.php deleted file mode 100644 index c17de74e3..000000000 --- a/src/database/Postgres81.php +++ /dev/null @@ -1,348 +0,0 @@ - ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'], - 'view' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'], - 'sequence' => ['SELECT', 'UPDATE', 'ALL PRIVILEGES'], - 'database' => ['CREATE', 'TEMPORARY', 'ALL PRIVILEGES'], - 'function' => ['EXECUTE', 'ALL PRIVILEGES'], - 'language' => ['USAGE', 'ALL PRIVILEGES'], - 'schema' => ['CREATE', 'USAGE', 'ALL PRIVILEGES'], - 'tablespace' => ['CREATE', 'ALL PRIVILEGES'], - ]; - - // List of characters in acl lists and the privileges they - // refer to. - public $privmap = [ - 'r' => 'SELECT', - 'w' => 'UPDATE', - 'a' => 'INSERT', - 'd' => 'DELETE', - 'R' => 'RULE', - 'x' => 'REFERENCES', - 't' => 'TRIGGER', - 'X' => 'EXECUTE', - 'U' => 'USAGE', - 'C' => 'CREATE', - 'T' => 'TEMPORARY', - ]; - - // Array of allowed index types - public $typIndexes = ['BTREE', 'RTREE', 'GIST', 'HASH']; - - // Database functions - - /** - * Returns all databases available on the server. - * - * @param null|string $currentdatabase - * - * @return \ADORecordSet|int A list of databases, sorted alphabetically - */ - public function getDatabases($currentdatabase = null) - { - $conf = $this->conf; - $server_info = $this->server_info; - - if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) { - $username = $server_info['username']; - $this->clean($username); - $clause = " AND pr.rolname='{$username}'"; - } else { - $clause = ''; - } - - if (null !== $currentdatabase) { - $this->clean($currentdatabase); - $orderby = "ORDER BY pdb.datname = '{$currentdatabase}' DESC, pdb.datname"; - } else { - $orderby = 'ORDER BY pdb.datname'; - } - - if (!$conf['show_system']) { - $where = ' AND NOT pdb.datistemplate'; - } else { - $where = ' AND pdb.datallowconn'; - } - - $sql = "SELECT - pdb.datname AS datname, - pr.rolname AS datowner, pg_encoding_to_char(encoding) AS datencoding, - (SELECT description FROM pg_catalog.pg_description pd WHERE pdb.oid=pd.objoid) AS datcomment, - (SELECT spcname FROM pg_catalog.pg_tablespace pt WHERE pt.oid=pdb.dattablespace) AS tablespace, - pg_catalog.pg_database_size(pdb.oid) as dbsize - FROM pg_catalog.pg_database pdb LEFT JOIN pg_catalog.pg_roles pr ON (pdb.datdba = pr.oid) - WHERE true - {$where} - {$clause} - {$orderby}"; - - return $this->selectSet($sql); - } - - /** - * Alters a database - * the multiple return vals are for postgres 8+ which support more functionality in alter database. - * - * @param string $dbName The name of the database - * @param string $newName new name for the database - * @param string $newOwner The new owner for the database - * @param string $comment - * - * @return bool|int 0 success - */ - public function alterDatabase($dbName, $newName, $newOwner = '', $comment = '') - { - $this->clean($dbName); - $this->clean($newName); - $this->clean($newOwner); - $this->clean($comment); - //ignore $comment, not supported pre 8.2 - - $status = $this->beginTransaction(); - - if (0 !== $status) { - $this->rollbackTransaction(); - - return -1; - } - - if ($dbName !== $newName) { - $status = $this->alterDatabaseRename($dbName, $newName); - - if (0 !== $status) { - $this->rollbackTransaction(); - - return -3; - } - } - - $status = $this->alterDatabaseOwner($newName, $newOwner); - - if (0 !== $status) { - $this->rollbackTransaction(); - - return -2; - } - - return $this->endTransaction(); - } - - // Autovacuum functions - - /** - * @param mixed $table - * @param mixed $vacenabled - * @param mixed $vacthreshold - * @param mixed $vacscalefactor - * @param mixed $anathresold - * @param mixed $anascalefactor - * @param mixed $vaccostdelay - * @param mixed $vaccostlimit - * - * @return \ADORecordSet|int - */ - public function saveAutovacuum( - $table, - $vacenabled, - $vacthreshold, - $vacscalefactor, - $anathresold, - $anascalefactor, - $vaccostdelay, - $vaccostlimit - ) { - $defaults = $this->getAutovacuum(); - $c_schema = $this->_schema; - $this->clean($c_schema); - $this->clean($table); - - $rs = $this->selectSet(" - SELECT c.oid - FROM pg_catalog.pg_class AS c - LEFT JOIN pg_catalog.pg_namespace AS n ON (n.oid=c.relnamespace) - WHERE - c.relname = '{$table}' AND n.nspname = '{$c_schema}' - "); - - if ($rs->EOF) { - return -1; - } - - $toid = $rs->fields('oid'); - unset($rs); - - if (empty($_POST['autovacuum_vacuum_threshold'])) { - $_POST['autovacuum_vacuum_threshold'] = $defaults['autovacuum_vacuum_threshold']; - } - - if (empty($_POST['autovacuum_vacuum_scale_factor'])) { - $_POST['autovacuum_vacuum_scale_factor'] = $defaults['autovacuum_vacuum_scale_factor']; - } - - if (empty($_POST['autovacuum_analyze_threshold'])) { - $_POST['autovacuum_analyze_threshold'] = $defaults['autovacuum_analyze_threshold']; - } - - if (empty($_POST['autovacuum_analyze_scale_factor'])) { - $_POST['autovacuum_analyze_scale_factor'] = $defaults['autovacuum_analyze_scale_factor']; - } - - if (empty($_POST['autovacuum_vacuum_cost_delay'])) { - $_POST['autovacuum_vacuum_cost_delay'] = $defaults['autovacuum_vacuum_cost_delay']; - } - - if (empty($_POST['autovacuum_vacuum_cost_limit'])) { - $_POST['autovacuum_vacuum_cost_limit'] = $defaults['autovacuum_vacuum_cost_limit']; - } - - $rs = $this->selectSet("SELECT vacrelid - FROM \"pg_catalog\".\"pg_autovacuum\" - WHERE vacrelid = {$toid};"); - - $status = -1; // ini - if ($rs->recordCount() && ($rs->fields['vacrelid'] === $toid)) { - // table exists in pg_autovacuum, UPDATE - $sql = \sprintf( - "UPDATE \"pg_catalog\".\"pg_autovacuum\" SET - enabled = '%s', - vac_base_thresh = %s, - vac_scale_factor = %s, - anl_base_thresh = %s, - anl_scale_factor = %s, - vac_cost_delay = %s, - vac_cost_limit = %s - WHERE vacrelid = {$toid}; - ", - ('on' === $_POST['autovacuum_enabled']) ? 't' : 'f', - $_POST['autovacuum_vacuum_threshold'], - $_POST['autovacuum_vacuum_scale_factor'], - $_POST['autovacuum_analyze_threshold'], - $_POST['autovacuum_analyze_scale_factor'], - $_POST['autovacuum_vacuum_cost_delay'], - $_POST['autovacuum_vacuum_cost_limit'] - ); - $status = $this->execute($sql); - } else { - // table doesn't exists in pg_autovacuum, INSERT - $sql = \sprintf( - "INSERT INTO \"pg_catalog\".\"pg_autovacuum\" - VALUES (%s, '%s', %s, %s, %s, %s, %s, %s)", - $toid, - ('on' === $_POST['autovacuum_enabled']) ? 't' : 'f', - $_POST['autovacuum_vacuum_threshold'], - $_POST['autovacuum_vacuum_scale_factor'], - $_POST['autovacuum_analyze_threshold'], - $_POST['autovacuum_analyze_scale_factor'], - $_POST['autovacuum_vacuum_cost_delay'], - $_POST['autovacuum_vacuum_cost_limit'] - ); - $status = $this->execute($sql); - } - - return $status; - } - - /** - * Returns all available process information. - * - * @param null|string $database (optional) Find only connections to specified database - * - * @return \ADORecordSet|int A recordset - */ - public function getProcesses($database = null) - { - if (null === $database) { - $sql = "SELECT datname, usename, procpid AS pid, current_query AS query, query_start, - case when (select count(*) from pg_locks where pid=pg_stat_activity.procpid and granted is false) > 0 then 't' else 'f' end as waiting - FROM pg_catalog.pg_stat_activity - ORDER BY datname, usename, procpid"; - } else { - $this->clean($database); - $sql = "SELECT datname, usename, procpid AS pid, current_query AS query, query_start - case when (select count(*) from pg_locks where pid=pg_stat_activity.procpid and granted is false) > 0 then 't' else 'f' end as waiting - FROM pg_catalog.pg_stat_activity - WHERE datname='{$database}' - ORDER BY usename, procpid"; - } - - return $this->selectSet($sql); - } - - // Tablespace functions - - /** - * Retrieves a tablespace's information. - * - * @param string $spcname namespace - * - * @return \ADORecordSet|int A recordset - */ - public function getTablespace($spcname) - { - $this->clean($spcname); - - $sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, spclocation - FROM pg_catalog.pg_tablespace WHERE spcname='{$spcname}'"; - - return $this->selectSet($sql); - } - - /** - * Retrieves information for all tablespaces. - * - * @param bool $all Include all tablespaces (necessary when moving objects back to the default space) - * - * @return \ADORecordSet|int A recordset - */ - public function getTablespaces($all = false) - { - $conf = $this->conf; - - $sql = 'SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, spclocation - FROM pg_catalog.pg_tablespace'; - - if (!$conf['show_system'] && !$all) { - $sql .= ' WHERE spcname NOT LIKE $$pg\_%$$'; - } - - $sql .= ' ORDER BY spcname'; - - return $this->selectSet($sql); - } - - // Capabilities - - public function hasCreateTableLikeWithConstraints() - { - return false; - } - - public function hasSharedComments() - { - return false; - } - - public function hasConcurrentIndexBuild() - { - return false; - } -} diff --git a/src/database/Postgres82.php b/src/database/Postgres82.php deleted file mode 100644 index 679a04c85..000000000 --- a/src/database/Postgres82.php +++ /dev/null @@ -1,439 +0,0 @@ - 'i', - '!=' => 'i', - '<' => 'i', - '>' => 'i', - '<=' => 'i', - '>=' => 'i', - '<<' => 'i', - '>>' => 'i', - '<<=' => 'i', - '>>=' => 'i', - 'LIKE' => 'i', - 'NOT LIKE' => 'i', - 'ILIKE' => 'i', - 'NOT ILIKE' => 'i', - 'SIMILAR TO' => 'i', - 'NOT SIMILAR TO' => 'i', - '~' => 'i', - '!~' => 'i', - '~*' => 'i', - '!~*' => 'i', - 'IS NULL' => 'p', - 'IS NOT NULL' => 'p', - 'IN' => 'x', - 'NOT IN' => 'x', - ]; - - // Database functions - - /** - * Returns table locks information in the current database. - * - * @return \ADORecordSet|int A recordset - */ - public function getLocks() - { - $conf = $this->conf; - - if (!$conf['show_system']) { - $where = 'AND pn.nspname NOT LIKE $$pg\_%$$'; - } else { - $where = "AND nspname !~ '^pg_t(emp_[0-9]+|oast)$'"; - } - - $sql = "SELECT pn.nspname, pc.relname AS tablename, pl.transaction, pl.pid, pl.mode, pl.granted - FROM pg_catalog.pg_locks pl, pg_catalog.pg_class pc, pg_catalog.pg_namespace pn - WHERE pl.relation = pc.oid AND pc.relnamespace=pn.oid {$where} - ORDER BY nspname,tablename"; - - return $this->selectSet($sql); - } - - // Sequence functions - - /** - * Rename a sequence. - * - * @param \ADORecordSet $seqrs The sequence RecordSet returned by getSequence() - * @param string $name The new name for the sequence - * - * @return \ADORecordSet|int 0 if operation was successful - */ - public function alterSequenceName($seqrs, $name) - { - /* vars are cleaned in _alterSequence */ - if (!empty($name) && ($seqrs->fields['seqname'] !== $name)) { - $f_schema = $this->_schema; - $this->fieldClean($f_schema); - $sql = "ALTER TABLE \"{$f_schema}\".\"{$seqrs->fields['seqname']}\" RENAME TO \"{$name}\""; - $status = $this->execute($sql); - - if (0 === $status) { - $seqrs->fields['seqname'] = $name; - } else { - return $status; - } - } - - return 0; - } - - // View functions - - /** - * Rename a view. - * - * @param \ADORecordSet $vwrs The view recordSet returned by getView() - * @param string $name The new view's name - * - * @return \ADORecordSet|int -1 if Failed - */ - public function alterViewName($vwrs, $name) - { - // Rename (only if name has changed) - /* $vwrs and $name are cleaned in _alterView */ - if (!empty($name) && ($name !== $vwrs->fields['relname'])) { - $f_schema = $this->_schema; - $this->fieldClean($f_schema); - $sql = "ALTER TABLE \"{$f_schema}\".\"{$vwrs->fields['relname']}\" RENAME TO \"{$name}\""; - $status = $this->execute($sql); - - if (0 === $status) { - $vwrs->fields['relname'] = $name; - } else { - return $status; - } - } - - return 0; - } - - // Trigger functions - - /** - * Grabs a list of triggers on a table. - * - * @param string $table The name of a table whose triggers to retrieve - * - * @return \ADORecordSet|int A recordset - */ - public function getTriggers($table = '') - { - $c_schema = $this->_schema; - $this->clean($c_schema); - $this->clean($table); - - $sql = "SELECT - t.tgname, pg_catalog.pg_get_triggerdef(t.oid) AS tgdef, t.tgenabled, p.oid AS prooid, - p.proname || ' (' || pg_catalog.oidvectortypes(p.proargtypes) || ')' AS proproto, - ns.nspname AS pronamespace - FROM pg_catalog.pg_trigger t, pg_catalog.pg_proc p, pg_catalog.pg_namespace ns - WHERE t.tgrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='{$table}' - AND relnamespace=(SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$c_schema}')) - AND (NOT tgisconstraint OR NOT EXISTS - (SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c - ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) - WHERE d.classid = t.tableoid AND d.objid = t.oid AND d.deptype = 'i' AND c.contype = 'f')) - AND p.oid=t.tgfoid - AND p.pronamespace = ns.oid"; - - return $this->selectSet($sql); - } - - // Function functions - - /** - * Returns all details for a particular function. - * - * @param int $function_oid - * - * @return \ADORecordSet|int Function info - * - * @internal param string The $func name of the function to retrieve - */ - public function getFunction($function_oid) - { - $this->clean($function_oid); - - $sql = "SELECT - pc.oid AS prooid, - proname, - pg_catalog.pg_get_userbyid(proowner) AS proowner, - nspname as proschema, - lanname as prolanguage, - pg_catalog.format_type(prorettype, NULL) as proresult, - prosrc, - probin, - proretset, - proisstrict, - provolatile, - prosecdef, - pg_catalog.oidvectortypes(pc.proargtypes) AS proarguments, - proargnames AS proargnames, - pg_catalog.obj_description(pc.oid, 'pg_proc') AS procomment - FROM - pg_catalog.pg_proc pc, pg_catalog.pg_language pl, pg_catalog.pg_namespace pn - WHERE - pc.oid = '{$function_oid}'::oid - AND pc.prolang = pl.oid - AND pc.pronamespace = pn.oid - "; - - return $this->selectSet($sql); - } - - /** - * Creates a new function. - * - * @param string $funcname The name of the function to create - * @param string $args A comma separated string of types - * @param string $returns The return type - * @param string $definition The definition for the new function - * @param string $language The language the function is written for - * @param array $flags An array of optional flags - * @param bool $setof True if it returns a set, false otherwise - * @param float $cost cost the planner should use in the function execution step - * @param int $rows number of rows planner should estimate will be returned - * @param string $comment The comment on the function - * @param bool $replace (optional) True if OR REPLACE, false for normal - * - * @return bool|int 0 success - */ - public function createFunction($funcname, $args, $returns, $definition, $language, $flags, $setof, $cost, $rows, $comment, $replace = false) - { - // Begin a transaction - $status = $this->beginTransaction(); - - if (0 !== $status) { - $this->rollbackTransaction(); - - return -1; - } - - $f_schema = $this->_schema; - $this->fieldClean($f_schema); - $this->fieldClean($funcname); - $this->clean($args); - $this->fieldClean($language); - $this->arrayClean($flags); - - $sql = 'CREATE'; - - if ($replace) { - $sql .= ' OR REPLACE'; - } - - $sql .= " FUNCTION \"{$f_schema}\".\"{$funcname}\" ("; - - if ('' !== $args) { - $sql .= $args; - } - - // For some reason, the returns field cannot have quotes... - $sql .= ') RETURNS '; - - if ($setof) { - $sql .= 'SETOF '; - } - - $sql .= "{$returns} AS "; - - if (\is_array($definition)) { - $this->arrayClean($definition); - $sql .= "'" . $definition[0] . "'"; - - if ($definition[1]) { - $sql .= ",'" . $definition[1] . "'"; - } - } else { - $this->clean($definition); - $sql .= "'" . $definition . "'"; - } - - $sql .= " LANGUAGE \"{$language}\""; - - // Add flags - foreach ($flags as $v) { - // Skip default flags - if ('' === $v) { - continue; - } - - $sql .= "\n{$v}"; - } - - $status = $this->execute($sql); - - if (0 !== $status) { - $this->rollbackTransaction(); - - return -3; - } - - /* set the comment */ - $status = $this->setComment('FUNCTION', "\"{$funcname}\"({$args})", null, $comment); - - if (0 !== $status) { - $this->rollbackTransaction(); - - return -4; - } - - return $this->endTransaction(); - } - - // Index functions - - /** - * Clusters an index. - * - * @param string $table The table the index is on - * @param string $index The name of the index - * - * @return array 0 if operation was successful - */ - public function clusterIndex($table = '', $index = '') - { - $sql = 'CLUSTER'; - - // We don't bother with a transaction here, as there's no point rolling - // back an expensive cluster if a cheap analyze fails for whatever reason - - if (!empty($table)) { - $f_schema = $this->_schema; - $this->fieldClean($f_schema); - $this->fieldClean($table); - - if (!empty($index)) { - $this->fieldClean($index); - $sql .= " \"{$index}\" ON \"{$f_schema}\".\"{$table}\""; - } else { - $sql .= " \"{$f_schema}\".\"{$table}\""; - } - } - - $status = $this->execute($sql); - - return [$status, $sql]; - } - - // Operator functions - - /** - * Returns all details for a particular operator. - * - * @param int $operator_oid The oid of the operator - * - * @return \ADORecordSet|int Function info - */ - public function getOperator($operator_oid) - { - $this->clean($operator_oid); - - $sql = " - SELECT - po.oid, po.oprname, - oprleft::pg_catalog.regtype AS oprleftname, - oprright::pg_catalog.regtype AS oprrightname, - oprresult::pg_catalog.regtype AS resultname, - po.oprcanhash, - oprcom::pg_catalog.regoperator AS oprcom, - oprnegate::pg_catalog.regoperator AS oprnegate, - oprlsortop::pg_catalog.regoperator AS oprlsortop, - oprrsortop::pg_catalog.regoperator AS oprrsortop, - oprltcmpop::pg_catalog.regoperator AS oprltcmpop, - oprgtcmpop::pg_catalog.regoperator AS oprgtcmpop, - po.oprcode::pg_catalog.regproc AS oprcode, - po.oprrest::pg_catalog.regproc AS oprrest, - po.oprjoin::pg_catalog.regproc AS oprjoin - FROM - pg_catalog.pg_operator po - WHERE - po.oid='{$operator_oid}' - "; - - return $this->selectSet($sql); - } - - // Operator Class functions - - /** - * Gets all opclasses. - * - * @return \ADORecordSet|int A recordset - */ - public function getOpClasses() - { - $c_schema = $this->_schema; - $this->clean($c_schema); - $sql = " - SELECT - pa.amname, - po.opcname, - po.opcintype::pg_catalog.regtype AS opcintype, - po.opcdefault, - pg_catalog.obj_description(po.oid, 'pg_opclass') AS opccomment - FROM - pg_catalog.pg_opclass po, pg_catalog.pg_am pa, pg_catalog.pg_namespace pn - WHERE - po.opcamid=pa.oid - AND po.opcnamespace=pn.oid - AND pn.nspname='{$c_schema}' - ORDER BY 1,2 - "; - - return $this->selectSet($sql); - } - - // Capabilities - - public function hasCreateTableLikeWithIndexes() - { - return false; - } - - public function hasEnumTypes() - { - return false; - } - - public function hasFTS() - { - return false; - } - - public function hasFunctionCosting() - { - return false; - } - - public function hasFunctionGUC() - { - return false; - } - - public function hasVirtualTransactionId() - { - return false; - } -} diff --git a/src/database/Postgres83.php b/src/database/Postgres83.php deleted file mode 100644 index 583744dac..000000000 --- a/src/database/Postgres83.php +++ /dev/null @@ -1,442 +0,0 @@ - ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'], - 'view' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'], - 'sequence' => ['SELECT', 'UPDATE', 'ALL PRIVILEGES'], - 'database' => ['CREATE', 'TEMPORARY', 'CONNECT', 'ALL PRIVILEGES'], - 'function' => ['EXECUTE', 'ALL PRIVILEGES'], - 'language' => ['USAGE', 'ALL PRIVILEGES'], - 'schema' => ['CREATE', 'USAGE', 'ALL PRIVILEGES'], - 'tablespace' => ['CREATE', 'ALL PRIVILEGES'], - ]; - - // List of characters in acl lists and the privileges they - // refer to. - public $privmap = [ - 'r' => 'SELECT', - 'w' => 'UPDATE', - 'a' => 'INSERT', - 'd' => 'DELETE', - 'R' => 'RULE', - 'x' => 'REFERENCES', - 't' => 'TRIGGER', - 'X' => 'EXECUTE', - 'U' => 'USAGE', - 'C' => 'CREATE', - 'T' => 'TEMPORARY', - 'c' => 'CONNECT', - ]; - - // Databse functions - - /** - * Return all database available on the server. - * - * @param string $currentdatabase database name that should be on top of the resultset - * - * @return PHPPgAdmin\ArrayRecordSet A recordset or an error number A list of databases, sorted alphabetically - */ - public function getDatabases($currentdatabase = null) - { - $conf = $this->conf; - $server_info = $this->server_info; - - if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) { - $username = $server_info['username']; - $this->clean($username); - $clause = " AND pr.rolname='{$username}'"; - } else { - $clause = ''; - } - - if (null !== $currentdatabase) { - $this->clean($currentdatabase); - $orderby = "ORDER BY pdb.datname = '{$currentdatabase}' DESC, pdb.datname"; - } else { - $orderby = 'ORDER BY pdb.datname'; - } - - if (!$conf['show_system']) { - $where = ' AND NOT pdb.datistemplate'; - } else { - $where = ' AND pdb.datallowconn'; - } - - $sql = " - SELECT pdb.datname AS datname, pr.rolname AS datowner, pg_encoding_to_char(encoding) AS datencoding, - (SELECT description FROM pg_catalog.pg_shdescription pd WHERE pdb.oid=pd.objoid AND pd.classoid='pg_database'::regclass) AS datcomment, - (SELECT spcname FROM pg_catalog.pg_tablespace pt WHERE pt.oid=pdb.dattablespace) AS tablespace, - pg_catalog.pg_database_size(pdb.oid) as dbsize - FROM pg_catalog.pg_database pdb LEFT JOIN pg_catalog.pg_roles pr ON (pdb.datdba = pr.oid) - WHERE true - {$where} - {$clause} - {$orderby}"; - - return $this->selectSet($sql); - } - - // Administration functions - - /** - * Returns all available autovacuum per table information. - * - * @param string $table - * - * @return PHPPgAdmin\ArrayRecordSet A recordset - */ - public function getTableAutovacuum($table = '') - { - $sql = ''; - - if ('' !== $table) { - $this->clean($table); - $c_schema = $this->_schema; - $this->clean($c_schema); - - $sql = " - SELECT vacrelid, nspname, relname, - CASE enabled - WHEN 't' THEN 'on' - ELSE 'off' - END AS autovacuum_enabled, vac_base_thresh AS autovacuum_vacuum_threshold, - vac_scale_factor AS autovacuum_vacuum_scale_factor, anl_base_thresh AS autovacuum_analyze_threshold, - anl_scale_factor AS autovacuum_analyze_scale_factor, vac_cost_delay AS autovacuum_vacuum_cost_delay, - vac_cost_limit AS autovacuum_vacuum_cost_limit - FROM pg_autovacuum AS a - join pg_class AS c on (c.oid=a.vacrelid) - join pg_namespace AS n on (n.oid=c.relnamespace) - WHERE c.relname = '{$table}' AND n.nspname = '{$c_schema}' - ORDER BY nspname, relname - "; - } else { - $sql = " - SELECT vacrelid, nspname, relname, - CASE enabled - WHEN 't' THEN 'on' - ELSE 'off' - END AS autovacuum_enabled, vac_base_thresh AS autovacuum_vacuum_threshold, - vac_scale_factor AS autovacuum_vacuum_scale_factor, anl_base_thresh AS autovacuum_analyze_threshold, - anl_scale_factor AS autovacuum_analyze_scale_factor, vac_cost_delay AS autovacuum_vacuum_cost_delay, - vac_cost_limit AS autovacuum_vacuum_cost_limit - FROM pg_autovacuum AS a - join pg_class AS c on (c.oid=a.vacrelid) - join pg_namespace AS n on (n.oid=c.relnamespace) - ORDER BY nspname, relname - "; - } - - return $this->selectSet($sql); - } - - /** - * @param mixed $table - * @param mixed $vacenabled - * @param mixed $vacthreshold - * @param mixed $vacscalefactor - * @param mixed $anathresold - * @param mixed $anascalefactor - * @param mixed $vaccostdelay - * @param mixed $vaccostlimit - * - * @return PHPPgAdmin\ArrayRecordSet - */ - public function saveAutovacuum( - $table, - $vacenabled, - $vacthreshold, - $vacscalefactor, - $anathresold, - $anascalefactor, - $vaccostdelay, - $vaccostlimit - ) { - $defaults = $this->getAutovacuum(); - $c_schema = $this->_schema; - $this->clean($c_schema); - $this->clean($table); - - $rs = $this->selectSet(" - SELECT c.oid - FROM pg_catalog.pg_class AS c - LEFT JOIN pg_catalog.pg_namespace AS n ON (n.oid=c.relnamespace) - WHERE - c.relname = '{$table}' AND n.nspname = '{$c_schema}' - "); - - if ($rs->EOF) { - return -1; - } - - $toid = $rs->fields('oid'); - unset($rs); - - if (empty($_POST['autovacuum_vacuum_threshold'])) { - $_POST['autovacuum_vacuum_threshold'] = $defaults['autovacuum_vacuum_threshold']; - } - - if (empty($_POST['autovacuum_vacuum_scale_factor'])) { - $_POST['autovacuum_vacuum_scale_factor'] = $defaults['autovacuum_vacuum_scale_factor']; - } - - if (empty($_POST['autovacuum_analyze_threshold'])) { - $_POST['autovacuum_analyze_threshold'] = $defaults['autovacuum_analyze_threshold']; - } - - if (empty($_POST['autovacuum_analyze_scale_factor'])) { - $_POST['autovacuum_analyze_scale_factor'] = $defaults['autovacuum_analyze_scale_factor']; - } - - if (empty($_POST['autovacuum_vacuum_cost_delay'])) { - $_POST['autovacuum_vacuum_cost_delay'] = $defaults['autovacuum_vacuum_cost_delay']; - } - - if (empty($_POST['autovacuum_vacuum_cost_limit'])) { - $_POST['autovacuum_vacuum_cost_limit'] = $defaults['autovacuum_vacuum_cost_limit']; - } - - if (empty($_POST['vacuum_freeze_min_age'])) { - $_POST['vacuum_freeze_min_age'] = $defaults['vacuum_freeze_min_age']; - } - - if (empty($_POST['autovacuum_freeze_max_age'])) { - $_POST['autovacuum_freeze_max_age'] = $defaults['autovacuum_freeze_max_age']; - } - - $rs = $this->selectSet("SELECT vacrelid - FROM \"pg_catalog\".\"pg_autovacuum\" - WHERE vacrelid = {$toid};"); - - $status = -1; // ini - if ($rs->recordCount() && ($rs->fields['vacrelid'] === $toid)) { - // table exists in pg_autovacuum, UPDATE - $sql = \sprintf( - "UPDATE \"pg_catalog\".\"pg_autovacuum\" SET - enabled = '%s', - vac_base_thresh = %s, - vac_scale_factor = %s, - anl_base_thresh = %s, - anl_scale_factor = %s, - vac_cost_delay = %s, - vac_cost_limit = %s, - freeze_min_age = %s, - freeze_max_age = %s - WHERE vacrelid = {$toid}; - ", - ('on' === $_POST['autovacuum_enabled']) ? 't' : 'f', - $_POST['autovacuum_vacuum_threshold'], - $_POST['autovacuum_vacuum_scale_factor'], - $_POST['autovacuum_analyze_threshold'], - $_POST['autovacuum_analyze_scale_factor'], - $_POST['autovacuum_vacuum_cost_delay'], - $_POST['autovacuum_vacuum_cost_limit'], - $_POST['vacuum_freeze_min_age'], - $_POST['autovacuum_freeze_max_age'] - ); - $status = $this->execute($sql); - } else { - // table doesn't exists in pg_autovacuum, INSERT - $sql = \sprintf( - "INSERT INTO \"pg_catalog\".\"pg_autovacuum\" - VALUES (%s, '%s', %s, %s, %s, %s, %s, %s, %s, %s )", - $toid, - ('on' === $_POST['autovacuum_enabled']) ? 't' : 'f', - $_POST['autovacuum_vacuum_threshold'], - $_POST['autovacuum_vacuum_scale_factor'], - $_POST['autovacuum_analyze_threshold'], - $_POST['autovacuum_analyze_scale_factor'], - $_POST['autovacuum_vacuum_cost_delay'], - $_POST['autovacuum_vacuum_cost_limit'], - $_POST['vacuum_freeze_min_age'], - $_POST['autovacuum_freeze_max_age'] - ); - $status = $this->execute($sql); - } - - return $status; - } - - /** - * @param mixed $table - * - * @return bool|int - */ - public function dropAutovacuum($table) - { - $c_schema = $this->_schema; - $this->clean($c_schema); - $this->clean($table); - - $rs = $this->selectSet(" - SELECT c.oid - FROM pg_catalog.pg_class AS c - LEFT JOIN pg_catalog.pg_namespace AS n ON (n.oid=c.relnamespace) - WHERE - c.relname = '{$table}' AND n.nspname = '{$c_schema}' - "); - - return $this->deleteRow('pg_autovacuum', ['vacrelid' => $rs->fields['oid']], 'pg_catalog'); - } - - // Sequence functions - - /** - * Alter a sequence's properties. - * - * @param \ADORecordSet $seqrs The sequence RecordSet returned by getSequence() - * @param int $increment The sequence incremental value - * @param int $minvalue The sequence minimum value - * @param int $maxvalue The sequence maximum value - * @param int $restartvalue The sequence current value - * @param int $cachevalue The sequence cache value - * @param bool $cycledvalue Sequence can cycle ? - * @param int $startvalue The sequence start value when issueing a restart (ignored) - * - * @return PHPPgAdmin\ArrayRecordSet 0 if operation was successful - */ - public function alterSequenceProps( - $seqrs, - $increment, - $minvalue, - $maxvalue, - $restartvalue, - $cachevalue, - $cycledvalue, - $startvalue - ) { - $sql = ''; - /* vars are cleaned in _alterSequence */ - if (!empty($increment) && ($increment !== $seqrs->fields['increment_by'])) { - $sql .= " INCREMENT {$increment}"; - } - - if (!empty($minvalue) && ($minvalue !== $seqrs->fields['min_value'])) { - $sql .= " MINVALUE {$minvalue}"; - } - - if (!empty($maxvalue) && ($maxvalue !== $seqrs->fields['max_value'])) { - $sql .= " MAXVALUE {$maxvalue}"; - } - - if (!empty($restartvalue) && ($restartvalue !== $seqrs->fields['last_value'])) { - $sql .= " RESTART {$restartvalue}"; - } - - if (!empty($cachevalue) && ($cachevalue !== $seqrs->fields['cache_value'])) { - $sql .= " CACHE {$cachevalue}"; - } - - // toggle cycle yes/no - if (null !== $cycledvalue) { - $sql .= (!$cycledvalue ? ' NO ' : '') . ' CYCLE'; - } - - if ('' !== $sql) { - $f_schema = $this->_schema; - $this->fieldClean($f_schema); - $sql = "ALTER SEQUENCE \"{$f_schema}\".\"{$seqrs->fields['seqname']}\" {$sql}"; - - return $this->execute($sql); - } - - return 0; - } - - /** - * Alter a sequence's owner. - * - * @param \ADORecordSet $seqrs The sequence RecordSet returned by getSequence() - * @param string $owner sequence owner - * - * @return PHPPgAdmin\ArrayRecordSet 0 if operation was successful - * - * @internal param string The $name new owner for the sequence - */ - public function alterSequenceOwner($seqrs, $owner) - { - // If owner has been changed, then do the alteration. We are - // careful to avoid this generally as changing owner is a - // superuser only function. - /* vars are cleaned in _alterSequence */ - if (!empty($owner) && ($seqrs->fields['seqowner'] !== $owner)) { - $f_schema = $this->_schema; - $this->fieldClean($f_schema); - $sql = "ALTER TABLE \"{$f_schema}\".\"{$seqrs->fields['seqname']}\" OWNER TO \"{$owner}\""; - - return $this->execute($sql); - } - - return 0; - } - - // Function functions - - /** - * Returns all details for a particular function. - * - * @param mixed $function_oid - * - * @return PHPPgAdmin\ArrayRecordSet Function info - * - * @internal param string $func name of the function to retrieve - */ - public function getFunction($function_oid) - { - $this->clean($function_oid); - - $sql = " - SELECT - pc.oid AS prooid, proname, pg_catalog.pg_get_userbyid(proowner) AS proowner, - nspname as proschema, lanname as prolanguage, procost, prorows, - pg_catalog.format_type(prorettype, NULL) as proresult, prosrc, - probin, proretset, proisstrict, provolatile, prosecdef, - pg_catalog.oidvectortypes(pc.proargtypes) AS proarguments, - proargnames AS proargnames, - pg_catalog.obj_description(pc.oid, 'pg_proc') AS procomment, - proconfig - FROM - pg_catalog.pg_proc pc, pg_catalog.pg_language pl, - pg_catalog.pg_namespace pn - WHERE - pc.oid = '{$function_oid}'::oid AND pc.prolang = pl.oid - AND pc.pronamespace = pn.oid - "; - - return $this->selectSet($sql); - } - - // Capabilities - public function hasQueryKill() - { - return false; - } - - public function hasDatabaseCollation() - { - return false; - } - - public function hasAlterSequenceStart() - { - return false; - } -} diff --git a/src/database/Postgres84.php b/src/database/Postgres84.php deleted file mode 100644 index d75a3f2c1..000000000 --- a/src/database/Postgres84.php +++ /dev/null @@ -1,224 +0,0 @@ - ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'], - 'view' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'], - 'sequence' => ['SELECT', 'UPDATE', 'ALL PRIVILEGES'], - 'database' => ['CREATE', 'TEMPORARY', 'CONNECT', 'ALL PRIVILEGES'], - 'function' => ['EXECUTE', 'ALL PRIVILEGES'], - 'language' => ['USAGE', 'ALL PRIVILEGES'], - 'schema' => ['CREATE', 'USAGE', 'ALL PRIVILEGES'], - 'tablespace' => ['CREATE', 'ALL PRIVILEGES'], - 'column' => ['SELECT', 'INSERT', 'UPDATE', 'REFERENCES', 'ALL PRIVILEGES'], - ]; - - // Database functions - - /** - * Grabs a list of triggers on a table. - * - * @param string $table The name of a table whose triggers to retrieve - * - * @return \ADORecordSet|int A recordset - */ - public function getTriggers($table = '') - { - $c_schema = $this->_schema; - $this->clean($c_schema); - $this->clean($table); - - $sql = "SELECT - t.tgname, pg_catalog.pg_get_triggerdef(t.oid) AS tgdef, - CASE WHEN t.tgenabled = 'D' THEN FALSE ELSE TRUE END AS tgenabled, p.oid AS prooid, - p.proname || ' (' || pg_catalog.oidvectortypes(p.proargtypes) || ')' AS proproto, - ns.nspname AS pronamespace - FROM pg_catalog.pg_trigger t, pg_catalog.pg_proc p, pg_catalog.pg_namespace ns - WHERE t.tgrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='{$table}' - AND relnamespace=(SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$c_schema}')) - AND (NOT tgisconstraint OR NOT EXISTS - (SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c - ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) - WHERE d.classid = t.tableoid AND d.objid = t.oid AND d.deptype = 'i' AND c.contype = 'f')) - AND p.oid=t.tgfoid - AND p.pronamespace = ns.oid"; - - return $this->selectSet($sql); - } - - /** - * Searches all system catalogs to find objects that match a certain name. - * - * @param string $term The search term - * @param string $filter The object type to restrict to ('' means no restriction) - * - * @return \ADORecordSet|int A recordset - */ - public function findObject($term, $filter) - { - $conf = $this->conf; - - /*about escaping: - * SET standard_conforming_string is not available before 8.2 - * So we must use PostgreSQL specific notation :/ - * E'' notation is not available before 8.1 - * $$ is available since 8.0 - * Nothing specific from 7.4 - */ - - // Escape search term for ILIKE match - $this->clean($term); - $this->clean($filter); - $term = \str_replace('_', '\_', $term); - $term = \str_replace('%', '\%', $term); - - // Exclude system relations if necessary - if (!$conf['show_system']) { - // XXX: The mention of information_schema here is in the wrong place, but - // it's the quickest fix to exclude the info schema from 7.4 - $where = " AND pn.nspname NOT LIKE \$_PATERN_\$pg\\_%\$_PATERN_\$ AND pn.nspname != 'information_schema'"; - $lan_where = 'AND pl.lanispl'; - } else { - $where = ''; - $lan_where = ''; - } - - // Apply outer filter - $sql = ''; - - if ('' !== $filter) { - $sql = 'SELECT * FROM ('; - } - - $term = "\$_PATERN_\$%{$term}%\$_PATERN_\$"; - - $sql .= " - SELECT 'SCHEMA' AS type, oid, NULL AS schemaname, NULL AS relname, nspname AS name - FROM pg_catalog.pg_namespace pn WHERE nspname ILIKE {$term} {$where} - UNION ALL - SELECT CASE WHEN relkind='r' THEN 'TABLE' WHEN relkind='v' THEN 'VIEW' WHEN relkind='S' THEN 'SEQUENCE' END, pc.oid, - pn.nspname, NULL, pc.relname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn - WHERE pc.relnamespace=pn.oid AND relkind IN ('r', 'v', 'S') AND relname ILIKE {$term} {$where} - UNION ALL - SELECT CASE WHEN pc.relkind='r' THEN 'COLUMNTABLE' ELSE 'COLUMNVIEW' END, NULL, pn.nspname, pc.relname, pa.attname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn, - pg_catalog.pg_attribute pa WHERE pc.relnamespace=pn.oid AND pc.oid=pa.attrelid - AND pa.attname ILIKE {$term} AND pa.attnum > 0 AND NOT pa.attisdropped AND pc.relkind IN ('r', 'v') {$where} - UNION ALL - SELECT 'FUNCTION', pp.oid, pn.nspname, NULL, pp.proname || '(' || pg_catalog.oidvectortypes(pp.proargtypes) || ')' FROM pg_catalog.pg_proc pp, pg_catalog.pg_namespace pn - WHERE pp.pronamespace=pn.oid AND NOT pp.proisagg AND pp.proname ILIKE {$term} {$where} - UNION ALL - SELECT 'INDEX', NULL, pn.nspname, pc.relname, pc2.relname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn, - pg_catalog.pg_index pi, pg_catalog.pg_class pc2 WHERE pc.relnamespace=pn.oid AND pc.oid=pi.indrelid - AND pi.indexrelid=pc2.oid - AND NOT EXISTS ( - SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c - ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) - WHERE d.classid = pc2.tableoid AND d.objid = pc2.oid AND d.deptype = 'i' AND c.contype IN ('u', 'p') - ) - AND pc2.relname ILIKE {$term} {$where} - UNION ALL - SELECT 'CONSTRAINTTABLE', NULL, pn.nspname, pc.relname, pc2.conname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn, - pg_catalog.pg_constraint pc2 WHERE pc.relnamespace=pn.oid AND pc.oid=pc2.conrelid AND pc2.conrelid != 0 - AND CASE WHEN pc2.contype IN ('f', 'c') THEN TRUE ELSE NOT EXISTS ( - SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c - ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) - WHERE d.classid = pc2.tableoid AND d.objid = pc2.oid AND d.deptype = 'i' AND c.contype IN ('u', 'p') - ) END - AND pc2.conname ILIKE {$term} {$where} - UNION ALL - SELECT 'CONSTRAINTDOMAIN', pt.oid, pn.nspname, pt.typname, pc.conname FROM pg_catalog.pg_type pt, pg_catalog.pg_namespace pn, - pg_catalog.pg_constraint pc WHERE pt.typnamespace=pn.oid AND pt.oid=pc.contypid AND pc.contypid != 0 - AND pc.conname ILIKE {$term} {$where} - UNION ALL - SELECT 'TRIGGER', NULL, pn.nspname, pc.relname, pt.tgname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn, - pg_catalog.pg_trigger pt WHERE pc.relnamespace=pn.oid AND pc.oid=pt.tgrelid - AND ( NOT pt.tgisconstraint OR NOT EXISTS - (SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c - ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) - WHERE d.classid = pt.tableoid AND d.objid = pt.oid AND d.deptype = 'i' AND c.contype = 'f')) - AND pt.tgname ILIKE {$term} {$where} - UNION ALL - SELECT 'RULETABLE', NULL, pn.nspname AS schemaname, c.relname AS tablename, r.rulename FROM pg_catalog.pg_rewrite r - JOIN pg_catalog.pg_class c ON c.oid = r.ev_class - LEFT JOIN pg_catalog.pg_namespace pn ON pn.oid = c.relnamespace - WHERE c.relkind='r' AND r.rulename != '_RETURN' AND r.rulename ILIKE {$term} {$where} - UNION ALL - SELECT 'RULEVIEW', NULL, pn.nspname AS schemaname, c.relname AS tablename, r.rulename FROM pg_catalog.pg_rewrite r - JOIN pg_catalog.pg_class c ON c.oid = r.ev_class - LEFT JOIN pg_catalog.pg_namespace pn ON pn.oid = c.relnamespace - WHERE c.relkind='v' AND r.rulename != '_RETURN' AND r.rulename ILIKE {$term} {$where} - "; - - // Add advanced objects if show_advanced is set - if ($conf['show_advanced']) { - $sql .= " - UNION ALL - SELECT CASE WHEN pt.typtype='d' THEN 'DOMAIN' ELSE 'TYPE' END, pt.oid, pn.nspname, NULL, - pt.typname FROM pg_catalog.pg_type pt, pg_catalog.pg_namespace pn - WHERE pt.typnamespace=pn.oid AND typname ILIKE {$term} - AND (pt.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = pt.typrelid)) - {$where} - UNION ALL - SELECT 'OPERATOR', po.oid, pn.nspname, NULL, po.oprname FROM pg_catalog.pg_operator po, pg_catalog.pg_namespace pn - WHERE po.oprnamespace=pn.oid AND oprname ILIKE {$term} {$where} - UNION ALL - SELECT 'CONVERSION', pc.oid, pn.nspname, NULL, pc.conname FROM pg_catalog.pg_conversion pc, - pg_catalog.pg_namespace pn WHERE pc.connamespace=pn.oid AND conname ILIKE {$term} {$where} - UNION ALL - SELECT 'LANGUAGE', pl.oid, NULL, NULL, pl.lanname FROM pg_catalog.pg_language pl - WHERE lanname ILIKE {$term} {$lan_where} - UNION ALL - SELECT DISTINCT ON (p.proname) 'AGGREGATE', p.oid, pn.nspname, NULL, p.proname FROM pg_catalog.pg_proc p - LEFT JOIN pg_catalog.pg_namespace pn ON p.pronamespace=pn.oid - WHERE p.proisagg AND p.proname ILIKE {$term} {$where} - UNION ALL - SELECT DISTINCT ON (po.opcname) 'OPCLASS', po.oid, pn.nspname, NULL, po.opcname FROM pg_catalog.pg_opclass po, - pg_catalog.pg_namespace pn WHERE po.opcnamespace=pn.oid - AND po.opcname ILIKE {$term} {$where} - "; - } else { - // Otherwise just add domains - $sql .= " - UNION ALL - SELECT 'DOMAIN', pt.oid, pn.nspname, NULL, - pt.typname FROM pg_catalog.pg_type pt, pg_catalog.pg_namespace pn - WHERE pt.typnamespace=pn.oid AND pt.typtype='d' AND typname ILIKE {$term} - AND (pt.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = pt.typrelid)) - {$where} - "; - } - - if ('' !== $filter) { - // We use like to make RULE, CONSTRAINT and COLUMN searches work - $sql .= ") AS sub WHERE type LIKE '{$filter}%' "; - } - - $sql .= 'ORDER BY type, schemaname, relname, name'; - - return $this->selectSet($sql); - } - - // Capabilities - - public function hasByteaHexDefault() - { - return false; - } -} diff --git a/src/database/Postgres91.php b/src/database/Postgres91.php index 4b63b6d21..e981f240f 100644 --- a/src/database/Postgres91.php +++ b/src/database/Postgres91.php @@ -25,7 +25,7 @@ class Postgres91 extends Postgres92 * * @param null|string $database (optional) Find only connections to specified database * - * @return \ADORecordSet|int A recordset + * @return int|\PHPPgAdmin\ADORecordSet A recordset */ public function getProcesses($database = null) { @@ -51,7 +51,7 @@ public function getProcesses($database = null) * * @param bool $all Include all tablespaces (necessary when moving objects back to the default space) * - * @return \ADORecordSet|int A recordset + * @return int|\PHPPgAdmin\ADORecordSet A recordset */ public function getTablespaces($all = false) { @@ -75,7 +75,7 @@ public function getTablespaces($all = false) * * @param string $spcname * - * @return \ADORecordSet|int A recordset + * @return int|\PHPPgAdmin\ADORecordSet A recordset */ public function getTablespace($spcname) { diff --git a/src/database/Postgres92.php b/src/database/Postgres92.php index 34180cefa..cb2ff754c 100644 --- a/src/database/Postgres92.php +++ b/src/database/Postgres92.php @@ -21,7 +21,7 @@ class Postgres92 extends Postgres93 * * @param null|string $database (optional) Find only connections to specified database * - * @return \ADORecordSet|int A recordset + * @return int|\PHPPgAdmin\ADORecordSet A recordset */ public function getProcesses($database = null) { @@ -47,7 +47,7 @@ public function getProcesses($database = null) * * @param bool $all Include all tablespaces (necessary when moving objects back to the default space) * - * @return \ADORecordSet|int A recordset + * @return int|\PHPPgAdmin\ADORecordSet A recordset */ public function getTablespaces($all = false) { @@ -71,9 +71,9 @@ public function getTablespaces($all = false) /** * Retrieves a tablespace's information. * - * @param $spcname + * @param string $spcname * - * @return \ADORecordSet|int A recordset + * @return int|\PHPPgAdmin\ADORecordSet A recordset */ public function getTablespace($spcname) { diff --git a/src/database/Postgres93.php b/src/database/Postgres93.php index 1c41a53c4..b2a0747fd 100644 --- a/src/database/Postgres93.php +++ b/src/database/Postgres93.php @@ -20,7 +20,7 @@ class Postgres93 extends Postgres94 * @param bool $all If true, will find all available functions, if false just those in search path * @param mixed $type If not null, will find all trigger functions * - * @return \ADORecordSet|int All functions + * @return int|\PHPPgAdmin\ADORecordSet All functions */ public function getFunctions($all = false, $type = null) { diff --git a/src/database/Postgres96.php b/src/database/Postgres96.php index b26589fbd..ef2ad7e56 100644 --- a/src/database/Postgres96.php +++ b/src/database/Postgres96.php @@ -23,7 +23,7 @@ class Postgres96 extends Postgres * * @param null|string $database (optional) Find only connections to specified database * - * @return \ADORecordSet|int A recordset + * @return int|\PHPPgAdmin\ADORecordSet A recordset */ public function getProcesses($database = null) { @@ -67,7 +67,7 @@ public function hasUserSignals() * @param string $expiry string Format 'YYYY-MM-DD HH:MM:SS'. '' means never expire * @param array $groups The groups to create the user in * - * @return \ADORecordSet|int 0 if operation was successful + * @return int|\PHPPgAdmin\ADORecordSet 0 if operation was successful * * @internal param $group (array) The groups to create the user in */ diff --git a/src/database/databasetraits/AggregateTrait.php b/src/database/databasetraits/AggregateTrait.php index 55fd82f85..98f09be12 100644 --- a/src/database/databasetraits/AggregateTrait.php +++ b/src/database/databasetraits/AggregateTrait.php @@ -83,7 +83,7 @@ public function createAggregate($name, $basetype, $sfunc, $stype, $ffunc, $initc * @param string $aggrtype The input data type of the aggregate * @param bool $cascade True to cascade drop, false to restrict * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropAggregate($aggrname, $aggrtype, $cascade) { @@ -107,7 +107,7 @@ public function dropAggregate($aggrname, $aggrtype, $cascade) * @param string $name The name of the aggregate * @param string $basetype The input data type of the aggregate * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getAggregate($name, $basetype) { @@ -137,7 +137,7 @@ public function getAggregate($name, $basetype) /** * Gets all aggregates. * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getAggregates() { @@ -244,7 +244,7 @@ public function alterAggregate( * @param string $aggrtype The input data type of the aggregate * @param string $newaggrowner The new owner of the aggregate * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function changeAggregateOwner($aggrname, $aggrtype, $newaggrowner) { @@ -264,7 +264,7 @@ public function changeAggregateOwner($aggrname, $aggrtype, $newaggrowner) * @param string $aggrtype The input data type of the aggregate * @param string $newaggrschema The new schema for the aggregate * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function changeAggregateSchema($aggrname, $aggrtype, $newaggrschema) { @@ -285,7 +285,7 @@ public function changeAggregateSchema($aggrname, $aggrtype, $newaggrschema) * @param string $aggrtype The actual input data type of the aggregate * @param string $newaggrname The new name of the aggregate * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function renameAggregate($aggrschema, $aggrname, $aggrtype, $newaggrname) { diff --git a/src/database/databasetraits/ColumnTrait.php b/src/database/databasetraits/ColumnTrait.php index 8e6687cbf..63c738361 100644 --- a/src/database/databasetraits/ColumnTrait.php +++ b/src/database/databasetraits/ColumnTrait.php @@ -270,7 +270,7 @@ public function renameColumn($table, $column, $newName) * @param string $column The column name to set * @param mixed $default The new default value * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function setColumnDefault($table, $column, $default) { @@ -291,7 +291,7 @@ public function setColumnDefault($table, $column, $default) * @param string $column The column to alter * @param bool $state True to set null, false to set not null * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function setColumnNull($table, $column, $state) { @@ -338,7 +338,7 @@ public function dropColumn($table, $column, $cascade) * @param string $table The table from which to drop * @param string $column The column name to drop default * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropColumnDefault($table, $column) { diff --git a/src/database/databasetraits/DatabaseTrait.php b/src/database/databasetraits/DatabaseTrait.php index 10d60e4b8..c03427081 100644 --- a/src/database/databasetraits/DatabaseTrait.php +++ b/src/database/databasetraits/DatabaseTrait.php @@ -58,7 +58,7 @@ public function isSuperUser($username = '') * * @param string $table (optional) The table to analyze * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function analyzeDB($table = '') { @@ -80,7 +80,7 @@ public function analyzeDB($table = '') * * @param string $database The name of the database to retrieve * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getDatabase($database) { @@ -95,13 +95,15 @@ public function getDatabase($database) * * @param null|string $currentdatabase database name that should be on top of the resultset * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getDatabases($currentdatabase = null) { $conf = $this->conf; $server_info = $this->server_info; + //$this->prtrace('server_info', $server_info); + if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) { $username = $server_info['username']; $this->clean($username); @@ -162,7 +164,7 @@ public function getDatabases($currentdatabase = null) * * @param string $database the name of the database to get the comment for * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getDatabaseComment($database) { @@ -181,7 +183,7 @@ public function getDatabaseComment($database) * * @param string $database the name of the database to get the owner for * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getDatabaseOwner($database) { @@ -274,7 +276,7 @@ public function createDatabase( * * @param string $database The name of the database to drop * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropDatabase($database) { @@ -345,7 +347,7 @@ public function alterDatabase($dbName, $newName, $newOwner = '', $comment = '') * @param string $oldName name of database to rename * @param string $newName new name of database * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function alterDatabaseRename($oldName, $newName) { @@ -368,7 +370,7 @@ public function alterDatabaseRename($oldName, $newName) * @param string $dbName database to change ownership of * @param string $newOwner user that will own the database * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function alterDatabaseOwner($dbName, $newOwner) { @@ -385,7 +387,7 @@ public function alterDatabaseOwner($dbName, $newOwner) * * @param null|string $database (optional) Find only prepared transactions executed in a specific database * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getPreparedXacts($database = null) { @@ -405,7 +407,7 @@ public function getPreparedXacts($database = null) * * @param null|string $database (optional) Find only connections to specified database * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getProcesses($database = null) { @@ -431,7 +433,7 @@ public function getProcesses($database = null) /** * Returns table locks information in the current database. * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getLocks() { @@ -569,7 +571,7 @@ public function getAutovacuum() /** * Returns all available variable information. * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getVariables() { diff --git a/src/database/databasetraits/DomainTrait.php b/src/database/databasetraits/DomainTrait.php index 9c9568cf9..88d5f593c 100644 --- a/src/database/databasetraits/DomainTrait.php +++ b/src/database/databasetraits/DomainTrait.php @@ -16,7 +16,7 @@ trait DomainTrait * * @param string $domain The name of the domain to fetch * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getDomain($domain) { @@ -46,7 +46,7 @@ public function getDomain($domain) /** * Return all domains in current schema. Excludes domain constraints. * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getDomains() { @@ -77,7 +77,7 @@ public function getDomains() * * @param string $domain The name of the domain whose constraints to fetch * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getDomainConstraints($domain) { @@ -116,7 +116,7 @@ public function getDomainConstraints($domain) * @param string $default Default value for domain * @param string $check A CHECK constraint if there is one * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function createDomain($domain, $type, $length, $array, $notnull, $default, $check) { @@ -245,7 +245,7 @@ public function alterDomain($domain, $domdefault, $domnotnull, $domowner) * @param string $domain The name of the domain to drop * @param string $cascade True to cascade drop, false to restrict * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropDomain($domain, $cascade) { @@ -269,7 +269,7 @@ public function dropDomain($domain, $cascade) * @param string $definition The definition of the check * @param string $name (optional) The name to give the check, otherwise default name is assigned * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function addDomainCheckConstraint($domain, $definition, $name = '') { @@ -296,7 +296,7 @@ public function addDomainCheckConstraint($domain, $definition, $name = '') * @param string $constraint The constraint to remove * @param bool $cascade True to cascade, false otherwise * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropDomainConstraint($domain, $constraint, $cascade) { diff --git a/src/database/databasetraits/FunctionTrait.php b/src/database/databasetraits/FunctionTrait.php index bdb574c20..9c2555da4 100644 --- a/src/database/databasetraits/FunctionTrait.php +++ b/src/database/databasetraits/FunctionTrait.php @@ -17,7 +17,7 @@ trait FunctionTrait * @param bool $all If true, will find all available functions, if false just those in search path * @param mixed $type If truthy, will return functions of type trigger * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getFunctions($all = false, $type = null) { @@ -64,7 +64,7 @@ public function getFunctions($all = false, $type = null) /** * Returns a list of all functions that can be used in triggers. * - * @return \ADORecordSet|int + * @return \PHPPgAdmin\ADORecordSet Functions that can be used in a trigger */ public function getTriggerFunctions() { @@ -234,7 +234,7 @@ public function setFunction( * @param string $language The language the function is written for * @param array $flags An array of optional flags * @param bool $setof True if it returns a set, false otherwise - * @param float $cost cost the planner should use in the function execution step + * @param string $cost cost the planner should use in the function execution step * @param int $rows number of rows planner should estimate will be returned * @param string $comment Comment for the function * @param bool $replace (optional) True if OR REPLACE, false for @@ -342,7 +342,7 @@ public function createFunction($funcname, $args, $returns, $definition, $languag * @param int $function_oid The OID of the function to drop * @param bool $cascade True to cascade drop, false to restrict * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropFunction($function_oid, $cascade) { @@ -366,7 +366,7 @@ public function dropFunction($function_oid, $cascade) * * @param int $function_oid * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet * * @internal param string The $func name of the function to retrieve */ @@ -405,7 +405,7 @@ public function getFunction($function_oid) * * @param int $function_oid * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getFunctionDef($function_oid) { diff --git a/src/database/databasetraits/IndexTrait.php b/src/database/databasetraits/IndexTrait.php index 800c08343..ca328c102 100644 --- a/src/database/databasetraits/IndexTrait.php +++ b/src/database/databasetraits/IndexTrait.php @@ -126,7 +126,7 @@ public function dropIndex($index, $cascade) * @param bool $force If true, recreates indexes forcedly in PostgreSQL 7.0-7.1, forces rebuild of system indexes in * 7.2-7.3, ignored in >=7.4 * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function reindex($type, $name, $force = false) { @@ -199,7 +199,7 @@ public function clusterIndex($table = '', $index = '') * * @param string $table the table where we are looking for fk * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getConstraintsWithFields($table) { @@ -267,7 +267,7 @@ public function getConstraintsWithFields($table) * @param string $name (optional) The name to give the key, otherwise default name is assigned * @param string $tablespace (optional) The tablespace for the schema, '' indicates default * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function addPrimaryKey($table, $fields, $name = '', $tablespace = '') { @@ -305,7 +305,7 @@ public function addPrimaryKey($table, $fields, $name = '', $tablespace = '') * @param string $name (optional) The name to give the key, otherwise default name is assigned * @param string $tablespace (optional) The tablespace for the schema, '' indicates default * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function addUniqueKey($table, $fields, $name = '', $tablespace = '') { @@ -344,7 +344,7 @@ public function addUniqueKey($table, $fields, $name = '', $tablespace = '') * @param string $definition The definition of the check * @param string $name (optional) The name to give the check, otherwise default name is assigned * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function addCheckConstraint($table, $definition, $name = '') { @@ -446,7 +446,7 @@ public function dropCheckConstraint($table, $name) * @param string $initially The initially parameter for the FK (eg. INITIALLY IMMEDIATE) * @param string $name [optional] The name to give the key, otherwise default name is assigned * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet * * @internal param \PHPPgAdmin\Database\The $target table that contains the target columns * @internal param \PHPPgAdmin\Database\The $intially initial deferrability (eg. INITIALLY IMMEDIATE) @@ -519,7 +519,7 @@ public function addForeignKey( * @param string $type The type of constraint (c, f, u or p) * @param bool $cascade True to cascade drop, false to restrict * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropConstraint($constraint, $relation, $type, $cascade) { @@ -542,7 +542,7 @@ public function dropConstraint($constraint, $relation, $type, $cascade) * * @param array $tables multi dimensional assoc array that holds schema and table name * - * @return \ADORecordSet|int recordset of linked tables and columns or -1 if $tables isn't an array + * @return int|\PHPPgAdmin\ADORecordSet recordset of linked tables and columns or -1 if $tables isn't an array */ public function getLinkingKeys($tables) { @@ -636,7 +636,7 @@ public function getLinkingKeys($tables) * * @param string $table The table to find referrers for * - * @return \ADORecordSet|int A recordset or -1 in case of error + * @return int|\PHPPgAdmin\ADORecordSet A recordset or -1 in case of error */ public function getReferrers($table) { diff --git a/src/database/databasetraits/OperatorTrait.php b/src/database/databasetraits/OperatorTrait.php index 72193eb75..b6da2376e 100644 --- a/src/database/databasetraits/OperatorTrait.php +++ b/src/database/databasetraits/OperatorTrait.php @@ -14,7 +14,7 @@ trait OperatorTrait /** * Returns a list of all operators in the database. * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getOperators() { @@ -45,7 +45,7 @@ public function getOperators() * @param mixed $operator_oid The OID of the operator to drop * @param bool $cascade True to cascade drop, false to restrict * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropOperator($operator_oid, $cascade) { @@ -81,7 +81,7 @@ public function dropOperator($operator_oid, $cascade) * * @param mixed $operator_oid The oid of the operator * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getOperator($operator_oid) { @@ -112,7 +112,7 @@ public function getOperator($operator_oid) /** * Gets all opclasses. * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getOpClasses() { diff --git a/src/database/databasetraits/PrivilegesTrait.php b/src/database/databasetraits/PrivilegesTrait.php index 648098138..bb5522387 100644 --- a/src/database/databasetraits/PrivilegesTrait.php +++ b/src/database/databasetraits/PrivilegesTrait.php @@ -108,7 +108,7 @@ public function getPrivileges($object, $type, $table = null) * @param bool $cascade True for cascade revoke, false otherwise * @param string $table the column's table if type=column * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function setPrivileges( $mode, diff --git a/src/database/databasetraits/RoleTrait.php b/src/database/databasetraits/RoleTrait.php index 8804b7df6..015248d47 100644 --- a/src/database/databasetraits/RoleTrait.php +++ b/src/database/databasetraits/RoleTrait.php @@ -16,7 +16,7 @@ trait RoleTrait * * @param string $rolename (optional) The role name to exclude from the select * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getRoles($rolename = '') { @@ -51,7 +51,7 @@ public function getRoles($rolename = '') * * @param string $rolename The name of the role to retrieve * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getRole($rolename) { @@ -80,7 +80,7 @@ public function getRole($rolename) /** * Returns all users in the database cluster. * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getUsers() { @@ -102,7 +102,7 @@ public function getUsers() * * @param string $username The username of the user to retrieve * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getUser($username) { @@ -138,7 +138,7 @@ public function getUser($username) * @param array $new_members_of_role (array) Roles which are automatically added as members of the new role * @param array $new_admins_of_role (array) Roles which are automatically added as admin members of the new role * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function createRole( $rolename, @@ -305,7 +305,7 @@ public function setRenameRole( * @param string $rolename The name of the role to rename * @param string $newrolename The new name of the role * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function renameRole($rolename, $newrolename) { @@ -404,7 +404,7 @@ public function setRole( * @param string $rolename The name of the role that will belong to the target role * @param int $admin (optional) Flag to grant the admin option * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function grantRole($role, $rolename, $admin = 0) { @@ -428,7 +428,7 @@ public function grantRole($role, $rolename, $admin = 0) * @param int $admin (optional) Flag to revoke only the admin option * @param string $type (optional) Type of revoke: RESTRICT | CASCADE * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function revokeRole($role, $rolename, $admin = 0, $type = 'RESTRICT') { @@ -451,7 +451,7 @@ public function revokeRole($role, $rolename, $admin = 0, $type = 'RESTRICT') * * @param string $rolename The name of the role to drop * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropRole($rolename) { @@ -472,7 +472,7 @@ public function dropRole($rolename) * @param string $expiry string Format 'YYYY-MM-DD HH:MM:SS'. '' means never expire * @param array $groups The groups to create the user in * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet * * @internal param $group (array) The groups to create the user in */ @@ -554,7 +554,7 @@ public function setRenameUser($username, $password, $createdb, $createuser, $exp * @param string $username The username of the user to rename * @param string $newname The new name of the user * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function renameUser($username, $newname) { @@ -577,7 +577,7 @@ public function renameUser($username, $newname) * @param bool $createuser boolean Whether or not the user can create other users * @param string $expiry string Format 'YYYY-MM-DD HH:MM:SS'. '' means never expire. * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function setUser($username, $password, $createdb, $createuser, $expiry) { @@ -609,7 +609,7 @@ public function setUser($username, $password, $createdb, $createuser, $expiry) * * @param string $username The username of the user to drop * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropUser($username) { @@ -626,7 +626,7 @@ public function dropUser($username) * @param string $rolename The role name * @param string $password The new password * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function changePassword($rolename, $password) { @@ -645,7 +645,7 @@ public function changePassword($rolename, $password) * @param string $groname The name of the group * @param string $user The name of the user to add to the group * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function addGroupMember($groname, $user) { @@ -662,7 +662,7 @@ public function addGroupMember($groname, $user) * * @param string $rolename The role name * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getMemberOf($rolename) { @@ -687,7 +687,7 @@ public function getMemberOf($rolename) * @param string $rolename The role name * @param string $admin (optional) Find only admin members * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getMembers($rolename, $admin = 'f') { @@ -709,7 +709,7 @@ public function getMembers($rolename, $admin = 'f') * @param string $groname The name of the group * @param string $user The name of the user to remove from the group * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropGroupMember($groname, $user) { @@ -726,7 +726,7 @@ public function dropGroupMember($groname, $user) * * @param string $groname The name of the group * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getGroup($groname) { @@ -743,7 +743,7 @@ public function getGroup($groname) /** * Returns all groups in the database cluser. * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getGroups() { @@ -758,7 +758,7 @@ public function getGroups() * @param string $groname The name of the group * @param array $users An array of users to add to the group * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function createGroup($groname, $users) { @@ -779,7 +779,7 @@ public function createGroup($groname, $users) * * @param string $groname The name of the group to drop * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropGroup($groname) { diff --git a/src/database/databasetraits/RowTrait.php b/src/database/databasetraits/RowTrait.php index a657f7969..3ddd05a1c 100644 --- a/src/database/databasetraits/RowTrait.php +++ b/src/database/databasetraits/RowTrait.php @@ -17,7 +17,7 @@ trait RowTrait * @param string $table The name of a table * @param array $key The associative array holding the key to retrieve * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function browseRow($table, $key) { @@ -112,7 +112,7 @@ public function getRowIdentifier($table) * @param array $format An array of the data type (VALUE or EXPRESSION) * @param array $types An array of field types * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function insertRow($table, $fields, $values, $nulls, $format, $types) { diff --git a/src/database/databasetraits/SchemaTrait.php b/src/database/databasetraits/SchemaTrait.php index 2111f75fb..32e5af686 100644 --- a/src/database/databasetraits/SchemaTrait.php +++ b/src/database/databasetraits/SchemaTrait.php @@ -16,7 +16,7 @@ trait SchemaTrait /** * Return all schemas in the current database. * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getSchemas() { @@ -58,7 +58,7 @@ public function getSchemas() * * @param string $schema The the name of the schema to work in * - * @return \ADORecordSet|int + * @return int 0 if operation was successful */ public function setSchema($schema) { @@ -99,7 +99,7 @@ public function getSearchPath() * * @param mixed $paths An array of schemas in required search order * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function setSearchPath($paths) { @@ -249,7 +249,7 @@ public function updateSchema($schemaname, $comment, $name, $owner) * * @param string $schema The name of the schema * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getSchemaByName($schema) { @@ -272,7 +272,7 @@ public function getSchemaByName($schema) * @param string $schemaname The name of the schema to drop * @param bool $cascade True to cascade drop, false to restrict * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropSchema($schemaname, $cascade) { diff --git a/src/database/databasetraits/StatsTrait.php b/src/database/databasetraits/StatsTrait.php index deb7edaa1..9c8813271 100644 --- a/src/database/databasetraits/StatsTrait.php +++ b/src/database/databasetraits/StatsTrait.php @@ -16,7 +16,7 @@ trait StatsTrait * * @param string $database The database to fetch stats for * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getStatsDatabase($database) { @@ -32,7 +32,7 @@ public function getStatsDatabase($database) * * @param string $table The table to fetch stats for * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getStatsTableTuples($table) { @@ -51,7 +51,7 @@ public function getStatsTableTuples($table) * * @param string $table The table to fetch stats for * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getStatsTableIO($table) { @@ -70,7 +70,7 @@ public function getStatsTableIO($table) * * @param string $table The table to fetch index stats for * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getStatsIndexTuples($table) { @@ -89,7 +89,7 @@ public function getStatsIndexTuples($table) * * @param string $table The table to fetch index stats for * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getStatsIndexIO($table) { diff --git a/src/database/databasetraits/TableTrait.php b/src/database/databasetraits/TableTrait.php index 8cbda72f0..084418fdd 100644 --- a/src/database/databasetraits/TableTrait.php +++ b/src/database/databasetraits/TableTrait.php @@ -18,7 +18,7 @@ trait TableTrait /** * Return all tables in current database excluding schemas 'pg_catalog', 'information_schema' and 'pg_toast'. * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getAllTables() { @@ -36,7 +36,7 @@ public function getAllTables() /** * Return all tables in current database (and schema). * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getTables() { @@ -75,7 +75,7 @@ public function getTables() * * @param string $table The table to find the parents for * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getTableParents($table) { @@ -105,7 +105,7 @@ public function getTableParents($table) * * @param string $table The table to find the children for * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getTableChildren($table) { @@ -269,7 +269,7 @@ public function getTableDefPrefix($table, $cleanprefix = ''): ?string * * @param string $table The name of the table * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getTable($table) { @@ -304,7 +304,7 @@ public function getTable($table) * @param string $table The name of the table * @param string $field (optional) The name of a field to return * - * @return \ADORecordSet|int + * @return \PHPPgAdmin\ADORecordSet All attributes in order */ public function getTableAttributes($table, $field = '') { @@ -328,7 +328,7 @@ public function getTableAttributes($table, $field = '') * * @param string $table The table to find rules for * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getConstraints($table) { @@ -474,7 +474,7 @@ public function getTableDefSuffix($table): ?string * @param string $table The name of a table whose indexes to retrieve * @param bool $unique Only get unique/pk indexes * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getIndexes($table = '', $unique = false) { @@ -502,7 +502,7 @@ public function getIndexes($table = '', $unique = false) * * @param string $table The name of a table whose triggers to retrieve * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getTriggers($table = '') { @@ -533,7 +533,7 @@ public function getTriggers($table = '') * * @param string $table The table to find rules for * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getRules($table) { @@ -852,10 +852,10 @@ public function alterTable($table, $name, $owner, $schema, $comment, $tablespace * Alter a table's owner * /!\ this function is called from _alterTable which take care of escaping fields. * - * @param \ADORecordSet $tblrs The table RecordSet returned by getTable() - * @param null|string $owner + * @param \PHPPgAdmin\ADORecordSet $tblrs The table RecordSet returned by getTable() + * @param null|string $owner * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function alterTableOwner($tblrs, $owner = null) { @@ -878,10 +878,10 @@ public function alterTableOwner($tblrs, $owner = null) * Alter a table's tablespace * /!\ this function is called from _alterTable which take care of escaping fields. * - * @param \ADORecordSet $tblrs The table RecordSet returned by getTable() - * @param null|string $tablespace + * @param \PHPPgAdmin\ADORecordSet $tblrs The table RecordSet returned by getTable() + * @param null|string $tablespace * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function alterTableTablespace($tblrs, $tablespace = null) { @@ -904,10 +904,10 @@ public function alterTableTablespace($tblrs, $tablespace = null) * Alter a table's name * /!\ this function is called from _alterTable which take care of escaping fields. * - * @param \ADORecordSet $tblrs The table RecordSet returned by getTable() - * @param string $name The new table's name + * @param \PHPPgAdmin\ADORecordSet $tblrs The table RecordSet returned by getTable() + * @param string $name The new table's name * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function alterTableName($tblrs, $name = null) { @@ -936,10 +936,10 @@ public function alterTableName($tblrs, $name = null) * Alter a table's schema * /!\ this function is called from _alterTable which take care of escaping fields. * - * @param \ADORecordSet $tblrs The table RecordSet returned by getTable() - * @param null|string $schema + * @param \PHPPgAdmin\ADORecordSet $tblrs The table RecordSet returned by getTable() + * @param null|string $schema * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function alterTableSchema($tblrs, $schema = null) { @@ -988,7 +988,7 @@ public function emptyTable($table, $cascade) * @param string $table The table to drop * @param bool $cascade True to cascade drop, false to restrict * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropTable($table, $cascade) { @@ -1071,7 +1071,7 @@ public function endDump() * @param string $relation The name of a relation * @param bool $oids true to dump also the oids * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dumpRelation($relation, $oids) { @@ -1172,7 +1172,7 @@ public function getChangeUserSQL($user) * @param int $vaccostdelay vacuum cost delay * @param int $vaccostlimit vacuum cost limit * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function saveAutovacuum( $table, @@ -1239,7 +1239,7 @@ public function saveAutovacuum( * * @param string $table The table * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropAutovacuum($table) { @@ -1298,12 +1298,12 @@ abstract public function getAttributeNames($table, $atts); * Protected method which alter a table * SHOULDN'T BE CALLED OUTSIDE OF A TRANSACTION. * - * @param \ADORecordSet $tblrs The table recordSet returned by getTable() - * @param string $name The new name for the table - * @param string $owner The new owner for the table - * @param string $schema The new schema for the table - * @param string $comment The comment on the table - * @param string $tablespace The new tablespace for the table ('' means leave as is) + * @param \PHPPgAdmin\ADORecordSet $tblrs The table recordSet returned by getTable() + * @param string $name The new name for the table + * @param string $owner The new owner for the table + * @param string $schema The new schema for the table + * @param string $comment The comment on the table + * @param string $tablespace The new tablespace for the table ('' means leave as is) * * @return int 0 success */ @@ -1356,19 +1356,19 @@ protected function _alterTable($tblrs, $name, $owner, $schema, $comment, $tables /** * Dumps serial-like columns in the table. * - * @param \ADORecordSet $atts table attributes - * @param \ADORecordSet $tblfields table fields object - * @param string $sql The sql sentence - * generated so far - * @param string $col_comments_sql Column comments, - * passed by reference - * @param int $i current counter to - * know if we should - * append a comma to the - * sentence - * @param int $num Table attributes - * count + table - * constraints count + * @param \PHPPgAdmin\ADORecordSet $atts table attributes + * @param \PHPPgAdmin\ADORecordSet $tblfields table fields object + * @param string $sql The sql sentence + * generated so far + * @param string $col_comments_sql Column comments, + * passed by reference + * @param int $i current counter to + * know if we should + * append a comma to the + * sentence + * @param int $num Table attributes + * count + table + * constraints count * * @return string original $sql plus appended strings */ @@ -1422,13 +1422,13 @@ private function _dumpSerials($atts, $tblfields, $sql, &$col_comments_sql, $i, $ /** * Dumps constraints. * - * @param \ADORecordSet $cons The table constraints - * @param string $table The table to define - * @param string $sql The sql sentence generated so - * far - * @param mixed $i - * @param int $num Table attributes count + table - * constraints count + * @param \PHPPgAdmin\ADORecordSet $cons The table constraints + * @param string $table The table to define + * @param string $sql The sql sentence generated so + * far + * @param mixed $i + * @param int $num Table attributes count + table + * constraints count */ private function _dumpConstraints($cons, $table, $sql, $i, $num): ?string { @@ -1477,9 +1477,9 @@ private function _dumpConstraints($cons, $table, $sql, $i, $num): ?string /** * Dumps col statistics. * - * @param \ADORecordSet $atts table attributes - * @param \ADORecordSet $tblfields table field attributes - * @param string $sql The sql sentence generated so far + * @param \PHPPgAdmin\ADORecordSet $atts table attributes + * @param \PHPPgAdmin\ADORecordSet $tblfields table field attributes + * @param string $sql The sql sentence generated so far */ private function _dumpColStats($atts, $tblfields, $sql): ?string { @@ -1535,9 +1535,9 @@ private function _dumpColStats($atts, $tblfields, $sql): ?string /** * Dumps privileges. * - * @param \ADORecordSet $privs The table privileges - * @param \ADORecordSet $tblfields The table fields definition - * @param string $sql The sql sentence generated so far + * @param \PHPPgAdmin\ADORecordSet $privs The table privileges + * @param \PHPPgAdmin\ADORecordSet $tblfields The table fields definition + * @param string $sql The sql sentence generated so far */ private function _dumpPrivileges($privs, $tblfields, $sql): ?string { @@ -1651,10 +1651,10 @@ private function _dumpPrivileges($privs, $tblfields, $sql): ?string /** * Dumps a create. * - * @param \ADORecordSet $tblfields table fields object - * @param string $sql The sql sentence generated so far - * @param string $cleanprefix set to '-- ' to avoid issuing DROP statement - * @param mixed $fields + * @param \PHPPgAdmin\ADORecordSet $tblfields table fields object + * @param string $sql The sql sentence generated so far + * @param string $cleanprefix set to '-- ' to avoid issuing DROP statement + * @param mixed $fields * * @return string original $sql plus appended strings */ @@ -1679,7 +1679,7 @@ private function _dumpCreate($tblfields, $sql, $cleanprefix) * @param string $table The name of the table * @param string $c_schema The name of the schema * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ private function _getTableAttributesAll($table, $c_schema) { @@ -1731,7 +1731,7 @@ private function _getTableAttributesAll($table, $c_schema) * @param string $c_schema The schema of the table * @param string $field (optional) The name of a field to return * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ private function _getTableAttribute($table, $c_schema, $field) { diff --git a/src/database/databasetraits/TablespaceTrait.php b/src/database/databasetraits/TablespaceTrait.php index a08f99dd0..18771b48d 100644 --- a/src/database/databasetraits/TablespaceTrait.php +++ b/src/database/databasetraits/TablespaceTrait.php @@ -16,7 +16,7 @@ trait TablespaceTrait * * @param bool $all Include all tablespaces (necessary when moving objects back to the default space) * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getTablespaces($all = false) { @@ -42,7 +42,7 @@ public function getTablespaces($all = false) * * @param string $spcname * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getTablespace($spcname) { @@ -160,7 +160,7 @@ public function alterTablespace($spcname, $name, $owner, $comment = '') * * @param string $spcname The name of the domain to drop * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropTablespace($spcname) { diff --git a/src/database/databasetraits/TriggerTrait.php b/src/database/databasetraits/TriggerTrait.php index 2547d3926..5ab24c1cf 100644 --- a/src/database/databasetraits/TriggerTrait.php +++ b/src/database/databasetraits/TriggerTrait.php @@ -17,7 +17,7 @@ trait TriggerTrait * @param string $table The name of a table whose triggers to retrieve * @param string $trigger The name of the trigger to retrieve * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getTrigger($table, $trigger) { @@ -47,7 +47,7 @@ public function getTrigger($table, $trigger) * @param string $tgfrequency * @param string $tgargs The function arguments * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function createTrigger($tgname, $table, $tgproc, $tgtime, $tgevent, $tgfrequency, $tgargs) { @@ -72,7 +72,7 @@ public function createTrigger($tgname, $table, $tgproc, $tgtime, $tgevent, $tgfr * @param string $trigger The name of the trigger to alter * @param string $name The new name for the trigger * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function alterTrigger($table, $trigger, $name) { @@ -94,7 +94,7 @@ public function alterTrigger($table, $trigger, $name) * @param string $table The table from which to drop the trigger * @param bool $cascade True to cascade drop, false to restrict * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropTrigger($tgname, $table, $cascade) { @@ -118,7 +118,7 @@ public function dropTrigger($tgname, $table, $cascade) * @param string $tgname The name of the trigger to enable * @param string $table The table in which to enable the trigger * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function enableTrigger($tgname, $table) { @@ -138,7 +138,7 @@ public function enableTrigger($tgname, $table) * @param string $tgname The name of the trigger to disable * @param string $table The table in which to disable the trigger * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function disableTrigger($tgname, $table) { @@ -167,7 +167,7 @@ public function disableTrigger($tgname, $table) * @param string $type NOTHING for a do nothing rule, SOMETHING to use given action * @param string $action The action to take * - * @return \ADORecordSet|int + * @return int 0 if operation was successful */ public function setRule($name, $event, $table, $where, $instead, $type, $action) { @@ -189,7 +189,7 @@ public function setRule($name, $event, $table, $where, $instead, $type, $action) * @param bool $replace (optional) True to replace existing rule, false * otherwise * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function createRule($name, $event, $table, $where, $instead, $type, $action, $replace = false) { @@ -236,7 +236,7 @@ public function createRule($name, $event, $table, $where, $instead, $type, $acti * @param string $relation The relation from which to drop * @param string $cascade True to cascade drop, false to restrict * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropRule($rule, $relation, $cascade) { diff --git a/src/database/databasetraits/ViewTrait.php b/src/database/databasetraits/ViewTrait.php index b1be08d07..fe89fb633 100644 --- a/src/database/databasetraits/ViewTrait.php +++ b/src/database/databasetraits/ViewTrait.php @@ -14,7 +14,7 @@ trait ViewTrait /** * Returns a list of all views in the database. * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getViews() { @@ -34,7 +34,7 @@ public function getViews() /** * Returns a list of all materialized views in the database. * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getMaterializedViews() { @@ -163,7 +163,7 @@ public function alterView($view, $name, $owner, $schema, $comment) * * @param string $view The name of the view or materialized to retrieve * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function getView($view) { @@ -186,10 +186,10 @@ public function getView($view) /** * Alter a view's owner. * - * @param \ADORecordSet $vwrs The view recordSet returned by getView() - * @param null|string $owner + * @param \PHPPgAdmin\ADORecordSet $vwrs The view recordSet returned by getView() + * @param null|string $owner * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet * * @internal param $name new view's owner */ @@ -214,10 +214,10 @@ public function alterViewOwner($vwrs, $owner = null) /** * Rename a view. * - * @param \ADORecordSet $vwrs The view recordSet returned by getView() - * @param string $name The new view's name + * @param \PHPPgAdmin\ADORecordSet $vwrs The view recordSet returned by getView() + * @param string $name The new view's name * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function alterViewName($vwrs, $name) { @@ -243,10 +243,10 @@ public function alterViewName($vwrs, $name) /** * Alter a view's schema. * - * @param \ADORecordSet $vwrs The view recordSet returned by getView() - * @param string $schema + * @param \PHPPgAdmin\ADORecordSet $vwrs The view recordSet returned by getView() + * @param string $schema * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet * * @internal param The $name new view's schema */ @@ -274,7 +274,7 @@ public function alterViewSchema($vwrs, $schema) * @param string $viewname The name of the view to drop * @param string $cascade True to cascade drop, false to restrict * - * @return \ADORecordSet|int + * @return int|\PHPPgAdmin\ADORecordSet */ public function dropView($viewname, $cascade) { @@ -316,11 +316,11 @@ abstract public function fieldArrayClean(&$arr); * Protected method which alter a view * SHOULDN'T BE CALLED OUTSIDE OF A TRANSACTION. * - * @param \ADORecordSet $vwrs The view recordSet returned by getView() - * @param string $name The new name for the view - * @param string $owner The new owner for the view - * @param string $schema Schema name - * @param string $comment The comment on the view + * @param \PHPPgAdmin\ADORecordSet $vwrs The view recordSet returned by getView() + * @param string $name The new name for the view + * @param string $owner The new owner for the view + * @param string $schema Schema name + * @param string $comment The comment on the view * * @return int 0 success */ diff --git a/src/router.php b/src/router.php index 0d87621aa..20d9909a6 100644 --- a/src/router.php +++ b/src/router.php @@ -32,8 +32,8 @@ $body = $response->getBody(); $misc = $this->misc; - $loginShared = $request->getParsedBodyParam('loginShared'); - $loginServer = $request->getParsedBodyParam('loginServer'); + $loginShared = $request->getParsedBodyParam('loginShared'); + $loginServer = $request->getParsedBodyParam('loginServer'); $loginUsername = $request->getParsedBodyParam('loginUsername'); $loginPassword = $request->getParsedBodyParam('loginPassword_' . \md5($loginServer)); @@ -83,7 +83,7 @@ /* @scrutinizer ignore-unused */ array $args ) { - $subject = (isset($args['subject'])) ? $args['subject'] : 'root'; + $subject = (isset($args['subject'])) ? $args['subject'] : 'root'; $destinationurl = $this->utils->getDestinationWithLastTab($subject); return $response->withStatus(302)->withHeader('Location', $destinationurl); @@ -116,7 +116,7 @@ return $response->withStatus(302)->withHeader('Location', $destinationurl); } - $className = '\PHPPgAdmin\Controller\\' . \ucfirst($subject) . 'Controller'; + $className = '\PHPPgAdmin\Controller\\' . \ucfirst($subject) . 'Controller'; $controller = new $className($this); return $controller->render(); @@ -166,7 +166,7 @@ return $this->view->maybeRenderIframes($response, $subject, $query_string); }); -$app->get('[/{path:.*}]', static function ( +$app->get('[/{path:.*}]', function ( /* @scrutinizer ignore-unused */ \Slim\Http\Request $request, /* @scrutinizer ignore-unused */ @@ -174,7 +174,7 @@ /* @scrutinizer ignore-unused */ array $args ) { - $filepath = \dirname(__DIR__) . '/' . $args['path']; + $filepath = \dirname(__DIR__) . '/' . $args['path']; $query_string = $request->getUri()->getQuery(); //d($this->subfolder, $args, $query_string, $filepath);