Support JSON since MariaDB 10.2 (bug #590)

This commit is contained in:
Jakub Vrana 2018-01-29 21:08:38 +01:00
parent c3b4208853
commit 75450548b3
4 changed files with 11 additions and 6 deletions

View file

@ -307,7 +307,7 @@ if (!defined("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");
if (version_compare($connection->server_info, '5.7.8') >= 0) { if (min_version('5.7.8', 10.2, $connection) >= 0) {
$structured_types[lang('Strings')][] = "json"; $structured_types[lang('Strings')][] = "json";
$types["json"] = 4294967295; $types["json"] = 4294967295;
} }

View file

@ -190,12 +190,12 @@ if (isset($_GET["pgsql"])) {
$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])) {
if ($connection->server_info >= 9) { if (min_version(9, 0, $connection)) {
$connection->query("SET application_name = 'Adminer'"); $connection->query("SET application_name = 'Adminer'");
if ($connection->server_info >= 9.2) { if (min_version(9.2, 0, $connection)) {
$structured_types[lang('Strings')][] = "json"; $structured_types[lang('Strings')][] = "json";
$types["json"] = 4294967295; $types["json"] = 4294967295;
if ($connection->server_info >= 9.4) { if (min_version(9.4, 0, $connection)) {
$structured_types[lang('Strings')][] = "jsonb"; $structured_types[lang('Strings')][] = "jsonb";
$types["jsonb"] = 4294967295; $types["jsonb"] = 4294967295;
} }

View file

@ -76,11 +76,15 @@ function bracket_escape($idf, $back = false) {
/** Check if connection has at least the given version /** Check if connection has at least the given version
* @param string required version * @param string required version
* @param string required MariaDB version * @param string required MariaDB version
* @param Min_DB defaults to $connection
* @return bool * @return bool
*/ */
function min_version($version, $maria_db = "") { function min_version($version, $maria_db = "", $connection2 = null) {
global $connection; global $connection;
$server_info = $connection->server_info; if (!$connection2) {
$connection2 = $connection;
}
$server_info = $connection2->server_info;
if ($maria_db && preg_match('~([\d.]+)-MariaDB~', $server_info, $match)) { if ($maria_db && preg_match('~([\d.]+)-MariaDB~', $server_info, $match)) {
$server_info = $match[1]; $server_info = $match[1];
$version = $maria_db; $version = $maria_db;

View file

@ -1,6 +1,7 @@
Adminer 4.5.1-dev: Adminer 4.5.1-dev:
Fix counting selected rows after going back to select page Fix counting selected rows after going back to select page
PHP <5.3 compatibility even with Elasticsearch enabled PHP <5.3 compatibility even with Elasticsearch enabled
MariaDB: Support JSON since MariaDB 10.2
Malay translation Malay translation
Adminer 4.5.0 (released 2018-01-24): Adminer 4.5.0 (released 2018-01-24):