Commit 17601a7e authored by Petr Škoda's avatar Petr Škoda Committed by Dan Poltawski
Browse files

MDL-39985 add explicit MariaDB support

parent a60bc9a3
......@@ -188,6 +188,7 @@ $CFG->target_release = $release;
//Database types
$databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
'oci' => moodle_database::get_driver_instance('oci', 'native'),
'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
......
......@@ -899,6 +899,7 @@
</FEEDBACK>
</UNICODE>
<DATABASE level="required">
<VENDOR name="mariadb" version="5.3.5" />
<VENDOR name="mysql" version="5.1.33" />
<VENDOR name="postgres" version="8.3" />
<VENDOR name="mssql" version="9.0" />
......
......@@ -52,6 +52,7 @@ class auth_db_testcase extends advanced_testcase {
set_config('sybasequoting', '1', 'auth/db');
break;
case 'mariadb_native_moodle_database':
case 'mysqli_native_moodle_database':
set_config('type', 'mysqli', 'auth/db');
set_config('setupsql', "SET NAMES 'UTF-8'", 'auth/db');
......
......@@ -38,7 +38,7 @@ $CFG = new stdClass();
// will be stored. This database must already have been created //
// and a username/password created to access it. //
$CFG->dbtype = 'pgsql'; // 'pgsql', 'mysqli', 'mssql', 'sqlsrv' or 'oci'
$CFG->dbtype = 'pgsql'; // 'pgsql', 'mariadb', 'mysqli', 'mssql', 'sqlsrv' or 'oci'
$CFG->dblibrary = 'native'; // 'native' only at the moment
$CFG->dbhost = 'localhost'; // eg 'localhost' or 'db.isp.com' or IP
$CFG->dbname = 'moodle'; // database name, eg moodle
......
......@@ -53,6 +53,7 @@ class enrol_database_testcase extends advanced_testcase {
set_config('dbsybasequoting', '1', 'enrol_database');
break;
case 'mariadb_native_moodle_database':
case 'mysqli_native_moodle_database':
set_config('dbtype', 'mysqli', 'enrol_database');
set_config('dbsetupsql', "SET NAMES 'UTF-8'", 'enrol_database');
......
......@@ -469,6 +469,7 @@ if ($config->stage == INSTALL_DATABASETYPE) {
get_string('databasetypesub', 'install'));
$databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
'oci' => moodle_database::get_driver_instance('oci', 'native'),
'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
......
......@@ -283,6 +283,10 @@ $string['mysql'] = 'MySQL (mysql)';
$string['mysqlextensionisnotpresentinphp'] = 'PHP has not been properly configured with the MySQL extension so that it can communicate with MySQL. Please check your php.ini file or recompile PHP.';
$string['mysqli'] = 'Improved MySQL (mysqli)';
$string['mysqliextensionisnotpresentinphp'] = 'PHP has not been properly configured with the MySQLi extension so that it can communicate with MySQL. Please check your php.ini file or recompile PHP. MySQLi extension is not available for PHP 4.';
$string['nativemariadb'] = 'MariaDB (native/mariadb)';
$string['nativemariadbhelp'] = 'Now you need to configure the database where most Moodle data will be stored.
Database may be created if database user has needed permissions, username and password must already exist. Table prefix is optional.
This driver is not compatible with legacy MyISAM engine.';
$string['nativemysqli'] = 'Improved MySQL (native/mysqli)';
$string['nativemysqlihelp'] = 'Now you need to configure the database where most Moodle data will be stored.
Database may be created if database user has needed permissions, username and password must already exist. Table prefix is optional.';
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Native MariaDB class representing moodle database interface.
*
* @package core_dml
* @copyright 2013 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__.'/moodle_database.php');
require_once(__DIR__.'/mysqli_native_moodle_database.php');
require_once(__DIR__.'/mysqli_native_moodle_recordset.php');
require_once(__DIR__.'/mysqli_native_moodle_temptables.php');
/**
* Native MariaDB class representing moodle database interface.
*
* @package core_dml
* @copyright 2013 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mariadb_native_moodle_database extends mysqli_native_moodle_database {
/**
* Returns localised database type name
* Note: can be used before connect()
* @return string
*/
public function get_name() {
return get_string('nativemariadb', 'install');
}
/**
* Returns localised database configuration help.
* Note: can be used before connect()
* @return string
*/
public function get_configuration_help() {
return get_string('nativemariadbhelp', 'install');
}
/**
* Returns the database vendor.
* Note: can be used before connect()
* @return string The db vendor name, usually the same as db family name.
*/
public function get_dbvendor() {
return 'mariadb';
}
/**
* Returns more specific database driver type
* Note: can be used before connect()
* @return string db type mysqli, pgsql, oci, mssql, sqlsrv
*/
protected function get_dbtype() {
return 'mariadb';
}
/**
* It is time to require transactions everywhere.
*
* MyISAM is NOT supported!
*
* @return bool
*/
protected function transactions_supported() {
if ($this->external) {
return parent::transactions_supported();
}
return true;
}
/**
* Returns the current db engine.
*
* MyISAM is NOT supported!
*
* @return string or null MySQL engine name
*/
public function get_dbengine() {
if ($this->external) {
return null;
}
$engine = parent::get_dbengine();
if ($engine === 'MyISAM') {
debugging('MyISAM tables are not supported in MariaDB driver!');
$engine = 'XtraDB';
}
return $engine;
}
}
......@@ -184,6 +184,15 @@ abstract class moodle_database {
return new $classname($external);
}
/**
* Returns the database vendor.
* Note: can be used before connect()
* @return string The db vendor name, usually the same as db family name.
*/
public function get_dbvendor() {
return $this->get_dbfamily();
}
/**
* Returns the database family type. (This sort of describes the SQL 'dialect')
* Note: can be used before connect()
......
......@@ -962,7 +962,7 @@ function environment_check_database($version, $env_select) {
}
/// Now search the version we are using (depending of vendor)
$current_vendor = $DB->get_dbfamily();
$current_vendor = $DB->get_dbvendor();
$dbinfo = $DB->get_server_info();
$current_version = normalize_version($dbinfo['version']);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment