summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume (ioguix) de Rorthais2008-11-05 06:52:35 +0000
committerGuillaume (ioguix) de Rorthais2008-11-05 06:52:35 +0000
commit06c2263c185db44c5722fc32062e8849b4058c0c (patch)
tree6a2dc3cb6ae1035d77b1cd300e77bad795a9f2a5
parenta7691608ce208d1fce7034103b74b813b0bab642 (diff)
Remove everything about hasSchema as all supported pg version supports schema now (from pg73)
-rw-r--r--classes/Misc.php16
-rw-r--r--classes/Reports.php2
-rwxr-xr-xclasses/database/Postgres.php155
-rwxr-xr-xclasses/plugins/Slony.php3
-rw-r--r--colproperties.php4
-rw-r--r--constraints.php8
-rwxr-xr-xdatabase.php68
-rw-r--r--dataexport.php2
-rw-r--r--dbexport.php8
-rw-r--r--display.php2
-rw-r--r--info.php24
-rw-r--r--libraries/lib.inc.php2
-rwxr-xr-xschemas.php105
-rw-r--r--sequences.php2
-rw-r--r--sql.php2
-rw-r--r--sqledit.php23
-rw-r--r--triggers.php1
-rw-r--r--views.php63
18 files changed, 169 insertions, 321 deletions
diff --git a/classes/Misc.php b/classes/Misc.php
index 1f1b8fc1..172c4057 100644
--- a/classes/Misc.php
+++ b/classes/Misc.php
@@ -588,7 +588,6 @@
'title' => $lang['strschemas'],
'url' => 'schemas.php',
'urlvars' => array('subject' => 'database'),
- 'hide' => (!$data->hasSchemas()),
'help' => 'pg.schema',
'icon' => 'Schemas',
),
@@ -692,7 +691,6 @@
),
);
if (!$data->hasFTS()) unset($tabs['fulltext']);
- if (!$data->hasSchemas()) unset($tabs['schemas']);
return $tabs;
case 'schema':
@@ -777,7 +775,6 @@
'title' => $lang['strprivileges'],
'url' => 'privileges.php',
'urlvars' => array('subject' => 'schema'),
- 'hide' => (!$data->hasSchemas()),
'help' => 'pg.privilege',
'tree' => false,
'icon' => 'Privileges',
@@ -1064,18 +1061,7 @@
function getLastTabURL($section) {
global $data;
- switch ($section) {
- case 'database':
- case 'role':
- case 'schema':
- if ($data->hasSchemas() === false) {
- $section = 'database';
- $tabs = array_merge($this->getNavTabs('schema'), $this->getNavTabs('database'));
- break;
- }
- default:
- $tabs = $this->getNavTabs($section);
- }
+ $tabs = $this->getNavTabs($section);
if (isset($_SESSION['webdbLastTab'][$section]) && isset($tabs[$_SESSION['webdbLastTab'][$section]]))
$tab = $tabs[$_SESSION['webdbLastTab'][$section]];
diff --git a/classes/Reports.php b/classes/Reports.php
index 3ad5181a..0688f35a 100644
--- a/classes/Reports.php
+++ b/classes/Reports.php
@@ -37,7 +37,7 @@
// Create a new database access object.
$this->driver = $misc->getDatabaseAccessor($this->reports_db);
// Reports database should have been created in public schema
- if ($this->driver->hasSchemas()) $this->driver->setSchema($this->reports_schema);
+ $this->driver->setSchema($this->reports_schema);
$status = 0;
}
}
diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php
index ac6b873d..6ab8caa7 100755
--- a/classes/database/Postgres.php
+++ b/classes/database/Postgres.php
@@ -841,13 +841,6 @@ class Postgres extends ADODB_base {
// Schema functons
/**
- * Returns the current schema to prepend on object names
- */
- function schema() {
- return "\"{$this->_schema}\".";
- }
-
- /**
* Return all schemas in the current database. This differs from the version
* in 7.3 only in that it considers the information_schema to be a system schema.
* @return All schemas, sorted alphabetically
@@ -907,7 +900,7 @@ class Postgres extends ADODB_base {
$this->clean($schema);
$this->_schema = $schema;
return 0;
- }
+ }
else return $status;
}
@@ -1278,12 +1271,8 @@ class Postgres extends ADODB_base {
// Output a reconnect command to create the table as the correct user
$sql = $this->getChangeUserSQL($t->fields['relowner']) . "\n\n";
- // Set schema search path if we support schemas
- $schema = '';
- if ($this->hasSchemas()) {
- $schema = "\"{$this->_schema}\".";
- $sql .= "SET search_path = \"{$this->_schema}\", pg_catalog;\n\n";
- }
+ // Set schema search path
+ $sql .= "SET search_path = \"{$this->_schema}\", pg_catalog;\n\n";
// Begin CREATE TABLE definition
$sql .= "-- Definition\n\n";
@@ -1291,8 +1280,8 @@ class Postgres extends ADODB_base {
// in pg_catalog.
if (!$clean) $sql .= "-- ";
$sql .= "DROP TABLE ";
- $sql .= "{$schema}\"{$t->fields['relname']}\";\n";
- $sql .= "CREATE TABLE {$schema}\"{$t->fields['relname']}\" (\n";
+ $sql .= "{$this->_schema}\"{$t->fields['relname']}\";\n";
+ $sql .= "CREATE TABLE {$this->_schema}\"{$t->fields['relname']}\" (\n";
// Output all table columns
$col_comments_sql = ''; // Accumulate comments on columns
@@ -1381,7 +1370,7 @@ class Postgres extends ADODB_base {
while (!$parents->EOF) {
$this->fieldClean($parents->fields['relname']);
// Qualify the parent table if it's in another schema
- if ($this->hasSchemas() && $parents->fields['schemaname'] != $this->_schema) {
+ if ($parents->fields['schemaname'] != $this->_schema) {
$this->fieldClean($parents->fields['schemaname']);
$sql .= "\"{$parents->fields['schemaname']}\".";
}
@@ -1415,7 +1404,7 @@ class Postgres extends ADODB_base {
$sql .= "\n";
$first = false;
}
- $sql .= "ALTER TABLE ONLY {$schema}\"{$t->fields['relname']}\" ALTER COLUMN \"{$atts->fields['attname']}\" SET STATISTICS {$atts->fields['attstattarget']};\n";
+ $sql .= "ALTER TABLE ONLY {$this->_schema}\"{$t->fields['relname']}\" ALTER COLUMN \"{$atts->fields['attname']}\" SET STATISTICS {$atts->fields['attstattarget']};\n";
}
// Then storage
if ($atts->fields['attstorage'] != $atts->fields['typstorage']) {
@@ -1437,7 +1426,7 @@ class Postgres extends ADODB_base {
$this->rollbackTransaction();
return null;
}
- $sql .= "ALTER TABLE ONLY {$schema}\"{$t->fields['relname']}\" ALTER COLUMN \"{$atts->fields['attname']}\" SET STORAGE {$storage};\n";
+ $sql .= "ALTER TABLE ONLY {$this->_schema}\"{$t->fields['relname']}\" ALTER COLUMN \"{$atts->fields['attname']}\" SET STORAGE {$storage};\n";
}
$atts->moveNext();
@@ -1447,7 +1436,7 @@ class Postgres extends ADODB_base {
if ($t->fields['relcomment'] !== null) {
$this->clean($t->fields['relcomment']);
$sql .= "\n-- Comment\n\n";
- $sql .= "COMMENT ON TABLE {$schema}\"{$t->fields['relname']}\" IS '{$t->fields['relcomment']}';\n";
+ $sql .= "COMMENT ON TABLE {$this->_schema}\"{$t->fields['relname']}\" IS '{$t->fields['relcomment']}';\n";
}
// Add comments on columns, if any
@@ -1467,7 +1456,7 @@ class Postgres extends ADODB_base {
* wire-in knowledge about the default public privileges for different
* kinds of objects.
*/
- $sql .= "REVOKE ALL ON TABLE {$schema}\"{$t->fields['relname']}\" FROM PUBLIC;\n";
+ $sql .= "REVOKE ALL ON TABLE {$this->_schema}\"{$t->fields['relname']}\" FROM PUBLIC;\n";
foreach ($privs as $v) {
// Get non-GRANT OPTION privs
$nongrant = array_diff($v[2], $v[4]);
@@ -1647,12 +1636,10 @@ class Postgres extends ADODB_base {
$status = $this->beginTransaction();
if ($status != 0) return -1;
- $schema = $this->schema();
-
$found = false;
$first = true;
$comment_sql = ''; //Accumulate comments for the columns
- $sql = "CREATE TABLE {$schema}\"{$name}\" (";
+ $sql = "CREATE TABLE \"{$this->_schema}\".\"{$name}\" (";
for ($i = 0; $i < $fields; $i++) {
$this->fieldClean($field[$i]);
$this->clean($type[$i]);
@@ -2042,10 +2029,8 @@ class Postgres extends ADODB_base {
$this->clean($length);
$this->clean($comment);
- $schema = $this->schema();
-
if ($length == '')
- $sql = "ALTER TABLE {$schema}\"{$table}\" ADD COLUMN \"{$column}\" {$type}";
+ $sql = "ALTER TABLE \"{$this->_schema}\".\"{$table}\" ADD COLUMN \"{$column}\" {$type}";
else {
switch ($type) {
// Have to account for weird placing of length for with/without
@@ -2053,15 +2038,15 @@ class Postgres extends ADODB_base {
case 'timestamp with time zone':
case 'timestamp without time zone':
$qual = substr($type, 9);
- $sql = "ALTER TABLE {$schema}\"{$table}\" ADD COLUMN \"{$column}\" timestamp({$length}){$qual}";
+ $sql = "ALTER TABLE \"{$this->_schema}\".\"{$table}\" ADD COLUMN \"{$column}\" timestamp({$length}){$qual}";
break;
case 'time with time zone':
case 'time without time zone':
$qual = substr($type, 4);
- $sql = "ALTER TABLE {$schema}\"{$table}\" ADD COLUMN \"{$column}\" time({$length}){$qual}";
+ $sql = "ALTER TABLE \"{$this->_schema}\".\"{$table}\" ADD COLUMN \"{$column}\" time({$length}){$qual}";
break;
default:
- $sql = "ALTER TABLE {$schema}\"{$table}\" ADD COLUMN \"{$column}\" {$type}({$length})";
+ $sql = "ALTER TABLE \"{$this->_schema}\".\"{$table}\" ADD COLUMN \"{$column}\" {$type}({$length})";
}
}
@@ -2405,8 +2390,6 @@ class Postgres extends ADODB_base {
else {
$this->fieldClean($table);
- $schema = $this->schema();
-
// Build clause
if (sizeof($vars) > 0) {
$fields = '';
@@ -2419,7 +2402,7 @@ class Postgres extends ADODB_base {
else $tmp = $this->formatValue($types[$key], $format[$key], $value);
if ($fields) $fields .= ", \"{$key}\"";
- else $fields = "INSERT INTO {$schema}\"{$table}\" (\"{$key}\"";
+ else $fields = "INSERT INTO \"{$this->_schema}\".\"{$table}\" (\"{$key}\"";
if ($values) $values .= ", {$tmp}";
else $values = ") VALUES ({$tmp}";
@@ -2449,7 +2432,6 @@ class Postgres extends ADODB_base {
// Build clause
if (sizeof($vars) > 0) {
- $schema = $this->schema();
foreach($vars as $key => $value) {
$this->fieldClean($key);
@@ -2459,7 +2441,7 @@ class Postgres extends ADODB_base {
else $tmp = $this->formatValue($types[$key], $format[$key], $value);
if (isset($sql)) $sql .= ", \"{$key}\"={$tmp}";
- else $sql = "UPDATE {$schema}\"{$table}\" SET \"{$key}\"={$tmp}";
+ else $sql = "UPDATE \"{$this->_schema}\".\"{$table}\" SET \"{$key}\"={$tmp}";
}
$first = true;
foreach ($keyarr as $k => $v) {
@@ -2644,9 +2626,7 @@ class Postgres extends ADODB_base {
$this->clean($startvalue);
$this->clean($cachevalue);
- $schema = $this->schema();
-
- $sql = "CREATE SEQUENCE {$schema}\"{$sequence}\"";
+ $sql = "CREATE SEQUENCE \"{$this->_schema}\".\"{$sequence}\"";
if ($increment != '') $sql .= " INCREMENT {$increment}";
if ($minvalue != '') $sql .= " MINVALUE {$minvalue}";
if ($maxvalue != '') $sql .= " MAXVALUE {$maxvalue}";
@@ -2929,7 +2909,7 @@ class Postgres extends ADODB_base {
$sql = "CREATE ";
if ($replace) $sql .= "OR REPLACE ";
- $sql .= "VIEW ". $this->schema() ."\"{$viewname}\" AS {$definition}";
+ $sql .= "VIEW \"{$this->_schema}\".\"{$viewname}\" AS {$definition}";
$status = $this->execute($sql);
if ($status) {
@@ -3085,7 +3065,7 @@ class Postgres extends ADODB_base {
function dropView($viewname, $cascade) {
$this->fieldClean($viewname);
- $sql = "DROP VIEW ". $this->schema() ."\"{$viewname}\"";
+ $sql = "DROP VIEW \"{$this->_schema}\".\"{$viewname}\"";
if ($cascade) $sql .= " CASCADE";
return $this->execute($sql);
@@ -3131,11 +3111,9 @@ class Postgres extends ADODB_base {
$this->fieldClean($name);
$this->fieldClean($table);
- $schema = $this->schema();
-
$sql = "CREATE";
if ($unique) $sql .= " UNIQUE";
- $sql .= " INDEX \"{$name}\" ON {$schema}\"{$table}\" USING {$type} ";
+ $sql .= " INDEX \"{$name}\" ON \"{$this->_schema}\".\"{$table}\" USING {$type} ";
if (is_array($columns)) {
$this->arrayClean($columns);
@@ -3334,9 +3312,7 @@ class Postgres extends ADODB_base {
$this->fieldClean($name);
$this->fieldClean($tablespace);
- $schema = $this->schema();
-
- $sql = "ALTER TABLE {$schema}\"{$table}\" ADD ";
+ $sql = "ALTER TABLE \"{$this->_schema}\".\"{$table}\" ADD ";
if ($name != '') $sql .= "CONSTRAINT \"{$name}\" ";
$sql .= "PRIMARY KEY (\"" . join('","', $fields) . "\")";
@@ -3362,9 +3338,7 @@ class Postgres extends ADODB_base {
$this->fieldClean($name);
$this->fieldClean($tablespace);
- $schema = $this->schema();
-
- $sql = "ALTER TABLE {$schema}\"{$table}\" ADD ";
+ $sql = "ALTER TABLE \"{$this->_schema}\".\"{$table}\" ADD ";
if ($name != '') $sql .= "CONSTRAINT \"{$name}\" ";
$sql .= "UNIQUE (\"" . join('","', $fields) . "\")";
@@ -3471,17 +3445,11 @@ class Postgres extends ADODB_base {
$this->fieldArrayClean($tfields);
$this->fieldClean($name);
- $schema = $this->schema();
-
- $sql = "ALTER TABLE {$schema}\"{$table}\" ADD ";
+ $sql = "ALTER TABLE \"{$this->_schema}\".\"{$table}\" ADD ";
if ($name != '') $sql .= "CONSTRAINT \"{$name}\" ";
$sql .= "FOREIGN KEY (\"" . join('","', $sfields) . "\") ";
- $sql .= "REFERENCES ";
// Target table needs to be fully qualified
- if ($this->hasSchemas()) {
- $sql .= "\"{$targschema}\".";
- }
- $sql .= "\"{$targtable}\"(\"" . join('","', $tfields) . "\") ";
+ $sql .= "REFERENCES \"{$targschema}\".\"{$targtable}\"(\"" . join('","', $tfields) . "\") ";
if ($match != $this->fkmatches[0]) $sql .= " {$match}";
if ($upd_action != $this->fkactions[0]) $sql .= " ON UPDATE {$upd_action}";
if ($del_action != $this->fkactions[0]) $sql .= " ON DELETE {$del_action}";
@@ -4208,10 +4176,8 @@ class Postgres extends ADODB_base {
$this->fieldClean($typin);
$this->fieldClean($typout);
- $schema = $this->schema();
-
$sql = "
- CREATE TYPE {$schema}\"{$typname}\" (
+ CREATE TYPE \"{$this->_schema}\".\"{$typname}\" (
INPUT = \"{$typin}\",
OUTPUT = \"{$typout}\",
INTERNALLENGTH = {$typlen}";
@@ -4513,11 +4479,9 @@ class Postgres extends ADODB_base {
$this->fieldClean($table);
if (!in_array($event, $this->rule_events)) return -1;
- $schema = $this->schema();
-
$sql = "CREATE";
if ($replace) $sql .= " OR REPLACE";
- $sql .= " RULE \"{$name}\" AS ON {$event} TO {$schema}\"{$table}\"";
+ $sql .= " RULE \"{$name}\" AS ON {$event} TO \"{$this->_schema}\".\"{$table}\"";
// Can't escape WHERE clause
if ($where != '') $sql .= " WHERE {$where}";
$sql .= " DO";
@@ -4648,10 +4612,7 @@ class Postgres extends ADODB_base {
}
// Table name
- $tgdef .= " ON ";
- if($this->hasSchemas())
- $tgdef .= "\"{$this->_schema}\".";
- $tgdef .= "\"{$trigger['relname']}\" ";
+ $tgdef .= " ON \"{$this->_schema}\".\"{$trigger['relname']}\" ";
// Deferrability
if ($trigger['tgisconstraint']) {
@@ -4859,9 +4820,7 @@ class Postgres extends ADODB_base {
$opr = $this->getOperator($operator_oid);
$this->fieldClean($opr->fields['oprname']);
- $schema = $this->schema();
-
- $sql = "DROP OPERATOR {$schema}{$opr->fields['oprname']} (";
+ $sql = "DROP OPERATOR \"{$this->_schema}\".{$opr->fields['oprname']} (";
// Quoting or formatting here???
if ($opr->fields['oprleftname'] !== null) $sql .= $opr->fields['oprleftname'] . ', ';
else $sql .= "NONE, ";
@@ -5396,8 +5355,7 @@ class Postgres extends ADODB_base {
$this->beginTransaction();
- $schema = $this->schema();
- $sql = "CREATE AGGREGATE {$schema}\"{$name}\" (BASETYPE = \"{$basetype}\", SFUNC = \"{$sfunc}\", STYPE = \"{$stype}\"";
+ $sql = "CREATE AGGREGATE \"{$this->_schema}\".\"{$name}\" (BASETYPE = \"{$basetype}\", SFUNC = \"{$sfunc}\", STYPE = \"{$stype}\"";
if(trim($ffunc) != '') $sql .= ", FINALFUNC = \"{$ffunc}\"";
if(trim($initcond) != '') $sql .= ", INITCOND = \"{$initcond}\"";
if(trim($sortop) != '') $sql .= ", SORTOP = \"{$sortop}\"";
@@ -6380,7 +6338,6 @@ class Postgres extends ADODB_base {
(!$public && sizeof($usernames) == 0 && sizeof($groupnames) == 0)) return -4;
if ($mode != 'GRANT' && $mode != 'REVOKE') return -5;
- $schema = $this->schema();
$sql = $mode;
// Grant option
@@ -6397,7 +6354,7 @@ class Postgres extends ADODB_base {
case 'view':
case 'sequence':
$this->fieldClean($object);
- $sql .= " {$schema}\"{$object}\"";
+ $sql .= " \"{$this->_schema}\".\"{$object}\"";
break;
case 'database':
$this->fieldClean($object);
@@ -6407,7 +6364,7 @@ class Postgres extends ADODB_base {
// Function comes in with $object as function OID
$fn = $this->getFunction($object);
$this->fieldClean($fn->fields['proname']);
- $sql .= " FUNCTION {$schema}\"{$fn->fields['proname']}\"({$fn->fields['proarguments']})";
+ $sql .= " FUNCTION \"{$this->_schema}\".\"{$fn->fields['proname']}\"({$fn->fields['proarguments']})";
break;
case 'language':
$this->fieldClean($object);
@@ -6746,19 +6703,17 @@ class Postgres extends ADODB_base {
function setComment($obj_type, $obj_name, $table, $comment, $basetype = NULL) {
$sql = "COMMENT ON {$obj_type} " ;
- $schema = $this->schema();
-
switch ($obj_type) {
case 'TABLE':
- $sql .= "{$schema}\"{$table}\" IS ";
+ $sql .= "\"{$this->_schema}\".\"{$table}\" IS ";
break;
case 'COLUMN':
- $sql .= "{$schema}\"{$table}\".\"{$obj_name}\" IS ";
+ $sql .= "\"{$this->_schema}\".\"{$table}\".\"{$obj_name}\" IS ";
break;
case 'SEQUENCE':
case 'VIEW':
case 'TYPE':
- $sql .= "{$schema}";
+ $sql .= "\"{$this->_schema}\".";
case 'DATABASE':
case 'ROLE':
case 'SCHEMA':
@@ -6770,10 +6725,10 @@ class Postgres extends ADODB_base {
$sql .= "\"{$obj_name}\" IS ";
break;
case 'FUNCTION':
- $sql .= "{$schema}{$obj_name} IS ";
+ $sql .= "\"{$this->_schema}\".{$obj_name} IS ";
break;
case 'AGGREGATE':
- $sql .= "{$schema}\"{$obj_name}\" (\"{$basetype}\") IS ";
+ $sql .= "\"{$this->_schema}\".\"{$obj_name}\" (\"{$basetype}\") IS ";
break;
default:
// Unknown object type
@@ -7108,7 +7063,7 @@ class Postgres extends ADODB_base {
$sql .= join('","', $show) . "\" FROM ";
}
- if ($this->hasSchemas() && isset($_REQUEST['schema'])) {
+ if (isset($_REQUEST['schema'])) {
$this->fieldClean($_REQUEST['schema']);
$sql .= "\"{$_REQUEST['schema']}\".";
}
@@ -7288,7 +7243,7 @@ class Postgres extends ADODB_base {
*/
function browseQueryCount($query, $count) {
return $this->selectField($count, 'total');
- }
+ }
/**
* Returns a recordset of all columns in a table
@@ -7299,9 +7254,7 @@ class Postgres extends ADODB_base {
function browseRow($table, $key) {
$this->fieldClean($table);
- $schema = $this->schema();
-
- $sql = "SELECT * FROM {$schema}\"{$table}\"";
+ $sql = "SELECT * FROM \"{$this->_schema}\".\"{$table}\"";
if (is_array($key) && sizeof($key) > 0) {
$sql .= " WHERE true";
foreach ($key as $k => $v) {
@@ -7359,12 +7312,11 @@ class Postgres extends ADODB_base {
function getStatsTableTuples($table) {
$this->clean($table);
- $sql = 'SELECT * FROM pg_stat_all_tables WHERE';
- if ($this->hasSchemas()) $sql .= " schemaname='{$this->_schema}' AND";
- $sql .= " relname='{$table}'";
+ $sql = "SELECT * FROM pg_stat_all_tables
+ WHERE schemaname=\'{$this->_schema}\' AND relname='{$table}'";
return $this->selectSet($sql);
- }
+ }
/**
* Fetches I/0 statistics for a table
@@ -7374,12 +7326,11 @@ class Postgres extends ADODB_base {
function getStatsTableIO($table) {
$this->clean($table);
- $sql = 'SELECT * FROM pg_statio_all_tables WHERE';
- if ($this->hasSchemas()) $sql .= " schemaname='{$this->_schema}' AND";
- $sql .= " relname='{$table}'";
+ $sql = "SELECT * FROM pg_statio_all_tables
+ WHERE schemaname='{$this->_schema}' AND relname='{$table}'";
return $this->selectSet($sql);
- }
+ }
/**
* Fetches tuple statistics for all indexes on a table
@@ -7389,12 +7340,11 @@ class Postgres extends ADODB_base {
function getStatsIndexTuples($table) {
$this->clean($table);
- $sql = 'SELECT * FROM pg_stat_all_indexes WHERE';
- if ($this->hasSchemas()) $sql .= " schemaname='{$this->_schema}' AND";
- $sql .= " relname='{$table}' ORDER BY indexrelname";
+ $sql = "SELECT * FROM pg_stat_all_indexes
+ WHERE schemaname='{$this->_schema}' AND relname='{$table}' ORDER BY indexrelname";
return $this->selectSet($sql);
- }
+ }
/**
* Fetches I/0 statistics for all indexes on a table
@@ -7404,9 +7354,9 @@ class Postgres extends ADODB_base {
function getStatsIndexIO($table) {
$this->clean($table);
- $sql = 'SELECT * FROM pg_statio_all_indexes WHERE';
- if ($this->hasSchemas()) $sql .= " schemaname='{$this->_schema}' AND";
- $sql .= " relname='{$table}' ORDER BY indexrelname";
+ $sql = "SELECT * FROM pg_statio_all_indexes
+ WHERE schemaname='{$this->_schema}' AND relname='{$table}'
+ ORDER BY indexrelname";
return $this->selectSet($sql);
}
@@ -7460,7 +7410,6 @@ class Postgres extends ADODB_base {
function hasReadOnlyQueries() { return true; }
function hasRecluster() { return true; }
function hasRoles() { return true; }
- function hasSchemas() { return true; }
function hasSequenceAlterSchema() { return true; }
function hasServerAdminFuncs() { return true; }
function hasSharedComments() { return true; }
diff --git a/classes/plugins/Slony.php b/classes/plugins/Slony.php
index 94061fa8..e73f9dbe 100755
--- a/classes/plugins/Slony.php
+++ b/classes/plugins/Slony.php
@@ -38,9 +38,6 @@ class Slony extends Plugin {
global $data;
- // Slony needs schemas
- if (!$data->hasSchemas()) return false;
-
// Check for the slonyversion() function and find the schema
// it's in. We put an order by and limit 1 in here to guarantee
// only finding the first one, even if there are somehow two
diff --git a/colproperties.php b/colproperties.php
index d7f2a656..0ab126e9 100644
--- a/colproperties.php
+++ b/colproperties.php
@@ -234,12 +234,10 @@
if ($isTable) {
$return_url = urlencode("colproperties.php?{$misc->href}&amp;table=$tableName&amp;column={$_REQUEST['column']}");
- $schema = $data->schema();
-
/* Browse link */
echo "\t<li><a href=\"display.php?{$misc->href}&amp;subject=column&amp;table=", urlencode($_REQUEST['table']), "&amp;column=",
urlencode($_REQUEST['column']), "&amp;return_url={$return_url}&amp;return_desc=", urlencode($lang['strback']), "&amp;query=",
- urlencode("SELECT \"{$_REQUEST['column']}\", count(*) AS \"count\" FROM {$schema}\"$tableName\" GROUP BY \"{$_REQUEST['column']}\" ORDER BY \"{$_REQUEST['column']}\"") , "\">{$lang['strbrowse']}</a></li>\n";
+ urlencode("SELECT \"{$_REQUEST['column']}\", count(*) AS \"count\" FROM \"{$data->_schema}\".\"$tableName\" GROUP BY \"{$_REQUEST['column']}\" ORDER BY \"{$_REQUEST['column']}\"") , "\">{$lang['strbrowse']}</a></li>\n";
/* Edit link */
echo "\t<li><a href=\"colproperties.php?action=properties&amp;{$misc->href}&amp;table=", urlencode($_REQUEST['table']),
diff --git a/constraints.php b/constraints.php
index eb925951..ce052aaf 100644
--- a/constraints.php
+++ b/constraints.php
@@ -46,11 +46,9 @@
// Unserialize target and fetch appropriate table. This is a bit messy
// because the table could be in another schema.
- if ($data->hasSchemas())
- $data->setSchema($_REQUEST['target']['schemaname']);
+ $data->setSchema($_REQUEST['target']['schemaname']);
$attrs = $data->getTableAttributes($_REQUEST['target']['tablename']);
- if ($data->hasSchemas())
- $data->setSchema($_REQUEST['schema']);
+ $data->setSchema($_REQUEST['schema']);
$selColumns = new XHTML_select('TableColumnList', true, 10);
$selColumns->set_style('width: 15em;');
@@ -192,7 +190,7 @@
$key = array('schemaname' => $tables->fields['nspname'], 'tablename' => $tables->fields['relname']);
$key = serialize($key);
echo "<option value=\"", htmlspecialchars($key), "\">";
- if ($data->hasSchemas() && $tables->fields['nspname'] != $_REQUEST['schema']) {
+ if ($tables->fields['nspname'] != $_REQUEST['schema']) {
echo htmlspecialchars($tables->fields['nspname']), '.';
}
echo htmlspecialchars($tables->fields['relname']), "</option>\n";
diff --git a/database.php b/database.php
index 7ee241c9..dfccf2cd 100755
--- a/database.php
+++ b/database.php
@@ -49,8 +49,7 @@
// Output list of filters. This is complex due to all the 'has' and 'conf' feature possibilities
echo "<select name=\"filter\">\n";
echo "\t<option value=\"\"", ($_REQUEST['filter'] == '') ? ' selected="selected"' : '', ">{$lang['strallobjects']}</option>\n";
- if ($data->hasSchemas())
- echo "\t<option value=\"SCHEMA\"", ($_REQUEST['filter'] == 'SCHEMA') ? ' selected="selected"' : '', ">{$lang['strschemas']}</option>\n";
+ echo "\t<option value=\"SCHEMA\"", ($_REQUEST['filter'] == 'SCHEMA') ? ' selected="selected"' : '', ">{$lang['strschemas']}</option>\n";
echo "\t<option value=\"TABLE\"", ($_REQUEST['filter'] == 'TABLE') ? ' selected="selected"' : '', ">{$lang['strtables']}</option>\n";
echo "\t<option value=\"VIEW\"", ($_REQUEST['filter'] == 'VIEW') ? ' selected="selected"' : '', ">{$lang['strviews']}</option>\n";
echo "\t<option value=\"SEQUENCE\"", ($_REQUEST['filter'] == 'SEQUENCE') ? ' selected="selected"' : '', ">{$lang['strsequences']}</option>\n";
@@ -165,41 +164,31 @@
}
}
- // Generate schema prefix
- if ($data->hasSchemas())
- $prefix = $rs->fields['schemaname'];
- else
- $prefix = '';
-
switch ($curr) {
case 'SCHEMA':
echo "<li><a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", $misc->printVal($rs->fields['name']), "\">", _highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'TABLE':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"tables.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"tables.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"redirect.php?subject=table&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;table=",
urlencode($rs->fields['name']), "\">", _highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'VIEW':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"views.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"views.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"redirect.php?subject=view&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;view=",
urlencode($rs->fields['name']), "\">", _highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'SEQUENCE':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"sequences.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"sequences.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"sequences.php?subject=sequence&amp;action=properties&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']),
"&amp;sequence=", urlencode($rs->fields['name']), "\">", _highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'COLUMNTABLE':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"tblproperties.php?subject=table&amp;{$misc->href}&amp;table=", urlencode($rs->fields['relname']), "&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['relname']), "</a>.";
echo "<a href=\"colproperties.php?{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;table=",
urlencode($rs->fields['relname']), "&amp;column=", urlencode($rs->fields['name']), "\">",
@@ -207,92 +196,80 @@
break;
case 'COLUMNVIEW':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "</a>.";
- echo "<a href=\"viewproperties.php?subject=view&amp;{$misc->href}&amp;view=", urlencode($rs->fields['relname']), "&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['relname']), "</a>.";
+ echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
+ echo "<a href=\"viewproperties.php?subject=view&amp;{$misc->href}&amp;view=", urlencode($rs->fields['relname']), "&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['relname']), "</a>.";
echo "<a href=\"colproperties.php?{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;view=",
urlencode($rs->fields['relname']), "&amp;column=", urlencode($rs->fields['name']), "\">",
_highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'INDEX':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "}</a>.";
+ echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "}</a>.";
echo "<a href=\"redirect.php?subject=table&amp;{$misc->href}&amp;table=", urlencode($rs->fields['relname']), "&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['relname']), "</a>.";
echo "<a href=\"indexes.php?{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;table=", urlencode($rs->fields['relname']), "\">", _highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'CONSTRAINTTABLE':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"redirect.php?subject=table&amp;{$misc->href}&amp;table=", urlencode($rs->fields['relname']), "&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['relname']), "</a>.";
echo "<a href=\"constraints.php?{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;table=",
urlencode($rs->fields['relname']), "\">", _highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'CONSTRAINTDOMAIN':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"domains.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"domains.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"domains.php?action=properties&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;domain=", urlencode($rs->fields['relname']), "\">",
$misc->printVal($rs->fields['relname']), '.', _highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'TRIGGER':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"redirect.php?subject=table&amp;{$misc->href}&amp;table=", urlencode($rs->fields['relname']), "&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['relname']), "</a>.";
echo "<a href=\"triggers.php?{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;table=", urlencode($rs->fields['relname']), "\">",
_highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'RULETABLE':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"redirect.php?subject=table&amp;{$misc->href}&amp;table=", urlencode($rs->fields['relname']), "&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['relname']), "</a>.";
echo "<a href=\"rules.php?subject=table&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;reltype=table&amp;table=",
urlencode($rs->fields['relname']), "\">", _highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'RULEVIEW':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"redirect.php?subject=view&amp;{$misc->href}&amp;view=", urlencode($rs->fields['relname']), "&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['relname']), "</a>.";
echo "<a href=\"rules.php?subject=view&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;reltype=view&amp;view=",
urlencode($rs->fields['relname']), "\">", _highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'FUNCTION':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"functions.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"functions.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"functions.php?action=properties&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;function=",
urlencode($rs->fields['name']), "&amp;function_oid=", urlencode($rs->fields['oid']), "\">",
_highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'TYPE':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"types.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"types.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"types.php?action=properties&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;type=",
urlencode($rs->fields['name']), "\">", _highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'DOMAIN':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"domains.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"domains.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"domains.php?action=properties&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;domain=",
urlencode($rs->fields['name']), "\">", _highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'OPERATOR':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"operators.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"operators.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"operators.php?action=properties&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "&amp;operator=",
urlencode($rs->fields['name']), "&amp;operator_oid=", urlencode($rs->fields['oid']) ,"\">", _highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'CONVERSION':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"conversions.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"conversions.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"conversions.php?{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']),
"\">", _highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
@@ -301,15 +278,13 @@
break;
case 'AGGREGATE':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"aggregates.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"aggregates.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"aggregates.php?{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">",
_highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'OPCLASS':
echo "<li>";
- if (!empty($prefix))
- echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($prefix), "\">", $misc->printVal($prefix), "</a>.";
+ echo "<a href=\"redirect.php?subject=schema&amp;{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">", $misc->printVal($rs->fields['schemaname']), "</a>.";
echo "<a href=\"opclasses.php?{$misc->href}&amp;schema=", urlencode($rs->fields['schemaname']), "\">",
_highlight($misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
@@ -889,9 +864,6 @@
$reqvars = $misc->getRequestVars('database');
$tabs = $misc->getNavTabs('database');
- if (!$data->hasSchemas()) {
- $tabs = array_merge($misc->getNavTabs('schema'), $tabs);
- }
$items = $misc->adjustTabsForTree($tabs);
diff --git a/dataexport.php b/dataexport.php
index acfd082f..ca6f7d32 100644
--- a/dataexport.php
+++ b/dataexport.php
@@ -92,7 +92,7 @@
if (isset($_REQUEST['query'])) $_REQUEST['query'] = trim(urldecode($_REQUEST['query']));
// Set the schema search path
- if ($data->hasSchemas() && isset($_REQUEST['search_path'])) {
+ if (isset($_REQUEST['search_path'])) {
$data->setSearchPath(array_map('trim',explode(',',$_REQUEST['search_path'])));
}
diff --git a/dbexport.php b/dbexport.php
index f429404d..2c922607 100644
--- a/dbexport.php
+++ b/dbexport.php
@@ -82,12 +82,8 @@
// If we are 7.4 or higher, assume they are using 7.4 pg_dump and
// set dump schema as well. Also, mixed case dumping has been fixed
// then..
- $cmd .= " -t " . $misc->escapeShellArg($_REQUEST[$_REQUEST['subject']]);
- // Even though they're using a schema-enabled pg_dump, the backend database
- // may not support schemas.
- if ($data->hasSchemas()) {
- $cmd .= " -n " . $misc->escapeShellArg($_REQUEST['schema']);
- }
+ $cmd .= " -t " . $misc->escapeShellArg($_REQUEST[$_REQUEST['subject']])
+ . " -n " . $misc->escapeShellArg($_REQUEST['schema']);
}
else {
// This is an annoying hack needed to work around a bug in dumping
diff --git a/display.php b/display.php
index 31887ffb..60971b7e 100644
--- a/display.php
+++ b/display.php
@@ -301,7 +301,7 @@
$key = array();
// Set the schema search path
- if ($data->hasSchemas() && isset($_REQUEST['search_path'])) {
+ if (isset($_REQUEST['search_path'])) {
if ($data->setSearchPath(array_map('trim',explode(',',$_REQUEST['search_path']))) != 0) {
return;
}
diff --git a/info.php b/info.php
index cc992b43..98ae6d5a 100644
--- a/info.php
+++ b/info.php
@@ -50,9 +50,7 @@
echo "<h3>{$lang['strreferringtables']}</h3>\n";
echo "<table>\n";
echo "\t<tr>\n\t\t";
- if ($data->hasSchemas()) {
- echo "<th class=\"data\">{$lang['strschema']}</th>";
- }
+ echo "<th class=\"data\">{$lang['strschema']}</th>";
echo "<th class=\"data\">{$lang['strtable']}</th>";
echo "<th class=\"data\">{$lang['strname']}</th><th class=\"data\">{$lang['strdefinition']}</th>";
echo "<th class=\"data\">{$lang['stractions']}</th>\n";
@@ -62,9 +60,7 @@
while (!$referrers->EOF) {
$id = ( ($i % 2 ) == 0 ? '1' : '2' );
echo "\t<tr>\n\t\t";
- if ($data->hasSchemas()) {
- echo "<td class=\"data{$id}\">", $misc->printVal($referrers->fields['nspname']), "</td>";
- }
+ echo "<td class=\"data{$id}\">", $misc->printVal($referrers->fields['nspname']), "</td>";
echo "<td class=\"data{$id}\">", $misc->printVal($referrers->fields['relname']), "</td>";
echo "<td class=\"data{$id}\">", $misc->printVal($referrers->fields['conname']), "</td>";
echo "<td class=\"data{$id}\">", $misc->printVal($referrers->fields['consrc']), "</td>";
@@ -84,9 +80,7 @@
echo "<h3>{$lang['strparenttables']}</h3>\n";
echo "<table>\n";
echo "\t<tr>\n\t\t";
- if ($data->hasSchemas()) {
- echo "<th class=\"data\">{$lang['strschema']}</th>";
- }
+ echo "<th class=\"data\">{$lang['strschema']}</th>";
echo "\t\t<th class=\"data\">{$lang['strtable']}</th>";
echo "<th class=\"data\">{$lang['stractions']}</th>\n";
echo "\t</tr>\n";
@@ -95,9 +89,7 @@
while (!$parents->EOF) {
$id = ( ($i % 2 ) == 0 ? '1' : '2' );
echo "\t<tr>\n";
- if ($data->hasSchemas()) {
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($parents->fields['nspname']), "</td>";
- }
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($parents->fields['nspname']), "</td>";
echo "<td class=\"data{$id}\">", $misc->printVal($parents->fields['relname']), "</td>";
echo "<td class=\"opbutton{$id}\"><a href=\"tblproperties.php?{$misc->href}",
"&amp;schema=", urlencode($parents->fields['nspname']),
@@ -115,9 +107,7 @@
echo "<h3>{$lang['strchildtables']}</h3>\n";
echo "<table>\n";
echo "\t<tr>\n";
- if ($data->hasSchemas()) {
- echo "<th class=\"data\">{$lang['strschema']}</th>";
- }
+ echo "<th class=\"data\">{$lang['strschema']}</th>";
echo "\t\t<th class=\"data\">{$lang['strtable']}</th>";
echo "<th class=\"data\">{$lang['stractions']}</th>\n";
echo "\t</tr>\n";
@@ -126,9 +116,7 @@
while (!$children->EOF) {
$id = ( ($i % 2 ) == 0 ? '1' : '2' );
echo "\t<tr>\n";
- if ($data->hasSchemas()) {
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($children->fields['schemaname']), "</td>";
- }
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($children->fields['schemaname']), "</td>";
echo "<td class=\"data{$id}\">", $misc->printVal($children->fields['relname']), "</td>";
echo "<td class=\"opbutton{$id}\"><a href=\"tblproperties.php?{$misc->href}",
"&amp;schema=", urlencode($children->fields['schemaname']),
diff --git a/libraries/lib.inc.php b/libraries/lib.inc.php
index 4e1345b8..d425dc15 100644
--- a/libraries/lib.inc.php
+++ b/libraries/lib.inc.php
@@ -177,7 +177,7 @@
// If schema is defined and database supports schemas, then set the
// schema explicitly.
- if (isset($_REQUEST['database']) && isset($_REQUEST['schema']) && $data->hasSchemas()) {
+ if (isset($_REQUEST['database']) && isset($_REQUEST['schema'])) {
$status = $data->setSchema($_REQUEST['schema']);
if ($status != 0) {
echo $lang['strbadschema'];
diff --git a/schemas.php b/schemas.php
index ff3914f6..9a22f52a 100755
--- a/schemas.php
+++ b/schemas.php
@@ -24,61 +24,56 @@
$misc->printMsg($msg);
// Check that the DB actually supports schemas
- if ($data->hasSchemas()) {
- $schemas = $data->getSchemas();
-
- $columns = array(
- 'schema' => array(
- 'title' => $lang['strschema'],
- 'field' => field('nspname'),
- 'url' => "redirect.php?subject=schema&amp;{$misc->href}&amp;",
- 'vars' => array('schema' => 'nspname'),
- ),
- 'owner' => array(
- 'title' => $lang['strowner'],
- 'field' => field('nspowner'),
- ),
- 'actions' => array(
- 'title' => $lang['stractions'],
- ),
- 'comment' => array(
- 'title' => $lang['strcomment'],
- 'field' => field('nspcomment'),
- ),
- );
-
- $actions = array(
- 'multiactions' => array(
- 'keycols' => array('nsp' => 'nspname'),
- 'url' => 'schemas.php',
- ),
- 'drop' => array(
- 'title' => $lang['strdrop'],
- 'url' => "schemas.php?action=drop&amp;{$misc->href}&amp;",
- 'vars' => array('nsp' => 'nspname'),
- 'multiaction' => 'drop',
- ),
- 'privileges' => array(
- 'title' => $lang['strprivileges'],
- 'url' => "privileges.php?subject=schema&amp;{$misc->href}&amp;",
- 'vars' => array('schema' => 'nspname'),
- ),
- 'alter' => array(
- 'title' => $lang['stralter'],
- 'url' => "schemas.php?action=alter&amp;{$misc->href}&amp;",
- 'vars' => array('schema' => 'nspname'),
- ),
- );
-
- if (!$data->hasAlterSchema()) unset($actions['alter']);
-
- $misc->printTable($schemas, $columns, $actions, $lang['strnoschemas']);
-
- echo "<p><a class=\"navlink\" href=\"schemas.php?action=create&amp;{$misc->href}\">{$lang['strcreateschema']}</a></p>\n";
- } else {
- // If the database does not support schemas...
- echo "<p>{$lang['strnoschemas']}</p>\n";
- }
+ $schemas = $data->getSchemas();
+
+ $columns = array(
+ 'schema' => array(
+ 'title' => $lang['strschema'],
+ 'field' => field('nspname'),
+ 'url' => "redirect.php?subject=schema&amp;{$misc->href}&amp;",
+ 'vars' => array('schema' => 'nspname'),
+ ),
+ 'owner' => array(
+ 'title' => $lang['strowner'],
+ 'field' => field('nspowner'),
+ ),
+ 'actions' => array(
+ 'title' => $lang['stractions'],
+ ),
+ 'comment' => array(
+ 'title' => $lang['strcomment'],
+ 'field' => field('nspcomment'),
+ ),
+ );
+
+ $actions = array(
+ 'multiactions' => array(
+ 'keycols' => array('nsp' => 'nspname'),
+ 'url' => 'schemas.php',
+ ),
+ 'drop' => array(
+ 'title' => $lang['strdrop'],
+ 'url' => "schemas.php?action=drop&amp;{$misc->href}&amp;",
+ 'vars' => array('nsp' => 'nspname'),
+ 'multiaction' => 'drop',
+ ),
+ 'privileges' => array(
+ 'title' => $lang['strprivileges'],
+ 'url' => "privileges.php?subject=schema&amp;{$misc->href}&amp;",
+ 'vars' => array('schema' => 'nspname'),
+ ),
+ 'alter' => array(
+ 'title' => $lang['stralter'],
+ 'url' => "schemas.php?action=alter&amp;{$misc->href}&amp;",
+ 'vars' => array('schema' => 'nspname'),
+ ),
+ );
+
+ if (!$data->hasAlterSchema()) unset($actions['alter']);
+
+ $misc->printTable($schemas, $columns, $actions, $lang['strnoschemas']);
+
+ echo "<p><a class=\"navlink\" href=\"schemas.php?action=create&amp;{$misc->href}\">{$lang['strcreateschema']}</a></p>\n";
}
/**
diff --git a/sequences.php b/sequences.php
index e46e0593..06b7725c 100644
--- a/sequences.php
+++ b/sequences.php
@@ -442,7 +442,7 @@
if (!isset($_POST['name'])) $_POST['name'] = $_REQUEST['sequence'];
if (!isset($_POST['comment'])) $_POST['comment'] = $sequence->fields['seqcomment'];
if (!isset($_POST['owner'])) $_POST['owner'] = $sequence->fields['seqowner'];
- if (!isset($_POST['newschema']) && $data->hasSchemas()) $_POST['newschema'] = $sequence->fields['nspname'];
+ if (!isset($_POST['newschema'])) $_POST['newschema'] = $sequence->fields['nspname'];
// Handle Checkbox Value
$sequence->fields['is_cycled'] = $data->phpBool($sequence->fields['is_cycled']);
diff --git a/sql.php b/sql.php
index 316cc259..85a5e00f 100644
--- a/sql.php
+++ b/sql.php
@@ -111,7 +111,7 @@
$misc->printTitle($lang['strqueryresults']);
// Set the schema search path
- if ($data->hasSchemas() && isset($_REQUEST['search_path'])) {
+ if (isset($_REQUEST['search_path'])) {
if ($data->setSearchPath(array_map('trim',explode(',',$_REQUEST['search_path']))) != 0) {
$misc->printFooter();
exit;
diff --git a/sqledit.php b/sqledit.php
index 95e0e071..10abcc1d 100644
--- a/sqledit.php
+++ b/sqledit.php
@@ -28,9 +28,7 @@
if ($action == 'find') {
$onchange .= "'&amp;term=' + encodeURI(term.value) + '&amp;filter=' + encodeURI(filter.value) + '&amp;'\"";
} else {
- $onchange .= "'&amp;query=' + encodeURI(query.value) ";
- if ($data->hasSchemas()) $onchange .= "+ '&amp;search_path=' + encodeURI(search_path.value) ";
- $onchange .= "+ (paginate.checked ? '&amp;paginate=on' : '') + '&amp;'\"";
+ $onchange .= "'&amp;query=' + encodeURI(query.value) + '&amp;search_path=' + encodeURI(search_path.value) + (paginate.checked ? '&amp;paginate=on' : '') + '&amp;'\"";
}
$misc->printConnection($onchange);
@@ -61,8 +59,7 @@
// Output list of filters. This is complex due to all the 'has' and 'conf' feature possibilities
echo "<select name=\"filter\">\n";
echo "\t<option value=\"\"", ($_REQUEST['filter'] == '') ? ' selected="selected"' : '', ">{$lang['strallobjects']}</option>\n";
- if ($data->hasSchemas())
- echo "\t<option value=\"SCHEMA\"", ($_REQUEST['filter'] == 'SCHEMA') ? ' selected="selected"' : '', ">{$lang['strschemas']}</option>\n";
+ echo "\t<option value=\"SCHEMA\"", ($_REQUEST['filter'] == 'SCHEMA') ? ' selected="selected"' : '', ">{$lang['strschemas']}</option>\n";
echo "\t<option value=\"TABLE\"", ($_REQUEST['filter'] == 'TABLE') ? ' selected="selected"' : '', ">{$lang['strtables']}</option>\n";
echo "\t<option value=\"VIEW\"", ($_REQUEST['filter'] == 'VIEW') ? ' selected="selected"' : '', ">{$lang['strviews']}</option>\n";
echo "\t<option value=\"SEQUENCE\"", ($_REQUEST['filter'] == 'SEQUENCE') ? ' selected="selected"' : '', ">{$lang['strsequences']}</option>\n";
@@ -112,15 +109,13 @@
echo "<form action=\"sql.php\" method=\"post\" target=\"detail\">\n";
_printConnection();
echo "\n";
- if ($data->hasSchemas()) {
- if (!isset($_REQUEST['search_path']))
- $_REQUEST['search_path'] = implode(',',$data->getSearchPath());
-
- echo "<p><label>";
- $misc->printHelp($lang['strsearchpath'], 'pg.schema.search_path');
- echo ": <input type=\"text\" name=\"search_path\" size=\"50\" value=\"",
- htmlspecialchars($_REQUEST['search_path']), "\" /></label></p>\n";
- }
+ if (!isset($_REQUEST['search_path']))
+ $_REQUEST['search_path'] = implode(',',$data->getSearchPath());
+
+ echo "<p><label>";
+ $misc->printHelp($lang['strsearchpath'], 'pg.schema.search_path');
+ echo ": <input type=\"text\" name=\"search_path\" size=\"50\" value=\"",
+ htmlspecialchars($_REQUEST['search_path']), "\" /></label></p>\n";
echo "<textarea style=\"width: 100%;\" rows=\"10\" cols=\"50\" name=\"query\">",
htmlspecialchars($_SESSION['sqlquery']), "</textarea>\n";
diff --git a/triggers.php b/triggers.php
index 41674b89..d597b63d 100644
--- a/triggers.php
+++ b/triggers.php
@@ -314,7 +314,6 @@
'vars' => array('trigger' => 'tgname'),
),
);
- if(!$data->hasSchemas()) unset($columns['function']['vars']['schema']);
if($data->hasDisableTriggers()) {
if(!$data->phpBool($triggers->fields["tgenabled"])) {
$actions['enable'] = array(
diff --git a/views.php b/views.php
index da3bbba0..cd73f98e 100644
--- a/views.php
+++ b/views.php
@@ -235,27 +235,23 @@
//if we have schemas we need to specify the correct schema for each table we're retrieiving
//with getTableAttributes
- $curSchema = $data->hasSchemas() ? $data->_schema : NULL;
+ $curSchema = $data->_schema;
for ($i = 0; $i < $tblCount; $i++) {
- if ($data->hasSchemas() && $data->_schema != $arrSelTables[$i]['schemaname']) {
+ if ($data->_schema != $arrSelTables[$i]['schemaname']) {
$data->setSchema($arrSelTables[$i]['schemaname']);
}
$attrs = $data->getTableAttributes($arrSelTables[$i]['tablename']);
while (!$attrs->EOF) {
- if ($data->hasSchemas() ) {
- $arrFields["{$arrSelTables[$i]['schemaname']}.{$arrSelTables[$i]['tablename']}.{$attrs->fields['attname']}"] = serialize(array('schemaname' => $arrSelTables[$i]['schemaname'], 'tablename' => $arrSelTables[$i]['tablename'], 'fieldname' => $attrs->fields['attname']) );
- }
- else {
- $arrFields["{$arrSelTables[$i]['tablename']}.{$attrs->fields['attname']}"] = serialize(array('schemaname' => NULL, 'tablename' => $arrSelTables[$i]['tablename'], 'fieldname' => $attrs->fields['attname']) );
- }
+ $arrFields["{$arrSelTables[$i]['schemaname']}.{$arrSelTables[$i]['tablename']}.{$attrs->fields['attname']}"] = serialize(array(
+ 'schemaname' => $arrSelTables[$i]['schemaname'],
+ 'tablename' => $arrSelTables[$i]['tablename'],
+ 'fieldname' => $attrs->fields['attname'])
+ );
$attrs->moveNext();
}
- //reset back to our original schema in case we switched from it
- if ($data->hasSchemas() ) {
- $data->setSchema($curSchema);
- }
+ $data->setSchema($curSchema);
}
asort($arrFields);
@@ -367,12 +363,7 @@
$arrTmp = array();
$arrTmp['schemaname'] = $tables->fields['nspname'];
$arrTmp['tablename'] = $tables->fields['relname'];
- if ($data->hasSchemas() ) { //if schemas aren't available don't show them in the interface
- $arrTables[$tables->fields['nspname'] . '.' . $tables->fields['relname']] = serialize($arrTmp);
- }
- else {
- $arrTables[$tables->fields['relname']] = serialize($arrTmp);
- }
+ $arrTables[$tables->fields['nspname'] . '.' . $tables->fields['relname']] = serialize($arrTmp);
$tables->moveNext();
}
echo GUI::printCombo($arrTables, 'formTables[]', false, '', true);
@@ -460,18 +451,15 @@
$arrTmp = unserialize($curField);
if (! empty($_POST['dblFldMeth']) ) { // doublon control
if (empty($tmpHsh[$arrTmp['fieldname']])) { // field does not exist
- $selFields .= $data->hasSchemas() ? "\"{$arrTmp['schemaname']}\"." : '';
- $selFields .= "\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\", ";
+ $selFields .= "\"{$arrTmp['schemaname']}\".\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\", ";
$tmpHsh[$arrTmp['fieldname']] = 1;
} else if ($_POST['dblFldMeth'] == 'rename') { // field exist and must be renamed
$tmpHsh[$arrTmp['fieldname']]++;
- $selFields .= $data->hasSchemas() ? "\"{$arrTmp['schemaname']}\"." : '';
- $selFields .= "\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\" AS \"{$arrTmp['schemaname']}_{$arrTmp['tablename']}_{$arrTmp['fieldname']}{$tmpHsh[$arrTmp['fieldname']]}\", ";
+ $selFields .= "\"{$arrTmp['schemaname']}\".\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\" AS \"{$arrTmp['schemaname']}_{$arrTmp['tablename']}_{$arrTmp['fieldname']}{$tmpHsh[$arrTmp['fieldname']]}\", ";
}
/* field already exist, just ignore this one */
} else { // no doublon control
- $selFields .= $data->hasSchemas() ? "\"{$arrTmp['schemaname']}\"." : '';
- $selFields .= "\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\", ";
+ $selFields .= "\"{$arrTmp['schemaname']}\".\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\", ";
}
}
@@ -502,8 +490,8 @@
$arrLeftLink = unserialize($curLink['leftlink']);
$arrRightLink = unserialize($curLink['rightlink']);
- $tbl1 = $data->hasSchemas() ? "\"{$arrLeftLink['schemaname']}\".\"{$arrLeftLink['tablename']}\"" : $arrLeftLink['tablename'];
- $tbl2 = $data->hasSchemas() ? "\"{$arrRightLink['schemaname']}\".\"{$arrRightLink['tablename']}\"" : $arrRightLink['tablename'];
+ $tbl1 = "\"{$arrLeftLink['schemaname']}\".\"{$arrLeftLink['tablename']}\"";
+ $tbl2 = "\"{$arrRightLink['schemaname']}\".\"{$arrRightLink['tablename']}\"";
if ( (!in_array($curLink, $arrJoined) && in_array($tbl1, $arrUsedTbls)) || !count($arrJoined) ) {
@@ -511,12 +499,8 @@
// This can (and should be) more optimized for multi-column foreign keys
$adj_tbl2 = in_array($tbl2, $arrUsedTbls) ? "$tbl2 AS alias_ppa_" . mktime() : $tbl2;
- if ($data->hasSchemas() ) {
- $linkFields .= strlen($linkFields) ? "{$curLink['operator']} $adj_tbl2 ON (\"{$arrLeftLink['schemaname']}\".\"{$arrLeftLink['tablename']}\".\"{$arrLeftLink['fieldname']}\" = \"{$arrRightLink['schemaname']}\".\"{$arrRightLink['tablename']}\".\"{$arrRightLink['fieldname']}\") " : "$tbl1 {$curLink['operator']} $adj_tbl2 ON (\"{$arrLeftLink['schemaname']}\".\"{$arrLeftLink['tablename']}\".\"{$arrLeftLink['fieldname']}\" = \"{$arrRightLink['schemaname']}\".\"{$arrRightLink['tablename']}\".\"{$arrRightLink['fieldname']}\") ";
- }
- else {
- $linkFields .= strlen($linkFields) ? "{$curLink['operator']} $adj_tbl2 ON (\"{$arrLeftLink['tablename']}\".\"{$arrLeftLink['fieldname']}\" = \"{$arrRightLink['tablename']}\".\"{$arrRightLink['fieldname']}\") " : "$tbl1 {$curLink['operator']} $adj_tbl2 ON (\"{$arrLeftLink['tablename']}\".\"{$arrLeftLink['fieldname']}\" = \"{$arrRightLink['tablename']}\".\"{$arrRightLink['fieldname']}\") ";
- }
+ $linkFields .= strlen($linkFields) ? "{$curLink['operator']} $adj_tbl2 ON (\"{$arrLeftLink['schemaname']}\".\"{$arrLeftLink['tablename']}\".\"{$arrLeftLink['fieldname']}\" = \"{$arrRightLink['schemaname']}\".\"{$arrRightLink['tablename']}\".\"{$arrRightLink['fieldname']}\") "
+ : "$tbl1 {$curLink['operator']} $adj_tbl2 ON (\"{$arrLeftLink['schemaname']}\".\"{$arrLeftLink['tablename']}\".\"{$arrLeftLink['fieldname']}\" = \"{$arrRightLink['schemaname']}\".\"{$arrRightLink['tablename']}\".\"{$arrRightLink['fieldname']}\") ";
$arrJoined[] = $curLink;
if (!in_array($tbl1, $arrUsedTbls) ) $arrUsedTbls[] = $tbl1;
@@ -533,12 +517,7 @@
if (!strlen($linkFields) ) {
foreach ($_POST['formTables'] AS $curTable) {
$arrTmp = unserialize($curTable);
- if ($data->hasSchemas() ) {
- $linkFields .= strlen($linkFields) ? ", \"{$arrTmp['schemaname']}\".\"{$arrTmp['tablename']}\"" : "\"{$arrTmp['schemaname']}\".\"{$arrTmp['tablename']}\"";
- }
- else {
- $linkFields .= strlen($linkFields) ? ", \"{$arrTmp['tablename']}\"" : "\"{$arrTmp['tablename']}\"";
- }
+ $linkFields .= strlen($linkFields) ? ", \"{$arrTmp['schemaname']}\".\"{$arrTmp['tablename']}\"" : "\"{$arrTmp['schemaname']}\".\"{$arrTmp['tablename']}\"";
}
}
@@ -547,12 +526,8 @@
foreach ($_POST['formCondition'] AS $curCondition) {
if (strlen($curCondition['field']) && strlen($curCondition['txt']) ) {
$arrTmp = unserialize($curCondition['field']);
- if ($data->hasSchemas() ) {
- $addConditions .= strlen($addConditions) ? " AND \"{$arrTmp['schemaname']}\".\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\" {$curCondition['operator']} '{$curCondition['txt']}' " : " \"{$arrTmp['schemaname']}\".\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\" {$curCondition['operator']} '{$curCondition['txt']}' ";
- }
- else {
- $addConditions .= strlen($addConditions) ? " AND \"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\" {$curCondition['field']} {$curCondition['operator']} '{$curCondition['txt']}' " : " \"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\" {$curCondition['operator']} '{$curCondition['txt']}' ";
- }
+ $addConditions .= strlen($addConditions) ? " AND \"{$arrTmp['schemaname']}\".\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\" {$curCondition['operator']} '{$curCondition['txt']}' "
+ : " \"{$arrTmp['schemaname']}\".\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\" {$curCondition['operator']} '{$curCondition['txt']}' ";
}
}
}