Skip to content

Commit

Permalink
Clean up OID handling changes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xzilla committed Dec 8, 2019
1 parent f40fcaa commit b7cf1b6
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 29 deletions.
8 changes: 4 additions & 4 deletions all_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,29 +303,29 @@ function doExport($msg = '') {
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=\"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=\"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";
Expand Down
12 changes: 4 additions & 8 deletions classes/database/Postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -8076,6 +8071,7 @@ function hasQueryKill() { return true; }
function hasConcurrentIndexBuild() { return true; }
function hasForceReindex() { return false; }
function hasByteaHexDefault() { return true; }
function hasServerOids() { return false; }

}
?>
28 changes: 20 additions & 8 deletions classes/database/Postgres11.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
}

/**
Expand All @@ -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; }

}
?>
1 change: 1 addition & 0 deletions conf/config.inc.php-dist
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions database.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,29 +313,29 @@ function doExport($msg = '') {
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=\"copy\">COPY</option>\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";
Expand Down
8 changes: 4 additions & 4 deletions schemas.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,29 +342,29 @@ function doExport($msg = '') {
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=\"copy\">COPY</option>\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";
Expand Down
2 changes: 1 addition & 1 deletion tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function doCreate($msg = '') {
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 {
Expand Down

0 comments on commit b7cf1b6

Please sign in to comment.