patch from Joshua Nye to get valid statistics whatever are the table type

This commit is contained in:
Loïc Chapeaux
2002-02-22 11:56:11 +00:00
parent 28cb4c2888
commit 716ffda77b
3 changed files with 52 additions and 40 deletions

View File

@@ -11,6 +11,9 @@ $Source$
in HTTP_ACCEPT_LANGUAGE nor in HTTP_USER_AGENT variables.
* libraries/common.lib.php3, line 848: coding standard.
* lang/*: cleanup and font fixes thanks to Oliver Heinisch.
* db_details.php3; tbl_properties.php3: patch from Joshua Nye
<josh at boxcarmedia.com> to get valid statistics whatever are the table
types.
2002-02-19 Marc Delisle <lem9@users.sourceforge.net>
* libraries/common.lib.php3: get_magic_quotes fix thanks to

View File

@@ -222,7 +222,7 @@ else if (PMA_MYSQL_INT_VERSION >= 32300) {
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php
if ($sts_data['Rows']>0) {
if ($sts_data['Rows'] > 0) {
echo '<a href="sql.php3?' . $url_query
. '&amp;sql_query='
. urlencode('DELETE FROM ' . PMA_backquote($table))
@@ -237,50 +237,55 @@ else if (PMA_MYSQL_INT_VERSION >= 32300) {
</td>
<?php
echo "\n";
$mergetable = FALSE;
$nonisam = FALSE;
if (isset($sts_data['Type'])) {
if ($sts_data['Type'] == 'MRG_MyISAM') {
$mergetable = TRUE;
} else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
$nonisam = TRUE;
}
}
// loic1: Patch from Joshua Nye <josh at boxcarmedia.com> to get valid
// statistics whatever is the table type
if (isset($sts_data['Rows'])) {
if ($mergetable == FALSE) {
if ($cfgShowStats && $nonisam == FALSE) {
$tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
$sum_size += $tblsize;
if ($tblsize > 0) {
list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
} else {
list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
}
} else if ($cfgShowStats) {
$formated_size = '&nbsp;-&nbsp;';
$unit = '';
// MyISAM, ISAM or Heap table: Row count, data size and index size
// is accurate.
if (isset($sts_data['Type']) && ereg('^(MyISAM|ISAM|HEAP)$', $sts_data['Type'])) {
if ($cfgShowStats) {
$tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
$sum_size += $tblsize;
list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0);
}
$sum_entries += $sts_data['Rows'];
$sum_entries += $sts_data['Rows'];
$display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
}
// MyISAM MERGE Table
else if ($cfgShowStats && $mergetable == TRUE) {
$formated_size = '&nbsp;-&nbsp;';
$unit = '';
// InnoDB table: Row count is not accurate but data and index
// sizes are.
else if (isset($sts_data['Type']) && $sts_data['Type'] == 'InnoDB') {
if ($cfgShowStats) {
$tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
$sum_size += $tblsize;
list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0);
}
$display_rows = '&nbsp;-&nbsp;';
}
else if ($cfgShowStats) {
$formated_size = 'unknown';
$unit = '';
// Merge or BerkleyDB table: Only row count is accurate.
else if (isset($sts_data['Type']) && ereg('^(MRG_MyISAM|BerkeleyDB)$', $sts_data['Type'])) {
if ($cfgShowStats) {
$formated_size = '&nbsp;-&nbsp;';
$unit = '';
}
$sum_entries += $sts_data['Rows'];
$display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
}
// Unknown table type.
else {
if ($cfgShowStats) {
$formated_size = 'unknown';
$unit = '';
}
$display_rows = 'unknown';
}
?>
<td align="right" bgcolor="<?php echo $bgcolor; ?>">
<?php
echo "\n" . ' ';
if ($mergetable == TRUE) {
echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
} else {
echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
}
echo "\n" . ' ' . $display_rows . "\n";
?>
</td>
<td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">

View File

@@ -482,12 +482,16 @@ require ('./tbl_indexes.php3');
* Displays Space usage and row statistics
*/
// BEGIN - Calc Table Space - staybyte - 9 June 2001
// loic1, 22 feb. 2002: updated with patch from
// Joshua Nye <josh at boxcarmedia.com> to get valid
// statistics whatever is the table type
if ($cfgShowStats) {
$nonisam = FALSE;
$is_innodb = ($showtable['Type'] == 'InnoDB');
if (isset($showtable['Type']) && !eregi('ISAM|HEAP', $showtable['Type'])) {
$nonisam = TRUE;
}
if (PMA_MYSQL_INT_VERSION >= 32303 && $nonisam == FALSE) {
if (PMA_MYSQL_INT_VERSION >= 32303 && ($nonisam == FALSE || $is_innodb)) {
// Gets some sizes
$mergetable = FALSE;
if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
@@ -613,7 +617,7 @@ if ($cfgShowStats) {
</tr>
<?php
}
if (isset($showtable['Rows'])) {
if (!$is_innodb && isset($showtable['Rows'])) {
$bgcolor = ((++$i%2) ? $cfgBgcolorTwo : $cfgBgcolorOne);
echo "\n";
?>
@@ -625,7 +629,7 @@ if ($cfgShowStats) {
</tr>
<?php
}
if (isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
$bgcolor = ((++$i%2) ? $cfgBgcolorTwo : $cfgBgcolorOne);
echo "\n";
?>
@@ -637,7 +641,7 @@ if ($cfgShowStats) {
</tr>
<?php
}
if (isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == FALSE) {
if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == FALSE) {
$bgcolor = ((++$i%2) ? $cfgBgcolorTwo : $cfgBgcolorOne);
echo "\n";
?>