From 793689e30d640c9d4b7e73578ab689f83ebe14cf Mon Sep 17 00:00:00 2001 From: chriskl Date: Mon, 4 Aug 2003 08:27:27 +0000 Subject: [PATCH] always show dbs for superuser. add without oids in create table --- BUGS | 3 +-- HISTORY | 1 + TODO | 4 ++-- classes/database/Postgres.php | 27 +++++++++++++++++---------- classes/database/Postgres71.php | 4 ++-- classes/database/Postgres72.php | 6 +++++- classes/database/Postgres73.php | 3 +-- tables.php | 20 +++++++++++++++----- 8 files changed, 44 insertions(+), 24 deletions(-) diff --git a/BUGS b/BUGS index ac40252e..9f460a71 100644 --- a/BUGS +++ b/BUGS @@ -6,5 +6,4 @@ * Add owner everywhere * Cancel/ buttons everywhere * pg_dump feature!!! - - +* Add default_db_encoding support to lang files and create database diff --git a/HISTORY b/HISTORY index a21dbe31..dc6b3879 100644 --- a/HISTORY +++ b/HISTORY @@ -19,6 +19,7 @@ Version 3.1 * Default database encoding for languages * Lots of NULL value in table dump fixes (XML format changed slightly) * Convert our images to PNG format +* Allow creating tables WITHOUT OIDS Version 3.0 ----------- diff --git a/TODO b/TODO index 3e49d45c..0aafbfee 100644 --- a/TODO +++ b/TODO @@ -117,9 +117,9 @@ Miscellaneous Exotic ------ -* Support contrib/tsearch for easy full text indexes +* Support contrib/tsearch2 for easy full text indexes * -Search for object feature (chriskl, half done) -* Pivot reports +* Pivot reports (ADODB has a feature for this) Principles ---------- diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index 67cd8078..b10f1aea 100755 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres.php,v 1.130 2003/07/31 08:28:03 chriskl Exp $ + * $Id: Postgres.php,v 1.131 2003/08/04 08:27:27 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -200,7 +200,7 @@ class Postgres extends BaseDB { function &getDatabases() { global $conf; - if (isset($conf['owned_only']) && $conf['owned_only']) { + if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser($_SESSION['webdbUsername'])) { $username = $_SESSION['webdbUsername']; $this->clean($username); $clause = " AND pu.usename='{$username}'"; @@ -595,13 +595,14 @@ class Postgres extends BaseDB { * @param $length An array of field lengths * @param $notnull An array of not null * @param $default An array of default values + * @param $withoutoids True if WITHOUT OIDS, false otherwise * @return 0 success * @return -1 no fields supplied */ - function createTable($name, $fields, $field, $type, $length, $notnull, $default) { + function createTable($name, $fields, $field, $type, $length, $notnull, $default, $withoutoids) { // @@ NOTE: $default field not being cleaned - how on earth DO we clean it?? $this->fieldClean($name); - + $found = false; $sql = "CREATE TABLE \"{$name}\" ("; @@ -646,6 +647,10 @@ class Postgres extends BaseDB { $sql .= ")"; + // WITHOUT OIDS + if ($this->hasWithoutOIDs() && $withoutoids) + $sql .= ' WITHOUT OIDS'; + return $this->execute($sql); } @@ -2084,7 +2089,7 @@ class Postgres extends BaseDB { CAST('public' AS TEXT) AS schemaname, CAST(NULL AS TEXT) AS relname, relname AS name, - relacl + NULL AS relacl FROM pg_class WHERE @@ -2098,7 +2103,7 @@ class Postgres extends BaseDB { if (!is_object($acls)) return array(); // RETURN FORMAT: - // ARRAY(type, schemaname, relname, name, ARRAY(privs), ARRAY(grantoptions)) + // ARRAY(type, schemaname, relname, name, ARRAY(privs), grantor, ARRAY(grantoptions)) // Loop over the results and check to see if any of the ACLs apply to the user $temp = array(); @@ -2106,25 +2111,27 @@ class Postgres extends BaseDB { // If they own the table, then do an 'all privileges simulation' if ($acls->f['relacl'] == null) { $temp[] = array($acls->f['type'], $acls->f['schemaname'], $acls->f['relname'], $acls->f['name'], - array(), array()); + array(), $username, array()); } else { $privs = $this->_parseACL($acls->f['relacl']); + // Loop over all privs to see if we're in there foreach ($privs as $v) { // Skip non-user ACEs if ($v[0] != 'user') continue; // Skip entities that aren't us - if ($v[1] != $usernmae) continue; + if ($v[1] != $username) continue; + echo "
", var_dump($v), "
"; // OK, so it's for us... $temp[] = array($acls->f['type'], $acls->f['schemaname'], $acls->f['relname'], $acls->f['name'], - $v[2], $v[4]); + $v[2], $v[3], $v[4]); } } $acls->moveNext(); } - +echo "
", var_dump($temp), "
"; return $temp; } diff --git a/classes/database/Postgres71.php b/classes/database/Postgres71.php index 1d677f1c..f8e070c3 100644 --- a/classes/database/Postgres71.php +++ b/classes/database/Postgres71.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres71.php,v 1.35 2003/05/20 05:43:46 chriskl Exp $ + * $Id: Postgres71.php,v 1.36 2003/08/04 08:27:27 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -78,7 +78,7 @@ class Postgres71 extends Postgres { function &getDatabases() { global $conf; - if (isset($conf['owned_only']) && $conf['owned_only']) { + if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser($_SESSION['webdbUsername'])) { $username = $_SESSION['webdbUsername']; $this->clean($username); $clause = " AND pu.usename='{$username}'"; diff --git a/classes/database/Postgres72.php b/classes/database/Postgres72.php index 2880a523..a91ec7e2 100644 --- a/classes/database/Postgres72.php +++ b/classes/database/Postgres72.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres72.php,v 1.46 2003/06/01 11:53:47 chriskl Exp $ + * $Id: Postgres72.php,v 1.47 2003/08/04 08:27:27 chriskl Exp $ */ @@ -276,6 +276,10 @@ class Postgres72 extends Postgres71 { return $this->execute($sql); } + + // Capabilities + function hasWithoutOIDs() { return true; } + } ?> diff --git a/classes/database/Postgres73.php b/classes/database/Postgres73.php index 3b23a281..b94ba4ca 100644 --- a/classes/database/Postgres73.php +++ b/classes/database/Postgres73.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres73.php,v 1.55 2003/08/04 05:20:02 chriskl Exp $ + * $Id: Postgres73.php,v 1.56 2003/08/04 08:27:27 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -1028,7 +1028,6 @@ class Postgres73 extends Postgres72 { function hasDropColumn() { return true; } function hasDomains() { return true; } function hasAlterTrigger() { return true; } - function hasWithoutOIDs() { return true; } } diff --git a/tables.php b/tables.php index bff23d37..624efe08 100644 --- a/tables.php +++ b/tables.php @@ -3,7 +3,7 @@ /** * List tables in a database * - * $Id: tables.php,v 1.27 2003/07/25 08:39:25 chriskl Exp $ + * $Id: tables.php,v 1.28 2003/08/04 08:27:27 chriskl Exp $ */ // Include application functions @@ -29,19 +29,25 @@ $misc->printMsg($msg); echo "
\n"; - echo "\n"; + echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; + if ($data->hasWithoutOIDs()) { + echo "\n"; + echo "\n"; + } echo "
{$lang['strname']}
_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['name']), "\" />
{$lang['strnumfields']}
_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['fields']), "\" />
{$lang['stroptions']}
WITHOUT OIDS\n"; + echo "
\n"; - echo "\n"; + echo "

\n"; echo "\n"; echo $misc->form; echo "\n"; - echo "\n"; + echo "

\n"; echo "
\n"; break; case 2: @@ -107,6 +113,9 @@ echo $misc->form; echo "\n"; echo "\n"; + if (isset($_REQUEST['withoutoids'])) { + echo "\n"; + } echo "\n"; echo "

\n"; echo "\n"; @@ -131,7 +140,8 @@ } $status = $localData->createTable($_REQUEST['name'], $_REQUEST['fields'], $_REQUEST['field'], - $_REQUEST['type'], $_REQUEST['length'], $_REQUEST['notnull'], $_REQUEST['default']); + $_REQUEST['type'], $_REQUEST['length'], $_REQUEST['notnull'], $_REQUEST['default'], + isset($_REQUEST['withoutoids'])); if ($status == 0) { $_reload_browser = true; doDefault($lang['strtablecreated']); -- 2.39.5