From b7cf1b61cd87060afadbb51ba625697823ef51ad Mon Sep 17 00:00:00 2001 From: Robert Treat Date: Sat, 7 Dec 2019 21:39:12 -0500 Subject: [PATCH] Clean up OID handling changes This is mostly just refactoring Nirgals patch to use a standard capability function. I also short-circuited default_with_oid check since it will always show false in >=PG12, so this saves a round trip. This also adds a comment in the config file that show oids is no longer supported. This could lead to a slight difference in running instalations, but since it does not affect any code/behavior, not going to bump the config version. --- all_db.php | 8 ++++---- classes/database/Postgres.php | 12 ++++-------- classes/database/Postgres11.php | 28 ++++++++++++++++++++-------- conf/config.inc.php-dist | 1 + database.php | 8 ++++---- schemas.php | 8 ++++---- tables.php | 2 +- 7 files changed, 38 insertions(+), 29 deletions(-) diff --git a/all_db.php b/all_db.php index 4739d5feb..3368bab28 100644 --- a/all_db.php +++ b/all_db.php @@ -303,21 +303,21 @@ function doExport($msg = '') { echo "\n"; echo "\n"; // Data only - echo "\n"; echo "\n\n"; - if ($data->supportOids) { + if ($data->hasServerOids()) { echo "\n\n"; } // Structure only echo "\n"; echo "\n\n"; // Structure and data - echo "\n"; echo "\n\n"; echo "\n\n"; - if ($data->supportOids) { + if ($data->hasServerOids()) { echo "\n\n"; } echo "
{$lang['strformat']}{$lang['stroptions']}
supportOids ? 2 : 1) ."\">"; + echo "
hasServerOids() ? 2 : 1) ."\">"; echo "{$lang['strformat']}\n"; echo "\n
supportOids ? 3 : 2) ."\">"; + echo "
hasServerOids() ? 3 : 2) ."\">"; echo "{$lang['strformat']}\n"; echo "\n
\n"; diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index 786dafcaf..b780e0add 100644 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -165,10 +165,6 @@ 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 @@ -523,10 +519,9 @@ function getDatabaseEncoding() { * @return default_with_oids setting */ function getDefaultWithOid() { - - $sql = "SHOW default_with_oids"; - - return $this->selectField($sql, 'default_with_oids'); + // OID support was removed in PG12 + // But this function is referenced when browsing data + return false; } /** @@ -8076,6 +8071,7 @@ function hasQueryKill() { return true; } function hasConcurrentIndexBuild() { return true; } function hasForceReindex() { return false; } function hasByteaHexDefault() { return true; } + function hasServerOids() { return false; } } ?> diff --git a/classes/database/Postgres11.php b/classes/database/Postgres11.php index 46ef936d0..d78b6f7ca 100644 --- a/classes/database/Postgres11.php +++ b/classes/database/Postgres11.php @@ -11,10 +11,6 @@ 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 @@ -23,11 +19,15 @@ function __construct($conn) { parent::__construct($conn); } - // Help functions + /** + * Returns the current default_with_oids setting + * @return default_with_oids setting + */ + function getDefaultWithOid() { - function getHelpPages() { - include_once('./help/PostgresDoc11.php'); - return $this->help_page; + $sql = "SHOW default_with_oids"; + + return $this->selectField($sql, 'default_with_oids'); } /** @@ -52,5 +52,17 @@ function hasObjectID($table) { } } + + // Help functions + + function getHelpPages() { + include_once('./help/PostgresDoc11.php'); + return $this->help_page; + } + + + // Capabilities + function hasServerOids() { return true; } + } ?> diff --git a/conf/config.inc.php-dist b/conf/config.inc.php-dist index 917ab958e..017c640ba 100644 --- a/conf/config.inc.php-dist +++ b/conf/config.inc.php-dist @@ -133,6 +133,7 @@ $conf['theme'] = 'default'; // Show OIDs when browsing tables? + // Only supported in versions <=11 $conf['show_oids'] = false; // Max rows to show on a page when browsing record sets diff --git a/database.php b/database.php index 433ac863f..b7012672b 100644 --- a/database.php +++ b/database.php @@ -313,21 +313,21 @@ function doExport($msg = '') { echo "\n"; echo "\n"; // Data only - echo "\n"; echo "\n"; echo "\n\n"; - if ($data->supportOids) { + if ($data->hasServerOids()) { echo "\n\n"; } // Structure only echo "\n"; echo "\n\n"; // Structure and data - echo "\n"; echo "\n"; echo "\n\n"; echo "\n\n"; - if ($data->supportOids) { + if ($data->hasServerOids()) { echo "\n\n"; } echo "
{$lang['strformat']}{$lang['stroptions']}
supportOids ? 2 : 1) ."\">"; + echo "
hasServerOids() ? 2 : 1) ."\">"; echo "{$lang['strformat']}\n
supportOids ? 3 : 2) ."\">"; + echo "
hasServerOids() ? 3 : 2) ."\">"; echo "{$lang['strformat']}\n
\n"; diff --git a/schemas.php b/schemas.php index 1a4681b94..5b97b27e3 100644 --- a/schemas.php +++ b/schemas.php @@ -342,21 +342,21 @@ function doExport($msg = '') { echo "\n"; echo "\n"; // Data only - echo "\n"; echo "\n"; echo "\n\n"; - if ($data->supportOids) { + if ($data->hasServerOids()) { echo "\n\n"; } // Structure only echo "\n"; echo "\n\n"; // Structure and data - echo "\n"; echo "\n"; echo "\n\n"; echo "\n\n"; - if ($data->supportOids) { + if ($data->hasServerOids()) { echo "\n\n"; } echo "
{$lang['strformat']}{$lang['stroptions']}
supportOids ? 2 : 1) ."\">"; + echo "
hasServerOids() ? 2 : 1) ."\">"; echo "{$lang['strformat']}\n
supportOids ? 3 : 2) ."\">"; + echo "
hasServerOids() ? 3 : 2) ."\">"; echo "{$lang['strformat']}\n
\n"; diff --git a/tables.php b/tables.php index e65d87935..e15f2d2e6 100644 --- a/tables.php +++ b/tables.php @@ -46,7 +46,7 @@ function doCreate($msg = '') { echo "\t\n\t\t{$lang['strnumcols']}\n"; echo "\t\t_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['fields']), "\" />\n\t\n"; - if ($data->supportOids) { + if ($data->hasServerOids()) { echo "\t\n\t\t{$lang['stroptions']}\n"; echo "\t\t\n\t\n"; } else {