1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-29 17:19:52 +02:00

MariaDB: Add support for UUID data type

- MariaDB >= 10.7
- UUID string data type
- uuid() function for UUID type on new/edit item form
This commit is contained in:
vukbgit
2024-11-02 14:52:23 +01:00
committed by Peter Knut
parent 9eeeca6b0e
commit 2430ad2702
2 changed files with 21 additions and 2 deletions

View File

@@ -371,16 +371,28 @@ if (!defined("DRIVER")) {
* @return mixed Min_DB or string for error * @return mixed Min_DB or string for error
*/ */
function connect() { function connect() {
global $adminer, $types, $structured_types; global $adminer, $types, $structured_types, $edit_functions;
$connection = new Min_DB; $connection = new Min_DB;
$credentials = $adminer->credentials(); $credentials = $adminer->credentials();
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) { if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
$connection->set_charset(charset($connection)); $connection->set_charset(charset($connection));
$connection->query("SET sql_quote_show_create = 1, autocommit = 1"); $connection->query("SET sql_quote_show_create = 1, autocommit = 1");
if (min_version('5.7.8', 10.2, $connection)) {
if (min_version('5.7.8', '10.2', $connection)) {
$structured_types[lang('Strings')][] = "json"; $structured_types[lang('Strings')][] = "json";
$types["json"] = 4294967295; $types["json"] = 4294967295;
} }
// UUID data type for Mariadb >= 10.7
if (min_version('', '10.7', $connection)) {
$structured_types[lang('Strings')][] = "uuid";
$types["uuid"] = 128;
// insert/update function
$edit_functions[0]['uuid'] = 'uuid';
}
return $connection; return $connection;
} }
$return = $connection->error; $return = $connection->error;

View File

@@ -108,6 +108,9 @@ function min_version($version, $maria_db = "", $connection2 = null) {
$server_info = $match[1]; $server_info = $match[1];
$version = $maria_db; $version = $maria_db;
} }
if ($version == "") {
return false;
}
return (version_compare($server_info, $version) >= 0); return (version_compare($server_info, $version) >= 0);
} }
@@ -1575,6 +1578,10 @@ function edit_form($table, $fields, $row, $update) {
$value = ""; $value = "";
$function = "now"; $function = "now";
} }
if ($field["type"] == "uuid" && $value == "uuid()") {
$value = "";
$function = "uuid";
}
input($field, $value, $function); input($field, $value, $function);
echo "\n"; echo "\n";
} }