From 0148cd852ea37f0e10722d19b1279f14d9dad6b7 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Tue, 31 Mar 2015 14:35:45 +0800 Subject: [PATCH] MDL-49723 tool: deprecate guess_antolope_row_size method --- admin/cli/mysql_compressed_rows.php | 6 +++--- lib/ddl/mysql_sql_generator.php | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/admin/cli/mysql_compressed_rows.php b/admin/cli/mysql_compressed_rows.php index 95af47d19cc..df693768021 100644 --- a/admin/cli/mysql_compressed_rows.php +++ b/admin/cli/mysql_compressed_rows.php @@ -90,7 +90,7 @@ if (!empty($options['info'])) { $problem = false; foreach ($DB->get_tables(false) as $table) { $columns = $DB->get_columns($table, false); - $size = $generator->guess_antolope_row_size($columns); + $size = $generator->guess_antelope_row_size($columns); $format = $DB->get_row_format($table); if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) { continue; @@ -120,7 +120,7 @@ if (!empty($options['info'])) { $fixtables = array(); foreach ($DB->get_tables(false) as $table) { $columns = $DB->get_columns($table, false); - $size = $generator->guess_antolope_row_size($columns); + $size = $generator->guess_antelope_row_size($columns); $format = $DB->get_row_format($table); if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) { continue; @@ -169,7 +169,7 @@ if (!empty($options['info'])) { foreach ($DB->get_tables(false) as $table) { $columns = $DB->get_columns($table, false); - $size = $generator->guess_antolope_row_size($columns); + $size = $generator->guess_antelope_row_size($columns); $format = $DB->get_row_format($table); if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) { continue; diff --git a/lib/ddl/mysql_sql_generator.php b/lib/ddl/mysql_sql_generator.php index 5c0de51f987..fb669315c4a 100644 --- a/lib/ddl/mysql_sql_generator.php +++ b/lib/ddl/mysql_sql_generator.php @@ -118,10 +118,25 @@ class mysql_sql_generator extends sql_generator { * Note: the returned value is a bit higher to compensate for * errors and changes of column data types. * + * @deprecated since Moodle 2.9 MDL-49723 - please do not use this function any more. * @param xmldb_field[]|database_column_info[] $columns * @return int approximate row size in bytes */ public function guess_antolope_row_size(array $columns) { + debugging('guess_antolope_row_size() is deprecated, please use guess_antelope_row_size() instead.', DEBUG_DEVELOPER); + return $this->guess_antelope_row_size($columns); + } + + /** + * Calculate proximate row size when using InnoDB tables in Antelope row format. + * + * Note: the returned value is a bit higher to compensate for errors and changes of column data types. + * + * @param xmldb_field[]|database_column_info[] $columns + * @return int approximate row size in bytes + */ + public function guess_antelope_row_size(array $columns) { + if (empty($columns)) { return 0; } @@ -199,7 +214,7 @@ class mysql_sql_generator extends sql_generator { // Do we need to use compressed format for rows? $rowformat = ""; - $size = $this->guess_antolope_row_size($xmldb_table->getFields()); + $size = $this->guess_antelope_row_size($xmldb_table->getFields()); if ($size > self::ANTELOPE_MAX_ROW_SIZE) { if ($this->mdb->is_compressed_row_format_supported()) { $rowformat = "\n ROW_FORMAT=Compressed"; @@ -289,8 +304,8 @@ class mysql_sql_generator extends sql_generator { if ($this->table_exists($xmldb_table)) { $tablename = $xmldb_table->getName(); - $size = $this->guess_antolope_row_size($this->mdb->get_columns($tablename)); - $size += $this->guess_antolope_row_size(array($xmldb_field)); + $size = $this->guess_antelope_row_size($this->mdb->get_columns($tablename)); + $size += $this->guess_antelope_row_size(array($xmldb_field)); if ($size > self::ANTELOPE_MAX_ROW_SIZE) { if ($this->mdb->is_compressed_row_format_supported()) {