diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index eca33c48..8c412dca 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -366,11 +366,16 @@ if (!defined("DRIVER")) { /** Get table status * @param string + * @param bool return only "Name", "Engine" and "Comment" fields * @return array array($name => array("Name" => , "Engine" => , "Comment" => , "Oid" => , "Rows" => , "Collation" => , "Auto_increment" => , "Data_length" => , "Index_length" => , "Data_free" => )) or only inner array with $name */ - function table_status($name = "") { + function table_status($name = "", $fast = false) { + global $connection; $return = array(); - foreach (get_rows("SHOW TABLE STATUS" . ($name != "" ? " LIKE " . q(addcslashes($name, "%_\\")) : "")) as $row) { + foreach (get_rows($fast && $connection->server_info >= 5 + ? "SELECT table_name AS Name, Engine, TABLE_COMMENT AS Comment FROM information_schema.TABLES WHERE table_schema = " . q(DB) . ($name != "" ? " AND table_name = " . q($name) : "") + : "SHOW TABLE STATUS" . ($name != "" ? " LIKE " . q(addcslashes($name, "%_\\")) : "") + ) as $row) { if ($row["Engine"] == "InnoDB") { // ignore internal comment, unnecessary since MySQL 5.1.21 $row["Comment"] = preg_replace('~(?:(.+); )?InnoDB free: .*~', '\\1', $row["Comment"]); @@ -391,7 +396,7 @@ if (!defined("DRIVER")) { * @return bool */ function is_view($table_status) { - return !isset($table_status["Rows"]); + return !isset($table_status["Engine"]); } /** Check if table supports foreign keys @@ -960,6 +965,9 @@ if (!defined("DRIVER")) { if (ereg("binary", $field["type"])) { return "HEX(" . idf_escape($field["field"]) . ")"; } + if ($field["type"] == "bit") { + return "BIN(" . idf_escape($field["field"]) . " + 0)"; // + 0 is required outside MySQLnd + } if (ereg("geometry|point|linestring|polygon", $field["type"])) { return "AsWKT(" . idf_escape($field["field"]) . ")"; } @@ -974,6 +982,9 @@ if (!defined("DRIVER")) { if (ereg("binary", $field["type"])) { $return = "UNHEX($return)"; } + if ($field["type"] == "bit") { + return "CONV($return, 2, 10) + 0"; + } if (ereg("geometry|point|linestring|polygon", $field["type"])) { $return = "GeomFromText($return)"; } diff --git a/adminer/dump.inc.php b/adminer/dump.inc.php index 02fa52ee..3d9f0bcd 100644 --- a/adminer/dump.inc.php +++ b/adminer/dump.inc.php @@ -66,7 +66,7 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; if ($_POST["table_style"] || $_POST["data_style"]) { $views = array(); - foreach (table_status() as $name => $table_status) { + foreach (table_status('', true) as $name => $table_status) { $table = (DB == "" || in_array($name, (array) $_POST["tables"])); $data = (DB == "" || in_array($name, (array) $_POST["data"])); if ($table || $data) { diff --git a/adminer/edit.inc.php b/adminer/edit.inc.php index b3f9d301..08892e94 100644 --- a/adminer/edit.inc.php +++ b/adminer/edit.inc.php @@ -38,7 +38,7 @@ if ($_POST && !$error && !isset($_GET["select"])) { } } -$table_name = $adminer->tableName(table_status($TABLE)); +$table_name = $adminer->tableName(table_status($TABLE, true)); page_header( ($update ? lang('Edit') : lang('Insert')), $error, diff --git a/adminer/foreign.inc.php b/adminer/foreign.inc.php index 081b6510..95ca075b 100644 --- a/adminer/foreign.inc.php +++ b/adminer/foreign.inc.php @@ -39,12 +39,7 @@ if ($_POST) { $source = array_keys(fields($TABLE)); //! no text and blob $target = ($TABLE === $row["table"] ? $source : array_keys(fields($row["table"]))); -$referencable = array(); -foreach (table_status() as $name => $table_status) { - if (fk_support($table_status)) { - $referencable[] = $name; - } -} +$referencable = array_keys(array_filter(table_status('', true), 'fk_support')); ?>