From: Jean-Michel Vourgère Date: Wed, 6 Nov 2019 17:01:27 +0000 (+0100) Subject: Disable OID handling on PG12 X-Git-Tag: REL_7-12-1~2 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=f40fcaa3dd89b5baf7c68b03e47618261960b872;p=phppgadmin.git Disable OID handling on PG12 Notes: - "CREATE TABLE WITHOUT OIDS" continues to work, for now - "SHOW default_with_oids" continues to work, for now --- diff --git a/all_db.php b/all_db.php index 3c6ca115..4739d5fe 100644 --- a/all_db.php +++ b/all_db.php @@ -303,19 +303,21 @@ echo "\n"; echo "\n"; // Data only - echo "\n"; echo "\n\n"; - echo "\n\n"; + if ($data->supportOids) { + echo "\n\n"; + } // Structure only echo "\n"; echo "\n\n"; // Structure and data - echo "\n"; echo "\n\n"; echo "\n\n"; - echo "\n\n"; + if ($data->supportOids) { + echo "\n\n"; + } echo "
{$lang['strformat']}{$lang['stroptions']}
"; + echo "
supportOids ? 2 : 1) ."\">"; echo "{$lang['strformat']}\n"; echo "\n
"; + echo "
supportOids ? 3 : 2) ."\">"; echo "{$lang['strformat']}\n"; echo "\n
\n"; echo "

{$lang['stroptions']}

\n"; diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index 1daebd3c..786dafca 100644 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -165,6 +165,10 @@ class Postgres extends ADODB_base { // The default type storage var $typStorageDef = 'plain'; + // PG <= 11 could have hidden OID columns + // This disables extra OID related GUI options (exports, ...) + var $supportOids = false; + /** * Constructor * @param $conn The database connection @@ -1039,19 +1043,9 @@ class Postgres extends ADODB_base { * @return null error **/ function hasObjectID($table) { - $c_schema = $this->_schema; - $this->clean($c_schema); - $this->clean($table); - - $sql = "SELECT relhasoids FROM pg_catalog.pg_class WHERE relname='{$table}' - AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$c_schema}')"; - - $rs = $this->selectSet($sql); - if ($rs->recordCount() != 1) return null; - else { - $rs->fields['relhasoids'] = $this->phpBool($rs->fields['relhasoids']); - return $rs->fields['relhasoids']; - } + // OID support is gone since PG12 + // But that function is required by table exports + return false; } /** diff --git a/classes/database/Postgres11.php b/classes/database/Postgres11.php index 38aa20fb..46ef936d 100644 --- a/classes/database/Postgres11.php +++ b/classes/database/Postgres11.php @@ -11,6 +11,10 @@ class Postgres11 extends Postgres { var $major_version = 11; + // PG<=11 could have hidden OID columns + // This enables extra OID related GUI options (exports, ...) + var $supportOids = true; + /** * Constructor * @param $conn The database connection @@ -26,5 +30,27 @@ class Postgres11 extends Postgres { return $this->help_page; } + /** + * Checks to see whether or not a table has a unique id column + * @param $table The table name + * @return True if it has a unique id, false otherwise + * @return null error + **/ + function hasObjectID($table) { + $c_schema = $this->_schema; + $this->clean($c_schema); + $this->clean($table); + + $sql = "SELECT relhasoids FROM pg_catalog.pg_class WHERE relname='{$table}' + AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$c_schema}')"; + + $rs = $this->selectSet($sql); + if ($rs->recordCount() != 1) return null; + else { + $rs->fields['relhasoids'] = $this->phpBool($rs->fields['relhasoids']); + return $rs->fields['relhasoids']; + } + } + } ?> diff --git a/database.php b/database.php index cdd53c60..433ac863 100644 --- a/database.php +++ b/database.php @@ -313,19 +313,21 @@ echo "\n"; echo "\n"; // Data only - echo "\n"; echo "\n"; echo "\n\n"; - echo "\n\n"; + if ($data->supportOids) { + echo "\n\n"; + } // Structure only echo "\n"; echo "\n\n"; // Structure and data - echo "\n"; echo "\n"; echo "\n\n"; echo "\n\n"; - echo "\n\n"; + if ($data->supportOids) { + echo "\n\n"; + } echo "
{$lang['strformat']}{$lang['stroptions']}
"; + echo "
supportOids ? 2 : 1) ."\">"; echo "{$lang['strformat']}\n
"; + echo "
supportOids ? 3 : 2) ."\">"; echo "{$lang['strformat']}\n
\n"; echo "

{$lang['stroptions']}

\n"; diff --git a/schemas.php b/schemas.php index ebfff74b..1a4681b9 100644 --- a/schemas.php +++ b/schemas.php @@ -342,19 +342,21 @@ echo "\n"; echo "\n"; // Data only - echo "\n"; echo "\n"; echo "\n\n"; - echo "\n\n"; + if ($data->supportOids) { + echo "\n\n"; + } // Structure only echo "\n"; echo "\n\n"; // Structure and data - echo "\n"; echo "\n"; echo "\n\n"; echo "\n\n"; - echo "\n\n"; + if ($data->supportOids) { + echo "\n\n"; + } echo "
{$lang['strformat']}{$lang['stroptions']}
"; + echo "
supportOids ? 2 : 1) ."\">"; echo "{$lang['strformat']}\n
"; + echo "
supportOids ? 3 : 2) ."\">"; echo "{$lang['strformat']}\n
\n"; echo "

{$lang['stroptions']}

\n"; diff --git a/tables.php b/tables.php index a2c189e4..e65d8793 100644 --- a/tables.php +++ b/tables.php @@ -46,8 +46,12 @@ echo "\t\n\t\t{$lang['strnumcols']}\n"; echo "\t\t_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['fields']), "\" />\n\t\n"; - echo "\t\n\t\t{$lang['stroptions']}\n"; - echo "\t\t\n\t\n"; + if ($data->supportOids) { + echo "\t\n\t\t{$lang['stroptions']}\n"; + echo "\t\t\n\t\n"; + } else { + echo "\t\thasTablespaces() && $tablespaces->recordCount() > 0) { diff --git a/tblproperties.php b/tblproperties.php index f73ce8b6..aed1bb54 100644 --- a/tblproperties.php +++ b/tblproperties.php @@ -139,7 +139,7 @@ global $data, $misc; global $lang; - // Determine whether or not the table has an object ID + // Determine whether or not the table has an object ID (Always false if version>=12) $hasID = $data->hasObjectID($_REQUEST['table']); $misc->printTrail('table');