Schema support for PostgreSQL
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1521 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
4809139347
commit
6420c5848c
|
@ -65,7 +65,7 @@ if ($collations) {
|
||||||
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
||||||
<input type="submit" value="<?php echo lang('Save'); ?>">
|
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||||
<?php
|
<?php
|
||||||
if (strlen(DB)) {
|
if (DB != "") {
|
||||||
echo "<input type='submit' name='drop' value='" . lang('Drop') . "'$confirm>\n";
|
echo "<input type='submit' name='drop' value='" . lang('Drop') . "'$confirm>\n";
|
||||||
} elseif (!$_POST["add_x"] && $_GET["db"] == "") {
|
} elseif (!$_POST["add_x"] && $_GET["db"] == "") {
|
||||||
echo "<input type='image' name='add' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>\n";
|
echo "<input type='image' name='add' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>\n";
|
||||||
|
|
|
@ -36,125 +36,128 @@ if ($tables_views && !$error && !$_POST["search"]) {
|
||||||
queries_redirect(substr(ME, 0, -1), $message, $result);
|
queries_redirect(substr(ME, 0, -1), $message, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
page_header(lang('Database') . ": " . h(DB), $error, true);
|
page_header(($_GET["ns"] == "" ? lang('Database') . ": " . h(DB) : lang('Schema') . ": " . h($_GET["ns"])), $error, true);
|
||||||
echo '<p><a href="' . h(ME) . 'database=">' . lang('Alter database') . "</a>\n";
|
echo '<p>' . ($_GET["ns"] == "" ? '<a href="' . h(ME) . 'database=">' . lang('Alter database') . "</a>\n" : "");
|
||||||
echo '<a href="' . h(ME) . 'schema=">' . lang('Database schema') . "</a>\n";
|
echo (support("scheme") ? "<a href='" . h(ME) . "scheme='>" . ($_GET["ns"] != "" ? lang('Alter schema') : lang('Create schema')) . "</a>\n" : "");
|
||||||
$sums = array("Data_length" => 0, "Index_length" => 0, "Data_free" => 0);
|
if ($_GET["ns"] !== "") {
|
||||||
|
echo '<a href="' . h(ME) . 'schema=">' . lang('Database schema') . "</a>\n";
|
||||||
|
$sums = array("Data_length" => 0, "Index_length" => 0, "Data_free" => 0);
|
||||||
|
|
||||||
echo "<h3>" . lang('Tables and views') . "</h3>\n";
|
echo "<h3>" . lang('Tables and views') . "</h3>\n";
|
||||||
$tables_list = tables_list();
|
$tables_list = tables_list();
|
||||||
if (!$tables_list) {
|
if (!$tables_list) {
|
||||||
echo "<p class='message'>" . lang('No tables.') . "\n";
|
echo "<p class='message'>" . lang('No tables.') . "\n";
|
||||||
} else {
|
} else {
|
||||||
echo "<form action='' method='post'>\n";
|
echo "<form action='' method='post'>\n";
|
||||||
echo "<p><input name='query' value='" . h($_POST["query"]) . "'> <input type='submit' name='search' value='" . lang('Search') . "'>\n";
|
echo "<p><input name='query' value='" . h($_POST["query"]) . "'> <input type='submit' name='search' value='" . lang('Search') . "'>\n";
|
||||||
if ($_POST["search"] && $_POST["query"] != "") {
|
if ($_POST["search"] && $_POST["query"] != "") {
|
||||||
$_GET["where"][0]["op"] = "LIKE %%";
|
$_GET["where"][0]["op"] = "LIKE %%";
|
||||||
$_GET["where"][0]["val"] = $_POST["query"];
|
$_GET["where"][0]["val"] = $_POST["query"];
|
||||||
search_tables();
|
search_tables();
|
||||||
}
|
}
|
||||||
echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);'>\n";
|
echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);'>\n";
|
||||||
echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^(tables|views)\[/);"><th>' . lang('Table') . '<td>' . lang('Engine') . '<td>' . lang('Collation') . '<td>' . lang('Data Length') . '<td>' . lang('Index Length') . '<td>' . lang('Data Free') . '<td>' . lang('Auto Increment') . '<td>' . lang('Rows') . (support("comment") ? '<td>' . lang('Comment') : '') . "</thead>\n";
|
echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^(tables|views)\[/);"><th>' . lang('Table') . '<td>' . lang('Engine') . '<td>' . lang('Collation') . '<td>' . lang('Data Length') . '<td>' . lang('Index Length') . '<td>' . lang('Data Free') . '<td>' . lang('Auto Increment') . '<td>' . lang('Rows') . (support("comment") ? '<td>' . lang('Comment') : '') . "</thead>\n";
|
||||||
foreach ($tables_list as $name => $type) {
|
foreach ($tables_list as $name => $type) {
|
||||||
$view = (isset($type) && !eregi("table", $type));
|
$view = (isset($type) && !eregi("table", $type));
|
||||||
echo '<tr' . odd() . '><td>' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "formUncheck('check-all');");
|
echo '<tr' . odd() . '><td>' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "formUncheck('check-all');");
|
||||||
echo '<th><a href="' . h(ME) . 'table=' . urlencode($name) . '">' . h($name) . '</a>';
|
echo '<th><a href="' . h(ME) . 'table=' . urlencode($name) . '">' . h($name) . '</a>';
|
||||||
if ($view) {
|
if ($view) {
|
||||||
echo '<td colspan="6"><a href="' . h(ME) . "view=" . urlencode($name) . '">' . lang('View') . '</a>';
|
echo '<td colspan="6"><a href="' . h(ME) . "view=" . urlencode($name) . '">' . lang('View') . '</a>';
|
||||||
echo '<td align="right"><a href="' . h(ME) . "select=" . urlencode($name) . '">?</a>';
|
echo '<td align="right"><a href="' . h(ME) . "select=" . urlencode($name) . '">?</a>';
|
||||||
} else {
|
} else {
|
||||||
echo "<td id='Engine-" . h($name) . "'> <td id='Collation-" . h($name) . "'> ";
|
echo "<td id='Engine-" . h($name) . "'> <td id='Collation-" . h($name) . "'> ";
|
||||||
foreach (array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "auto_increment=1&create", "Rows" => "select") as $key => $link) {
|
foreach (array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "auto_increment=1&create", "Rows" => "select") as $key => $link) {
|
||||||
echo "<td align='right'><a href='" . h(ME . "$link=") . urlencode($name) . "' id='$key-" . h($name) . "'>?</a>";
|
echo "<td align='right'><a href='" . h(ME . "$link=") . urlencode($name) . "' id='$key-" . h($name) . "'>?</a>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
echo (support("comment") ? "<td id='Comment-" . h($name) . "'> " : "");
|
||||||
}
|
}
|
||||||
echo (support("comment") ? "<td id='Comment-" . h($name) . "'> " : "");
|
echo "<tr><td> <th>" . lang('%d in total', count($tables_list));
|
||||||
}
|
echo "<td>" . $connection->result("SELECT @@storage_engine");
|
||||||
echo "<tr><td> <th>" . lang('%d in total', count($tables_list));
|
echo "<td>" . db_collation(DB, collations());
|
||||||
echo "<td>" . $connection->result("SELECT @@storage_engine");
|
foreach ($sums as $key => $val) {
|
||||||
echo "<td>" . db_collation(DB, collations());
|
echo "<td align='right' id='sum-$key'> ";
|
||||||
foreach ($sums as $key => $val) {
|
|
||||||
echo "<td align='right' id='sum-$key'> ";
|
|
||||||
}
|
|
||||||
echo "</table>\n";
|
|
||||||
if (!information_schema(DB)) {
|
|
||||||
echo "<p><input type='hidden' name='token' value='$token'>" . ($driver == "sql" ? "<input type='submit' value='" . lang('Analyze') . "'> <input type='submit' name='optimize' value='" . lang('Optimize') . "'> <input type='submit' name='check' value='" . lang('Check') . "'> <input type='submit' name='repair' value='" . lang('Repair') . "'> " : "") . "<input type='submit' name='truncate' value='" . lang('Truncate') . "' onclick=\"return confirm('" . lang('Are you sure?') . " (' + formChecked(this, /tables/) + ')');\"> <input type='submit' name='drop' value='" . lang('Drop') . "' onclick=\"return confirm('" . lang('Are you sure?') . " (' + formChecked(this, /tables|views/) + ')');\">\n";
|
|
||||||
$dbs = get_databases();
|
|
||||||
if (count($dbs) != 1) {
|
|
||||||
$db = (isset($_POST["target"]) ? $_POST["target"] : DB);
|
|
||||||
echo "<p>" . lang('Move to other database') . ($dbs ? ": " . html_select("target", $dbs, $db) : ': <input name="target" value="' . h($db) . '">') . " <input type='submit' name='move' value='" . lang('Move') . "'>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
echo "</form>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<p><a href="' . h(ME) . 'create=">' . lang('Create table') . "</a>\n";
|
|
||||||
if (support("view")) {
|
|
||||||
echo '<a href="' . h(ME) . 'view=">' . lang('Create view') . "</a>\n";
|
|
||||||
}
|
|
||||||
if (support("routine")) {
|
|
||||||
echo "<h3>" . lang('Routines') . "</h3>\n";
|
|
||||||
$routines = routines();
|
|
||||||
if ($routines) {
|
|
||||||
echo "<table cellspacing='0'>\n";
|
|
||||||
echo '<thead><tr><th>' . lang('Name') . '<td>' . lang('Type') . '<td>' . lang('Return type') . "<td> </thead>\n";
|
|
||||||
odd('');
|
|
||||||
foreach ($routines as $row) {
|
|
||||||
echo '<tr' . odd() . '>';
|
|
||||||
echo '<th><a href="' . h(ME) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'callf=' : 'call=') . urlencode($row["ROUTINE_NAME"]) . '">' . h($row["ROUTINE_NAME"]) . '</a>';
|
|
||||||
echo '<td>' . h($row["ROUTINE_TYPE"]);
|
|
||||||
echo '<td>' . h($row["DTD_IDENTIFIER"]);
|
|
||||||
echo '<td><a href="' . h(ME) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'function=' : 'procedure=') . urlencode($row["ROUTINE_NAME"]) . '">' . lang('Alter') . "</a>";
|
|
||||||
}
|
}
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
}
|
if (!information_schema(DB)) {
|
||||||
echo '<p><a href="' . h(ME) . 'procedure=">' . lang('Create procedure') . '</a> <a href="' . h(ME) . 'function=">' . lang('Create function') . "</a>\n";
|
echo "<p><input type='hidden' name='token' value='$token'>" . ($driver == "sql" ? "<input type='submit' value='" . lang('Analyze') . "'> <input type='submit' name='optimize' value='" . lang('Optimize') . "'> <input type='submit' name='check' value='" . lang('Check') . "'> <input type='submit' name='repair' value='" . lang('Repair') . "'> " : "") . "<input type='submit' name='truncate' value='" . lang('Truncate') . "' onclick=\"return confirm('" . lang('Are you sure?') . " (' + formChecked(this, /tables/) + ')');\"> <input type='submit' name='drop' value='" . lang('Drop') . "' onclick=\"return confirm('" . lang('Are you sure?') . " (' + formChecked(this, /tables|views/) + ')');\">\n";
|
||||||
}
|
$dbs = get_databases();
|
||||||
|
if (count($dbs) != 1) {
|
||||||
if (support("event")) {
|
$db = (isset($_POST["target"]) ? $_POST["target"] : DB);
|
||||||
echo "<h3>" . lang('Events') . "</h3>\n";
|
echo "<p>" . lang('Move to other database') . ($dbs ? ": " . html_select("target", $dbs, $db) : ': <input name="target" value="' . h($db) . '">') . " <input type='submit' name='move' value='" . lang('Move') . "'>\n";
|
||||||
$result = $connection->query("SHOW EVENTS");
|
|
||||||
if ($result && $result->num_rows) {
|
|
||||||
echo "<table cellspacing='0'>\n";
|
|
||||||
echo "<thead><tr><th>" . lang('Name') . "<td>" . lang('Schedule') . "<td>" . lang('Start') . "<td>" . lang('End') . "</thead>\n";
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
echo "<tr>";
|
|
||||||
echo '<th><a href="' . h(ME) . 'event=' . urlencode($row["Name"]) . '">' . h($row["Name"]) . "</a>";
|
|
||||||
echo "<td>" . ($row["Execute at"] ? lang('At given time') . "<td>" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "<td>$row[Starts]");
|
|
||||||
echo "<td>$row[Ends]";
|
|
||||||
}
|
|
||||||
echo "</table>\n";
|
|
||||||
}
|
|
||||||
echo '<p><a href="' . h(ME) . 'event=">' . lang('Create event') . "</a>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
page_footer();
|
|
||||||
$table_status = table_status();
|
|
||||||
if ($table_status) {
|
|
||||||
echo "<script type='text/javascript'>\n";
|
|
||||||
foreach ($table_status as $row) {
|
|
||||||
$id = addcslashes($row["Name"], "\\'/");
|
|
||||||
echo "setHtml('Comment-$id', '" . nbsp($row["Comment"]) . "');\n";
|
|
||||||
if (!eregi("view", $row["Engine"])) {
|
|
||||||
foreach (array("Engine", "Collation") as $key) {
|
|
||||||
echo "setHtml('$key-$id', '" . nbsp($row[$key]) . "');\n";
|
|
||||||
}
|
}
|
||||||
foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) {
|
}
|
||||||
if ($row[$key] != "") {
|
echo "</form>\n";
|
||||||
$val = number_format($row[$key], 0, '.', lang(','));
|
}
|
||||||
echo "setHtml('$key-$id', '" . ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? "~ $val" : $val) . "');\n";
|
|
||||||
if (isset($sums[$key])) {
|
echo '<p><a href="' . h(ME) . 'create=">' . lang('Create table') . "</a>\n";
|
||||||
$sums[$key] += ($row["Engine"] != "InnoDB" || $key != "Data_free" ? $row[$key] : 0);
|
if (support("view")) {
|
||||||
|
echo '<a href="' . h(ME) . 'view=">' . lang('Create view') . "</a>\n";
|
||||||
|
}
|
||||||
|
if (support("routine")) {
|
||||||
|
echo "<h3>" . lang('Routines') . "</h3>\n";
|
||||||
|
$routines = routines();
|
||||||
|
if ($routines) {
|
||||||
|
echo "<table cellspacing='0'>\n";
|
||||||
|
echo '<thead><tr><th>' . lang('Name') . '<td>' . lang('Type') . '<td>' . lang('Return type') . "<td> </thead>\n";
|
||||||
|
odd('');
|
||||||
|
foreach ($routines as $row) {
|
||||||
|
echo '<tr' . odd() . '>';
|
||||||
|
echo '<th><a href="' . h(ME) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'callf=' : 'call=') . urlencode($row["ROUTINE_NAME"]) . '">' . h($row["ROUTINE_NAME"]) . '</a>';
|
||||||
|
echo '<td>' . h($row["ROUTINE_TYPE"]);
|
||||||
|
echo '<td>' . h($row["DTD_IDENTIFIER"]);
|
||||||
|
echo '<td><a href="' . h(ME) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'function=' : 'procedure=') . urlencode($row["ROUTINE_NAME"]) . '">' . lang('Alter') . "</a>";
|
||||||
|
}
|
||||||
|
echo "</table>\n";
|
||||||
|
}
|
||||||
|
echo '<p><a href="' . h(ME) . 'procedure=">' . lang('Create procedure') . '</a> <a href="' . h(ME) . 'function=">' . lang('Create function') . "</a>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (support("event")) {
|
||||||
|
echo "<h3>" . lang('Events') . "</h3>\n";
|
||||||
|
$result = $connection->query("SHOW EVENTS");
|
||||||
|
if ($result && $result->num_rows) {
|
||||||
|
echo "<table cellspacing='0'>\n";
|
||||||
|
echo "<thead><tr><th>" . lang('Name') . "<td>" . lang('Schedule') . "<td>" . lang('Start') . "<td>" . lang('End') . "</thead>\n";
|
||||||
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
echo "<tr>";
|
||||||
|
echo '<th><a href="' . h(ME) . 'event=' . urlencode($row["Name"]) . '">' . h($row["Name"]) . "</a>";
|
||||||
|
echo "<td>" . ($row["Execute at"] ? lang('At given time') . "<td>" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "<td>$row[Starts]");
|
||||||
|
echo "<td>$row[Ends]";
|
||||||
|
}
|
||||||
|
echo "</table>\n";
|
||||||
|
}
|
||||||
|
echo '<p><a href="' . h(ME) . 'event=">' . lang('Create event') . "</a>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
page_footer();
|
||||||
|
$table_status = table_status();
|
||||||
|
if ($table_status) {
|
||||||
|
echo "<script type='text/javascript'>\n";
|
||||||
|
foreach ($table_status as $row) {
|
||||||
|
$id = addcslashes($row["Name"], "\\'/");
|
||||||
|
echo "setHtml('Comment-$id', '" . nbsp($row["Comment"]) . "');\n";
|
||||||
|
if (!eregi("view", $row["Engine"])) {
|
||||||
|
foreach (array("Engine", "Collation") as $key) {
|
||||||
|
echo "setHtml('$key-$id', '" . nbsp($row[$key]) . "');\n";
|
||||||
|
}
|
||||||
|
foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) {
|
||||||
|
if ($row[$key] != "") {
|
||||||
|
$val = number_format($row[$key], 0, '.', lang(','));
|
||||||
|
echo "setHtml('$key-$id', '" . ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? "~ $val" : $val) . "');\n";
|
||||||
|
if (isset($sums[$key])) {
|
||||||
|
$sums[$key] += ($row["Engine"] != "InnoDB" || $key != "Data_free" ? $row[$key] : 0);
|
||||||
|
}
|
||||||
|
} elseif (array_key_exists($key, $row)) {
|
||||||
|
echo "setHtml('$key-$id');\n";
|
||||||
}
|
}
|
||||||
} elseif (array_key_exists($key, $row)) {
|
|
||||||
echo "setHtml('$key-$id');\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach ($sums as $key => $val) {
|
||||||
|
echo "setHtml('sum-$key', '" . number_format($val, 0, '.', lang(',')) . "');\n";
|
||||||
|
}
|
||||||
|
echo "</script>\n";
|
||||||
}
|
}
|
||||||
foreach ($sums as $key => $val) {
|
exit; // page_footer() already called
|
||||||
echo "setHtml('sum-$key', '" . number_format($val, 0, '.', lang(',')) . "');\n";
|
|
||||||
}
|
|
||||||
echo "</script>\n";
|
|
||||||
}
|
}
|
||||||
exit; // page_footer() already called
|
|
||||||
|
|
|
@ -490,7 +490,7 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . $connection->quote($table)
|
||||||
}
|
}
|
||||||
|
|
||||||
function support($feature) {
|
function support($feature) {
|
||||||
return ereg('^(trigger|drop_col)$', $feature); //! view|routine|
|
return ereg('^(trigger|drop_col)$', $feature); //! view|routine|scheme|
|
||||||
}
|
}
|
||||||
|
|
||||||
$driver = "mssql";
|
$driver = "mssql";
|
||||||
|
|
|
@ -755,6 +755,28 @@ if (!defined("DRIVER")) {
|
||||||
return $connection->query("EXPLAIN $query");
|
return $connection->query("EXPLAIN $query");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get existing schemas
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function schemas() {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get current schema
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function get_schema() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set current schema
|
||||||
|
* @param string
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function set_schema($schema) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get SQL command to create table
|
/** Get SQL command to create table
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -810,7 +832,7 @@ if (!defined("DRIVER")) {
|
||||||
*/
|
*/
|
||||||
function support($feature) {
|
function support($feature) {
|
||||||
global $connection;
|
global $connection;
|
||||||
return ($connection->server_info >= 5.1 || ($connection->server_info >= 5 && !ereg("event|partitioning")) || !ereg("view|routine|trigger"));
|
return !ereg("scheme" . ($connection->server_info < 5.1 ? "|event|partitioning" . ($connection->server_info < 5 ? "|view|routine|trigger" : "") : ""), $feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
$driver = "sql"; ///< @var string JUSH identifier
|
$driver = "sql"; ///< @var string JUSH identifier
|
||||||
|
|
|
@ -452,12 +452,26 @@ WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name = " . $connection->qu
|
||||||
return $connection->query("EXPLAIN $query");
|
return $connection->query("EXPLAIN $query");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function schemas() {
|
||||||
|
return get_vals("SELECT nspname FROM pg_namespace");
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_schema() {
|
||||||
|
global $connection;
|
||||||
|
return $connection->result("SELECT current_schema()");
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_schema($schema) {
|
||||||
|
global $connection;
|
||||||
|
return $connection->query("SET search_path TO " . idf_escape($schema));
|
||||||
|
}
|
||||||
|
|
||||||
function use_sql($database) {
|
function use_sql($database) {
|
||||||
return "\connect " . idf_escape($database);
|
return "\connect " . idf_escape($database);
|
||||||
}
|
}
|
||||||
|
|
||||||
function support($feature) {
|
function support($feature) {
|
||||||
return ereg('^(comment|view|trigger|drop_col)$', $feature); //! routine|
|
return ereg('^(comment|view|scheme|trigger|drop_col)$', $feature); //! routine|sequence|
|
||||||
}
|
}
|
||||||
|
|
||||||
$driver = "pgsql";
|
$driver = "pgsql";
|
||||||
|
|
|
@ -496,6 +496,18 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
return $connection->query("EXPLAIN $query");
|
return $connection->query("EXPLAIN $query");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function schemas() {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_schema() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_schema($scheme) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function create_sql($table) {
|
function create_sql($table) {
|
||||||
global $connection;
|
global $connection;
|
||||||
return $connection->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . $connection->quote($table));
|
return $connection->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . $connection->quote($table));
|
||||||
|
|
|
@ -506,32 +506,40 @@ document.getElementById('username').focus();
|
||||||
<p>
|
<p>
|
||||||
<?php hidden_fields_get(); ?>
|
<?php hidden_fields_get(); ?>
|
||||||
<?php echo ($databases ? html_select("db", array("" => "(" . lang('database') . ")") + $databases, DB, "this.form.submit();") : '<input name="db" value="' . h(DB) . '">'); ?>
|
<?php echo ($databases ? html_select("db", array("" => "(" . lang('database') . ")") + $databases, DB, "this.form.submit();") : '<input name="db" value="' . h(DB) . '">'); ?>
|
||||||
<?php if (isset($_GET["sql"])) { ?><input type="hidden" name="sql" value=""><?php } ?>
|
|
||||||
<?php if (isset($_GET["schema"])) { ?><input type="hidden" name="schema" value=""><?php } ?>
|
|
||||||
<?php if (isset($_GET["dump"])) { ?><input type="hidden" name="dump" value=""><?php } ?>
|
|
||||||
<input type="submit" value="<?php echo lang('Use'); ?>"<?php echo ($databases ? " class='hidden'" : ""); ?>>
|
<input type="submit" value="<?php echo lang('Use'); ?>"<?php echo ($databases ? " class='hidden'" : ""); ?>>
|
||||||
</p>
|
|
||||||
</form>
|
|
||||||
<?php
|
<?php
|
||||||
if ($missing != "db" && DB != "" && $connection->select_db(DB)) {
|
if ($missing != "db" && DB != "" && $connection->select_db(DB)) {
|
||||||
$tables = tables_list();
|
if (support("scheme")) {
|
||||||
if (!$tables) {
|
echo "<br>" . html_select("ns", array("" => "(" . lang('schema') . ")") + schemas(), $_GET["ns"], "this.form.submit();");
|
||||||
echo "<p class='message'>" . lang('No tables.') . "\n";
|
if ($_GET["ns"] != "") {
|
||||||
} else {
|
set_schema($_GET["ns"]);
|
||||||
$this->tablesPrint($tables);
|
|
||||||
$links = array();
|
|
||||||
foreach ($tables as $table => $type) {
|
|
||||||
$links[] = preg_quote($table, '/');
|
|
||||||
}
|
}
|
||||||
echo "<script type='text/javascript'>\n";
|
|
||||||
echo "var jushLinks = { $driver: [ '" . addcslashes(h(ME), "\\'/") . "table=\$&', /\\b(" . implode("|", $links) . ")\\b/g ] };\n";
|
|
||||||
foreach (array("bac", "bra", "sqlite_quo", "mssql_bra") as $val) {
|
|
||||||
echo "jushLinks.$val = jushLinks.$driver;\n";
|
|
||||||
}
|
|
||||||
echo "</script>\n";
|
|
||||||
}
|
}
|
||||||
echo '<p><a href="' . h(ME) . 'create=">' . bold(lang('Create new table'), $_GET["create"] === "") . "</a>\n";
|
if ($_GET["ns"] !== "") {
|
||||||
|
$tables = tables_list();
|
||||||
|
if (!$tables) {
|
||||||
|
echo "<p class='message'>" . lang('No tables.') . "\n";
|
||||||
|
} else {
|
||||||
|
$this->tablesPrint($tables);
|
||||||
|
$links = array();
|
||||||
|
foreach ($tables as $table => $type) {
|
||||||
|
$links[] = preg_quote($table, '/');
|
||||||
|
}
|
||||||
|
echo "<script type='text/javascript'>\n";
|
||||||
|
echo "var jushLinks = { $driver: [ '" . addcslashes(h(ME), "\\'/") . "table=\$&', /\\b(" . implode("|", $links) . ")\\b/g ] };\n";
|
||||||
|
foreach (array("bac", "bra", "sqlite_quo", "mssql_bra") as $val) {
|
||||||
|
echo "jushLinks.$val = jushLinks.$driver;\n";
|
||||||
|
}
|
||||||
|
echo "</script>\n";
|
||||||
|
}
|
||||||
|
echo '<p><a href="' . h(ME) . 'create=">' . bold(lang('Create new table'), $_GET["create"] === "") . "</a>\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
echo (isset($_GET["sql"]) ? '<input type="hidden" name="sql" value="">'
|
||||||
|
: (isset($_GET["schema"]) ? '<input type="hidden" name="schema" value="">'
|
||||||
|
: (isset($_GET["dump"]) ? '<input type="hidden" name="dump" value="">'
|
||||||
|
: "")));
|
||||||
|
echo "</form>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ if (isset($_POST["server"])) {
|
||||||
set_session($key, null);
|
set_session($key, null);
|
||||||
}
|
}
|
||||||
cookie("adminer_permanent", "");
|
cookie("adminer_permanent", "");
|
||||||
redirect(substr(preg_replace('~(username|db)=[^&]*&~', '', ME), 0, -1), lang('Logout successful.'));
|
redirect(substr(preg_replace('~(username|db|ns)=[^&]*&~', '', ME), 0, -1), lang('Logout successful.'));
|
||||||
}
|
}
|
||||||
} elseif ($_COOKIE["adminer_permanent"]) {
|
} elseif ($_COOKIE["adminer_permanent"]) {
|
||||||
list($server, $username, $cipher, $system) = array_map('base64_decode', explode(":", $_COOKIE["adminer_permanent"])); // $driver is a global variable
|
list($server, $username, $cipher, $system) = array_map('base64_decode', explode(":", $_COOKIE["adminer_permanent"])); // $driver is a global variable
|
||||||
|
|
|
@ -71,7 +71,7 @@ define("ME", preg_replace('~^[^?]*/([^?]*).*~', '\\1', $_SERVER["REQUEST_URI"])
|
||||||
. (SID && !$_COOKIE ? SID . '&' : '') // !$_COOKIE - don't pass SID with permanent login
|
. (SID && !$_COOKIE ? SID . '&' : '') // !$_COOKIE - don't pass SID with permanent login
|
||||||
. (SERVER !== null ? DRIVER . "=" . urlencode(SERVER) . '&' : '')
|
. (SERVER !== null ? DRIVER . "=" . urlencode(SERVER) . '&' : '')
|
||||||
. (isset($_GET["username"]) ? "username=" . urlencode($_GET["username"]) . '&' : '')
|
. (isset($_GET["username"]) ? "username=" . urlencode($_GET["username"]) . '&' : '')
|
||||||
. (DB != "" ? 'db=' . urlencode(DB) . '&' : '')
|
. (DB != "" ? 'db=' . urlencode(DB) . '&' . (isset($_GET["ns"]) ? "ns=" . urlencode($_GET["ns"]) . "&" : "") : '')
|
||||||
);
|
);
|
||||||
|
|
||||||
include "../adminer/include/version.inc.php";
|
include "../adminer/include/version.inc.php";
|
||||||
|
|
|
@ -61,3 +61,7 @@ if (!(DB != "" ? $connection->select_db(DB) : isset($_GET["sql"]) || isset($_GET
|
||||||
connect_error(); // separate function to catch SQLite error
|
connect_error(); // separate function to catch SQLite error
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (support("scheme") && DB != "" && $_GET["ns"] !== "" && (!isset($_GET["ns"]) || !set_schema($_GET["ns"]))) {
|
||||||
|
redirect(preg_replace('~ns=[^&]*&~', '', ME) . "ns=" . get_schema());
|
||||||
|
}
|
||||||
|
|
|
@ -31,17 +31,20 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<?php
|
<?php
|
||||||
if (isset($breadcrumb)) {
|
if (isset($breadcrumb)) {
|
||||||
$link = substr(preg_replace('~(username|db)=[^&]*&~', '', ME), 0, -1);
|
$link = substr(preg_replace('~(username|db|ns)=[^&]*&~', '', ME), 0, -1);
|
||||||
echo '<p id="breadcrumb"><a href="' . ($link ? h($link) : ".") . '">' . $drivers[DRIVER] . '</a> » ';
|
echo '<p id="breadcrumb"><a href="' . ($link ? h($link) : ".") . '">' . $drivers[DRIVER] . '</a> » ';
|
||||||
$link = substr(preg_replace('~db=[^&]*&~', '', ME), 0, -1);
|
$link = substr(preg_replace('~(db|ns)=[^&]*&~', '', ME), 0, -1);
|
||||||
$server = (SERVER != "" ? h(SERVER) : lang('Server'));
|
$server = (SERVER != "" ? h(SERVER) : lang('Server'));
|
||||||
if ($breadcrumb === false) {
|
if ($breadcrumb === false) {
|
||||||
echo "$server\n";
|
echo "$server\n";
|
||||||
} else {
|
} else {
|
||||||
echo "<a href='" . ($link ? h($link) : ".") . "'>$server</a> » ";
|
echo "<a href='" . ($link ? h($link) : ".") . "'>$server</a> » ";
|
||||||
|
if ($_GET["ns"] != "" || (DB != "" && is_array($breadcrumb))) {
|
||||||
|
echo '<a href="' . h($link . "&db=" . urlencode(DB) . (support("scheme") ? "&ns=" : "")) . '">' . h(DB) . '</a> » ';
|
||||||
|
}
|
||||||
if (is_array($breadcrumb)) {
|
if (is_array($breadcrumb)) {
|
||||||
if (DB != "") {
|
if ($_GET["ns"] != "") {
|
||||||
echo '<a href="' . h(substr(ME, 0, -1)) . '">' . h(DB) . '</a> » ';
|
echo '<a href="' . h(substr(ME, 0, -1)) . '">' . h($_GET["ns"]) . '</a> » ';
|
||||||
}
|
}
|
||||||
foreach ($breadcrumb as $key => $val) {
|
foreach ($breadcrumb as $key => $val) {
|
||||||
$desc = (is_array($val) ? $val[1] : $val);
|
$desc = (is_array($val) ? $val[1] : $val);
|
||||||
|
|
|
@ -40,6 +40,8 @@ if (isset($_GET["download"])) {
|
||||||
include "./indexes.inc.php";
|
include "./indexes.inc.php";
|
||||||
} elseif (isset($_GET["database"])) {
|
} elseif (isset($_GET["database"])) {
|
||||||
include "./database.inc.php";
|
include "./database.inc.php";
|
||||||
|
} elseif (isset($_GET["scheme"])) {
|
||||||
|
include "./scheme.inc.php";
|
||||||
} elseif (isset($_GET["call"])) {
|
} elseif (isset($_GET["call"])) {
|
||||||
include "./call.inc.php";
|
include "./call.inc.php";
|
||||||
} elseif (isset($_GET["foreign"])) {
|
} elseif (isset($_GET["foreign"])) {
|
||||||
|
|
|
@ -237,4 +237,11 @@ $translations = array(
|
||||||
'Double click on a value to modify it.' => 'Dvojklikněte na políčko, které chcete změnit.',
|
'Double click on a value to modify it.' => 'Dvojklikněte na políčko, které chcete změnit.',
|
||||||
'Increase text length to modify this value.' => 'Ke změně této hodnoty zvyšte délku textů.',
|
'Increase text length to modify this value.' => 'Ke změně této hodnoty zvyšte délku textů.',
|
||||||
'Use edit link to modify this value.' => 'Ke změně této hodnoty použijte odkaz upravit.',
|
'Use edit link to modify this value.' => 'Ke změně této hodnoty použijte odkaz upravit.',
|
||||||
|
'Alter schema' => 'Pozměnit schéma',
|
||||||
|
'Create schema' => 'Vytvořit schéma',
|
||||||
|
'Schema has been dropped.' => 'Schéma bylo odstraněno.',
|
||||||
|
'Schema has been created.' => 'Schéma bylo vytvořeno.',
|
||||||
|
'Schema has been altered.' => 'Schéma bylo změněno.',
|
||||||
|
'schema' => 'schéma',
|
||||||
|
'Schema' => 'Schéma',
|
||||||
);
|
);
|
||||||
|
|
35
adminer/scheme.inc.php
Normal file
35
adminer/scheme.inc.php
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
if ($_POST && !$error) {
|
||||||
|
$link = preg_replace('~ns=[^&]*&~', '', ME) . "ns=";
|
||||||
|
if ($_POST["drop"]) {
|
||||||
|
query_redirect("DROP SCHEMA " . idf_escape($_GET["ns"]), $link, lang('Schema has been dropped.'));
|
||||||
|
} else {
|
||||||
|
$link .= urlencode($_POST["name"]);
|
||||||
|
if ($_GET["ns"] == "") {
|
||||||
|
query_redirect("CREATE SCHEMA " . idf_escape($_POST["name"]), $link, lang('Schema has been created.'));
|
||||||
|
} elseif ($_GET["ns"] != $_POST["name"]) {
|
||||||
|
query_redirect("ALTER SCHEMA " . idf_escape($_GET["ns"]) . " RENAME TO " . idf_escape($_POST["name"]), $link, lang('Schema has been altered.'));
|
||||||
|
} else {
|
||||||
|
redirect($link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
page_header($_GET["ns"] != "" ? lang('Alter schema') : lang('Create schema'), $error);
|
||||||
|
|
||||||
|
$row = array("name" => $_GET["ns"]);
|
||||||
|
if ($_POST) {
|
||||||
|
$row = $_POST;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form action="" method="post">
|
||||||
|
<p><input name="name" value="<?php echo h($row["name"]); ?>">
|
||||||
|
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
||||||
|
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||||
|
<?php
|
||||||
|
if ($_GET["ns"] != "") {
|
||||||
|
echo "<input type='submit' name='drop' value='" . lang('Drop') . "'$confirm>\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</form>
|
|
@ -190,13 +190,15 @@ foreach (glob(dirname(__FILE__) . "/adminer/drivers/" . ($DRIVER ? $DRIVER : "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$drivers = array();
|
||||||
foreach (array("adminer", "editor") as $project) {
|
foreach (array("adminer", "editor") as $project) {
|
||||||
$lang_ids = array(); // global variable simplifies usage in a callback function
|
$lang_ids = array(); // global variable simplifies usage in a callback function
|
||||||
$file = file_get_contents(dirname(__FILE__) . "/$project/index.php");
|
$file = file_get_contents(dirname(__FILE__) . "/$project/index.php");
|
||||||
if ($DRIVER && $DRIVER != "mysql") {
|
if ($DRIVER) {
|
||||||
|
$connection = (object) array("server_info" => 5.1); // MySQL support is version specific
|
||||||
$_GET[$DRIVER] = true; // to load the driver
|
$_GET[$DRIVER] = true; // to load the driver
|
||||||
include_once dirname(__FILE__) . "/adminer/drivers/$DRIVER.inc.php";
|
include_once dirname(__FILE__) . "/adminer/drivers/$DRIVER.inc.php";
|
||||||
foreach (array("view", "event", "privileges", "user", "processlist", "variables", "trigger") as $feature) {
|
foreach (array("view", "event", "privileges", "user", "processlist", "variables", "trigger", "scheme") as $feature) {
|
||||||
if (!support($feature)) {
|
if (!support($feature)) {
|
||||||
$file = str_replace("} elseif (isset(\$_GET[\"$feature\"])) {\n\tinclude \"./$feature.inc.php\";\n", "", $file);
|
$file = str_replace("} elseif (isset(\$_GET[\"$feature\"])) {\n\tinclude \"./$feature.inc.php\";\n", "", $file);
|
||||||
}
|
}
|
||||||
|
|
1
todo.txt
1
todo.txt
|
@ -35,7 +35,6 @@ Backward keys in Editor
|
||||||
PostgreSQL:
|
PostgreSQL:
|
||||||
Users - SELECT * FROM pg_user
|
Users - SELECT * FROM pg_user
|
||||||
ORDER BY COUNT(*)
|
ORDER BY COUNT(*)
|
||||||
Table schema - SELECT * FROM pg_namespace, CREATE|ALTER|DROP SCHEMA, SET default_tablespace
|
|
||||||
Export - http://www.postgresql.org/docs/8.4/static/functions-info.html
|
Export - http://www.postgresql.org/docs/8.4/static/functions-info.html
|
||||||
Column rights - http://www.postgresql.org/docs/8.4/static/functions-info.html
|
Column rights - http://www.postgresql.org/docs/8.4/static/functions-info.html
|
||||||
Dollar terminated string in SQL command
|
Dollar terminated string in SQL command
|
||||||
|
|
Loading…
Reference in a new issue