1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

CockroachDB: Display CockroachDB instead of PostgreSQL

This commit is contained in:
Jakub Vrana
2025-03-16 19:02:29 +01:00
parent 777d5dca0e
commit d8a9a3db8d
3 changed files with 11 additions and 6 deletions

View File

@@ -441,7 +441,7 @@ if (!defined('Adminer\DRIVER')) {
$connection->set_charset(charset($connection));
$connection->query("SET sql_quote_show_create = 1, autocommit = 1");
$connection->maria = preg_match('~MariaDB~', $connection->server_info);
$drivers["server"] = ($connection->maria ? "MariaDB" : "MySQL");
$drivers[DRIVER] = ($connection->maria ? "MariaDB" : "MySQL");
return $connection;
}
$return = $connection->error;

View File

@@ -321,6 +321,7 @@ if (isset($_GET["pgsql"])) {
}
function connect($credentials) {
global $drivers;
$connection = new Db;
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
if (min_version(9, 0, $connection)) {
@@ -328,6 +329,10 @@ if (isset($_GET["pgsql"])) {
}
$crdb_version = $connection->result("SHOW crdb_version");
$connection->server_info .= ($crdb_version ? "-" . preg_replace('~ \(.*~', '', $crdb_version) : "");
$connection->cockroach = preg_match('~CockroachDB~', $connection->server_info);
if ($connection->cockroach) { // we don't use "PostgreSQL / CockroachDB" by default because it's too long
$drivers[DRIVER] = "CockroachDB";
}
return $connection;
}
return $connection->error;
@@ -954,10 +959,10 @@ AND typelem = 0"
function support($feature) {
global $connection;
return ($feature == "processlist"
? !preg_match('~CockroachDB~', $connection->server_info) // https://github.com/cockroachdb/cockroach/issues/24745
: preg_match('~^(check|database|table|columns|sql|indexes|descidx|comment|view|' . (min_version(9.3) ? 'materializedview|' : '') . 'scheme|routine|sequence|trigger|type|variables|drop_col|kill|dump)$~', $feature)
);
return preg_match('~^(check|database|table|columns|sql|indexes|descidx|comment|view|' . (min_version(9.3) ? 'materializedview|' : '') . 'scheme|routine|sequence|trigger|type|variables|drop_col'
. ($connection->cockroach ? '' : '|processlist') // https://github.com/cockroachdb/cockroach/issues/24745
. '|kill|dump)$~', $feature)
;
}
function kill_process($val) {

View File

@@ -169,7 +169,7 @@ if (isset($_GET["username"]) && is_string(get_password())) {
if ($adminer->operators === null) {
$adminer->operators = $driver->operators;
}
if (isset($connection->maria)) {
if (isset($connection->maria) || $connection->cockroach) {
save_settings(array("vendor-" . SERVER => $drivers[DRIVER]));
}
}