From ba4ad6379708cb742f5e0c052b741469229b0f41 Mon Sep 17 00:00:00 2001
From: jakubvrana
Date: Fri, 12 Dec 2008 14:03:02 +0000
Subject: [PATCH] Partitioning
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@542 7c3ca157-0c34-0410-bff1-cbf682f78f5c
---
create.inc.php | 47 +++++++++++++++++-
design.inc.php | 2 +-
index.php | 2 +-
lang/cs.inc.php | 4 ++
tests/20-partitioning.html | 97 ++++++++++++++++++++++++++++++++++++++
tests/selenium.html | 1 +
6 files changed, 150 insertions(+), 3 deletions(-)
create mode 100644 tests/20-partitioning.html
diff --git a/create.inc.php b/create.inc.php
index b751cd68..0aac00f1 100644
--- a/create.inc.php
+++ b/create.inc.php
@@ -1,4 +1,6 @@
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) {
/>
+server_info >= 5.1) { ?>
+
+:
+(" />)
+: " />
+
+
+
diff --git a/design.inc.php b/design.inc.php
index 332f14ad..51df16ab 100644
--- a/design.inc.php
+++ b/design.inc.php
@@ -9,7 +9,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
-
+
diff --git a/index.php b/index.php
index 12f3ef10..d15d51f1 100644
--- a/index.php
+++ b/index.php
@@ -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"])) {
diff --git a/lang/cs.inc.php b/lang/cs.inc.php
index 31ab0484..16533e56 100644
--- a/lang/cs.inc.php
+++ b/lang/cs.inc.php
@@ -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',
);
diff --git a/tests/20-partitioning.html b/tests/20-partitioning.html
new file mode 100644
index 00000000..4296ca69
--- /dev/null
+++ b/tests/20-partitioning.html
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+Partitioning
+
+
+
+
+Partitioning |
+
+
+ open |
+ /phpMinAdmin/?db=selenium&table=interprets |
+ |
+
+
+ clickAndWait |
+ link=Alter table |
+ |
+
+
+ select |
+ partition_by |
+ label=HASH |
+
+
+ type |
+ partition |
+ id |
+
+
+ type |
+ partitions |
+ 2 |
+
+
+ clickAndWait |
+ //input[@value='Save'] |
+ |
+
+
+ verifyTextPresent |
+ Table has been altered. |
+ |
+
+
+ clickAndWait |
+ link=Alter table |
+ |
+
+
+ select |
+ partition_by |
+ label=RANGE |
+
+
+ type |
+ partition_values[0] |
+ 10 |
+
+
+ clickAndWait |
+ //input[@value='Save'] |
+ |
+
+
+ verifyTextPresent |
+ Table has been altered. |
+ |
+
+
+ clickAndWait |
+ link=Alter table |
+ |
+
+
+ select |
+ partition_by |
+ label= |
+
+
+ clickAndWait |
+ //input[@value='Save'] |
+ |
+
+
+ verifyTextPresent |
+ Table has been altered. |
+ |
+
+
+
+
+
diff --git a/tests/selenium.html b/tests/selenium.html
index b1ad560d..031fd5d5 100644
--- a/tests/selenium.html
+++ b/tests/selenium.html
@@ -13,6 +13,7 @@
Create table |
Create index |
Create table 2 |
+Partitioning |
Foreign key |
Alter table |
Create trigger |