fixed display of table statistics for information_schema
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
----------------------
|
||||
----------------------
|
||||
phpMyAdmin - Changelog
|
||||
----------------------
|
||||
|
||||
@@ -19,6 +19,8 @@ $Source$
|
||||
no table statistics for information_schema
|
||||
* tbl_properties_table_info.php:
|
||||
bug #1317655 information_schema browsing
|
||||
* db_details_db_info.php, db_details_structure.php:
|
||||
fixed display table statistics for information_schema
|
||||
|
||||
2005-10-09 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* tbl_properties_links.php: invalid js confirmation and operation feedback
|
||||
|
@@ -63,6 +63,11 @@ if ($cfg['SkipLockedTables'] == TRUE) {
|
||||
$db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . $tbl_group_sql . ';', NULL, PMA_DBI_QUERY_STORE);
|
||||
if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
|
||||
while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
|
||||
if ( NULL === $tmp['Rows'] ) {
|
||||
$tmp['Rows'] = PMA_countRecords( $GLOBALS['db'],
|
||||
$tmp['Name'], $return = true, $force_exact = true );
|
||||
}
|
||||
|
||||
if (!isset($sot_cache[$tmp[0]])) {
|
||||
$sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
|
||||
$sts_tmp = PMA_DBI_fetch_assoc($sts_result);
|
||||
@@ -99,6 +104,11 @@ if (!isset($sot_ready)) {
|
||||
$db_info_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . $tbl_group_sql . ';', NULL, PMA_DBI_QUERY_STORE);
|
||||
if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
|
||||
while ($sts_tmp = PMA_DBI_fetch_assoc($db_info_result)) {
|
||||
if ( NULL === $sts_tmp['Rows'] ) {
|
||||
$sts_tmp['Rows'] = PMA_countRecords( $GLOBALS['db'],
|
||||
$sts_tmp['Name'], $return = true, $force_exact = true );
|
||||
}
|
||||
|
||||
if (!isset($sts_tmp['Type']) && isset($sts_tmp['Engine'])) {
|
||||
$sts_tmp['Type'] =& $sts_tmp['Engine'];
|
||||
}
|
||||
|
@@ -34,25 +34,29 @@ if (PMA_MYSQL_INT_VERSION >= 40101) {
|
||||
|
||||
|
||||
// Display function
|
||||
function pma_TableHeader($alternate = FALSE, $record_count = TRUE) {
|
||||
function pma_TableHeader( $is_schema = false ) {
|
||||
$cnt = 0; // Let's count the columns...
|
||||
|
||||
if ( $is_schema ) {
|
||||
$action_colspan = 3;
|
||||
} else {
|
||||
$action_colspan = 6;
|
||||
}
|
||||
|
||||
echo ' <table border="' . $GLOBALS['cfg']['Border'] . '" cellpadding="2" cellspacing="1">' . "\n"
|
||||
. ' <tr>' . "\n"
|
||||
. ' <td></td>' . "\n"
|
||||
. ' <th>' . "\n"
|
||||
. ' ' . $GLOBALS['strTable'] . ' ' . "\n"
|
||||
. ' </th>' . "\n"
|
||||
. ' <th colspan="6">' . "\n"
|
||||
. ' <th colspan="' . $action_colspan . '">' . "\n"
|
||||
. ' ' . $GLOBALS['strAction'] . ' ' . "\n"
|
||||
. ' </th>' . "\n";
|
||||
$cnt += 3;
|
||||
if ($record_count) {
|
||||
$cnt += 2 + $action_colspan;
|
||||
echo ' <th>' . "\n"
|
||||
. ' ' . $GLOBALS['strRecords'] . PMA_showHint($GLOBALS['strApproximateCount']) . ' ' . "\n"
|
||||
. ' </th>' . "\n";
|
||||
$cnt++;
|
||||
}
|
||||
if (!$alternate) {
|
||||
if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
|
||||
echo ' <th>' . "\n"
|
||||
. ' ' . $GLOBALS['strType'] . ' ' . "\n"
|
||||
@@ -75,7 +79,6 @@ function pma_TableHeader($alternate = FALSE, $record_count = TRUE) {
|
||||
$cnt += 2;
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
echo ' </tr>' . "\n";
|
||||
$GLOBALS['structure_tbl_col_cnt'] = $cnt;
|
||||
}
|
||||
@@ -159,12 +162,13 @@ else {
|
||||
}
|
||||
|
||||
// rabus: disable statistics for information_schema.
|
||||
if (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema') {
|
||||
$cfg['ShowStats'] = FALSE;
|
||||
pma_TableHeader(FALSE, FALSE);
|
||||
if (PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema') {
|
||||
$cfg['ShowStats'] = false;
|
||||
$table_is_schema = true;
|
||||
} else {
|
||||
pma_TableHeader();
|
||||
$table_is_schema = false;
|
||||
}
|
||||
pma_TableHeader( $table_is_schema );
|
||||
|
||||
$i = $sum_entries = 0;
|
||||
(double) $sum_size = 0;
|
||||
@@ -232,7 +236,7 @@ else {
|
||||
<td><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" border="0" width="10" height="1" alt="" /></td>
|
||||
<td valign="top">
|
||||
<?php
|
||||
pma_TableHeader(FALSE, !(PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema'));
|
||||
pma_TableHeader();
|
||||
}
|
||||
?>
|
||||
<tr <?php echo $on_mouse; ?>>
|
||||
@@ -254,7 +258,7 @@ else {
|
||||
require_once('./libraries/bookmark.lib.php');
|
||||
$book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
|
||||
|
||||
if (!empty($sts_data['Rows']) || $is_view || (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema')) {
|
||||
if ( ! empty( $sts_data['Rows'] ) || $is_view ) {
|
||||
echo '<a href="sql.php?' . $tbl_url_query . '&sql_query='
|
||||
. (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table)))
|
||||
. '&pos=0">' . $titles['Browse'] . '</a>';
|
||||
@@ -269,7 +273,7 @@ else {
|
||||
</td>
|
||||
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
|
||||
<?php
|
||||
if (!empty($sts_data['Rows']) || $is_view || (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema')) {
|
||||
if ( ! empty($sts_data['Rows'] ) || $is_view ) {
|
||||
echo '<a href="tbl_select.php?' . $tbl_url_query . '">'
|
||||
. $titles['Search'] . '</a>';
|
||||
} else {
|
||||
@@ -277,22 +281,16 @@ else {
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
|
||||
<?php
|
||||
if (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema') {
|
||||
// rabus: We cannot insert into information_schema tables!
|
||||
echo $titles['NoInsert'];
|
||||
} else {
|
||||
if ( ! $table_is_schema ) {
|
||||
?>
|
||||
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
|
||||
<a href="tbl_change.php?<?php echo $tbl_url_query; ?>">
|
||||
<?php echo $titles['Insert']; ?></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
|
||||
<?php
|
||||
if (!empty($sts_data['Rows'])) {
|
||||
if ( ! empty($sts_data['Rows']) ) {
|
||||
echo '<a href="sql.php?' . $tbl_url_query
|
||||
. '&sql_query=';
|
||||
if (PMA_MYSQL_INT_VERSION >= 40000) {
|
||||
@@ -310,37 +308,32 @@ else {
|
||||
} else {
|
||||
echo $titles['NoEmpty'];
|
||||
}
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
|
||||
<?php
|
||||
$drop_query = 'DROP '
|
||||
. ($is_view ? 'VIEW' : 'TABLE')
|
||||
. ' ' . PMA_backquote($table);
|
||||
$drop_message = sprintf(($is_view ? $strViewHasBeenDropped : $strTableHasBeenDropped), htmlspecialchars($table));
|
||||
?>
|
||||
</td>
|
||||
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
|
||||
<?php
|
||||
// rabus: We cannot drop information_schema tables!
|
||||
if (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema') {
|
||||
echo $titles['NoDrop'];
|
||||
} else {
|
||||
?>
|
||||
<a href="sql.php?<?php echo $tbl_url_query; ?>&reload=1&purge=1&sql_query=<?php echo urlencode($drop_query); ?>&zero_rows=<?php echo urlencode($drop_message); ?>"
|
||||
onclick="return confirmLink(this, '<?php echo PMA_jsFormat($drop_query, FALSE); ?>')">
|
||||
<?php echo $titles['Drop']; ?></a>
|
||||
<?php
|
||||
unset($drop_query, $drop_message);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
||||
<?php
|
||||
unset($drop_query, $drop_message);
|
||||
echo "\n";
|
||||
|
||||
// loic1: Patch from Joshua Nye <josh at boxcarmedia.com> to get valid
|
||||
// statistics whatever is the table type
|
||||
if (isset($sts_data['Rows']) || (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema')) {
|
||||
if ( isset( $sts_data['Rows'] ) ) {
|
||||
// MyISAM, ISAM or Heap table: Row count, data size and index size
|
||||
// is accurate.
|
||||
if (isset($sts_data['Type']) && preg_match('@^(MyISAM|ISAM|HEAP)$@', $sts_data['Type'])) {
|
||||
if (isset($sts_data['Type']) && preg_match('@^(MyISAM|ISAM|HEAP|MEMORY)$@', $sts_data['Type'])) {
|
||||
if ($cfg['ShowStats']) {
|
||||
$tblsize = doubleval($sts_data['Data_length']) + doubleval($sts_data['Index_length']);
|
||||
$sum_size += $tblsize;
|
||||
@@ -398,8 +391,6 @@ else {
|
||||
}
|
||||
$display_rows = 'unknown';
|
||||
}
|
||||
// Don't display number of rows for information_schema tables.
|
||||
if (!(PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema')) {
|
||||
?>
|
||||
<td align="right" bgcolor="<?php echo $bgcolor; ?>" <?php echo $click_mouse; ?>>
|
||||
<?php
|
||||
@@ -407,7 +398,6 @@ else {
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
}
|
||||
if (!($cfg['PropertiesNumColumns'] > 1)) {
|
||||
echo ' <td bgcolor="' . $bgcolor . '" nowrap="nowrap" ' . $click_mouse . '>' . "\n"
|
||||
. ' ' . (isset($sts_data['Type']) ? $sts_data['Type'] : ' ') . ' ' . "\n"
|
||||
@@ -419,7 +409,7 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
if ($cfg['ShowStats']) {
|
||||
if ( $cfg['ShowStats']) {
|
||||
echo "\n";
|
||||
?>
|
||||
<td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap" <?php echo $click_mouse; ?>>
|
||||
@@ -467,7 +457,7 @@ else {
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<td colspan="<?php echo ($structure_tbl_col_cnt - 8) ?>" align="center" bgcolor="<?php echo $bgcolor; ?>" <?php echo $click_mouse; ?>>
|
||||
<td colspan="<?php echo ($structure_tbl_col_cnt - ($table_is_schema ? 5 : 8)) ?>" align="center" bgcolor="<?php echo $bgcolor; ?>" <?php echo $click_mouse; ?>>
|
||||
<?php echo $strInUse . "\n"; ?>
|
||||
</td>
|
||||
<?php
|
||||
@@ -489,21 +479,13 @@ else {
|
||||
<th align="center" nowrap="nowrap">
|
||||
<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>
|
||||
</th>
|
||||
<?php
|
||||
if (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema') {
|
||||
?>
|
||||
<th colspan="6"> </th>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<th colspan="6" align="center">
|
||||
<th colspan="<?php echo ( $table_is_schema ? 3 : 6 ) ?>" align="center">
|
||||
<b><?php echo $strSum; ?></b>
|
||||
</th>
|
||||
<th align="right" nowrap="nowrap">
|
||||
<b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
|
||||
</th>
|
||||
<?php
|
||||
}
|
||||
if (!($cfg['PropertiesNumColumns'] > 1)) {
|
||||
echo ' <th align="center">' . "\n"
|
||||
. ' <b>--</b>' . "\n"
|
||||
@@ -633,7 +615,7 @@ if ($num_tables > 0) {
|
||||
<?php
|
||||
} // end if
|
||||
|
||||
if (PMA_MYSQL_INT_VERSION < 50002 || (PMA_MYSQL_INT_VERSION >= 50002 && $db != 'information_schema')) {
|
||||
if ( ! $table_is_schema ) {
|
||||
require('./libraries/display_create_table.lib.php');
|
||||
} // end if (Create Table dialog)
|
||||
|
||||
|
Reference in New Issue
Block a user