Skip to content

Commit 66ba391

Browse files
mackensenstronk7
authored andcommitted
MDL-58931 dml: add support for aurora mysql
1 parent a2b286c commit 66ba391

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed

admin/cli/install.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@
215215

216216
//Database types
217217
$databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
218+
'auroramysql' => moodle_database::get_driver_instance('auroramysql', 'native'),
218219
'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
219220
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
220221
'oci' => moodle_database::get_driver_instance('oci', 'native'),

install.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@
493493
get_string('databasetypesub', 'install'));
494494

495495
$databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
496+
'auroramysql' => moodle_database::get_driver_instance('auroramysql', 'native'),
496497
'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
497498
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
498499
'oci' => moodle_database::get_driver_instance('oci', 'native'),

lang/en/install.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@
169169
(you will see errors when you look at pages) so you\'ll have to remove the .htaccess file.</p></li>
170170
</ol>';
171171
$string['mysqliextensionisnotpresentinphp'] = 'PHP has not been properly configured with the MySQLi extension for it to communicate with MySQL. Please check your php.ini file or recompile PHP.';
172+
$string['nativeauroramysql'] = 'Aurora MySQL (native/auroramysql)';
173+
$string['nativeauroramysqlhelp'] = '<p>The database is where most of the Moodle settings and data are stored and must be configured here.</p>
174+
<p>The database name, username, and password are required fields; table prefix is optional.</p>
175+
<p>The database name may contain only alphanumeric characters, dollar ($) and underscore (_).</p>
176+
<p>If the database currently does not exist, and the user you specify has permission, Moodle will attempt to create a new database with the correct permissions and settings.</p>
177+
<p>This driver is not compatible with legacy MyISAM engine.</p>';
172178
$string['nativemariadb'] = 'MariaDB (native/mariadb)';
173179
$string['nativemariadbhelp'] = '<p>The database is where most of the Moodle settings and data are stored and must be configured here.</p>
174180
<p>The database name, username, and password are required fields; table prefix is optional.</p>
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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 Aurora MySQL class representing moodle database interface.
19+
*
20+
* @package core_dml
21+
* @copyright 2020 Lafayette College ITS
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 Aurora MySQL class representing moodle database interface.
34+
*
35+
* @package core_dml
36+
* @copyright 2020 Lafayette College ITS
37+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38+
*/
39+
class auroramysql_native_moodle_database extends mysqli_native_moodle_database {
40+
41+
/** @var bool is compressed row format supported cache */
42+
protected $compressedrowformatsupported = false;
43+
44+
/**
45+
* Returns localised database type name.
46+
*
47+
* Returns localised database type name. Can be used before connect().
48+
* @return string
49+
*/
50+
public function get_name(): ?string {
51+
return get_string('nativeauroramysql', 'install');
52+
}
53+
54+
/**
55+
* Returns localised database configuration help.
56+
*
57+
* Returns localised database configuration help. Can be used before connect().
58+
* @return string
59+
*/
60+
public function get_configuration_help(): ?string {
61+
return get_string('nativeauroramysql', 'install');
62+
}
63+
64+
/**
65+
* Returns the database vendor.
66+
*
67+
* Returns the database vendor. Can be used before connect().
68+
* @return string The db vendor name, usually the same as db family name.
69+
*/
70+
public function get_dbvendor(): ?string {
71+
return 'mysql';
72+
}
73+
74+
/**
75+
* Returns more specific database driver type
76+
*
77+
* Returns more specific database driver type. Can be used before connect().
78+
* @return string db type mysqli, pgsql, oci, mssql, sqlsrv
79+
*/
80+
protected function get_dbtype(): ?string {
81+
return 'auroramysql';
82+
}
83+
84+
/**
85+
* It is time to require transactions everywhere.
86+
*
87+
* MyISAM is NOT supported!
88+
*
89+
* @return bool
90+
*/
91+
protected function transactions_supported(): ?bool {
92+
if ($this->external) {
93+
return parent::transactions_supported();
94+
}
95+
return true;
96+
}
97+
98+
99+
}

0 commit comments

Comments
 (0)