MDL-59596 ddl: Support MariaDB 10.2.4+ SQL_MODE new default value.

This commit is contained in:
Matteo Scaramuccia 2017-09-04 00:34:12 +02:00
parent f6b16e95a8
commit 1f8d943461

View File

@ -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).