diff --git a/ChangeLog b/ChangeLog index f120b5a1a..26f8b7085 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 624007eea..f051877f7 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 bf51015f3..d656f0e84 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 fa1839034..845ffd383 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 f8c991469..dae4cf4f0 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 0f407e761..de2cfe299 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 a6809955d..186b0d36f 100644 --- a/libraries/display_export.lib.php +++ b/libraries/display_export.lib.php @@ -104,10 +104,7 @@ echo PMA_pluginGetJavascript($export_list); //]]> - +