diff --git a/admin/tool/innodb/index.php b/admin/tool/innodb/index.php index d629486aaa4..3e57e904fdd 100644 --- a/admin/tool/innodb/index.php +++ b/admin/tool/innodb/index.php @@ -42,29 +42,40 @@ if ($DB->get_dbfamily() != 'mysql') { notice('This function is for MySQL databases only!', new moodle_url('/admin/')); } +$prefix = str_replace('_', '\\_', $DB->get_prefix()).'%'; +$sql = "SHOW TABLE STATUS WHERE Name LIKE ? AND Engine <> 'InnoDB'"; +$rs = $DB->get_recordset_sql($sql, array($prefix)); +if (!$rs->valid()) { + $rs->close(); + echo $OUTPUT->box('
All tables are already using InnoDB database engine.
'); + echo $OUTPUT->continue_button('/admin/'); + echo $OUTPUT->footer(); + die; +} + if (data_submitted() and $confirm and confirm_sesskey()) { echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess'); set_time_limit(0); - if ($tables = $DB->get_tables()) { + foreach ($rs as $table) { $DB->set_debug(true); - foreach ($tables as $table) { - $fulltable = $DB->get_prefix().$table; - try { - $DB->change_database_structure("ALTER TABLE $fulltable ENGINE=INNODB"); - } catch (moodle_exception $e) { - echo $OUTPUT->notification(s($e->getMessage()).'