MDL-49723 tool: deprecate guess_antolope_row_size method
authorSimey Lameze <simey@moodle.com>
Tue, 31 Mar 2015 06:35:45 +0000 (14:35 +0800)
committerSimey Lameze <simey@moodle.com>
Fri, 10 Apr 2015 01:33:35 +0000 (09:33 +0800)
admin/cli/mysql_compressed_rows.php
lib/ddl/mysql_sql_generator.php

index 95af47d..df69376 100644 (file)
@@ -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;
index 5c0de51..fb66931 100644 (file)
@@ -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()) {