Partitioning
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@542 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
b0bfb5a466
commit
ba4ad63797
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
$partition_by = array('HASH', 'LINEAR HASH', 'KEY', 'LINEAR KEY', 'RANGE', 'LIST');
|
||||
|
||||
if (strlen($_GET["create"])) {
|
||||
$orig_fields = fields($_GET["create"]);
|
||||
}
|
||||
|
@ -44,6 +46,18 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
|
|||
. (strlen($_POST["Auto_increment"]) ? " AUTO_INCREMENT=" . intval($_POST["Auto_increment"]) : "")
|
||||
. " COMMENT='" . $mysql->escape_string($_POST["Comment"]) . "'"
|
||||
;
|
||||
if (in_array($_POST["partition_by"], $partition_by)) {
|
||||
$partitions = array();
|
||||
if ($_POST["partition_by"] == 'RANGE' || $_POST["partition_by"] == 'LIST') {
|
||||
foreach (array_filter($_POST["partition_names"]) as $key => $val) {
|
||||
$value = $_POST["partition_values"][$key];
|
||||
$partitions[] = "PARTITION $val VALUES " . ($_POST["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . (strlen($value) ? " ($value)" : " MAXVALUE"); //! SQL injection
|
||||
}
|
||||
}
|
||||
$status .= " PARTITION BY $_POST[partition_by]($_POST[partition])" . ($partitions ? " (" . implode(", ", $partitions) . ")" : ($_POST["partitions"] ? " PARTITIONS " . intval($_POST["partitions"]) : ""));
|
||||
} elseif ($mysql->server_info >= 5.1 && strlen($_GET["create"])) {
|
||||
$status .= " REMOVE PARTITIONING";
|
||||
}
|
||||
$location = $SELF . "table=" . urlencode($_POST["name"]);
|
||||
if (strlen($_GET["create"])) {
|
||||
query_redirect("ALTER TABLE " . idf_escape($_GET["create"]) . " " . implode(", ", $fields) . ", RENAME TO " . idf_escape($_POST["name"]) . ", $status", $location, lang('Table has been altered.'));
|
||||
|
@ -74,8 +88,22 @@ if ($_POST) {
|
|||
table_comment($row);
|
||||
$row["name"] = $_GET["create"];
|
||||
$row["fields"] = array_values($orig_fields);
|
||||
if ($mysql->server_info >= 5.1) {
|
||||
$from = "FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = '" . $mysql->escape_string($_GET["db"]) . "' AND TABLE_NAME = '" . $mysql->escape_string($_GET["create"]) . "'";
|
||||
$result = $mysql->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION $from ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1");
|
||||
list($row["partition_by"], $row["partitions"], $row["partition"]) = $result->fetch_row();
|
||||
$result->free();
|
||||
$row["partition_names"] = array();
|
||||
$row["partition_values"] = array();
|
||||
$result = $mysql->query("SELECT PARTITION_NAME, PARTITION_DESCRIPTION $from AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION");
|
||||
while ($row1 = $result->fetch_assoc()) {
|
||||
$row["partition_names"][] = $row1["PARTITION_NAME"];
|
||||
$row["partition_values"][] = $row1["PARTITION_DESCRIPTION"];
|
||||
}
|
||||
$result->free();
|
||||
}
|
||||
} else {
|
||||
$row = array("fields" => array(array("field" => "")));
|
||||
$row = array("fields" => array(array("field" => "")), "partition_names" => array());
|
||||
}
|
||||
$collations = collations();
|
||||
?>
|
||||
|
@ -110,4 +138,21 @@ function column_comments_click(checked) {
|
|||
<input type="submit" value="<?php echo lang('Save'); ?>" />
|
||||
<?php if (strlen($_GET["create"])) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?> /><?php } ?>
|
||||
</p>
|
||||
<?php if ($mysql->server_info >= 5.1) { ?>
|
||||
<p>
|
||||
<?php echo lang('Partition by'); ?>: <select name="partition_by"><option></option><?php echo optionlist($partition_by, $row["partition_by"]); ?></select>
|
||||
(<input name="partition" value="<?php echo htmlspecialchars($row["partition"]); ?>" />)
|
||||
<?php echo lang('Partitions'); ?>: <input name="partitions" size="2" value="<?php echo htmlspecialchars($row["partitions"]); ?>" />
|
||||
</p>
|
||||
<table border="0" cellspacing="0" cellpadding="2">
|
||||
<thead><tr><th><?php echo lang('Partition name'); ?></th><th><?php echo lang('Values'); ?></th></tr></thead>
|
||||
<?php
|
||||
foreach ($row["partition_names"] as $key => $val) {
|
||||
echo '<tr><td><input name="partition_names[' . intval($key) . ']" value="' . htmlspecialchars($val) . '" /></td><td><input name="partition_values[' . intval($key) . ']" value="' . htmlspecialchars($row["partition_values"][$key]) . "\" /></td></tr>\n";
|
||||
}
|
||||
//! JS for next row
|
||||
?>
|
||||
<tr><td><input name="partition_names[<?php echo $key+1; ?>]" value="" /></td><td><input name="partition_values[<?php echo $key+1; ?>]" value="" /></td></tr>
|
||||
</table>
|
||||
<?php } ?>
|
||||
</form>
|
||||
|
|
|
@ -9,7 +9,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
||||
<meta name="robots" content="noindex" />
|
||||
<title><?php echo $title . (strlen($title2) ? ": " . htmlspecialchars($title2) : "") . " - " . lang('phpMinAdmin') . " 1.9.2-dev"; ?></title>
|
||||
<title><?php echo $title . (strlen($title2) ? ": " . htmlspecialchars($title2) : "") . " - " . lang('phpMinAdmin') . " 1.10.0-dev"; ?></title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="default.css" /><?php // Ondrej Valka, http://valka.info ?>
|
||||
</head>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
if (!ini_get("session.auto_start")) {
|
||||
session_name("phpMinAdmin_SID");
|
||||
session_set_cookie_params(ini_get("session.cookie_lifetime"), preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]));
|
||||
session_set_cookie_params(0, preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]));
|
||||
session_start();
|
||||
}
|
||||
if (isset($_SESSION["coverage"])) {
|
||||
|
|
|
@ -203,4 +203,8 @@ $translations = array(
|
|||
'whole result' => 'celý výsledek',
|
||||
'Tables have been dropped.' => 'Tabulky byla odstraněny.',
|
||||
'Clone' => 'Klonovat',
|
||||
'Partition by' => 'Rozdělit podle',
|
||||
'Partitions' => 'Oddílů',
|
||||
'Partition name' => 'Název oddílu',
|
||||
'Values' => 'Hodnoty',
|
||||
);
|
||||
|
|
97
tests/20-partitioning.html
Normal file
97
tests/20-partitioning.html
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<link rel="selenium.base" href="" />
|
||||
<title>Partitioning</title>
|
||||
</head>
|
||||
<body>
|
||||
<table cellpadding="1" cellspacing="1" border="1">
|
||||
<thead>
|
||||
<tr><td rowspan="1" colspan="3">Partitioning</td></tr>
|
||||
</thead><tbody>
|
||||
<tr>
|
||||
<td>open</td>
|
||||
<td>/phpMinAdmin/?db=selenium&table=interprets</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>clickAndWait</td>
|
||||
<td>link=Alter table</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>select</td>
|
||||
<td>partition_by</td>
|
||||
<td>label=HASH</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>type</td>
|
||||
<td>partition</td>
|
||||
<td>id</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>type</td>
|
||||
<td>partitions</td>
|
||||
<td>2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>clickAndWait</td>
|
||||
<td>//input[@value='Save']</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>verifyTextPresent</td>
|
||||
<td>Table has been altered.</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>clickAndWait</td>
|
||||
<td>link=Alter table</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>select</td>
|
||||
<td>partition_by</td>
|
||||
<td>label=RANGE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>type</td>
|
||||
<td>partition_values[0]</td>
|
||||
<td>10</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>clickAndWait</td>
|
||||
<td>//input[@value='Save']</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>verifyTextPresent</td>
|
||||
<td>Table has been altered.</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>clickAndWait</td>
|
||||
<td>link=Alter table</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>select</td>
|
||||
<td>partition_by</td>
|
||||
<td>label=</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>clickAndWait</td>
|
||||
<td>//input[@value='Save']</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>verifyTextPresent</td>
|
||||
<td>Table has been altered.</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
</tbody></table>
|
||||
</body>
|
||||
</html>
|
|
@ -13,6 +13,7 @@
|
|||
<tr><td><a href="2-create-table.html">Create table</a></td></tr>
|
||||
<tr><td><a href="3-create-index.html">Create index</a></td></tr>
|
||||
<tr><td><a href="4-create-table-2.html">Create table 2</a></td></tr>
|
||||
<tr><td><a href="20-partitioning.html">Partitioning</a></td></tr>
|
||||
<tr><td><a href="5-foreign-key.html">Foreign key</a></td></tr>
|
||||
<tr><td><a href="6-alter-table.html">Alter table</a></td></tr>
|
||||
<tr><td><a href="7-create-trigger.html">Create trigger</a></td></tr>
|
||||
|
|
Loading…
Reference in a new issue