Permalink
Browse files

MDL-44377 dml: enforce non-empty prefix for sqlsrv

Only MySQL is allowed to run Moodle instances without
(with an empty) database prefix. The rationale is that
"user" is a reserved word in every RDBMS but MySQL.

Before this patch, installation was breaking badly, when
the "user" CREATE TABLE statement was issued. With this
patch the error is shown earlier (on connection) preventing
any advance/use of the database.

This check is present in all the drivers, just sqlsrv was missing it.
  • Loading branch information...
stronk7 committed Feb 26, 2014
1 parent ed0a48b commit 36f74f56d8299458b01686e73737e3a4a665ac3b
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/dml/sqlsrv_native_moodle_database.php
@@ -130,6 +130,11 @@ public function get_configuration_help() {
* @throws dml_connection_exception if error
*/
public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) {
+ if ($prefix == '' and !$this->external) {
+ // Enforce prefixes for everybody but mysql.
+ throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily());
+ }
+
$driverstatus = $this->driver_installed();
if ($driverstatus !== true) {

0 comments on commit 36f74f5

Please sign in to comment.