summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Michel Vourgère2019-11-06 17:01:27 +0000
committerRobert Treat2019-12-08 02:43:22 +0000
commitf40fcaa3dd89b5baf7c68b03e47618261960b872 (patch)
tree17cc445d047298b8c67be44b548d681e6e57e74e
parentfa5119cc1afcf62e5d647a0855ad37637bc29cf2 (diff)
Disable OID handling on PG12
Notes: - "CREATE TABLE WITHOUT OIDS" continues to work, for now - "SHOW default_with_oids" continues to work, for now
-rw-r--r--all_db.php12
-rw-r--r--classes/database/Postgres.php20
-rw-r--r--classes/database/Postgres11.php26
-rw-r--r--database.php12
-rw-r--r--schemas.php12
-rw-r--r--tables.php8
-rw-r--r--tblproperties.php2
7 files changed, 64 insertions, 28 deletions
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 "<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";
@@ -323,7 +325,9 @@
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";
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 "<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";
@@ -333,7 +335,9 @@
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";
diff --git a/schemas.php b/schemas.php
index ebfff74b..1a4681b9 100644
--- a/schemas.php
+++ b/schemas.php
@@ -342,19 +342,21 @@
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";
@@ -362,7 +364,9 @@
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";
diff --git a/tables.php b/tables.php
index a2c189e4..e65d8793 100644
--- a/tables.php
+++ b/tables.php
@@ -46,8 +46,12 @@
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) {
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');