MDL-49723 tool: deprecate guess_antolope_row_size method

This commit is contained in:
Simey Lameze 2015-03-31 14:35:45 +08:00
parent d7551257a0
commit 0148cd852e
2 changed files with 21 additions and 6 deletions

View file

@ -90,7 +90,7 @@ if (!empty($options['info'])) {
$problem = false; $problem = false;
foreach ($DB->get_tables(false) as $table) { foreach ($DB->get_tables(false) as $table) {
$columns = $DB->get_columns($table, false); $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); $format = $DB->get_row_format($table);
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) { if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
continue; continue;
@ -120,7 +120,7 @@ if (!empty($options['info'])) {
$fixtables = array(); $fixtables = array();
foreach ($DB->get_tables(false) as $table) { foreach ($DB->get_tables(false) as $table) {
$columns = $DB->get_columns($table, false); $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); $format = $DB->get_row_format($table);
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) { if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
continue; continue;
@ -169,7 +169,7 @@ if (!empty($options['info'])) {
foreach ($DB->get_tables(false) as $table) { foreach ($DB->get_tables(false) as $table) {
$columns = $DB->get_columns($table, false); $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); $format = $DB->get_row_format($table);
if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) { if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
continue; continue;

View file

@ -118,10 +118,25 @@ class mysql_sql_generator extends sql_generator {
* Note: the returned value is a bit higher to compensate for * Note: the returned value is a bit higher to compensate for
* errors and changes of column data types. * 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 * @param xmldb_field[]|database_column_info[] $columns
* @return int approximate row size in bytes * @return int approximate row size in bytes
*/ */
public function guess_antolope_row_size(array $columns) { 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)) { if (empty($columns)) {
return 0; return 0;
} }
@ -199,7 +214,7 @@ class mysql_sql_generator extends sql_generator {
// Do we need to use compressed format for rows? // Do we need to use compressed format for rows?
$rowformat = ""; $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 ($size > self::ANTELOPE_MAX_ROW_SIZE) {
if ($this->mdb->is_compressed_row_format_supported()) { if ($this->mdb->is_compressed_row_format_supported()) {
$rowformat = "\n ROW_FORMAT=Compressed"; $rowformat = "\n ROW_FORMAT=Compressed";
@ -289,8 +304,8 @@ class mysql_sql_generator extends sql_generator {
if ($this->table_exists($xmldb_table)) { if ($this->table_exists($xmldb_table)) {
$tablename = $xmldb_table->getName(); $tablename = $xmldb_table->getName();
$size = $this->guess_antolope_row_size($this->mdb->get_columns($tablename)); $size = $this->guess_antelope_row_size($this->mdb->get_columns($tablename));
$size += $this->guess_antolope_row_size(array($xmldb_field)); $size += $this->guess_antelope_row_size(array($xmldb_field));
if ($size > self::ANTELOPE_MAX_ROW_SIZE) { if ($size > self::ANTELOPE_MAX_ROW_SIZE) {
if ($this->mdb->is_compressed_row_format_supported()) { if ($this->mdb->is_compressed_row_format_supported()) {