diff --git a/adminer/db.inc.php b/adminer/db.inc.php index d0251637..e7251933 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -126,6 +126,21 @@ if ($_GET["ns"] !== "") { echo "

" . lang('Create sequence') . "\n"; } + if (support("type")) { + echo "

" . lang('User types') . "

\n"; + $types = types(); + if ($types) { + echo "\n"; + echo "\n"; + odd(''); + foreach ($types as $val) { + echo "
" . lang('Name') . "
" . h($val) . "\n"; + } + echo "
\n"; + } + echo "

" . lang('Create type') . "\n"; + } + if (support("event")) { echo "

" . lang('Events') . "

\n"; $result = $connection->query("SHOW EVENTS"); diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index cde307f3..c46c54ef 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -777,6 +777,13 @@ if (!defined("DRIVER")) { return $connection->query("EXPLAIN $query"); } + /** Get user defined types + * @return array + */ + function types() { + return array(); + } + /** Get existing schemas * @return array */ @@ -854,7 +861,7 @@ if (!defined("DRIVER")) { */ function support($feature) { global $connection; - return !ereg("scheme|sequence" . ($connection->server_info < 5.1 ? "|event|partitioning" . ($connection->server_info < 5 ? "|view|routine|trigger" : "") : ""), $feature); + return !ereg("scheme|sequence|type" . ($connection->server_info < 5.1 ? "|event|partitioning" . ($connection->server_info < 5 ? "|view|routine|trigger" : "") : ""), $feature); } $jush = "sql"; ///< @var string JUSH identifier diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 51cd4e0a..a3ff8157 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -469,6 +469,15 @@ WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name = " . $connection->qu return $connection->query("EXPLAIN $query"); } + function types() { + return get_vals("SELECT typname +FROM pg_type +WHERE typnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema()) +AND typtype IN ('b','d','e') +AND typelem = 0" + ); + } + function schemas() { return get_vals("SELECT nspname FROM pg_namespace"); } @@ -480,18 +489,14 @@ WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name = " . $connection->qu function set_schema($schema) { global $connection, $types, $structured_types; - foreach (get_vals("SELECT typname -FROM pg_type -WHERE typnamespace = (SELECT oid FROM pg_namespace WHERE nspname = " . $connection->quote($schema) . ") -AND typtype IN ('b','d','e') -AND typelem = 0" - ) as $type) { //! get types from current_schemas('t') + $return = $connection->query("SET search_path TO " . idf_escape($schema)); + foreach (types() as $type) { //! get types from current_schemas('t') if (!isset($types[$type])) { $types[$type] = 0; $structured_types[lang('User types')][] = $type; } } - return $connection->query("SET search_path TO " . idf_escape($schema)); + return $return; } function use_sql($database) { @@ -503,7 +508,7 @@ AND typelem = 0" } function support($feature) { - return ereg('^(comment|view|scheme|sequence|trigger|variables|drop_col)$', $feature); //! routine| + return ereg('^(comment|view|scheme|sequence|trigger|type|variables|drop_col)$', $feature); //! routine| } $jush = "pgsql"; diff --git a/adminer/index.php b/adminer/index.php index 16f3086a..bff57f01 100644 --- a/adminer/index.php +++ b/adminer/index.php @@ -54,6 +54,8 @@ if (isset($_GET["download"])) { include "./procedure.inc.php"; } elseif (isset($_GET["sequence"])) { include "./sequence.inc.php"; +} elseif (isset($_GET["type"])) { + include "./type.inc.php"; } elseif (isset($_GET["trigger"])) { include "./trigger.inc.php"; } elseif (isset($_GET["user"])) { diff --git a/adminer/lang/cs.inc.php b/adminer/lang/cs.inc.php index 70131b78..09d46211 100644 --- a/adminer/lang/cs.inc.php +++ b/adminer/lang/cs.inc.php @@ -251,5 +251,9 @@ $translations = array( 'Sequence has been altered.' => 'Sekvence byla změněna.', 'Alter sequence' => 'Pozměnit sekvenci', 'User types' => 'Uživatelské typy', + 'Create type' => 'Vytvořit typ', + 'Type has been dropped.' => 'Typ byl odstraněn.', + 'Type has been created.' => 'Typ byl vytvořen.', + 'Alter type' => 'Pozměnit typ', 'Search data in tables' => 'Vyhledat data v tabulkách', ); diff --git a/adminer/type.inc.php b/adminer/type.inc.php new file mode 100644 index 00000000..f8b2ba13 --- /dev/null +++ b/adminer/type.inc.php @@ -0,0 +1,33 @@ + + +
+

+ +\n"; +} else { + echo "\n"; + textarea("as", $row["as"]); + echo "

\n"; +} +?> +

diff --git a/changes.txt b/changes.txt index 7c619dab..97d4c43d 100644 --- a/changes.txt +++ b/changes.txt @@ -8,7 +8,7 @@ Show number of tables in server overview Operator LIKE %% Remember export parameters in cookie Allow semicolon as CSV separator -Schema and sequences support (PostgreSQL) +Schemas, sequences and types support (PostgreSQL) Autofocus username in login form Disable spellchecking in SQL textareas Display auto_increment value of inserted item