1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Native MariaDB class representing moodle database interface.
|
|
|
19 |
*
|
|
|
20 |
* @package core_dml
|
|
|
21 |
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
defined('MOODLE_INTERNAL') || die();
|
|
|
26 |
|
|
|
27 |
require_once(__DIR__.'/moodle_database.php');
|
|
|
28 |
require_once(__DIR__.'/mysqli_native_moodle_database.php');
|
|
|
29 |
require_once(__DIR__.'/mysqli_native_moodle_recordset.php');
|
|
|
30 |
require_once(__DIR__.'/mysqli_native_moodle_temptables.php');
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* Native MariaDB class representing moodle database interface.
|
|
|
34 |
*
|
|
|
35 |
* @package core_dml
|
|
|
36 |
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
|
|
37 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
38 |
*/
|
|
|
39 |
class mariadb_native_moodle_database extends mysqli_native_moodle_database {
|
|
|
40 |
|
|
|
41 |
/**
|
|
|
42 |
* Returns localised database type name
|
|
|
43 |
* Note: can be used before connect()
|
|
|
44 |
* @return string
|
|
|
45 |
*/
|
|
|
46 |
public function get_name() {
|
|
|
47 |
return get_string('nativemariadb', 'install');
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
/**
|
|
|
51 |
* Returns localised database configuration help.
|
|
|
52 |
* Note: can be used before connect()
|
|
|
53 |
* @return string
|
|
|
54 |
*/
|
|
|
55 |
public function get_configuration_help() {
|
|
|
56 |
return get_string('nativemariadbhelp', 'install');
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* Returns the database vendor.
|
|
|
61 |
* Note: can be used before connect()
|
|
|
62 |
* @return string The db vendor name, usually the same as db family name.
|
|
|
63 |
*/
|
|
|
64 |
public function get_dbvendor() {
|
|
|
65 |
return 'mariadb';
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
/**
|
|
|
69 |
* Returns more specific database driver type
|
|
|
70 |
* Note: can be used before connect()
|
|
|
71 |
* @return string db type mysqli, pgsql, oci, mssql, sqlsrv
|
|
|
72 |
*/
|
|
|
73 |
protected function get_dbtype() {
|
|
|
74 |
return 'mariadb';
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
protected function has_breaking_change_quoted_defaults() {
|
|
|
78 |
$version = $this->get_server_info()['version'];
|
|
|
79 |
// Breaking change since 10.2.7: MDEV-13132.
|
|
|
80 |
return version_compare($version, '10.2.7', '>=');
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
public function has_breaking_change_sqlmode() {
|
|
|
84 |
$version = $this->get_server_info()['version'];
|
|
|
85 |
// Breaking change since 10.2.4: https://mariadb.com/kb/en/the-mariadb-library/sql-mode/#setting-sql_mode.
|
|
|
86 |
return version_compare($version, '10.2.4', '>=');
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
/**
|
|
|
90 |
* It is time to require transactions everywhere.
|
|
|
91 |
*
|
|
|
92 |
* MyISAM is NOT supported!
|
|
|
93 |
*
|
|
|
94 |
* @return bool
|
|
|
95 |
*/
|
|
|
96 |
protected function transactions_supported() {
|
|
|
97 |
if ($this->external) {
|
|
|
98 |
return parent::transactions_supported();
|
|
|
99 |
}
|
|
|
100 |
return true;
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
/**
|
|
|
104 |
* Does this mariadb instance support fulltext indexes?
|
|
|
105 |
*
|
|
|
106 |
* @return bool
|
|
|
107 |
*/
|
|
|
108 |
public function is_fulltext_search_supported() {
|
|
|
109 |
$info = $this->get_server_info();
|
|
|
110 |
|
|
|
111 |
if (version_compare($info['version'], '10.0.5', '>=')) {
|
|
|
112 |
return true;
|
|
|
113 |
}
|
|
|
114 |
return false;
|
|
|
115 |
}
|
|
|
116 |
}
|