mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 15:47:00 +02:00
MySQL: Simplify checking for MariaDB
This commit is contained in:
@@ -368,7 +368,7 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
|
|
||||||
function slowQuery($query, $timeout) {
|
function slowQuery($query, $timeout) {
|
||||||
if (min_version('5.7.8', '10.1.2')) {
|
if (min_version('5.7.8', '10.1.2')) {
|
||||||
if (preg_match('~MariaDB~', $this->conn->server_info)) {
|
if ($this->conn->maria) {
|
||||||
return "SET STATEMENT max_statement_time=$timeout FOR $query";
|
return "SET STATEMENT max_statement_time=$timeout FOR $query";
|
||||||
} elseif (preg_match('~^(SELECT\b)(.+)~is', $query, $match)) {
|
} elseif (preg_match('~^(SELECT\b)(.+)~is', $query, $match)) {
|
||||||
return "$match[1] /*+ MAX_EXECUTION_TIME(" . ($timeout * 1000) . ") */ $match[2]";
|
return "$match[1] /*+ MAX_EXECUTION_TIME(" . ($timeout * 1000) . ") */ $match[2]";
|
||||||
@@ -393,7 +393,7 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function tableHelp($name, $is_view = false) {
|
function tableHelp($name, $is_view = false) {
|
||||||
$maria = preg_match('~MariaDB~', $this->conn->server_info);
|
$maria = $this->conn->maria;
|
||||||
if (information_schema(DB)) {
|
if (information_schema(DB)) {
|
||||||
return strtolower("information-schema-" . ($maria ? "$name-table/" : str_replace("_", "-", $name) . "-table.html"));
|
return strtolower("information-schema-" . ($maria ? "$name-table/" : str_replace("_", "-", $name) . "-table.html"));
|
||||||
}
|
}
|
||||||
@@ -439,6 +439,7 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
|
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
|
||||||
$connection->set_charset(charset($connection)); // available in MySQLi since PHP 5.0.5
|
$connection->set_charset(charset($connection)); // available in MySQLi since PHP 5.0.5
|
||||||
$connection->query("SET sql_quote_show_create = 1, autocommit = 1");
|
$connection->query("SET sql_quote_show_create = 1, autocommit = 1");
|
||||||
|
$connection->maria = preg_match('~MariaDB~', $connection->server_info);
|
||||||
return $connection;
|
return $connection;
|
||||||
}
|
}
|
||||||
$return = $connection->error;
|
$return = $connection->error;
|
||||||
@@ -598,7 +599,7 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
*/
|
*/
|
||||||
function fields($table) {
|
function fields($table) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$maria = preg_match('~MariaDB~', $connection->server_info);
|
$maria = $connection->maria;
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_rows("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = " . q($table) . " ORDER BY ORDINAL_POSITION") as $row) {
|
foreach (get_rows("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = " . q($table) . " ORDER BY ORDINAL_POSITION") as $row) {
|
||||||
$field = $row["COLUMN_NAME"];
|
$field = $row["COLUMN_NAME"];
|
||||||
@@ -823,7 +824,7 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
$default = $field[1][3];
|
$default = $field[1][3];
|
||||||
if (preg_match('~ GENERATED~', $default)) {
|
if (preg_match('~ GENERATED~', $default)) {
|
||||||
// swap default and null
|
// swap default and null
|
||||||
$field[1][3] = (preg_match('~MariaDB~', $connection->server_info) ? "" : $field[1][2]); // MariaDB doesn't support NULL on virtual columns
|
$field[1][3] = ($connection->maria ? "" : $field[1][2]); // MariaDB doesn't support NULL on virtual columns
|
||||||
$field[1][2] = $default;
|
$field[1][2] = $default;
|
||||||
}
|
}
|
||||||
$alter[] = ($table != "" ? ($field[0] != "" ? "CHANGE " . idf_escape($field[0]) : "ADD") : " ") . " " . implode($field[1]) . ($table != "" ? $field[2] : "");
|
$alter[] = ($table != "" ? ($field[0] != "" ? "CHANGE " . idf_escape($field[0]) : "ADD") : " ") . " " . implode($field[1]) . ($table != "" ? $field[2] : "");
|
||||||
|
@@ -1030,9 +1030,8 @@ class Adminer {
|
|||||||
echo "jushLinks.$val = jushLinks." . JUSH . ";\n";
|
echo "jushLinks.$val = jushLinks." . JUSH . ";\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$server_info = $connection->server_info;
|
|
||||||
?>
|
?>
|
||||||
bodyLoad('<?php echo (is_object($connection) ? preg_replace('~^(\d\.?\d).*~s', '\1', $server_info) : ""); ?>'<?php echo (preg_match('~MariaDB~', $server_info) ? ", true" : ""); ?>);
|
bodyLoad('<?php echo (is_object($connection) ? preg_replace('~^(\d\.?\d).*~s', '\1', $connection->server_info) : ""); ?>'<?php echo ($connection->maria ? ", true" : ""); ?>);
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
@@ -630,7 +630,7 @@ function doc_link($paths, $text = "<sup>?</sup>") {
|
|||||||
'mssql' => "https://learn.microsoft.com/en-us/sql/",
|
'mssql' => "https://learn.microsoft.com/en-us/sql/",
|
||||||
'oracle' => "https://www.oracle.com/pls/topic/lookup?ctx=db" . preg_replace('~^.* (\d+)\.(\d+)\.\d+\.\d+\.\d+.*~s', '\1\2', $server_info) . "&id=",
|
'oracle' => "https://www.oracle.com/pls/topic/lookup?ctx=db" . preg_replace('~^.* (\d+)\.(\d+)\.\d+\.\d+\.\d+.*~s', '\1\2', $server_info) . "&id=",
|
||||||
);
|
);
|
||||||
if (preg_match('~MariaDB~', $server_info)) {
|
if ($connection->maria) {
|
||||||
$urls['sql'] = "https://mariadb.com/kb/en/";
|
$urls['sql'] = "https://mariadb.com/kb/en/";
|
||||||
$paths['sql'] = (isset($paths['mariadb']) ? $paths['mariadb'] : str_replace(".html", "/", $paths['sql']));
|
$paths['sql'] = (isset($paths['mariadb']) ? $paths['mariadb'] : str_replace(".html", "/", $paths['sql']));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user