]> git.joonet.de Git - adminer.git/commitdiff
MySQL: Simplify checking for MariaDB
authorJakub Vrana <jakub@vrana.cz>
Thu, 13 Mar 2025 11:24:35 +0000 (12:24 +0100)
committerJakub Vrana <jakub@vrana.cz>
Thu, 13 Mar 2025 11:24:35 +0000 (12:24 +0100)
adminer/drivers/mysql.inc.php
adminer/include/adminer.inc.php
adminer/include/editing.inc.php

index a563eca6e9b9571c84f1994cf1f58fe132a2d531..91c07414b3ebdff57a05b8e8d34f24f98073511d 100644 (file)
@@ -368,7 +368,7 @@ if (!defined('Adminer\DRIVER')) {
 
                function slowQuery($query, $timeout) {
                        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";
                                } elseif (preg_match('~^(SELECT\b)(.+)~is', $query, $match)) {
                                        return "$match[1] /*+ MAX_EXECUTION_TIME(" . ($timeout * 1000) . ") */ $match[2]";
@@ -393,7 +393,7 @@ if (!defined('Adminer\DRIVER')) {
                }
 
                function tableHelp($name, $is_view = false) {
-                       $maria = preg_match('~MariaDB~', $this->conn->server_info);
+                       $maria = $this->conn->maria;
                        if (information_schema(DB)) {
                                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])) {
                        $connection->set_charset(charset($connection)); // available in MySQLi since PHP 5.0.5
                        $connection->query("SET sql_quote_show_create = 1, autocommit = 1");
+                       $connection->maria = preg_match('~MariaDB~', $connection->server_info);
                        return $connection;
                }
                $return = $connection->error;
@@ -598,7 +599,7 @@ if (!defined('Adminer\DRIVER')) {
        */
        function fields($table) {
                global $connection;
-               $maria = preg_match('~MariaDB~', $connection->server_info);
+               $maria = $connection->maria;
                $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) {
                        $field = $row["COLUMN_NAME"];
@@ -823,7 +824,7 @@ if (!defined('Adminer\DRIVER')) {
                                $default = $field[1][3];
                                if (preg_match('~ GENERATED~', $default)) {
                                        // 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;
                                }
                                $alter[] = ($table != "" ? ($field[0] != "" ? "CHANGE " . idf_escape($field[0]) : "ADD") : " ") . " " . implode($field[1]) . ($table != "" ? $field[2] : "");
index 928b693864591f83a5441fe20ad306d7f19217dd..b320d4ec883753d5f4ab025d250f92c77f1bbf96 100644 (file)
@@ -1030,9 +1030,8 @@ class Adminer {
                                                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>
 <?php
                        }
index bf24a0a7b1c5308e3444e3c71316fd32b26f92eb..297e1da577e11d5ccc5c7aab998cc88682acbca6 100644 (file)
@@ -630,7 +630,7 @@ function doc_link($paths, $text = "<sup>?</sup>") {
                '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=",
        );
-       if (preg_match('~MariaDB~', $server_info)) {
+       if ($connection->maria) {
                $urls['sql'] = "https://mariadb.com/kb/en/";
                $paths['sql'] = (isset($paths['mariadb']) ? $paths['mariadb'] : str_replace(".html", "/", $paths['sql']));
        }