mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
Merge branch 'm35_MDL-59596_DDL_Issues_With_MariaDB_10p2_SQLMode' of https://github.com/scara/moodle
This commit is contained in:
commit
17ed12eb17
@ -321,6 +321,27 @@ class mysql_sql_generator extends sql_generator {
|
||||
return $sqls;
|
||||
}
|
||||
|
||||
public function getAlterFieldSQL($xmldb_table, $xmldb_field, $skip_type_clause = NULL, $skip_default_clause = NULL, $skip_notnull_clause = NULL)
|
||||
{
|
||||
$tablename = $xmldb_table->getName();
|
||||
$dbcolumnsinfo = $this->mdb->get_columns($tablename);
|
||||
|
||||
if (($this->mdb->has_breaking_change_sqlmode()) &&
|
||||
($dbcolumnsinfo[$xmldb_field->getName()]->meta_type == 'X') &&
|
||||
($xmldb_field->getType() == XMLDB_TYPE_INTEGER)) {
|
||||
// Ignore 1292 ER_TRUNCATED_WRONG_VALUE Truncated incorrect INTEGER value: '%s'.
|
||||
$altercolumnsqlorig = $this->alter_column_sql;
|
||||
$this->alter_column_sql = str_replace('ALTER TABLE', 'ALTER IGNORE TABLE', $this->alter_column_sql);
|
||||
$result = parent::getAlterFieldSQL($xmldb_table, $xmldb_field, $skip_type_clause, $skip_default_clause, $skip_notnull_clause);
|
||||
// Restore the original ALTER SQL statement pattern.
|
||||
$this->alter_column_sql = $altercolumnsqlorig;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return parent::getAlterFieldSQL($xmldb_table, $xmldb_field, $skip_type_clause, $skip_default_clause, $skip_notnull_clause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given one correct xmldb_table, returns the SQL statements
|
||||
* to create temporary table (inside one array).
|
||||
|
@ -94,6 +94,12 @@ class mariadb_native_moodle_database extends mysqli_native_moodle_database {
|
||||
return version_compare($version, '10.2.7', '>=');
|
||||
}
|
||||
|
||||
public function has_breaking_change_sqlmode() {
|
||||
$version = $this->get_server_info()['version'];
|
||||
// Breaking change since 10.2.4: https://mariadb.com/kb/en/the-mariadb-library/sql-mode/#setting-sql_mode.
|
||||
return version_compare($version, '10.2.4', '>=');
|
||||
}
|
||||
|
||||
/**
|
||||
* It is time to require transactions everywhere.
|
||||
*
|
||||
|
@ -817,6 +817,14 @@ class mysqli_native_moodle_database extends moodle_database {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether SQL_MODE default value has changed in a not backward compatible way.
|
||||
* @return boolean True when SQL_MODE breaks BC; otherwise, false.
|
||||
*/
|
||||
public function has_breaking_change_sqlmode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns moodle column info for raw column from information schema.
|
||||
* @param stdClass $rawcolumn
|
||||
|
Loading…
x
Reference in New Issue
Block a user