mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
Merge branch 'MDL-70181_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE
This commit is contained in:
commit
07d2b976f8
2 changed files with 10 additions and 10 deletions
|
@ -119,7 +119,7 @@ if (!empty($options['collation'])) {
|
||||||
if ($dbcollation->value !== $collation || $dbcharset->value !== $charset) {
|
if ($dbcollation->value !== $collation || $dbcharset->value !== $charset) {
|
||||||
// Try to convert the DB.
|
// Try to convert the DB.
|
||||||
echo "Converting database to '$collation' for $CFG->wwwroot:\n";
|
echo "Converting database to '$collation' for $CFG->wwwroot:\n";
|
||||||
$sql = "ALTER DATABASE $CFG->dbname DEFAULT CHARACTER SET $charset DEFAULT COLLATE = $collation";
|
$sql = "ALTER DATABASE `$CFG->dbname` DEFAULT CHARACTER SET $charset DEFAULT COLLATE = $collation";
|
||||||
try {
|
try {
|
||||||
$DB->change_database_structure($sql);
|
$DB->change_database_structure($sql);
|
||||||
} catch (exception $e) {
|
} catch (exception $e) {
|
||||||
|
@ -146,7 +146,7 @@ if (!empty($options['collation'])) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
$DB->change_database_structure("ALTER TABLE $table->name CONVERT TO CHARACTER SET $charset COLLATE $collation");
|
$DB->change_database_structure("ALTER TABLE `$table->name` CONVERT TO CHARACTER SET $charset COLLATE $collation");
|
||||||
echo "CONVERTED\n";
|
echo "CONVERTED\n";
|
||||||
$converted++;
|
$converted++;
|
||||||
} catch (ddl_exception $e) {
|
} catch (ddl_exception $e) {
|
||||||
|
@ -163,7 +163,7 @@ if (!empty($options['collation'])) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SHOW FULL COLUMNS FROM $table->name WHERE collation IS NOT NULL";
|
$sql = "SHOW FULL COLUMNS FROM `$table->name` WHERE collation IS NOT NULL";
|
||||||
$rs2 = $DB->get_recordset_sql($sql);
|
$rs2 = $DB->get_recordset_sql($sql);
|
||||||
foreach ($rs2 as $column) {
|
foreach ($rs2 as $column) {
|
||||||
$column = (object)array_change_key_case((array)$column, CASE_LOWER);
|
$column = (object)array_change_key_case((array)$column, CASE_LOWER);
|
||||||
|
@ -181,7 +181,7 @@ if (!empty($options['collation'])) {
|
||||||
$notnull = ($column->null === 'NO') ? 'NOT NULL' : 'NULL';
|
$notnull = ($column->null === 'NO') ? 'NOT NULL' : 'NULL';
|
||||||
$default = (!is_null($column->default) and $column->default !== '') ? "DEFAULT '$column->default'" : '';
|
$default = (!is_null($column->default) and $column->default !== '') ? "DEFAULT '$column->default'" : '';
|
||||||
// primary, unique and inc are not supported for texts
|
// primary, unique and inc are not supported for texts
|
||||||
$sql = "ALTER TABLE $table->name
|
$sql = "ALTER TABLE `$table->name`
|
||||||
MODIFY COLUMN $column->field $column->type
|
MODIFY COLUMN $column->field $column->type
|
||||||
CHARACTER SET $charset
|
CHARACTER SET $charset
|
||||||
COLLATE $collation $notnull $default";
|
COLLATE $collation $notnull $default";
|
||||||
|
@ -192,11 +192,11 @@ if (!empty($options['collation'])) {
|
||||||
$default = !is_null($column->default) ? "DEFAULT '$column->default'" : '';
|
$default = !is_null($column->default) ? "DEFAULT '$column->default'" : '';
|
||||||
|
|
||||||
if ($rowformat != '') {
|
if ($rowformat != '') {
|
||||||
$sql = "ALTER TABLE $table->name $rowformat";
|
$sql = "ALTER TABLE `$table->name` $rowformat";
|
||||||
$DB->change_database_structure($sql);
|
$DB->change_database_structure($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "ALTER TABLE $table->name
|
$sql = "ALTER TABLE `$table->name`
|
||||||
MODIFY COLUMN $column->field $column->type
|
MODIFY COLUMN $column->field $column->type
|
||||||
CHARACTER SET $charset
|
CHARACTER SET $charset
|
||||||
COLLATE $collation $notnull $default";
|
COLLATE $collation $notnull $default";
|
||||||
|
@ -315,8 +315,8 @@ function mysql_set_row_format($tablename, $charset, $collation, $engine) {
|
||||||
if ($rs->row_format == 'Compact' || $rs->row_format == 'Redundant') {
|
if ($rs->row_format == 'Compact' || $rs->row_format == 'Redundant') {
|
||||||
$rowformat = $DB->get_row_format_sql($engine, $collation);
|
$rowformat = $DB->get_row_format_sql($engine, $collation);
|
||||||
// Try to convert to compressed format and then try updating the collation again.
|
// Try to convert to compressed format and then try updating the collation again.
|
||||||
$DB->change_database_structure("ALTER TABLE $tablename $rowformat");
|
$DB->change_database_structure("ALTER TABLE `$tablename` $rowformat");
|
||||||
$DB->change_database_structure("ALTER TABLE $tablename CONVERT TO CHARACTER SET $charset COLLATE $collation");
|
$DB->change_database_structure("ALTER TABLE `$tablename` CONVERT TO CHARACTER SET $charset COLLATE $collation");
|
||||||
} else {
|
} else {
|
||||||
// Row format may not be the problem. Can not diagnose problem. Send fail reply.
|
// Row format may not be the problem. Can not diagnose problem. Send fail reply.
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -158,7 +158,7 @@ if (!empty($options['info'])) {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($fixtables as $table) {
|
foreach ($fixtables as $table) {
|
||||||
$DB->change_database_structure("ALTER TABLE {$prefix}$table ROW_FORMAT=Compressed");
|
$DB->change_database_structure("ALTER TABLE `{$prefix}$table` ROW_FORMAT=Compressed");
|
||||||
echo str_pad($prefix . $table, 32, ' ', STR_PAD_RIGHT) . " ... Compressed\n";
|
echo str_pad($prefix . $table, 32, ' ', STR_PAD_RIGHT) . " ... Compressed\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ if (!empty($options['info'])) {
|
||||||
echo "SET GLOBAL innodb_file_per_table=1;\n";
|
echo "SET GLOBAL innodb_file_per_table=1;\n";
|
||||||
echo "SET GLOBAL innodb_file_format=Barracuda;\n";
|
echo "SET GLOBAL innodb_file_format=Barracuda;\n";
|
||||||
foreach ($fixtables as $table) {
|
foreach ($fixtables as $table) {
|
||||||
echo "ALTER TABLE {$prefix}$table ROW_FORMAT=Compressed;\n";
|
echo "ALTER TABLE `{$prefix}$table` ROW_FORMAT=Compressed;\n";
|
||||||
}
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue