Disable OID handling on PG12
authorJean-Michel Vourgère <nirgal@debian.org>
Wed, 6 Nov 2019 17:01:27 +0000 (18:01 +0100)
committerRobert Treat <rob@xzilla.net>
Sun, 8 Dec 2019 02:43:22 +0000 (21:43 -0500)
Notes:
- "CREATE TABLE WITHOUT OIDS" continues to work, for now
- "SHOW default_with_oids" continues to work, for now

all_db.php
classes/database/Postgres.php
classes/database/Postgres11.php
database.php
schemas.php
tables.php
tblproperties.php

index 3c6ca11561d782b8f50ef2a61985c46388f36fd3..4739d5feb077662d3f1b8e80c69970e2f30cae34 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=\"2\">";
+               echo "<tr><th class=\"data left\" rowspan=\"". ($data->supportOids ? 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";
-               echo "<tr><td><input type=\"checkbox\" id=\"d_oids\" name=\"d_oids\" /><label for=\"d_oids\">{$lang['stroids']}</label></td>\n</tr>\n";
+               if ($data->supportOids) {
+                       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=\"3\">";
+               echo "<tr><th class=\"data left\" rowspan=\"". ($data->supportOids ? 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";
-               echo "<tr><td><input type=\"checkbox\" id=\"sd_oids\" name=\"sd_oids\" /><label for=\"sd_oids\">{$lang['stroids']}</label></td>\n</tr>\n";
+               if ($data->supportOids) {
+                       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";
 
                echo "<h3>{$lang['stroptions']}</h3>\n";
index 1daebd3ccda5e250a01509f7fc270de438f3a511..786dafcafc26593fe1a203b732cdc4f3e58b9c62 100644 (file)
@@ -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;
        }
 
        /**
index 38aa20fbe614379231e244d847900562098e351d..46ef936d01671707a569aa87dbe39074e532e405 100644 (file)
@@ -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'];
+               }
+       }
+
 }
 ?>
index cdd53c6078a4054a24883ec773e14e69ff2e9a80..433ac863f9a8d1959582cb77bd1f0ed82b8d3729 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=\"2\">";
+               echo "<tr><th class=\"data left\" rowspan=\"". ($data->supportOids ? 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";
-               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";
+               if ($data->supportOids) {
+                       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=\"3\">";
+               echo "<tr><th class=\"data left\" rowspan=\"". ($data->supportOids ? 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";
-               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";
+               if ($data->supportOids) {
+                       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";
                
                echo "<h3>{$lang['stroptions']}</h3>\n";
index ebfff74b3baec202625fdfc1af1ff73e200c9be9..1a4681b94b7b1db306dc9f4761fd58b2e3f2841e 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=\"2\">";
+               echo "<tr><th class=\"data left\" rowspan=\"". ($data->supportOids ? 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";
-               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";
+               if ($data->supportOids) {
+                       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=\"3\">";
+               echo "<tr><th class=\"data left\" rowspan=\"". ($data->supportOids ? 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";
-               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";
+               if ($data->supportOids) {
+                       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";
 
                echo "<h3>{$lang['stroptions']}</h3>\n";
index a2c189e4d1426c0ca0c3c8740a3488f07a1d9cdf..e65d87935489d378fc1eff6e830d3a433d5e1dc9 100644 (file)
                                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";
-                               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";
+                               if ($data->supportOids) {
+                                       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 {
+                                       echo "\t\t<input type=\"hidden\" id=\"withoutoids\" name=\"withoutoids\" value=\"checked\"\n";
+                               }
 
                                // Tablespace (if there are any)
                                if ($data->hasTablespaces() && $tablespaces->recordCount() > 0) {
index f73ce8b6c569d1eb6dd7966b7c8a509a9f176673..aed1bb542837546764421e4650bc09ec91fd835a 100644 (file)
                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');