From d0a74e4db9ecfaacfc6ea94107d5acb749d5da1a Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Fri, 10 Apr 2015 10:30:09 +0800 Subject: [PATCH] MDL-46963 environment: add check for antelope row format --- admin/environment.xml | 15 +++++++++++++++ lang/en/admin.php | 1 + lib/upgradelib.php | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/admin/environment.xml b/admin/environment.xml index 7ab2be0f7a8..d81383a7992 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -1139,6 +1139,11 @@ + + + + + @@ -1267,6 +1272,11 @@ + + + + + @@ -1400,6 +1410,11 @@ + + + + + diff --git a/lang/en/admin.php b/lang/en/admin.php index 29eabd09cf4..db5e99c3693 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -1054,6 +1054,7 @@ $string['unlockaccount'] = 'Unlock account'; $string['unsettheme'] = 'Unset theme'; $string['unsupported'] = 'Unsupported'; $string['unsupporteddbstorageengine'] = 'The database storage engine being used is no longer supported.'; +$string['unsupporteddbtablerowformat'] = 'Your database has tables using Antelope as the file format. You are recommended to convert the tables to the Barracuda file format. See the documentation Administration via command line for details of a tool for converting InnoDB tables to Barracuda.'; $string['unsuspenduser'] = 'Activate user account'; $string['updateaccounts'] = 'Update existing accounts'; $string['updatecomponent'] = 'Update component'; diff --git a/lib/upgradelib.php b/lib/upgradelib.php index fc89e6702b8..631b162536e 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -2234,3 +2234,35 @@ function check_slasharguments(environment_results $result){ return null; } + +/** + * This function verifies if the database has tables using innoDB Antelope row format. + * + * @param environment_results $result + * @return environment_results|null updated results object, or null if no Antelope table has been found. + */ +function check_database_tables_row_format(environment_results $result) { + global $DB; + + if ($DB->get_dbfamily() == 'mysql') { + $generator = $DB->get_manager()->generator; + + foreach ($DB->get_tables(false) as $table) { + $columns = $DB->get_columns($table, false); + $size = $generator->guess_antolope_row_size($columns); + $format = $DB->get_row_format($table); + + if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) { + continue; + } + + if ($format === 'Compact' or $format === 'Redundant') { + $result->setInfo('unsupported_db_table_row_format'); + $result->setStatus(false); + return $result; + } + } + } + + return null; +}