From 0b0c0c7e89cbee8e57eb9caaba92bda246f6cb49 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 18 Nov 2014 09:50:02 -0800 Subject: [PATCH] Don't alter table comment if not changed (was crashing MySQL Cluster) --- adminer/create.inc.php | 2 +- adminer/drivers/mysql.inc.php | 10 ++++++---- changes.txt | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/adminer/create.inc.php b/adminer/create.inc.php index c0e636a9..d813dbb6 100644 --- a/adminer/create.inc.php +++ b/adminer/create.inc.php @@ -107,7 +107,7 @@ if ($_POST && !process_fields($row["fields"]) && !$error) { $name, ($jush == "sqlite" && ($use_all_fields || $foreign) ? $all_fields : $fields), $foreign, - $row["Comment"], + ($row["Comment"] != $table_status["Comment"] ? $row["Comment"] : null), ($row["Engine"] && $row["Engine"] != $table_status["Engine"] ? $row["Engine"] : ""), ($row["Collation"] && $row["Collation"] != $table_status["Collation"] ? $row["Collation"] : ""), ($row["Auto_increment"] != "" ? +$row["Auto_increment"] : ""), diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 8705f5bb..3ca7abb9 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -662,20 +662,22 @@ if (!defined("DRIVER")) { ); } $alter = array_merge($alter, $foreign); - $status = "COMMENT=" . q($comment) + $status = ($comment !== null ? " COMMENT=" . q($comment) : "") . ($engine ? " ENGINE=" . q($engine) : "") . ($collation ? " COLLATE " . q($collation) : "") . ($auto_increment != "" ? " AUTO_INCREMENT=$auto_increment" : "") . $partitioning ; if ($table == "") { - return queries("CREATE TABLE " . table($name) . " (\n" . implode(",\n", $alter) . "\n) $status"); + return queries("CREATE TABLE " . table($name) . " (\n" . implode(",\n", $alter) . "\n)$status"); } if ($table != $name) { $alter[] = "RENAME TO " . table($name); } - $alter[] = $status; - return queries("ALTER TABLE " . table($table) . "\n" . implode(",\n", $alter)); + if ($status) { + $alter[] = ltrim($status); + } + return $alter ? queries("ALTER TABLE " . table($table) . "\n" . implode(",\n", $alter)) : true; } /** Run commands to alter indexes diff --git a/changes.txt b/changes.txt index 95fca169..fce223da 100644 --- a/changes.txt +++ b/changes.txt @@ -7,6 +7,7 @@ Specify encoding for PHP 5.6 with invalid default_charset Fix saving NULL value, bug since Adminer 4.0.3 Send 403 for auth error Report offline and other AJAX errors (bug #419) +Don't alter table comment if not changed Add links to documentation on table status page MySQL: Use utf8mb4 if available MySQL: Support foreign keys in NDB storage