From 06c2263c185db44c5722fc32062e8849b4058c0c Mon Sep 17 00:00:00 2001 From: "Guillaume (ioguix) de Rorthais" Date: Wed, 5 Nov 2008 01:52:35 -0500 Subject: [PATCH] Remove everything about hasSchema as all supported pg version supports schema now (from pg73) --- classes/Misc.php | 16 +--- classes/Reports.php | 2 +- classes/database/Postgres.php | 155 ++++++++++++---------------------- classes/plugins/Slony.php | 3 - colproperties.php | 4 +- constraints.php | 8 +- database.php | 68 +++++---------- dataexport.php | 2 +- dbexport.php | 8 +- display.php | 2 +- info.php | 24 ++---- libraries/lib.inc.php | 2 +- schemas.php | 105 +++++++++++------------ sequences.php | 2 +- sql.php | 2 +- sqledit.php | 23 ++--- triggers.php | 1 - views.php | 63 +++++--------- 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 @@ -840,13 +840,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. @@ -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}&table=$tableName&column={$_REQUEST['column']}"); - $schema = $data->schema(); - /* Browse link */ echo "\t
  • href}&subject=column&table=", urlencode($_REQUEST['table']), "&column=", urlencode($_REQUEST['column']), "&return_url={$return_url}&return_desc=", urlencode($lang['strback']), "&query=", - urlencode("SELECT \"{$_REQUEST['column']}\", count(*) AS \"count\" FROM {$schema}\"$tableName\" GROUP BY \"{$_REQUEST['column']}\" ORDER BY \"{$_REQUEST['column']}\"") , "\">{$lang['strbrowse']}
  • \n"; + urlencode("SELECT \"{$_REQUEST['column']}\", count(*) AS \"count\" FROM \"{$data->_schema}\".\"$tableName\" GROUP BY \"{$_REQUEST['column']}\" ORDER BY \"{$_REQUEST['column']}\"") , "\">{$lang['strbrowse']}\n"; /* Edit link */ echo "\t
  • href}&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 "\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 "\n"; echo "\t\n"; - if ($data->hasSchemas()) - echo "\t\n"; + echo "\t\n"; echo "\t\n"; echo "\t\n"; echo "\t\n"; @@ -112,15 +109,13 @@ echo "
    \n"; _printConnection(); echo "\n"; - if ($data->hasSchemas()) { - if (!isset($_REQUEST['search_path'])) - $_REQUEST['search_path'] = implode(',',$data->getSearchPath()); - - echo "

    \n"; - } + if (!isset($_REQUEST['search_path'])) + $_REQUEST['search_path'] = implode(',',$data->getSearchPath()); + + echo "

    \n"; echo "\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']}' "; } } } -- 2.39.5