From 4b0cd49219e94b61d5f53cf6a619b2ab312a7b96 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Fri, 4 Nov 2005 07:39:58 +0000 Subject: [PATCH] fixed display of stats for InnoDB and information_schema --- ChangeLog | 4 ++ db_details_structure.php | 143 ++++++++++++++++++--------------------- 2 files changed, 71 insertions(+), 76 deletions(-) diff --git a/ChangeLog b/ChangeLog index 646de61204..588d04ad54 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2005-11-03 Sebastian Mendel + * db_details_structure.php: + fixed display of stats for InnoDB and information_schema + 2005-11-03 Marc Delisle * tbl_change.php, tbl_replace.php, tbl_replace_fields.php: bug #1339184, problems in strict mode inserting auto-increment fields diff --git a/db_details_structure.php b/db_details_structure.php index f8b0d1f910..ab07e9f448 100644 --- a/db_details_structure.php +++ b/db_details_structure.php @@ -2,7 +2,6 @@ /* $Id$ */ // vim: expandtab sw=4 ts=4 sts=4: -require_once('./libraries/grab_globals.lib.php'); require_once('./libraries/common.lib.php'); /** @@ -26,11 +25,19 @@ if ( empty( $is_info ) ) { require('./db_details_db_info.php'); } +// rabus: disable statistics for information_schema. +if ( PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema' ) { + $cfg['ShowStats'] = false; + $db_is_information_schema = true; +} else { + $db_is_information_schema = false; +} + // 1. No tables if ( $num_tables == 0 ) { echo '

' . $strNoTablesFound . '

' . "\n"; - if ( empty( $table_is_schema ) ) { + if ( empty( $db_is_information_schema ) ) { require('./libraries/display_create_table.lib.php'); } // end if (Create Table dialog) @@ -46,24 +53,16 @@ if ( $num_tables == 0 ) { require_once('./libraries/bookmark.lib.php'); -// rabus: disable statistics for information_schema. -if ( PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema' ) { - $cfg['ShowStats'] = false; - $table_is_schema = true; -} else { - $table_is_schema = false; -} - if ( PMA_MYSQL_INT_VERSION >= 40101 ) { require_once('./libraries/mysql_charsets.lib.php'); $db_collation = PMA_getDbCollation( $db ); } // Display function -function PMA_TableHeader( $table_is_schema = false ) { +function PMA_TableHeader( $db_is_information_schema = false ) { $cnt = 0; // Let's count the columns... - if ( $table_is_schema ) { + if ( $db_is_information_schema ) { $action_colspan = 3; } else { $action_colspan = 6; @@ -147,7 +146,7 @@ if ( true == $cfg['PropertiesIconic'] ) { $sts_data ) { - $sts_data['Type'] = isset( $sts_data['Type'] ) ? $sts_data['Type'] : ''; +foreach ( $tables as $keyname => $each_table ) { + if ( $each_table['TABLE_ROWS'] === NULL ) { + $each_table['TABLE_ROWS'] = PMA_countRecords( $db, + $each_table['TABLE_NAME'], $return = true, $force_exact = true ); + } - $table_encoded = urlencode($sts_data['Name']); + $table_encoded = urlencode($each_table['TABLE_NAME']); // MySQL < 5.0.13 returns "view", >= 5.0.13 returns "VIEW" - $table_is_view = (PMA_MYSQL_INT_VERSION >= 50000 - && empty($sts_data['Type']) - && strtoupper($sts_data['Comment']) == 'VIEW'); + $table_is_view = ( $each_table['TABLE_TYPE'] === 'VIEW' + || $each_table['TABLE_TYPE'] === 'SYSTEM VIEW' ); - $alias = (!empty($tooltip_aliasname) && isset($tooltip_aliasname[$sts_data['Name']])) - ? htmlspecialchars($tooltip_aliasname[$sts_data['Name']]) - : htmlspecialchars($sts_data['Name']); - $truename = (!empty($tooltip_truename) && isset($tooltip_truename[$sts_data['Name']])) - ? htmlspecialchars($tooltip_truename[$sts_data['Name']]) - : htmlspecialchars($sts_data['Name']); + $alias = (!empty($tooltip_aliasname) && isset($tooltip_aliasname[$each_table['TABLE_NAME']])) + ? htmlspecialchars($tooltip_aliasname[$each_table['TABLE_NAME']]) + : htmlspecialchars($each_table['TABLE_NAME']); + $truename = (!empty($tooltip_truename) && isset($tooltip_truename[$each_table['TABLE_NAME']])) + ? htmlspecialchars($tooltip_truename[$each_table['TABLE_NAME']]) + : htmlspecialchars($each_table['TABLE_NAME']); // Sets parameters for links $tbl_url_query = $url_query . '&table=' . $table_encoded; $i++; $row_count++; - if ( $table_is_view ) { $hidden_fields[] = ''; } - - if ( ! empty( $sts_data['Rows'] ) || $table_is_view ) { - $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($sts_data['Name']) . '\'', 'label'); + if ( $each_table['TABLE_ROWS'] > 0 ) { + $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($each_table['TABLE_NAME']) . '\'', 'label'); $browse_table = '' . $titles['Browse'] . ''; - } else { - $browse_table = $titles['NoBrowse']; - } - - if ( ! empty($sts_data['Rows'] ) || $table_is_view ) { $search_table = '' . $titles['Search'] . ''; } else { + $browse_table = $titles['NoBrowse']; $search_table = $titles['NoSearch']; } - if ( ! $table_is_schema ) { - if ( ! empty($sts_data['Rows']) ) { + if ( ! $db_is_information_schema ) { + if ( ! empty($each_table['TABLE_ROWS']) ) { $empty_table = '' . $titles['Empty'] . ''; + $empty_table .= PMA_jsFormat($each_table['TABLE_NAME']) . '\')">' . $titles['Empty'] . ''; } else { $empty_table = $titles['NoEmpty']; } $drop_query = 'DROP ' . ( $table_is_view ? 'VIEW' : 'TABLE' ) - . ' ' . PMA_backquote($sts_data['Name']); + . ' ' . PMA_backquote($each_table['TABLE_NAME']); $drop_message = sprintf( $table_is_view ? $strViewHasBeenDropped : $strTableHasBeenDropped, - htmlspecialchars( $sts_data['Name'] ) ); + htmlspecialchars( $each_table['TABLE_NAME'] ) ); } // loic1: Patch from Joshua Nye to get valid // statistics whatever is the table type - if ( isset( $sts_data['Rows'] ) ) { + if ( isset( $each_table['TABLE_ROWS'] ) ) { // MyISAM, ISAM or Heap table: Row count, data size and index size // is accurate. - if ( preg_match('@^(MyISAM|ISAM|HEAP|MEMORY)$@', $sts_data['Type']) ) { + if ( preg_match('@^(MyISAM|ISAM|HEAP|MEMORY)$@', $each_table['ENGINE']) ) { if ($cfg['ShowStats']) { - $tblsize = doubleval($sts_data['Data_length']) + doubleval($sts_data['Index_length']); + $tblsize = doubleval($each_table['Data_length']) + doubleval($each_table['Index_length']); $sum_size += $tblsize; list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0); - if (isset($sts_data['Data_free']) && $sts_data['Data_free'] > 0) { - list($formated_overhead, $overhead_unit) = PMA_formatByteDown($sts_data['Data_free']); - $overhead_size += $sts_data['Data_free']; + if (isset($each_table['Data_free']) && $each_table['Data_free'] > 0) { + list($formated_overhead, $overhead_unit) = PMA_formatByteDown($each_table['Data_free']); + $overhead_size += $each_table['Data_free']; } } - $sum_entries += $sts_data['Rows']; - $display_rows = $sts_data['Rows']; - } elseif ( $sts_data['Type'] == 'InnoDB' ) { + $sum_entries += $each_table['TABLE_ROWS']; + } elseif ( $each_table['ENGINE'] == 'InnoDB' ) { // InnoDB table: Row count is not accurate but data and index // sizes are. if ($cfg['ShowStats']) { - $tblsize = $sts_data['Data_length'] + $sts_data['Index_length']; + $tblsize = $each_table['Data_length'] + $each_table['Index_length']; $sum_size += $tblsize; list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0); } //$display_rows = ' - '; // get row count with another method - if ($sts_data['Rows'] < $cfg['MaxExactCount']) { + if ($each_table['TABLE_ROWS'] < $cfg['MaxExactCount']) { $local_query = 'SELECT COUNT(*) AS count FROM ' . PMA_backquote($db) . '.' - . PMA_backquote($sts_data['Name']); - $sum_entries += PMA_DBI_fetch_value( $local_query ); + . PMA_backquote($each_table['TABLE_NAME']); + $each_table['TABLE_ROWS'] = PMA_DBI_fetch_value( $local_query ); + $sum_entries += $each_table['TABLE_ROWS']; unset( $local_query ); } else { - $row_count = $sts_data['Rows']; - $sum_entries += $sts_data['Rows']; + $sum_entries += $each_table['TABLE_ROWS']; } - $display_rows = $row_count; - } elseif ( preg_match('@^(MRG_MyISAM|BerkeleyDB)$@', $sts_data['Type']) ) { + } elseif ( preg_match('@^(MRG_MyISAM|BerkeleyDB)$@', $each_table['ENGINE']) ) { // Merge or BerkleyDB table: Only row count is accurate. if ($cfg['ShowStats']) { $formated_size = ' - '; $unit = ''; } - $sum_entries += $sts_data['Rows']; - $display_rows = $sts_data['Rows']; + $sum_entries += $each_table['TABLE_ROWS']; } else { // Unknown table type. if ($cfg['ShowStats']) { $formated_size = 'unknown'; $unit = ''; } - $display_rows = 'unknown'; } if (PMA_MYSQL_INT_VERSION >= 40100) { - if ( isset( $sts_data['Collation'] ) ) { + if ( isset( $each_table['Collation'] ) ) { $collation = '' - . $sts_data['Collation'] . ''; + . PMA_getCollationDescr($each_table['Collation']) . '">' + . $each_table['Collation'] . ''; } else { $collation = '---'; } @@ -334,7 +325,7 @@ foreach ( $tables as $keyname => $sts_data ) { - + @@ -346,11 +337,11 @@ foreach ( $tables as $keyname => $sts_data ) { echo urlencode($drop_message); ?>" onclick="return confirmLink(this, '')"> - - - + + + 1)) { ?> - + @@ -371,10 +362,10 @@ foreach ( $tables as $keyname => $sts_data ) { - - - + - + @@ -496,7 +487,7 @@ if($cfg['PropertiesIconic']){ echo $strDataDict . ''; echo '

'; -if ( empty( $table_is_schema ) ) { +if ( empty( $db_is_information_schema ) ) { require('./libraries/display_create_table.lib.php'); } // end if (Create Table dialog)