Clean up OID handling changes
authorRobert Treat <rob@xzilla.net>
Sun, 8 Dec 2019 02:39:12 +0000 (21:39 -0500)
committerRobert Treat <rob@xzilla.net>
Sun, 8 Dec 2019 02:54:11 +0000 (21:54 -0500)
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
classes/database/Postgres.php
classes/database/Postgres11.php
conf/config.inc.php-dist
database.php
schemas.php
tables.php

index 4739d5feb077662d3f1b8e80c69970e2f30cae34..3368bab28b61fb98041158664ed8369bbfe8b911 100644 (file)
                echo "<table>\n";
                echo "<tr><th class=\"data\">{$lang['strformat']}</th><th class=\"data\">{$lang['stroptions']}</th></tr>\n";
                // Data only
-               echo "<tr><th class=\"data left\" rowspan=\"". ($data->supportOids ? 2 : 1) ."\">";
+               echo "<tr><th class=\"data left\" rowspan=\"". ($data->hasServerOids() ? 2 : 1) ."\">";
                echo "<input type=\"radio\" id=\"what1\" name=\"what\" value=\"dataonly\" checked=\"checked\" /><label for=\"what1\">{$lang['strdataonly']}</label></th>\n";
                echo "<td>{$lang['strformat']}\n";
                echo "<select name=\"d_format\">\n";
                echo "<option value=\"copy\">COPY</option>\n";
                echo "<option value=\"sql\">SQL</option>\n";
                echo "</select>\n</td>\n</tr>\n";
-               if ($data->supportOids) {
+               if ($data->hasServerOids()) {
                        echo "<tr><td><input type=\"checkbox\" id=\"d_oids\" name=\"d_oids\" /><label for=\"d_oids\">{$lang['stroids']}</label></td>\n</tr>\n";
                }
                // Structure only
                echo "<tr><th class=\"data left\"><input type=\"radio\" id=\"what2\" name=\"what\" value=\"structureonly\" /><label for=\"what2\">{$lang['strstructureonly']}</label></th>\n";
                echo "<td><input type=\"checkbox\" id=\"s_clean\" name=\"s_clean\" /><label for=\"s_clean\">{$lang['strdrop']}</label></td>\n</tr>\n";
                // Structure and data
-               echo "<tr><th class=\"data left\" rowspan=\"". ($data->supportOids ? 3 : 2) ."\">";
+               echo "<tr><th class=\"data left\" rowspan=\"". ($data->hasServerOids() ? 3 : 2) ."\">";
                echo "<input type=\"radio\" id=\"what3\" name=\"what\" value=\"structureanddata\" /><label for=\"what3\">{$lang['strstructureanddata']}</label></th>\n";
                echo "<td>{$lang['strformat']}\n";
                echo "<select name=\"sd_format\">\n";
                echo "<option value=\"sql\">SQL</option>\n";
                echo "</select>\n</td>\n</tr>\n";
                echo "<tr><td><input type=\"checkbox\" id=\"sd_clean\" name=\"sd_clean\" /><label for=\"sd_clean\">{$lang['strdrop']}</label></td>\n</tr>\n";
-               if ($data->supportOids) {
+               if ($data->hasServerOids()) {
                        echo "<tr><td><input type=\"checkbox\" id=\"sd_oids\" name=\"sd_oids\" /><label for=\"sd_oids\">{$lang['stroids']}</label></td>\n</tr>\n";
                }
                echo "</table>\n";
index 786dafcafc26593fe1a203b732cdc4f3e58b9c62..b780e0add998d6b055b6f2945018266ae05f08f9 100644 (file)
@@ -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 @@ class Postgres extends ADODB_base {
         * @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 @@ class Postgres extends ADODB_base {
        function hasConcurrentIndexBuild() { return true; }
        function hasForceReindex() { return false; }
        function hasByteaHexDefault() { return true; } 
+       function hasServerOids() { return false; }
        
 }
 ?>
index 46ef936d01671707a569aa87dbe39074e532e405..d78b6f7ca86fdf714209752d2971cb6710f7b933 100644 (file)
@@ -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 @@ class Postgres11 extends Postgres {
                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 @@ class Postgres11 extends Postgres {
                }
        }
 
+
+       // Help functions
+
+       function getHelpPages() {
+               include_once('./help/PostgresDoc11.php');
+               return $this->help_page;
+       }
+
+
+       // Capabilities
+       function hasServerOids() { return true; }
+
 }
 ?>
index 917ab958ec73c1287d1e28f27348311c96ce7c3f..017c640baf05244a7ca3c6eb5fb465774ff64a80 100644 (file)
        $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
index 433ac863f9a8d1959582cb77bd1f0ed82b8d3729..b7012672b4187a3201c7cddd567226cc0fab4516 100644 (file)
                echo "<table>\n";
                echo "<tr><th class=\"data\">{$lang['strformat']}</th><th class=\"data\" colspan=\"2\">{$lang['stroptions']}</th></tr>\n";
                // Data only
-               echo "<tr><th class=\"data left\" rowspan=\"". ($data->supportOids ? 2 : 1) ."\">";
+               echo "<tr><th class=\"data left\" rowspan=\"". ($data->hasServerOids() ? 2 : 1) ."\">";
                echo "<input type=\"radio\" id=\"what1\" name=\"what\" value=\"dataonly\" checked=\"checked\" /><label for=\"what1\">{$lang['strdataonly']}</label></th>\n";
                echo "<td>{$lang['strformat']}</td>\n";
                echo "<td><select name=\"d_format\">\n";
                echo "<option value=\"copy\">COPY</option>\n";
                echo "<option value=\"sql\">SQL</option>\n";
                echo "</select>\n</td>\n</tr>\n";
-               if ($data->supportOids) {
+               if ($data->hasServerOids()) {
                        echo "<tr><td><label for=\"d_oids\">{$lang['stroids']}</label></td><td><input type=\"checkbox\" id=\"d_oids\" name=\"d_oids\" /></td>\n</tr>\n";
                }
                // Structure only
                echo "<tr><th class=\"data left\"><input type=\"radio\" id=\"what2\" name=\"what\" value=\"structureonly\" /><label for=\"what2\">{$lang['strstructureonly']}</label></th>\n";
                echo "<td><label for=\"s_clean\">{$lang['strdrop']}</label></td><td><input type=\"checkbox\" id=\"s_clean\" name=\"s_clean\" /></td>\n</tr>\n";
                // Structure and data
-               echo "<tr><th class=\"data left\" rowspan=\"". ($data->supportOids ? 3 : 2) ."\">";
+               echo "<tr><th class=\"data left\" rowspan=\"". ($data->hasServerOids() ? 3 : 2) ."\">";
                echo "<input type=\"radio\" id=\"what3\" name=\"what\" value=\"structureanddata\" /><label for=\"what3\">{$lang['strstructureanddata']}</label></th>\n";
                echo "<td>{$lang['strformat']}</td>\n";
                echo "<td><select name=\"sd_format\">\n";
                echo "<option value=\"sql\">SQL</option>\n";
                echo "</select>\n</td>\n</tr>\n";
                echo "<tr><td><label for=\"sd_clean\">{$lang['strdrop']}</label></td><td><input type=\"checkbox\" id=\"sd_clean\" name=\"sd_clean\" /></td>\n</tr>\n";
-               if ($data->supportOids) {
+               if ($data->hasServerOids()) {
                        echo "<tr><td><label for=\"sd_oids\">{$lang['stroids']}</label></td><td><input type=\"checkbox\" id=\"sd_oids\" name=\"sd_oids\" /></td>\n</tr>\n";
                }
                echo "</table>\n";
index 1a4681b94b7b1db306dc9f4761fd58b2e3f2841e..5b97b27e36b451d486b7af4cdbb4ff8c74f6095f 100644 (file)
                echo "<table>\n";
                echo "<tr><th class=\"data\">{$lang['strformat']}</th><th class=\"data\" colspan=\"2\">{$lang['stroptions']}</th></tr>\n";
                // Data only
-               echo "<tr><th class=\"data left\" rowspan=\"". ($data->supportOids ? 2 : 1) ."\">";
+               echo "<tr><th class=\"data left\" rowspan=\"". ($data->hasServerOids() ? 2 : 1) ."\">";
                echo "<input type=\"radio\" id=\"what1\" name=\"what\" value=\"dataonly\" checked=\"checked\" /><label for=\"what1\">{$lang['strdataonly']}</label></th>\n";
                echo "<td>{$lang['strformat']}</td>\n";
                echo "<td><select name=\"d_format\">\n";
                echo "<option value=\"copy\">COPY</option>\n";
                echo "<option value=\"sql\">SQL</option>\n";
                echo "</select>\n</td>\n</tr>\n";
-               if ($data->supportOids) {
+               if ($data->hasServerOids()) {
                        echo "<tr><td><label for=\"d_oids\">{$lang['stroids']}</label></td><td><input type=\"checkbox\" id=\"d_oids\" name=\"d_oids\" /></td>\n</tr>\n";
                }
                // Structure only
                echo "<tr><th class=\"data left\"><input type=\"radio\" id=\"what2\" name=\"what\" value=\"structureonly\" /><label for=\"what2\">{$lang['strstructureonly']}</label></th>\n";
                echo "<td><label for=\"s_clean\">{$lang['strdrop']}</label></td><td><input type=\"checkbox\" id=\"s_clean\" name=\"s_clean\" /></td>\n</tr>\n";
                // Structure and data
-               echo "<tr><th class=\"data left\" rowspan=\"". ($data->supportOids ? 3 : 2) ."\">";
+               echo "<tr><th class=\"data left\" rowspan=\"". ($data->hasServerOids() ? 3 : 2) ."\">";
                echo "<input type=\"radio\" id=\"what3\" name=\"what\" value=\"structureanddata\" /><label for=\"what3\">{$lang['strstructureanddata']}</label></th>\n";
                echo "<td>{$lang['strformat']}</td>\n";
                echo "<td><select name=\"sd_format\">\n";
                echo "<option value=\"sql\">SQL</option>\n";
                echo "</select>\n</td>\n</tr>\n";
                echo "<tr><td><label for=\"sd_clean\">{$lang['strdrop']}</label></td><td><input type=\"checkbox\" id=\"sd_clean\" name=\"sd_clean\" /></td>\n</tr>\n";
-               if ($data->supportOids) {
+               if ($data->hasServerOids()) {
                        echo "<tr><td><label for=\"sd_oids\">{$lang['stroids']}</label></td><td><input type=\"checkbox\" id=\"sd_oids\" name=\"sd_oids\" /></td>\n</tr>\n";
                }
                echo "</table>\n";
index e65d87935489d378fc1eff6e830d3a433d5e1dc9..e15f2d2e61d73e201a9e172f8da237297c8f576b 100644 (file)
@@ -46,7 +46,7 @@
                                echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strnumcols']}</th>\n";
                                echo "\t\t<td class=\"data\"><input name=\"fields\" size=\"5\" maxlength=\"{$data->_maxNameLen}\" value=\"",
                                        htmlspecialchars($_REQUEST['fields']), "\" /></td>\n\t</tr>\n";
-                               if ($data->supportOids) {
+                               if ($data->hasServerOids()) {
                                        echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['stroptions']}</th>\n";
                                        echo "\t\t<td class=\"data\"><label for=\"withoutoids\"><input type=\"checkbox\" id=\"withoutoids\" name=\"withoutoids\"", isset($_REQUEST['withoutoids']) ? ' checked="checked"' : '', " />WITHOUT OIDS</label></td>\n\t</tr>\n";
                                } else {