patch #2969449 Name for MERGE engine varies depending on the MySQL version

This commit is contained in:
Dieter Adriaenssens
2010-03-12 17:16:05 -05:00
committed by Marc Delisle
parent 4a53eb1916
commit 7c818d046a
9 changed files with 49 additions and 21 deletions

View File

@@ -6,6 +6,8 @@ $Id$
$HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyAdmin/ChangeLog $ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyAdmin/ChangeLog $
3.3.2.0 (not yet released) 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) 3.3.1.0 (not yet released)
- bug #2941037 [core] Database structure not sorted by table correctly - bug #2941037 [core] Database structure not sorted by table correctly

View File

@@ -110,7 +110,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
// do not copy the data from a Merge table // do not copy the data from a Merge table
// note: on the calling FORM, 'data' means 'structure and data' // 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') { if ($this_what == 'data') {
$this_what = 'structure'; $this_what = 'structure';
} }

View File

@@ -117,7 +117,7 @@ else {
$sum_entries = $sum_size = 0; $sum_entries = $sum_size = 0;
$odd_row = true; $odd_row = true;
foreach ($tables as $sts_data) { 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') { || strtoupper($sts_data['ENGINE']) == 'FEDERATED') {
$merged_size = true; $merged_size = true;
} else { } else {

View File

@@ -226,7 +226,11 @@ foreach ($tables as $keyname => $each_table) {
} }
//$display_rows = ' - '; //$display_rows = ' - ';
break; 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 'MRG_MYISAM' :
case 'MERGE' :
case 'BerkeleyDB' : case 'BerkeleyDB' :
// Merge or BerkleyDB table: Only row count is accurate. // Merge or BerkleyDB table: Only row count is accurate.
if ($is_show_stats) { if ($is_show_stats) {
@@ -255,7 +259,7 @@ foreach ($tables as $keyname => $each_table) {
} }
} // end switch } // end switch
if ('MRG_MYISAM' != $each_table['ENGINE']) { if (! PMA_Table::isMerge($db, $each_table['TABLE_NAME'])) {
$sum_entries += $each_table['TABLE_ROWS']; $sum_entries += $each_table['TABLE_ROWS'];
} }

View File

@@ -439,7 +439,7 @@ if ($export_type == 'server') {
} }
} }
// if this is a view or a merge table, don't export data // 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); $local_query = 'SELECT * FROM ' . PMA_backquote($current_db) . '.' . PMA_backquote($table);
if (!PMA_exportData($current_db, $table, $crlf, $err_url, $local_query)) { if (!PMA_exportData($current_db, $table, $crlf, $err_url, $local_query)) {
break 3; break 3;
@@ -488,7 +488,7 @@ if ($export_type == 'server') {
} }
} }
// if this is a view or a merge table, don't export data // 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); $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) { if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
break 2; break 2;
@@ -537,8 +537,7 @@ if ($export_type == 'server') {
// If this is an export of a single view, we have to export data; // If this is an export of a single view, we have to export data;
// for example, a PDF report // for example, a PDF report
// if it is a merge table, no data is exported // 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']) && ! PMA_Table::isMerge($db, $table)) {
if (isset($GLOBALS[$what . '_data']) && ! $is_merge) {
if (!empty($sql_query)) { if (!empty($sql_query)) {
// only preg_replace if needed // only preg_replace if needed
if (!empty($add_query)) { if (!empty($add_query)) {

View File

@@ -238,6 +238,31 @@ class PMA_Table
return $type == 'VIEW'; 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) static public function sGetToolTip($db, $table)
{ {
return PMA_Table::sGetStatusInfo($db, $table, 'Comment') return PMA_Table::sGetStatusInfo($db, $table, 'Comment')
@@ -254,9 +279,10 @@ class PMA_Table
* @param string $table * @param string $table
* @param string $info * @param string $info
* @param boolean $force_read * @param boolean $force_read
* @param boolean if true, disables error message
* @return mixed * @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) { if (! isset(PMA_Table::$cache[$db][$table]) || $force_read) {
PMA_DBI_get_tables_full($db, $table); PMA_DBI_get_tables_full($db, $table);
@@ -274,7 +300,9 @@ class PMA_Table
} }
if (! isset(PMA_Table::$cache[$db][$table][$info])) { if (! isset(PMA_Table::$cache[$db][$table][$info])) {
if (! $disable_error) {
trigger_error('unknown table status: ' . $info, E_USER_WARNING); trigger_error('unknown table status: ' . $info, E_USER_WARNING);
}
return false; return false;
} }

View File

@@ -104,10 +104,7 @@ echo PMA_pluginGetJavascript($export_list);
//]]> //]]>
</script> </script>
<?php <?php if (strlen($table) && ! isset($num_tables) && ! PMA_Table::isMerge($db, $table)) { ?>
$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) {
?>
<div class="formelementrow"> <div class="formelementrow">
<?php <?php
echo '<input type="radio" name="allrows" value="0" id="radio_allrows_0" checked="checked" />'; echo '<input type="radio" name="allrows" value="0" id="radio_allrows_0" checked="checked" />';

View File

@@ -279,10 +279,9 @@ foreach ($the_tables as $key => $table) {
} }
if ($nonisam == false) { if ($nonisam == false) {
// Gets some sizes // Gets some sizes
$mergetable = false;
if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') { $mergetable = PMA_Table::isMerge($db, $table);
$mergetable = true;
}
list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length']); list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length']);
if ($mergetable == false) { if ($mergetable == false) {
list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length']); list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length']);

View File

@@ -612,10 +612,9 @@ if ($cfg['ShowStats']) {
} }
// Gets some sizes // Gets some sizes
$mergetable = false;
if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') { $mergetable = PMA_Table::isMerge($GLOBALS['db'], $GLOBALS['table']);
$mergetable = true;
}
// this is to display for example 261.2 MiB instead of 268k KiB // this is to display for example 261.2 MiB instead of 268k KiB
$max_digits = 5; $max_digits = 5;
$decimals = 1; $decimals = 1;