information_schema stuff

This commit is contained in:
Alexander M. Turek
2005-03-06 22:57:37 +00:00
parent 24d82ebf8b
commit a6a072431e
3 changed files with 88 additions and 39 deletions

View File

@@ -42,6 +42,8 @@ $Source$
indicators. indicators.
* libraries/mysql_charsets.lib.php: Don't check the character set of the * libraries/mysql_charsets.lib.php: Don't check the character set of the
virtual database "information_schema" (MySQL 5.0). virtual database "information_schema" (MySQL 5.0).
* db_details_links.php, db_details_structure.php: Don't allow the user to
change anything in MySQL 5.0's information_schema database.
2005-03-05 Marc Delisle <lem9@users.sourceforge.net> 2005-03-05 Marc Delisle <lem9@users.sourceforge.net>
* tbl_alter.php, tbl_addfield.php, db_datadict.php, pdf_schema.php, * tbl_alter.php, tbl_addfield.php, db_datadict.php, pdf_schema.php,

View File

@@ -40,6 +40,9 @@ if (!$cfg['AllowUserDropDatabase']) {
$cfg['AllowUserDropDatabase'] = PMA_DBI_select_db('mysql'); $cfg['AllowUserDropDatabase'] = PMA_DBI_select_db('mysql');
PMA_DBI_select_db($db); PMA_DBI_select_db($db);
} }
// rabus: Don't even try to drop information_schema. You won't be able to.
// Believe me. You won't.
$cfg['AllowUserDropDatabase'] = $cfg['AllowUserDropDatabase'] && !(PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema');
if ($cfg['AllowUserDropDatabase']) { if ($cfg['AllowUserDropDatabase']) {
$lnk5 = 'sql.php'; $lnk5 = 'sql.php';
$arg5 = $url_query . '&amp;sql_query=' $arg5 = $url_query . '&amp;sql_query='

View File

@@ -34,7 +34,7 @@ if (PMA_MYSQL_INT_VERSION >= 40101) {
// Display function // Display function
function pma_TableHeader($alternate = FALSE) { function pma_TableHeader($alternate = FALSE, $record_count = TRUE) {
$cnt = 0; // Let's count the columns... $cnt = 0; // Let's count the columns...
echo ' <table border="' . $GLOBALS['cfg']['Border'] . '" cellpadding="2" cellspacing="1">' . "\n" echo ' <table border="' . $GLOBALS['cfg']['Border'] . '" cellpadding="2" cellspacing="1">' . "\n"
. ' <tr>' . "\n" . ' <tr>' . "\n"
@@ -44,11 +44,14 @@ function pma_TableHeader($alternate = FALSE) {
. ' </th>' . "\n" . ' </th>' . "\n"
. ' <th colspan="6">' . "\n" . ' <th colspan="6">' . "\n"
. ' &nbsp;' . $GLOBALS['strAction'] . '&nbsp;' . "\n" . ' &nbsp;' . $GLOBALS['strAction'] . '&nbsp;' . "\n"
. ' </th>' . "\n"
. ' <th>' . "\n"
. ' &nbsp;' . $GLOBALS['strRecords'] . PMA_showHint($GLOBALS['strApproximateCount']) . '&nbsp;' . "\n"
. ' </th>' . "\n"; . ' </th>' . "\n";
$cnt += 4; $cnt += 3;
if ($record_count) {
echo ' <th>' . "\n"
. ' &nbsp;' . $GLOBALS['strRecords'] . PMA_showHint($GLOBALS['strApproximateCount']) . '&nbsp;' . "\n"
. ' </th>' . "\n";
$cnt++;
}
if (!$alternate) { if (!$alternate) {
if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) { if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
echo ' <th>' . "\n" echo ' <th>' . "\n"
@@ -108,8 +111,10 @@ if ($cfg['PropertiesIconic'] == true) {
$titles['NoBrowse'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_browse.png" alt="' . $strBrowse . '" title="' . $strBrowse . '" border="0" />'; $titles['NoBrowse'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_browse.png" alt="' . $strBrowse . '" title="' . $strBrowse . '" border="0" />';
$titles['NoSearch'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_select.png" alt="' . $strSearch . '" title="' . $strSearch . '" border="0" />'; $titles['NoSearch'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_select.png" alt="' . $strSearch . '" title="' . $strSearch . '" border="0" />';
$titles['Insert'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_insrow.png" alt="' . $strInsert . '" title="' . $strInsert . '" border="0" />'; $titles['Insert'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_insrow.png" alt="' . $strInsert . '" title="' . $strInsert . '" border="0" />';
$titles['NoInsert'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_insrow.png" alt="' . $strInsert . '" title="' . $strInsert . '" border="0" style="opacity: 0.5" />'; //TODO: we need a proper disabled icon here.
$titles['Structure'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_props.png" alt="' . $strStructure . '" title="' . $strStructure . '" border="0" />'; $titles['Structure'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_props.png" alt="' . $strStructure . '" title="' . $strStructure . '" border="0" />';
$titles['Drop'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" border="0" />'; $titles['Drop'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" border="0" />';
$titles['NoDrop'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" border="0" />';
$titles['Empty'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_empty.png" alt="' . $strEmpty . '" title="' . $strEmpty . '" border="0" />'; $titles['Empty'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_empty.png" alt="' . $strEmpty . '" title="' . $strEmpty . '" border="0" />';
$titles['NoEmpty'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_empty.png" alt="' . $strEmpty . '" title="' . $strEmpty . '" border="0" />'; $titles['NoEmpty'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_empty.png" alt="' . $strEmpty . '" title="' . $strEmpty . '" border="0" />';
@@ -119,8 +124,10 @@ if ($cfg['PropertiesIconic'] == true) {
$titles['NoBrowse'] .= '&nbsp;' . $strBrowse . '</div>'; $titles['NoBrowse'] .= '&nbsp;' . $strBrowse . '</div>';
$titles['NoSearch'] .= '&nbsp;' . $strSearch . '</div>'; $titles['NoSearch'] .= '&nbsp;' . $strSearch . '</div>';
$titles['Insert'] .= '&nbsp;' . $strInsert . '</div>'; $titles['Insert'] .= '&nbsp;' . $strInsert . '</div>';
$titles['NoInsert'] .= '&nbsp;' . $strInsert . '</div>';
$titles['Structure'] .= '&nbsp;' . $strStructure . '</div>'; $titles['Structure'] .= '&nbsp;' . $strStructure . '</div>';
$titles['Drop'] .= '&nbsp;' . $strDrop . '</div>'; $titles['Drop'] .= '&nbsp;' . $strDrop . '</div>';
$titles['NoDrop'] .= '&nbsp;' . $strDrop . '</div>';
$titles['Empty'] .= '&nbsp;' . $strEmpty . '</div>'; $titles['Empty'] .= '&nbsp;' . $strEmpty . '</div>';
$titles['NoEmpty'] .= '&nbsp;' . $strEmpty . '</div>'; $titles['NoEmpty'] .= '&nbsp;' . $strEmpty . '</div>';
} }
@@ -130,8 +137,10 @@ if ($cfg['PropertiesIconic'] == true) {
$titles['NoBrowse'] = $strBrowse; $titles['NoBrowse'] = $strBrowse;
$titles['NoSearch'] = $strSearch; $titles['NoSearch'] = $strSearch;
$titles['Insert'] = $strInsert; $titles['Insert'] = $strInsert;
$titles['NoInsert'] = $strInsert;
$titles['Structure'] = $strStructure; $titles['Structure'] = $strStructure;
$titles['Drop'] = $strDrop; $titles['Drop'] = $strDrop;
$titles['NoDrop'] = $strDrop;
$titles['Empty'] = $strEmpty; $titles['Empty'] = $strEmpty;
$titles['NoEmpty'] = $strEmpty; $titles['NoEmpty'] = $strEmpty;
} }
@@ -171,7 +180,13 @@ else {
<?php <?php
} }
pma_TableHeader(); // rabus: disable statistics for information_schema.
if (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema') {
$cfg['ShowStats'] = FALSE;
pma_TableHeader(FALSE, FALSE);
} else {
pma_TableHeader();
}
$i = $sum_entries = 0; $i = $sum_entries = 0;
(double) $sum_size = 0; (double) $sum_size = 0;
@@ -199,9 +214,9 @@ else {
$table = $sts_data['Name']; $table = $sts_data['Name'];
$table_encoded = urlencode($table); $table_encoded = urlencode($table);
$table_name = htmlspecialchars($table); $table_name = htmlspecialchars($table);
$is_view = (PMA_MYSQL_INT_VERSION >= 50000 $is_view = (PMA_MYSQL_INT_VERSION >= 50000
&& !isset($sts_data['Type']) && !isset($sts_data['Type'])
&& $sts_data['Comment'] == 'view'); && $sts_data['Comment'] == 'view');
$alias = (!empty($tooltip_aliasname) && isset($tooltip_aliasname[$table])) $alias = (!empty($tooltip_aliasname) && isset($tooltip_aliasname[$table]))
? htmlspecialchars($tooltip_aliasname[$table]) ? htmlspecialchars($tooltip_aliasname[$table])
@@ -238,16 +253,16 @@ else {
<td><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" border="0" width="10" height="1" alt="" /></td> <td><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" border="0" width="10" height="1" alt="" /></td>
<td valign="top"> <td valign="top">
<?php <?php
pma_TableHeader(); pma_TableHeader(FALSE, !(PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema'));
} }
?> ?>
<tr <?php echo $on_mouse; ?>> <tr <?php echo $on_mouse; ?>>
<td align="center" bgcolor="<?php echo $bgcolor; ?>"> <td align="center" bgcolor="<?php echo $bgcolor; ?>">
<input type="checkbox" name="selected_tbl[]" value="<?php echo $table_encoded; ?>" id="checkbox_tbl_<?php echo $i; ?>"<?php echo $checked; ?> /> <input type="checkbox" name="selected_tbl[]" value="<?php echo $table_encoded; ?>" id="checkbox_tbl_<?php echo $i; ?>"<?php echo $checked; ?> />
<?php <?php
if ($is_view) { if ($is_view) {
?> ?>
<input type="hidden" name="views[]" value="<?php echo $table_encoded; ?>" /> <input type="hidden" name="views[]" value="<?php echo $table_encoded; ?>" />
<?php <?php
} }
?> ?>
@@ -260,7 +275,7 @@ else {
require_once('./libraries/bookmark.lib.php'); require_once('./libraries/bookmark.lib.php');
$book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label'); $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
if (!empty($sts_data['Rows']) || $is_view) { if (!empty($sts_data['Rows']) || $is_view || (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema')) {
echo '<a href="sql.php?' . $tbl_url_query . '&amp;sql_query=' echo '<a href="sql.php?' . $tbl_url_query . '&amp;sql_query='
. (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table)))
. '&amp;pos=0">' . $titles['Browse'] . '</a>'; . '&amp;pos=0">' . $titles['Browse'] . '</a>';
@@ -271,7 +286,7 @@ else {
</td> </td>
<td bgcolor="<?php echo $bgcolor; ?>"> <td bgcolor="<?php echo $bgcolor; ?>">
<?php <?php
if (!empty($sts_data['Rows']) || $is_view) { if (!empty($sts_data['Rows']) || $is_view || (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema')) {
echo '<a href="tbl_select.php?' . $tbl_url_query . '">' echo '<a href="tbl_select.php?' . $tbl_url_query . '">'
. $titles['Search'] . '</a>'; . $titles['Search'] . '</a>';
} else { } else {
@@ -280,10 +295,19 @@ else {
?> ?>
</td> </td>
<td align="center" bgcolor="<?php echo $bgcolor; ?>"> <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 {
?>
<a href="tbl_change.php?<?php echo $tbl_url_query; ?>"> <a href="tbl_change.php?<?php echo $tbl_url_query; ?>">
<?php echo $titles['Insert']; ?></a> <?php echo $titles['Insert']; ?></a>
</td> <?php
<td align="center" bgcolor="<?php echo $bgcolor; ?>"> }
?>
</td>
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
<a href="tbl_properties_structure.php?<?php echo $tbl_url_query; ?>"> <a href="tbl_properties_structure.php?<?php echo $tbl_url_query; ?>">
<?php echo $titles['Structure']; ?></a> <?php echo $titles['Structure']; ?></a>
</td> </td>
@@ -314,18 +338,27 @@ else {
$drop_message = sprintf(($is_view ? $strViewHasBeenDropped : $strTableHasBeenDropped), htmlspecialchars($table)); $drop_message = sprintf(($is_view ? $strViewHasBeenDropped : $strTableHasBeenDropped), htmlspecialchars($table));
?> ?>
</td> </td>
<td align="center" bgcolor="<?php echo $bgcolor; ?>"> <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; ?>&amp;reload=1&amp;purge=1&amp;sql_query=<?php echo urlencode($drop_query); ?>&amp;zero_rows=<?php echo $drop_message; ?>" <a href="sql.php?<?php echo $tbl_url_query; ?>&amp;reload=1&amp;purge=1&amp;sql_query=<?php echo urlencode($drop_query); ?>&amp;zero_rows=<?php echo $drop_message; ?>"
onclick="return confirmLink(this, '<?php echo PMA_jsFormat($drop_query, FALSE); ?>')"> onclick="return confirmLink(this, '<?php echo PMA_jsFormat($drop_query, FALSE); ?>')">
<?php echo $titles['Drop']; ?></a> <?php echo $titles['Drop']; ?></a>
<?php
}
?>
</td> </td>
<?php <?php
unset($drop_query, $drop_message); unset($drop_query, $drop_message);
echo "\n"; echo "\n";
// loic1: Patch from Joshua Nye <josh at boxcarmedia.com> to get valid // loic1: Patch from Joshua Nye <josh at boxcarmedia.com> to get valid
// statistics whatever is the table type // statistics whatever is the table type
if (isset($sts_data['Rows'])) { if (isset($sts_data['Rows']) || (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema')) {
// MyISAM, ISAM or Heap table: Row count, data size and index size // MyISAM, ISAM or Heap table: Row count, data size and index size
// is accurate. // 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)$@', $sts_data['Type'])) {
@@ -386,13 +419,16 @@ else {
} }
$display_rows = 'unknown'; $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; ?>> <td align="right" bgcolor="<?php echo $bgcolor; ?>" <?php echo $click_mouse; ?>>
<?php <?php
echo "\n" . ' ' . $display_rows . "\n"; echo "\n" . ' ' . $display_rows . "\n";
?> ?>
</td> </td>
<?php <?php
}
if (!($cfg['PropertiesNumColumns'] > 1)) { if (!($cfg['PropertiesNumColumns'] > 1)) {
echo ' <td bgcolor="' . $bgcolor . '" nowrap="nowrap" ' . $click_mouse . '>' . "\n" echo ' <td bgcolor="' . $bgcolor . '" nowrap="nowrap" ' . $click_mouse . '>' . "\n"
. ' &nbsp;' . (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;') . '&nbsp;' . "\n" . ' &nbsp;' . (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;') . '&nbsp;' . "\n"
@@ -426,21 +462,21 @@ else {
<?php <?php
echo "\n"; echo "\n";
} // end if } // end if
} else if (PMA_MYSQL_INT_VERSION >= 50000 && $sts_data['Comment'] == 'view') { } else if (PMA_MYSQL_INT_VERSION >= 50000 && $sts_data['Comment'] == 'view') {
// rabus: We've found a view // rabus: We've found a view
?> ?>
<td align="right" bgcolor="<?php echo $bgcolor; ?>"> <td align="right" bgcolor="<?php echo $bgcolor; ?>">
&nbsp;-&nbsp; &nbsp;-&nbsp;
</td> </td>
<td bgcolor="<?php echo $bgcolor; ?>"> <td bgcolor="<?php echo $bgcolor; ?>">
&nbsp;<?php echo $strView ; ?>&nbsp; &nbsp;<?php echo $strView ; ?>&nbsp;
</td> </td>
<td bgcolor="<?php echo $bgcolor; ?>"> <td bgcolor="<?php echo $bgcolor; ?>">
&nbsp;---&nbsp; &nbsp;---&nbsp;
</td> </td>
<?php <?php
if ($cfg['ShowStats']) { if ($cfg['ShowStats']) {
?> ?>
<td align="right" bgcolor="<?php echo $bgcolor; ?>"> <td align="right" bgcolor="<?php echo $bgcolor; ?>">
&nbsp;-&nbsp; &nbsp;-&nbsp;
</td> </td>
@@ -473,13 +509,21 @@ else {
<th align="center" nowrap="nowrap"> <th align="center" nowrap="nowrap">
&nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp; &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
</th> </th>
<?php
if (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema') {
?>
<th colspan="6">&nbsp;</th>
<?php
} else {
?>
<th colspan="6" align="center"> <th colspan="6" align="center">
<b><?php echo $strSum; ?></b> <b><?php echo $strSum; ?></b>
</th> </th>
<th align="right" nowrap="nowrap"> <th align="right" nowrap="nowrap">
<b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b> <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
</th> </th>
<?php <?php
}
if (!($cfg['PropertiesNumColumns'] > 1)) { if (!($cfg['PropertiesNumColumns'] > 1)) {
echo ' <th align="center">' . "\n" echo ' <th align="center">' . "\n"
. ' <b>--</b>' . "\n" . ' <b>--</b>' . "\n"