[Phpmyadmin-git] [SCM] phpMyAdmin branch, QA_3_3, updated. RELEASE_3_3_1RC1-53-g7c818d0

Marc Delisle lem9 at users.sourceforge.net
Fri Mar 12 23:22:24 CET 2010


The branch, QA_3_3 has been updated
       via  7c818d046a4c9f01a8e94b55a0726a1cc3d6a60d (commit)
      from  4a53eb19160936770d32244939ee82906e0f88c8 (commit)


- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                        |    2 ++
 db_operations.php                |    2 +-
 db_printview.php                 |    2 +-
 db_structure.php                 |    6 +++++-
 export.php                       |    7 +++----
 libraries/Table.class.php        |   32 ++++++++++++++++++++++++++++++--
 libraries/display_export.lib.php |    5 +----
 tbl_printview.php                |    7 +++----
 tbl_structure.php                |    7 +++----
 9 files changed, 49 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f120b5a..26f8b70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@ $Id$
 $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyAdmin/ChangeLog $
 
 3.3.2.0 (not yet released)
+- patch #2969449 [core] Name for MERGE engine varies depending on the
+  MySQL version, thanks to Dieter Adriaenssens - ruleant
 
 3.3.1.0 (not yet released)
 - bug #2941037 [core] Database structure not sorted by table correctly 
diff --git a/db_operations.php b/db_operations.php
index 624007e..f051877 100644
--- a/db_operations.php
+++ b/db_operations.php
@@ -110,7 +110,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
 
             // do not copy the data from a Merge table
             // note: on the calling FORM, 'data' means 'structure and data'
-            if ($tables_full[$each_table]['Engine'] == 'MRG_MyISAM') {
+            if (PMA_Table::isMerge($db, $each_table)) {
                 if ($this_what == 'data') {
                     $this_what = 'structure';
                 }
diff --git a/db_printview.php b/db_printview.php
index bf51015..d656f0e 100644
--- a/db_printview.php
+++ b/db_printview.php
@@ -117,7 +117,7 @@ else {
     $sum_entries = $sum_size = 0;
     $odd_row = true;
     foreach ($tables as $sts_data) {
-        if (strtoupper($sts_data['ENGINE']) == 'MRG_MYISAM'
+        if (PMA_Table::isMerge($db, $sts_data['TABLE_NAME'])
          || strtoupper($sts_data['ENGINE']) == 'FEDERATED') {
             $merged_size = true;
         } else {
diff --git a/db_structure.php b/db_structure.php
index fa18390..845ffd3 100644
--- a/db_structure.php
+++ b/db_structure.php
@@ -226,7 +226,11 @@ foreach ($tables as $keyname => $each_table) {
             }
             //$display_rows                   =  ' - ';
             break;
+	    // Mysql 5.0.x (and lower) uses MRG_MyISAM and MySQL 5.1.x (and higher) uses MRG_MYISAM
+        // Both are aliases for MERGE
+        case 'MRG_MyISAM' :
         case 'MRG_MYISAM' :
+        case 'MERGE' :
         case 'BerkeleyDB' :
             // Merge or BerkleyDB table: Only row count is accurate.
             if ($is_show_stats) {
@@ -255,7 +259,7 @@ foreach ($tables as $keyname => $each_table) {
             }
     } // end switch
 
-    if ('MRG_MYISAM' != $each_table['ENGINE']) {
+    if (! PMA_Table::isMerge($db, $each_table['TABLE_NAME'])) {
         $sum_entries += $each_table['TABLE_ROWS'];
     }
 
diff --git a/export.php b/export.php
index f8c9914..dae4cf4 100644
--- a/export.php
+++ b/export.php
@@ -439,7 +439,7 @@ if ($export_type == 'server') {
                     }
                 }
                 // if this is a view or a merge table, don't export data
-                if (isset($GLOBALS[$what . '_data']) && !($is_view || (strcasecmp(PMA_Table::sGetStatusInfo($current_db, $table, 'Engine'),'MRG_MYISAM') == 0))) {
+                if (isset($GLOBALS[$what . '_data']) && !($is_view || PMA_Table::isMerge($current_db, $table))) {
                     $local_query  = 'SELECT * FROM ' . PMA_backquote($current_db) . '.' . PMA_backquote($table);
                     if (!PMA_exportData($current_db, $table, $crlf, $err_url, $local_query)) {
                         break 3;
@@ -488,7 +488,7 @@ if ($export_type == 'server') {
             }
         }
         // if this is a view or a merge table, don't export data
-        if (isset($GLOBALS[$what . '_data']) && !($is_view || (strcasecmp(PMA_Table::sGetStatusInfo($db, $table, 'Engine'),'MRG_MYISAM') == 0))) {
+        if (isset($GLOBALS[$what . '_data']) && !($is_view || PMA_Table::isMerge($db, $table))) {
             $local_query  = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
             if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
                 break 2;
@@ -537,8 +537,7 @@ if ($export_type == 'server') {
     // If this is an export of a single view, we have to export data;
     // for example, a PDF report
     // if it is a merge table, no data is exported
-    $is_merge = ! PMA_Table::isView($db, $table) && (strcasecmp(PMA_Table::sGetStatusInfo($db, $table, 'Engine'),'MRG_MYISAM') == 0);
-    if (isset($GLOBALS[$what . '_data']) && ! $is_merge) {
+    if (isset($GLOBALS[$what . '_data']) && ! PMA_Table::isMerge($db, $table)) {
         if (!empty($sql_query)) {
             // only preg_replace if needed
             if (!empty($add_query)) {
diff --git a/libraries/Table.class.php b/libraries/Table.class.php
index 0f407e7..de2cfe2 100644
--- a/libraries/Table.class.php
+++ b/libraries/Table.class.php
@@ -238,6 +238,31 @@ class PMA_Table
         return $type == 'VIEW';
     }
 
+    /**
+     * Checks if this is a merge table
+     *
+     * If the ENGINE of the table is MERGE or MRG_MYISAM (alias), this is a merge table.
+     *
+     * @param   string   the database name
+     * @param   string   the table name
+     * @return  boolean  true if it is a merge table 
+     * @access  public
+     */
+    public function isMerge($db = null, $table = null)
+    {
+        // if called static, with parameters
+        if (! empty($db) && ! empty($table)) {
+            $engine = PMA_Table::sGetStatusInfo($db, $table, 'ENGINE', null, true);
+        }
+        // if called as an object
+        // does not work yet, because $this->settings[] is not filled correctly
+        else if (! empty($this)) {
+            $engine = $this->get('ENGINE');
+        }
+
+        return (! empty($engine) && ((strtoupper($engine) == 'MERGE') || (strtoupper($engine) == 'MRG_MYISAM')));
+    }
+
     static public function sGetToolTip($db, $table)
     {
         return PMA_Table::sGetStatusInfo($db, $table, 'Comment')
@@ -254,9 +279,10 @@ class PMA_Table
      * @param string $table
      * @param string $info
      * @param boolean $force_read
+     * @param boolean if true, disables error message
      * @return mixed
      */
-    static public function sGetStatusInfo($db, $table, $info = null, $force_read = false)
+    static public function sGetStatusInfo($db, $table, $info = null, $force_read = false, $disable_error = false)
     {
         if (! isset(PMA_Table::$cache[$db][$table]) || $force_read) {
             PMA_DBI_get_tables_full($db, $table);
@@ -274,7 +300,9 @@ class PMA_Table
         }
 
         if (! isset(PMA_Table::$cache[$db][$table][$info])) {
-            trigger_error('unknown table status: ' . $info, E_USER_WARNING);
+            if (! $disable_error) {
+                trigger_error('unknown table status: ' . $info, E_USER_WARNING);
+            }
             return false;
         }
 
diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php
index a680995..186b0d3 100644
--- a/libraries/display_export.lib.php
+++ b/libraries/display_export.lib.php
@@ -104,10 +104,7 @@ echo PMA_pluginGetJavascript($export_list);
 //]]>
 </script>
 
-<?php 
-    $is_merge = ! PMA_Table::isView($db, $table) && (strcasecmp(PMA_Table::sGetStatusInfo($db, $table, 'Engine'),'MRG_MYISAM') == 0);
-    if (strlen($table) && ! isset($num_tables) && ! $is_merge) { 
-?>
+<?php if (strlen($table) && ! isset($num_tables) && ! PMA_Table::isMerge($db, $table)) { ?>
     <div class="formelementrow">
         <?php
         echo '<input type="radio" name="allrows" value="0" id="radio_allrows_0" checked="checked" />';
diff --git a/tbl_printview.php b/tbl_printview.php
index 949a78a..c5b17ab 100644
--- a/tbl_printview.php
+++ b/tbl_printview.php
@@ -279,10 +279,9 @@ foreach ($the_tables as $key => $table) {
             }
             if ($nonisam == false) {
                 // Gets some sizes
-                $mergetable     = false;
-                if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
-                    $mergetable = true;
-                }
+
+		$mergetable = PMA_Table::isMerge($db, $table);
+
                 list($data_size, $data_unit)         = PMA_formatByteDown($showtable['Data_length']);
                 if ($mergetable == false) {
                     list($index_size, $index_unit)   = PMA_formatByteDown($showtable['Index_length']);
diff --git a/tbl_structure.php b/tbl_structure.php
index 750fbdc..0d966cc 100644
--- a/tbl_structure.php
+++ b/tbl_structure.php
@@ -612,10 +612,9 @@ if ($cfg['ShowStats']) {
     }
 
     // Gets some sizes
-    $mergetable     = false;
-    if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
-        $mergetable = true;
-    }
+
+    $mergetable = PMA_Table::isMerge($GLOBALS['db'], $GLOBALS['table']);
+
     // this is to display for example 261.2 MiB instead of 268k KiB
     $max_digits = 5;
     $decimals = 1;


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list