From 716ffda77bb2666f5f06cacb1eb4341ab6e06b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Chapeaux?= Date: Fri, 22 Feb 2002 11:56:11 +0000 Subject: [PATCH] patch from Joshua Nye to get valid statistics whatever are the table type --- ChangeLog | 3 ++ db_details.php3 | 77 ++++++++++++++++++++++++--------------------- tbl_properties.php3 | 12 ++++--- 3 files changed, 52 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index c299f42e9..307c35170 100755 --- a/ChangeLog +++ b/ChangeLog @@ -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 + to get valid statistics whatever are the table + types. 2002-02-19 Marc Delisle * libraries/common.lib.php3: get_magic_quotes fix thanks to diff --git a/db_details.php3 b/db_details.php3 index 69a287a29..15a1dab42 100755 --- a/db_details.php3 +++ b/db_details.php3 @@ -222,7 +222,7 @@ else if (PMA_MYSQL_INT_VERSION >= 32300) { 0) { + if ($sts_data['Rows'] > 0) { echo ' 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 = ' - '; - $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 = ' - '; - $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 = ' - '; } - 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 = ' - '; + $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'; } ?> ' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '' . "\n"; - } else { - echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; - } + echo "\n" . ' ' . $display_rows . "\n"; ?> diff --git a/tbl_properties.php3 b/tbl_properties.php3 index 15451556f..b9d9974ef 100755 --- a/tbl_properties.php3 +++ b/tbl_properties.php3 @@ -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 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) { @@ -625,7 +629,7 @@ if ($cfgShowStats) { 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) { 0 && $mergetable == FALSE) { + if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == FALSE) { $bgcolor = ((++$i%2) ? $cfgBgcolorTwo : $cfgBgcolorOne); echo "\n"; ?>