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

github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorffflabs <amenadiel@gmail.com>2020-05-25 17:49:40 +0300
committerffflabs <amenadiel@gmail.com>2020-05-25 17:53:14 +0300
commit16b6650726173410dd30ef1274da96d64d83d368 (patch)
tree86d0c2bf12a2bb265515ff8012cf1e97ec86be72
parent1f03c41543592f41ae17a3ae1606aeed38a23570 (diff)
fixes type lintingv6.0.0
fixes type linting fixes type linting fixes type linting
-rw-r--r--.php_cs2
-rw-r--r--Makefile2
-rw-r--r--README.md3
-rw-r--r--composer.json2
-rw-r--r--phpstan.neon5
-rw-r--r--src/classes/ADONewConnection.php19
-rw-r--r--src/classes/ADORecordSet.php12
-rw-r--r--src/classes/Misc.php9
-rw-r--r--src/classes/ViewManager.php7
-rw-r--r--src/controllers/DataimportController.php4
-rw-r--r--src/controllers/TreeController.php2
-rw-r--r--src/database/ADOdbBase.php15
-rw-r--r--src/database/Connection.php11
-rw-r--r--src/database/Postgres.php28
-rw-r--r--src/database/Postgres10.php2
-rw-r--r--src/database/Postgres11.php2
-rw-r--r--src/database/Postgres12.php2
-rw-r--r--src/database/Postgres74.php703
-rw-r--r--src/database/Postgres80.php463
-rw-r--r--src/database/Postgres81.php348
-rw-r--r--src/database/Postgres82.php439
-rw-r--r--src/database/Postgres83.php442
-rw-r--r--src/database/Postgres84.php224
-rw-r--r--src/database/Postgres91.php6
-rw-r--r--src/database/Postgres92.php8
-rw-r--r--src/database/Postgres93.php2
-rw-r--r--src/database/Postgres96.php4
-rw-r--r--src/database/databasetraits/AggregateTrait.php12
-rw-r--r--src/database/databasetraits/ColumnTrait.php6
-rw-r--r--src/database/databasetraits/DatabaseTrait.php26
-rw-r--r--src/database/databasetraits/DomainTrait.php14
-rw-r--r--src/database/databasetraits/FunctionTrait.php12
-rw-r--r--src/database/databasetraits/IndexTrait.php18
-rw-r--r--src/database/databasetraits/OperatorTrait.php8
-rw-r--r--src/database/databasetraits/PrivilegesTrait.php2
-rw-r--r--src/database/databasetraits/RoleTrait.php44
-rw-r--r--src/database/databasetraits/RowTrait.php4
-rw-r--r--src/database/databasetraits/SchemaTrait.php10
-rw-r--r--src/database/databasetraits/StatsTrait.php10
-rw-r--r--src/database/databasetraits/TableTrait.php128
-rw-r--r--src/database/databasetraits/TablespaceTrait.php6
-rw-r--r--src/database/databasetraits/TriggerTrait.php18
-rw-r--r--src/database/databasetraits/ViewTrait.php36
-rw-r--r--src/router.php12
44 files changed, 283 insertions, 2849 deletions
diff --git a/.php_cs b/.php_cs
index 6ed943a5..43d3c524 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 02866b7a..68f6d23f 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 47bce51a..f2d9979c 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 efa23e3c..e6a19a85 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 6c9235b4..7ea93f06 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 00000000..8f998c3b
--- /dev/null
+++ b/src/classes/ADONewConnection.php
@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * PHPPgAdmin 6.0.0
+ */
+
+namespace PHPPgAdmin;
+
+/**
+ * @file
+ * Extends \ADODB_postgres9 to let correct inference on PHPDoc params
+ */
+
+/**
+ * Extends \ADODB_postgres9 to let correct inference on PHPDoc params.
+ */
+class ADONewConnection extends \ADODB_postgres9
+{
+}
diff --git a/src/classes/ADORecordSet.php b/src/classes/ADORecordSet.php
index 05ed7b75..cb3cd9df 100644
--- a/src/classes/ADORecordSet.php
+++ b/src/classes/ADORecordSet.php
@@ -23,4 +23,16 @@ class ADORecordSet extends \ADORecordSet implements \Countable
{
return $this->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 e6a17619..ad4302aa 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 @@ class Misc
*
* @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 8c96da42..785096a3 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 @@ class ViewManager extends \Slim\Views\Twig
$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 29ea6a8f..8d917484 100644
--- a/src/controllers/DataimportController.php
+++ b/src/controllers/DataimportController.php
@@ -37,8 +37,8 @@ class DataimportController extends BaseController
/**
* 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 4d55ce57..29360a23 100644
--- a/src/controllers/TreeController.php
+++ b/src/controllers/TreeController.php
@@ -135,7 +135,7 @@ class TreeController extends BaseController
* '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<int|string, array<string, mixed>|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 33f180fa..bae800af 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 @@ class ADOdbBase
$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 @@ class ADOdbBase
* @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 @@ class ADOdbBase
*
* @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 @@ class ADOdbBase
*
* @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 @@ class ADOdbBase
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 8c4917eb..4f50cd49 100644
--- a/src/database/Connection.php
+++ b/src/database/Connection.php
@@ -69,7 +69,7 @@ class Connection
$this->container = $container;
- $this->conn = \ADONewConnection('postgres9');
+ $this->conn = ADONewConnection('postgres9');
//$this->conn->debug = true;
$this->conn->setFetchMode($fetchMode);
@@ -93,14 +93,15 @@ class Connection
/*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 @@ class Connection
} 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 c5c3c1a8..6e6dd3b5 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 @@ class Postgres extends ADOdbBase
* @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 @@ class Postgres extends ADOdbBase
*
* @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 @@ class Postgres extends ADOdbBase
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 @@ class Postgres extends ADOdbBase
/* 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 @@ class Postgres extends ADOdbBase
$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 @@ class Postgres extends ADOdbBase
$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 @@ class Postgres extends ADOdbBase
* @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 @@ class Postgres extends ADOdbBase
// Open a transaction
$status = $this->beginTransaction();
- if (false !== $status) {
+ if (0 !== $status) {
return -1;
}
@@ -802,7 +804,7 @@ class Postgres extends ADOdbBase
$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 880271ed..c14ba493 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 9d6ac895..850ae822 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 90e79f92..d2b63461 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 c6df56bd..00000000
--- a/src/database/Postgres74.php
+++ /dev/null
@@ -1,703 +0,0 @@
-<?php
-
-/**
- * PHPPgAdmin 6.0.0
- */
-
-namespace PHPPgAdmin\Database;
-
-/**
- * @file
- * A class that implements the DB interface for Postgres
- * Note: This class uses ADODB and returns RecordSets.
- *
- * Id: Postgres74.php,v 1.72 2008/02/20 21:06:18 ioguix Exp $
- */
-class Postgres74 extends Postgres80
-{
- public $major_version = 7.4;
-
- // List of all legal privileges that can be applied to different types
- // of objects.
- public $privlist = [
- 'table' => ['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 20dbf5df..00000000
--- a/src/database/Postgres80.php
+++ /dev/null
@@ -1,463 +0,0 @@
-<?php
-
-/**
- * PHPPgAdmin 6.0.0
- */
-
-namespace PHPPgAdmin\Database;
-
-/**
- * @file
- * PostgreSQL 8.0 support
- *
- * Id: Postgres80.php,v 1.28 2007/12/12 04:11:10 xzilla Exp $
- */
-class Postgres80 extends Postgres81
-{
- public $major_version = 8.0;
-
- // Map of database encoding names to HTTP encoding names. If a
- // database encoding does not appear in this list, then its HTTP
- // encoding name is the same as its database encoding name.
- public $codemap = [
- 'ALT' => '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 c17de74e..00000000
--- a/src/database/Postgres81.php
+++ /dev/null
@@ -1,348 +0,0 @@
-<?php
-
-/**
- * PHPPgAdmin 6.0.0
- */
-
-namespace PHPPgAdmin\Database;
-
-/**
- * @file
- * PostgreSQL 8.1 support
- *
- * Id: Postgres81.php,v 1.21 2008/01/19 13:46:15 ioguix Exp $
- */
-class Postgres81 extends Postgres82
-{
- public $major_version = 8.1;
-
- // List of all legal privileges that can be applied to different types
- // of objects.
- public $privlist = [
- 'table' => ['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 679a04c8..00000000
--- a/src/database/Postgres82.php
+++ /dev/null
@@ -1,439 +0,0 @@
-<?php
-
-/**
- * PHPPgAdmin 6.0.0
- */
-
-namespace PHPPgAdmin\Database;
-
-/**
- * @file
- * PostgreSQL 8.2 support
- *
- * Id: Postgres82.php,v 1.10 2007/12/28 16:21:25 ioguix Exp $
- */
-class Postgres82 extends Postgres83
-{
- public $major_version = 8.2;
-
- // Select operators
- public $selectOps = [
- '=' => '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 583744da..00000000
--- a/src/database/Postgres83.php
+++ /dev/null
@@ -1,442 +0,0 @@
-<?php
-
-/**
- * PHPPgAdmin 6.0.0
- */
-
-namespace PHPPgAdmin\Database;
-
-/**
- * @file
- * PostgreSQL 8.3 support
- *
- * Id: Postgres82.php,v 1.10 2007/12/28 16:21:25 ioguix Exp $
- */
-class Postgres83 extends Postgres84
-{
- public $major_version = 8.3;
-
- // List of all legal privileges that can be applied to different types
- // of objects.
- public $privlist = [
- 'table' => ['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 d75a3f2c..00000000
--- a/src/database/Postgres84.php
+++ /dev/null
@@ -1,224 +0,0 @@
-<?php
-
-/**
- * PHPPgAdmin 6.0.0
- */
-
-namespace PHPPgAdmin\Database;
-
-/**
- * @file
- * PostgreSQL 8.4 support
- *
- * Id: Postgres82.php,v 1.10 2007/12/28 16:21:25 ioguix Exp $
- */
-class Postgres84 extends Postgres90
-{
- public $major_version = 8.4;
-
- // List of all legal privileges that can be applied to different types
- // of objects.
- public $privlist = [
- 'table' => ['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 4b63b6d2..e981f240 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 @@ class Postgres91 extends Postgres92
*
* @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 @@ class Postgres91 extends Postgres92
*
* @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 34180cef..cb2ff754 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 @@ class Postgres92 extends Postgres93
*
* @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 @@ class Postgres92 extends Postgres93
/**
* 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 1c41a53c..b2a0747f 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 b26589fb..ef2ad7e5 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 @@ class Postgres96 extends Postgres
* @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 55fd82f8..98f09be1 100644
--- a/src/database/databasetraits/AggregateTrait.php
+++ b/src/database/databasetraits/AggregateTrait.php
@@ -83,7 +83,7 @@ trait AggregateTrait
* @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 @@ trait AggregateTrait
* @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 @@ trait AggregateTrait
/**
* Gets all aggregates.
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getAggregates()
{
@@ -244,7 +244,7 @@ trait AggregateTrait
* @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 @@ trait AggregateTrait
* @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 @@ trait AggregateTrait
* @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 8e6687cb..63c73836 100644
--- a/src/database/databasetraits/ColumnTrait.php
+++ b/src/database/databasetraits/ColumnTrait.php
@@ -270,7 +270,7 @@ trait ColumnTrait
* @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 @@ trait ColumnTrait
* @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 @@ trait ColumnTrait
* @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 10d60e4b..c0342708 100644
--- a/src/database/databasetraits/DatabaseTrait.php
+++ b/src/database/databasetraits/DatabaseTrait.php
@@ -58,7 +58,7 @@ trait DatabaseTrait
*
* @param string $table (optional) The table to analyze
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function analyzeDB($table = '')
{
@@ -80,7 +80,7 @@ trait DatabaseTrait
*
* @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 @@ trait DatabaseTrait
*
* @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 @@ trait DatabaseTrait
*
* @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 @@ trait DatabaseTrait
*
* @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 @@ trait DatabaseTrait
*
* @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 @@ trait DatabaseTrait
* @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 @@ trait DatabaseTrait
* @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 @@ trait DatabaseTrait
*
* @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 @@ trait DatabaseTrait
*
* @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 @@ trait DatabaseTrait
/**
* Returns table locks information in the current database.
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getLocks()
{
@@ -569,7 +571,7 @@ trait DatabaseTrait
/**
* 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 9c9568cf..88d5f593 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 @@ trait DomainTrait
/**
* Return all domains in current schema. Excludes domain constraints.
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getDomains()
{
@@ -77,7 +77,7 @@ trait DomainTrait
*
* @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 @@ trait DomainTrait
* @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 @@ trait DomainTrait
* @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 @@ trait DomainTrait
* @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 @@ trait DomainTrait
* @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 bdb574c2..9c2555da 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 @@ trait FunctionTrait
/**
* 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 @@ trait FunctionTrait
* @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 @@ trait FunctionTrait
* @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 @@ trait FunctionTrait
*
* @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 @@ trait FunctionTrait
*
* @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 800c0834..ca328c10 100644
--- a/src/database/databasetraits/IndexTrait.php
+++ b/src/database/databasetraits/IndexTrait.php
@@ -126,7 +126,7 @@ trait IndexTrait
* @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 @@ trait IndexTrait
*
* @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 @@ trait IndexTrait
* @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 @@ trait IndexTrait
* @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 @@ trait IndexTrait
* @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 @@ trait IndexTrait
* @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 @@ trait IndexTrait
* @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 @@ trait IndexTrait
*
* @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 @@ trait IndexTrait
*
* @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 72193eb7..b6da2376 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 @@ trait OperatorTrait
* @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 @@ trait OperatorTrait
*
* @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 @@ trait OperatorTrait
/**
* 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 64809813..bb552238 100644
--- a/src/database/databasetraits/PrivilegesTrait.php
+++ b/src/database/databasetraits/PrivilegesTrait.php
@@ -108,7 +108,7 @@ trait PrivilegesTrait
* @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 8804b7df..015248d4 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 @@ trait RoleTrait
*
* @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 @@ trait RoleTrait
/**
* Returns all users in the database cluster.
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getUsers()
{
@@ -102,7 +102,7 @@ trait RoleTrait
*
* @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 @@ trait RoleTrait
* @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 @@ trait RoleTrait
* @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 @@ trait RoleTrait
* @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 @@ trait RoleTrait
* @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 @@ trait RoleTrait
*
* @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 @@ trait RoleTrait
* @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 @@ trait RoleTrait
* @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 @@ trait RoleTrait
* @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 @@ trait RoleTrait
*
* @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 @@ trait RoleTrait
* @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 @@ trait RoleTrait
* @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 @@ trait RoleTrait
*
* @param string $rolename The role name
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getMemberOf($rolename)
{
@@ -687,7 +687,7 @@ trait RoleTrait
* @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 @@ trait RoleTrait
* @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 @@ trait RoleTrait
*
* @param string $groname The name of the group
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getGroup($groname)
{
@@ -743,7 +743,7 @@ trait RoleTrait
/**
* Returns all groups in the database cluser.
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getGroups()
{
@@ -758,7 +758,7 @@ trait RoleTrait
* @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 @@ trait RoleTrait
*
* @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 a657f796..3ddd05a1 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 @@ trait RowTrait
* @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 2111f75f..32e5af68 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 @@ trait SchemaTrait
*
* @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 @@ trait SchemaTrait
*
* @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 @@ trait SchemaTrait
*
* @param string $schema The name of the schema
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getSchemaByName($schema)
{
@@ -272,7 +272,7 @@ trait SchemaTrait
* @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 deb7edaa..9c881327 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 @@ trait StatsTrait
*
* @param string $table The table to fetch stats for
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getStatsTableTuples($table)
{
@@ -51,7 +51,7 @@ trait StatsTrait
*
* @param string $table The table to fetch stats for
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getStatsTableIO($table)
{
@@ -70,7 +70,7 @@ trait StatsTrait
*
* @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 @@ trait StatsTrait
*
* @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 8cbda72f..084418fd 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 @@ trait TableTrait
/**
* Return all tables in current database (and schema).
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getTables()
{
@@ -75,7 +75,7 @@ trait TableTrait
*
* @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 @@ trait TableTrait
*
* @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 @@ trait TableTrait
*
* @param string $table The name of the table
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getTable($table)
{
@@ -304,7 +304,7 @@ trait TableTrait
* @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 @@ trait TableTrait
*
* @param string $table The table to find rules for
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getConstraints($table)
{
@@ -474,7 +474,7 @@ trait TableTrait
* @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 @@ trait TableTrait
*
* @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 @@ trait TableTrait
*
* @param string $table The table to find rules for
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getRules($table)
{
@@ -852,10 +852,10 @@ trait TableTrait
* 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 @@ trait TableTrait
* 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 @@ trait TableTrait
* 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 @@ trait TableTrait
* 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 @@ trait TableTrait
* @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 @@ trait TableTrait
* @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 @@ trait TableTrait
* @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 @@ trait TableTrait
*
* @param string $table The table
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function dropAutovacuum($table)
{
@@ -1298,12 +1298,12 @@ trait TableTrait
* 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 @@ trait TableTrait
/**
* 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 @@ trait TableTrait
/**
* 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 @@ trait TableTrait
/**
* 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 @@ trait TableTrait
/**
* 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 @@ trait TableTrait
/**
* 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 @@ trait TableTrait
* @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 @@ trait TableTrait
* @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 a08f99dd..18771b48 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 @@ trait TablespaceTrait
*
* @param string $spcname
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getTablespace($spcname)
{
@@ -160,7 +160,7 @@ trait TablespaceTrait
*
* @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 2547d392..5ab24c1c 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 @@ trait TriggerTrait
* @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 @@ trait TriggerTrait
* @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 @@ trait TriggerTrait
* @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 @@ trait TriggerTrait
* @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 @@ trait TriggerTrait
* @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 @@ trait TriggerTrait
* @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 @@ trait TriggerTrait
* @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 @@ trait TriggerTrait
* @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 b1be08d0..fe89fb63 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 @@ trait ViewTrait
/**
* Returns a list of all materialized views in the database.
*
- * @return \ADORecordSet|int
+ * @return int|\PHPPgAdmin\ADORecordSet
*/
public function getMaterializedViews()
{
@@ -163,7 +163,7 @@ trait ViewTrait
*
* @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 @@ trait ViewTrait
/**
* 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 @@ trait ViewTrait
/**
* 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 @@ trait ViewTrait
/**
* 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 @@ trait ViewTrait
* @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 @@ trait ViewTrait
* 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 0d87621a..20d9909a 100644
--- a/src/router.php
+++ b/src/router.php
@@ -32,8 +32,8 @@ $app->post('/redirect/server', function (
$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 @@ $app->get('/redirect[/{subject}]', function (
/* @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 @@ $app->map(['GET', 'POST'], '/src/views/{subject}', function (
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 @@ $app->get('/', function (
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 @@ $app->get('[/{path:.*}]', static function (
/* @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);