<?php
+$partition_by = array('HASH', 'LINEAR HASH', 'KEY', 'LINEAR KEY', 'RANGE', 'LIST');
+
if (strlen($_GET["create"])) {
$orig_fields = fields($_GET["create"]);
}
. (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.'));
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();
?>
<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>
--- /dev/null
+<?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>